jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/401411 )
Change subject: Fix wgRestrictionEdit not exists in mw.config ...................................................................... Fix wgRestrictionEdit not exists in mw.config Added new TitleExists hook that gives true whether an Org or a Course actually exists. Bug: T133289 Change-Id: Ibe447488959e85f335af654e714db136ff22c8ab --- M EducationProgram.hooks.php M extension.json 2 files changed, 35 insertions(+), 12 deletions(-) Approvals: Florianschmidtwelzow: Looks good to me, approved jenkins-bot: Verified diff --git a/EducationProgram.hooks.php b/EducationProgram.hooks.php index 72191aa..0d5acb4 100644 --- a/EducationProgram.hooks.php +++ b/EducationProgram.hooks.php @@ -366,17 +366,7 @@ * @param bool|null &$isKnown */ public static function onTitleIsAlwaysKnown( Title $title, &$isKnown ) { - if ( $title->getNamespace() == EP_NS ) { - if ( Utils::isCourse( $title ) ) { - $class = 'EducationProgram\Courses'; - } else { - $class = 'EducationProgram\Orgs'; - } - - $identifier = $title->getText(); - - $isKnown = $class::singleton()->hasIdentifier( $identifier ); - } + self::doesOrgOrCourseExists( $title, $isKnown ); } public static function onMovePageIsValidMove( @@ -709,4 +699,36 @@ return true; } + + /** + * Title::exists() returns false for all actions across EducationProgram, fix that here. + * + * @param Title $title + * @param bool &$exists + */ + public static function onTitleExists( Title $title, &$exists ) { + self::doesOrgOrCourseExists( $title, $exists ); + } + + /** + * Note: This isn't a hook, it's a helper function that is called + * from self::onTitleIsAlwaysKnown and self::onTitleExists. + * + * @param Title $title + * @param boolean $exists + */ + private static function doesOrgOrCourseExists( Title $title, &$exists ) { + if ( $title->getNamespace() == EP_NS ) { + if ( Utils::isCourse( $title ) ) { + $class = Courses::class; + } else { + $class = Orgs::class; + } + + $identifier = $title->getText(); + + /** @var Courses|Orgs $class */ + $exists = $class::singleton()->hasIdentifier( $identifier ); + } + } } diff --git a/extension.json b/extension.json index 2d4aeb8..80b005b 100644 --- a/extension.json +++ b/extension.json @@ -705,7 +705,8 @@ "UserMergeAccountFields": "EducationProgram\\Hooks::onUserMergeAccountFields", "UserMergeAccountDeleteTables": "EducationProgram\\Hooks::onUserMergeAccountDeleteTables", "MergeAccountFromTo": "EducationProgram\\Hooks::onMergeAccountFromTo", - "ResourceLoaderRegisterModules": "EducationProgram\\Hooks::onResourceLoaderRegisterModules" + "ResourceLoaderRegisterModules": "EducationProgram\\Hooks::onResourceLoaderRegisterModules", + "TitleExists": "EducationProgram\\Hooks::onTitleExists" }, "config": { "EPSettings": { -- To view, visit https://gerrit.wikimedia.org/r/401411 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ibe447488959e85f335af654e714db136ff22c8ab Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/extensions/EducationProgram Gerrit-Branch: master Gerrit-Owner: Albert221 <w.albert...@gmail.com> Gerrit-Reviewer: Albert221 <w.albert...@gmail.com> Gerrit-Reviewer: AndyRussG <andrew.green...@gmail.com> Gerrit-Reviewer: D3r1ck01 <alangider...@gmail.com> Gerrit-Reviewer: Florianschmidtwelzow <florian.schmidt.stargatewis...@gmail.com> Gerrit-Reviewer: Ragesoss <rages...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits