Trim trailing whitespace
[lhc/web/wiklou.git] / includes / Title.php
index c21b63f..274bd25 100644 (file)
@@ -1045,8 +1045,8 @@ class Title {
         */
        public function getCanonicalURL( $query = '', $variant = false ) {
                global $wgCanonicalServer;
-               $url = $wgCanonicalServer . $this->getLocalURL( $query, $variant ) . $this->getFragmentForURL();
-               wfRunHooks( 'GetCanonicalURL', array( &$this, &$url, $query ) );
+               $url = wfExpandUrl( $this->getLocalURL( $query, $variant ) . $this->getFragmentForURL(), PROTO_CANONICAL );
+               wfRunHooks( '', array( &$this, &$url, $query ) );
                return $url;
        }
 
@@ -2552,7 +2552,7 @@ class Title {
         */
        public function resetArticleID( $newid ) {
                $linkCache = LinkCache::singleton();
-               $linkCache->clearBadLink( $this->getPrefixedDBkey() );
+               $linkCache->clearLink( $this );
 
                if ( $newid === false ) {
                        $this->mArticleID = -1;
@@ -3387,7 +3387,7 @@ class Title {
                                                        array(  'gtl_from_wiki' => wfGetID(),
                                                                        'gtl_from_page' => $newid ),
                                                        __METHOD__ );
-               }
+                       }
                }
 
                # Save a null revision in the page's history notifying of the move
@@ -3860,6 +3860,18 @@ class Title {
                        && $this->getDBkey() === $title->getDBkey();
        }
 
+       /**
+        * Check if this title is a subpage of another title
+        *
+        * @param $title Title
+        * @return Bool
+        */
+       public function isSubpageOf( Title $title ) {
+               return $this->getInterwiki() === $title->getInterwiki()
+                       && $this->getNamespace() == $title->getNamespace()
+                       && strpos( $this->getDBkey(), $title->getDBkey() . '/' ) === 0;
+       }
+
        /**
         * Callback for usort() to do title sorts by (namespace, title)
         *