-
Notifications
You must be signed in to change notification settings - Fork 2
/
bootstrap.php
95 lines (84 loc) · 4.2 KB
/
bootstrap.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
if ( defined( 'MWSTAKE_MEDIAWIKI_COMPONENT_COMMONWEBAPIS_VERSION' ) ) {
return;
}
define( 'MWSTAKE_MEDIAWIKI_COMPONENT_COMMONWEBAPIS_VERSION', '3.0.2' );
MWStake\MediaWiki\ComponentLoader\Bootstrapper::getInstance()
->register( 'commonwebapis', static function () {
$GLOBALS['wgExtensionFunctions'][]
= "\\MWStake\\MediaWiki\\Component\\CommonWebAPIs\\Setup::onExtensionFunctions";
$GLOBALS['wgServiceWiringFiles'][] = __DIR__ . '/includes/ServiceWiring.php';
$GLOBALS['wgExtensionFunctions'][] = static function () {
$lb = \MediaWiki\MediaWikiServices::getInstance()->getDBLoadBalancer();
$pageProps = \MediaWiki\MediaWikiServices::getInstance()->getPageProps();
$titleIndexUpdater = new \MWStake\MediaWiki\Component\CommonWebAPIs\TitleIndexUpdater( $lb, $pageProps );
$userIndexUpdater = new \MWStake\MediaWiki\Component\CommonWebAPIs\UserIndexUpdater( $lb );
$categoryIndexUpdater = new \MWStake\MediaWiki\Component\CommonWebAPIs\CategoryIndexUpdater( $lb );
$hookContainer = \MediaWiki\MediaWikiServices::getInstance()->getHookContainer();
$hookContainer->register( 'LoadExtensionSchemaUpdates', static function ( $updater ) {
if ( !$updater instanceof DatabaseUpdater ) {
throw new \MWException( "LoadExtensionSchemaUpdates hook must be called with a DatabaseUpdater" );
}
$updater->addExtensionTable(
'mws_user_index',
__DIR__ . "/sql/mws_user_index.sql"
);
$updater->addExtensionTable(
'mws_title_index',
__DIR__ . "/sql/mws_title_index.sql"
);
$updater->addExtensionField(
'mws_title_index',
'mti_displaytitle',
__DIR__ . "/sql/mws_title_index_displaytitle_patch.sql"
);
$updater->addExtensionTable(
'mws_category_index',
__DIR__ . "/sql/mws_category_index.sql"
);
$updater->addExtensionField(
'mws_category_index',
'mci_page_title',
__DIR__ . "/sql/mws_category_index_patch_page_title.sql"
);
$updater->addPostDatabaseUpdateMaintenance(
\MWStake\MediaWiki\Component\CommonWebAPIs\Maintenance\PopulateUserIndex::class
);
$updater->addPostDatabaseUpdateMaintenance(
\MWStake\MediaWiki\Component\CommonWebAPIs\Maintenance\PopulateTitleIndex::class
);
$updater->addPostDatabaseUpdateMaintenance(
\MWStake\MediaWiki\Component\CommonWebAPIs\Maintenance\PopulateCategoryIndex::class
);
} );
$hookContainer->register( 'UserSaveSettings', [ $userIndexUpdater, 'store' ] );
$hookContainer->register( 'PageSaveComplete', [ $titleIndexUpdater, 'onPageSaveComplete' ] );
$hookContainer->register( 'PageSaveComplete', [ $categoryIndexUpdater, 'onPageSaveComplete' ] );
$hookContainer->register( 'PageMoveComplete', [ $titleIndexUpdater, 'onPageMoveComplete' ] );
$hookContainer->register( 'PageMoveComplete', [ $categoryIndexUpdater, 'onPageMoveComplete' ] );
$hookContainer->register( 'PageDeleteComplete', [ $titleIndexUpdater, 'onPageDeleteComplete' ] );
$hookContainer->register( 'PageDeleteComplete', [ $categoryIndexUpdater, 'onPageDeleteComplete' ] );
$hookContainer->register( 'ArticleUndelete', [ $titleIndexUpdater, 'onArticleUndelete' ] );
$hookContainer->register( 'ArticleUndelete', [ $categoryIndexUpdater, 'onArticleUndelete' ] );
$hookContainer->register( 'AfterImportPage', [ $titleIndexUpdater, 'onAfterImportPage' ] );
$hookContainer->register( 'AfterImportPage', [ $categoryIndexUpdater, 'onAfterImportPage' ] );
$hookContainer->register( 'CategoryAfterPageAdded', [ $categoryIndexUpdater, 'onCategoryAfterPageAdded' ] );
$hookContainer->register(
'CategoryAfterPageRemoved', [ $categoryIndexUpdater, 'onCategoryAfterPageRemoved' ]
);
};
$GLOBALS['wgResourceModules']['ext.mws.commonwebapis'] = [
'scripts' => [
'api.js'
],
'localBasePath' => __DIR__ . '/resources'
];
// Exclude users from these groups in user store
$GLOBALS['mwsgCommonWebAPIsComponentUserStoreExcludeGroups'] = [ 'bot' ];
// Exclude porticular users from user store
$GLOBALS['mwsgCommonWebAPIsComponentUserStoreExcludeUsers'] = array_merge(
$GLOBALS['wgReservedUsernames'] ?? [], [ 'Mediawiki default' ]
);
// Exclude these groups from group store
$GLOBALS['mwsgCommonWebAPIsComponentGroupStoreExcludeGroups'] = [ 'bot' ];
} );