* e-mail notifications. Uses $wgCanonicalServer and the
* GetCanonicalURL hook.
*
+ * NOTE: Unlike getInternalURL(), the canonical URL includes the fragment
+ *
* @param $query string An optional query string
* @param $variant string Language variant of URL (for sr, zh, ...)
* @return string The URL
*/
public function getCanonicalURL( $query = '', $variant = false ) {
global $wgCanonicalServer;
- $url = $wgCanonicalServer . $this->getLocalURL( $query, $variant );
- wfRunHooks( 'GetCanonicalURL', array( &$this, &$url, $query ) );
+ $url = wfExpandUrl( $this->getLocalURL( $query, $variant ) . $this->getFragmentForURL(), PROTO_CANONICAL );
+ wfRunHooks( '', array( &$this, &$url, $query ) );
return $url;
}
$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 ) ) {
* @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;
}
/**
*/
public function resetArticleID( $newid ) {
$linkCache = LinkCache::singleton();
- $linkCache->clearBadLink( $this->getPrefixedDBkey() );
+ $linkCache->clearLink( $this );
if ( $newid === false ) {
$this->mArticleID = -1;
array( 'gtl_from_wiki' => wfGetID(),
'gtl_from_page' => $newid ),
__METHOD__ );
- }
+ }
}
# Save a null revision in the page's history notifying of the move
&& $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)
*