From 647909623384585b0fe07bdd32efccd46ac6735c Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Sun, 12 Feb 2012 23:10:06 +0000 Subject: [PATCH] follow up to r111017, move hook to isAlwatsKnown as per discussion on CR --- RELEASE-NOTES-1.20 | 2 +- docs/hooks.txt | 2 +- includes/Title.php | 35 ++++++++++++++++++++--------------- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/RELEASE-NOTES-1.20 b/RELEASE-NOTES-1.20 index 411d8e22bc..8f4bef6f3a 100644 --- a/RELEASE-NOTES-1.20 +++ b/RELEASE-NOTES-1.20 @@ -13,7 +13,7 @@ production. === Configuration changes in 1.20 === === New features in 1.20 === -* Added TitleIsKnown hook which gets called when determining if a page exists. +* Added TitleIsAlwaysKnown hook which gets called when determining if a page exists. * (bug 32341) Add upload by URL domain limitation. === Bug fixes in 1.20 === diff --git a/docs/hooks.txt b/docs/hooks.txt index e18fa4583f..70fe6396fb 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -1903,7 +1903,7 @@ $title: The title in question. $title: Title object that is being checked $result: Boolean; whether MediaWiki currently thinks this is a CSS/JS page. Hooks may change this value to override the return value of Title::isCssOrJsPage() -'TitleIsKnown': Called when determining if a page exists. +'TitleIsAlwaysKnown': Called when determining if a page exists. Allows overriding default behaviour for determining if a page exists. If $isKnown is kept as null, regular checks happen. If it's a boolean, this value is returned by the isKnown method. $title: Title object that is being checked diff --git a/includes/Title.php b/includes/Title.php index 0ef4cda26b..bd1851c46e 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -4134,9 +4134,28 @@ class Title { * @return Bool */ public function isAlwaysKnown() { + $isKnown = null; + + /** + * Allows overriding default behaviour for determining if a page exists. + * If $isKnown is kept as null, regular checks happen. If it's + * a boolean, this value is returned by the isKnown method. + * + * @since 1.20 + * + * @param Title $title + * @param boolean|null $isKnown + */ + wfRunHooks( 'TitleIsAlwaysKnown', array( $this, &$isKnown ) ); + + if ( !is_null( $isKnown ) ) { + return $isKnown; + } + if ( $this->mInterwiki != '' ) { return true; // any interwiki link might be viewable, for all we know } + switch( $this->mNamespace ) { case NS_MEDIA: case NS_FILE: @@ -4165,21 +4184,7 @@ class Title { * @return Bool */ public function isKnown() { - $isKnown = null; - - /** - * Allows overriding default behaviour for determining if a page exists. - * If $isKnown is kept as null, regular checks happen. If it's - * a boolean, this value is returned by the isKnown method. - * - * @since 1.20 - * - * @param Title $title - * @param boolean|null $isKnown - */ - wfRunHooks( 'TitleIsKnown', array( $this, &$isKnown ) ); - - return is_null( $isKnown ) ? ( $this->isAlwaysKnown() || $this->exists() ) : $isKnown; + return $this->isAlwaysKnown() || $this->exists(); } /** -- 2.20.1