add hook that allows changing the check to see if a page exists or not
authorJeroen De Dauw <jeroendedauw@users.mediawiki.org>
Mon, 30 Jan 2012 12:52:31 +0000 (12:52 +0000)
committerJeroen De Dauw <jeroendedauw@users.mediawiki.org>
Mon, 30 Jan 2012 12:52:31 +0000 (12:52 +0000)
includes/Title.php

index b91c55c..fd72309 100644 (file)
@@ -28,7 +28,8 @@
  *
  * @internal documentation reviewed 15 Mar 2010
  */
-class Title {
+class
+Title {
        /** @name Static cache variables */
        // @{
        static private $titleCache = array();
@@ -4164,7 +4165,21 @@ class Title {
         * @return Bool
         */
        public function isKnown() {
-               return $this->isAlwaysKnown() || $this->exists();
+               $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.19
+                *
+                * @param Title $title
+                * @param boolean|null $isKnown
+                */
+               wfRunHooks( 'TitleIsKnown', array( $this, &$isKnown ) );
+
+               return is_null( $isKnown ) ? ( $this->isAlwaysKnown() || $this->exists() ) : $isKnown;
        }
 
        /**