follow up to r111017, move hook to isAlwatsKnown as per discussion on CR
authorJeroen De Dauw <jeroendedauw@users.mediawiki.org>
Sun, 12 Feb 2012 23:10:06 +0000 (23:10 +0000)
committerJeroen De Dauw <jeroendedauw@users.mediawiki.org>
Sun, 12 Feb 2012 23:10:06 +0000 (23:10 +0000)
RELEASE-NOTES-1.20
docs/hooks.txt
includes/Title.php

index 411d8e2..8f4bef6 100644 (file)
@@ -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 ===
index e18fa45..70fe639 100644 (file)
@@ -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
index 0ef4cda..bd1851c 100644 (file)
@@ -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();
        }
 
        /**