Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 63 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
Schema | |
0.00% |
0 / 63 |
|
0.00% |
0 / 2 |
20 | |
0.00% |
0 / 1 |
onLoadExtensionSchemaUpdates | |
0.00% |
0 / 23 |
|
0.00% |
0 / 1 |
6 | |||
doOnSchemaUpdatesPopulatePageTriageTags | |
0.00% |
0 / 40 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Extension\PageTriage\HookHandlers; |
4 | |
5 | use MediaWiki\Installer\DatabaseUpdater; |
6 | use MediaWiki\Installer\Hook\LoadExtensionSchemaUpdatesHook; |
7 | |
8 | /** |
9 | * n.b. service dependencies cannot be injected for hooks handled by this class. |
10 | */ |
11 | class Schema implements LoadExtensionSchemaUpdatesHook { |
12 | |
13 | /** @inheritDoc */ |
14 | public function onLoadExtensionSchemaUpdates( $updater ) { |
15 | $base = __DIR__ . "/../../sql"; |
16 | $dbType = $updater->getDB()->getType(); |
17 | $updater->addExtensionTable( 'pagetriage_tags', "$base/$dbType/tables-generated.sql" ); |
18 | |
19 | $updater->addExtensionUpdate( [ |
20 | [ __CLASS__, 'doOnSchemaUpdatesPopulatePageTriageTags' ], |
21 | ] ); |
22 | |
23 | // 1.35 |
24 | $updater->dropExtensionIndex( |
25 | 'pagetriage_page_tags', |
26 | 'ptrpt_page_tag_id', |
27 | $base . '/PageTriagePageTagsPatch-pk.sql' |
28 | ); |
29 | |
30 | // 1.39 |
31 | if ( $dbType === 'mysql' ) { |
32 | $updater->modifyExtensionField( |
33 | 'pagetriage_page', |
34 | 'ptrp_reviewed_updated', |
35 | $base . '/patch-pagetriage_page-timestamps.sql' |
36 | ); |
37 | // T325519 |
38 | $updater->dropExtensionTable( 'pagetriage_log' ); |
39 | } |
40 | |
41 | // T333389 |
42 | $updater->modifyExtensionField( |
43 | 'pagetriage_page', |
44 | 'ptrp_tags_updated', |
45 | $base . '/' . $dbType . '/patch_ptrp_tags_updated_nullable.sql' |
46 | ); |
47 | } |
48 | |
49 | /** |
50 | * @param DatabaseUpdater $updater |
51 | * @return void |
52 | */ |
53 | public static function doOnSchemaUpdatesPopulatePageTriageTags( DatabaseUpdater $updater ): void { |
54 | $updateKey = 'populatePageTriageTags-1.34'; |
55 | if ( $updater->updateRowExists( $updateKey ) ) { |
56 | $updater->output( "...default pagetriage tags already added\n" ); |
57 | return; |
58 | } |
59 | |
60 | $updater->output( "Adding pagetriage tags...\n" ); |
61 | $pageTriageDefaultTags = [ |
62 | [ 'ptrt_tag_name' => 'linkcount', 'ptrt_tag_desc' => 'Number of inbound links' ], |
63 | [ 'ptrt_tag_name' => 'category_count', 'ptrt_tag_desc' => 'Category mapping count' ], |
64 | [ 'ptrt_tag_name' => 'csd_status', 'ptrt_tag_desc' => 'CSD status' ], |
65 | [ 'ptrt_tag_name' => 'prod_status', 'ptrt_tag_desc' => 'PROD status' ], |
66 | [ 'ptrt_tag_name' => 'blp_prod_status', 'ptrt_tag_desc' => 'BLP PROD status' ], |
67 | [ 'ptrt_tag_name' => 'afd_status', 'ptrt_tag_desc' => 'AFD status' ], |
68 | [ 'ptrt_tag_name' => 'rev_count', 'ptrt_tag_desc' => 'Number of edits to the article' ], |
69 | [ 'ptrt_tag_name' => 'page_len', 'ptrt_tag_desc' => 'Number of bytes of article' ], |
70 | [ 'ptrt_tag_name' => 'snippet', 'ptrt_tag_desc' => 'Beginning of article snippet' ], |
71 | [ 'ptrt_tag_name' => 'user_name', 'ptrt_tag_desc' => 'User name' ], |
72 | [ 'ptrt_tag_name' => 'user_editcount', 'ptrt_tag_desc' => 'User total edit' ], |
73 | [ 'ptrt_tag_name' => 'user_creation_date', 'ptrt_tag_desc' => 'User registration date' ], |
74 | [ 'ptrt_tag_name' => 'user_autoconfirmed', 'ptrt_tag_desc' => 'Check if user is autoconfirmed' ], |
75 | [ 'ptrt_tag_name' => 'user_experience', |
76 | 'ptrt_tag_desc' => 'Experience level: newcomer, learner, experienced or anonymous' ], |
77 | [ 'ptrt_tag_name' => 'user_bot', 'ptrt_tag_desc' => 'Check if user is in bot group' ], |
78 | [ 'ptrt_tag_name' => 'user_block_status', 'ptrt_tag_desc' => 'User block status' ], |
79 | [ 'ptrt_tag_name' => 'user_id', 'ptrt_tag_desc' => 'User id' ], |
80 | [ 'ptrt_tag_name' => 'reference', 'ptrt_tag_desc' => 'Check if page has references' ], |
81 | // 1.32 |
82 | [ 'ptrt_tag_name' => 'afc_state', 'ptrt_tag_desc' => 'The submission state of drafts' ], |
83 | [ 'ptrt_tag_name' => 'copyvio', 'ptrt_tag_desc' => |
84 | 'Latest revision ID that has been tagged as a likely copyright violation, if any' ], |
85 | // 1.34 |
86 | [ 'ptrt_tag_name' => 'recreated', 'ptrt_tag_desc' => 'Check if the page has been previously deleted.' ], |
87 | ]; |
88 | $dbw = $updater->getDB(); |
89 | $dbw->newInsertQueryBuilder() |
90 | ->insertInto( 'pagetriage_tags' ) |
91 | ->rows( $pageTriageDefaultTags ) |
92 | ->caller( __METHOD__ ) |
93 | // ignore() prevents inserting this tag again if it already exists, since ptrt_tag_name is a unique key |
94 | ->ignore() |
95 | ->execute(); |
96 | |
97 | $updater->output( "Done\n" ); |
98 | $updater->insertUpdateRow( $updateKey ); |
99 | } |
100 | } |