Trim trailing whitespace
[lhc/web/wiklou.git] / includes / Title.php
index 192e9ba..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;
        }
 
@@ -1555,7 +1555,7 @@ class Title {
                                $errors[] = array( 'immobile-source-namespace', $this->getNsText() );
                        } elseif ( !$this->isMovable() ) {
                                // Less specific message for rarer cases
-                               $errors[] = array( 'immobile-page' );
+                               $errors[] = array( 'immobile-source-page' );
                        }
                } elseif ( $action == 'move-target' ) {
                        if ( !MWNamespace::isMovable( $this->mNamespace ) ) {
@@ -1786,7 +1786,14 @@ class Title {
         * @return Bool TRUE or FALSE
         */
        public function isMovable() {
-               return MWNamespace::isMovable( $this->getNamespace() ) && $this->getInterwiki() == '';
+               if ( !MWNamespace::isMovable( $this->getNamespace() ) || $this->getInterwiki() != '' ) {
+                       // Interwiki title or immovable namespace. Hooks don't get to override here
+                       return false;
+               }
+               
+               $result = true;
+               wfRunHooks( 'TitleIsMovable', array( $this, &$result ) );
+               return $result;
        }
 
        /**
@@ -2545,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;
@@ -3380,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
@@ -3853,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)
         *