66 * @defgroup SemanticTasks Semantic Tasks
77 */
88
9+ use MediaWiki \MediaWikiServices ;
910use ST \SemanticTasksMailer ;
1011
1112SemanticTasks::load ();
@@ -22,13 +23,11 @@ public static function load() {
2223 }
2324
2425 /**
25- * @global boolean $wgSemanticTasksNotifyIfUnassigned
2626 * @since 1.0
2727 * @see https://www.mediawiki.org/wiki/Manual:Extension.json/Schema#callback
2828 */
2929 public static function initExtension ( $ credits = [] ) {
30-
31- $ version = 'UNKNOWN ' ;
30+ $ version = 'UNKNOWN ' ;
3231
3332 // See https://phabricator.wikimedia.org/T151136
3433 if ( isset ( $ credits ['version ' ] ) ) {
@@ -41,16 +40,12 @@ public static function initExtension( $credits = [] ) {
4140 if ( !defined ( 'MW_VERSION ' ) ) {
4241 define ( 'MW_VERSION ' , $ GLOBALS ['wgVersion ' ] );
4342 }
44-
45- // Register extension messages and other localisation.
46- $ wgMessagesDirs ['SemanticTasks ' ] = __DIR__ . '/i18n ' ;
4743 }
4844
4945 /**
5046 * @since 1.0
5147 */
5248 public static function onExtensionFunction () {
53-
5449 // Check requirements after LocalSetting.php has been processed
5550 if ( !defined ( 'SMW_VERSION ' ) ) {
5651 if ( PHP_SAPI === 'cli ' || PHP_SAPI === 'phpdbg ' ) {
@@ -66,37 +61,22 @@ public static function onExtensionFunction() {
6661 $ assignees = new \ST \Assignees ();
6762
6863 // Register extension hooks.
69- global $ wgHooks ;
70-
71- if ( version_compare ( MW_VERSION , '1.35 ' , '< ' ) ) {
72- $ wgHooks ['PageContentSave ' ][] = [ $ assignees , 'saveAssignees ' ];
73- $ wgHooks ['PageContentSaveComplete ' ][] = function (WikiPage $ article , User $ current_user , Content $ text ,
74- $ summary , $ minoredit , $ watchthis , $ sectionanchor , $ flags , $ revision ) use ($ assignees ) {
75- SemanticTasksMailer::mailAssigneesUpdatedTask (
76- $ assignees , $ article , $ current_user , $ text ,
77- $ summary , $ minoredit , $ watchthis , $ sectionanchor , $ flags , $ revision
78- );
79- };
80-
81- } else {
82- $ wgHooks ['MultiContentSave ' ][] = [ $ assignees , 'saveAssigneesMultiContentSave ' ];
83- $ wgHooks ['PageSaveComplete ' ][] = function ( WikiPage $ wikiPage , MediaWiki \User \UserIdentity $ user , string $ summary , int $ flags , MediaWiki \Revision \RevisionRecord $ revisionRecord , MediaWiki \Storage \EditResult $ editResult ) use ( $ assignees ) {
84-
85- // @see includes/Storage/PageUpdater.php
86- $ mainContent = $ revisionRecord ->getContent ( MediaWiki \Revision \SlotRecord::MAIN , MediaWiki \Revision \RevisionRecord::RAW );
87- $ minoredit = $ editResult ->isNullEdit () || ( $ flags & EDIT_MINOR )
88- // *** this is for the use in conjunction with WSSlots
89- || ( $ flags & EDIT_INTERNAL );
90- $ watchthis = null ;
91- $ sectionanchor = null ;
92-
93- SemanticTasksMailer::mailAssigneesUpdatedTask (
94- $ assignees , $ wikiPage , $ user , $ mainContent ,
95- $ summary , $ minoredit , $ watchthis , $ sectionanchor , $ flags , $ revisionRecord
96- );
97- };
98- }
99-
64+ $ hookContainer = MediaWikiServices::getInstance ()->getHookContainer ();
65+ $ hookContainer ->register ( 'MultiContentSave ' , [ $ assignees , 'saveAssigneesMultiContentSave ' ] );
66+ $ hookContainer ->register ( 'PageSaveComplete ' , static function ( WikiPage $ wikiPage , MediaWiki \User \UserIdentity $ user , string $ summary , int $ flags , MediaWiki \Revision \RevisionRecord $ revisionRecord , MediaWiki \Storage \EditResult $ editResult ) use ( $ assignees ) {
67+ // @see includes/Storage/PageUpdater.php
68+ $ mainContent = $ revisionRecord ->getContent ( MediaWiki \Revision \SlotRecord::MAIN , MediaWiki \Revision \RevisionRecord::RAW );
69+ $ minoredit = $ editResult ->isNullEdit () || ( $ flags & EDIT_MINOR )
70+ // *** this is for the use in conjunction with WSSlots
71+ || ( $ flags & EDIT_INTERNAL );
72+ $ watchthis = null ;
73+ $ sectionanchor = null ;
74+
75+ SemanticTasksMailer::mailAssigneesUpdatedTask (
76+ $ assignees , $ wikiPage , $ user , $ mainContent ,
77+ $ summary , $ minoredit , $ watchthis , $ sectionanchor , $ flags , $ revisionRecord
78+ );
79+ } );
10080 }
10181
10282}
0 commit comments