* @return String the URL
*/
public function getInternalURL( $query = '', $variant = false ) {
- global $wgInternalServer;
- $url = $wgInternalServer . $this->getLocalURL( $query, $variant );
+ global $wgInternalServer, $wgServer;
+ $server = $wgInternalServer !== false ? $wgInternalServer : $wgServer;
+ $url = $server . $this->getLocalURL( $query, $variant );
wfRunHooks( 'GetInternalURL', array( &$this, &$url, $query ) );
return $url;
}
* Is this a *valid* .css or .js subpage of a user page?
*
* @return Bool
- * @deprecated @since 1.17
+ * @deprecated since 1.17
*/
public function isValidCssJsSubpage() {
return $this->isCssJsSubpage();
// Image-specific checks
if ( $this->getNamespace() == NS_FILE ) {
- if ( $nt->getNamespace() != NS_FILE ) {
- $errors[] = array( 'imagenocrossnamespace' );
- }
- $file = wfLocalFile( $this );
- if ( $file->exists() ) {
- if ( $nt->getText() != wfStripIllegalFilenameChars( $nt->getText() ) ) {
- $errors[] = array( 'imageinvalidfilename' );
- }
- if ( !File::checkExtensionCompatibility( $file, $nt->getDBkey() ) ) {
- $errors[] = array( 'imagetypemismatch' );
- }
- }
- $destfile = wfLocalFile( $nt );
- if ( !$wgUser->isAllowed( 'reupload-shared' ) && !$destfile->exists() && wfFindFile( $nt ) ) {
- $errors[] = array( 'file-exists-sharedrepo' );
- }
+ $errors = array_merge( $errors, $this->validateFileMoveOperation( $nt ) );
}
-
+
if ( $nt->getNamespace() == NS_FILE && $this->getNamespace() != NS_FILE ) {
$errors[] = array( 'nonfile-cannot-move-to-file' );
}
}
return $errors;
}
+
+ /**
+ * Check if the requested move target is a valid file move target
+ * @param Title $nt Target title
+ * @return array List of errors
+ */
+ protected function validateFileMoveOperation( $nt ) {
+ global $wgUser;
+
+ $errors = array();
+
+ if ( $nt->getNamespace() != NS_FILE ) {
+ $errors[] = array( 'imagenocrossnamespace' );
+ }
+
+ $file = wfLocalFile( $this );
+ if ( $file->exists() ) {
+ if ( $nt->getText() != wfStripIllegalFilenameChars( $nt->getText() ) ) {
+ $errors[] = array( 'imageinvalidfilename' );
+ }
+ if ( !File::checkExtensionCompatibility( $file, $nt->getDBkey() ) ) {
+ $errors[] = array( 'imagetypemismatch' );
+ }
+ }
+
+ $destFile = wfLocalFile( $nt );
+ if ( !$wgUser->isAllowed( 'reupload-shared' ) && !$destfile->exists() && wfFindFile( $nt ) ) {
+ $errors[] = array( 'file-exists-sharedrepo' );
+ }
+
+ return $errors;
+ }
/**
* Move a title to a new location
* @return array applicable restriction types
*/
public function getRestrictionTypes() {
+ if ( $this->getNamespace() == NS_SPECIAL ) {
+ return array();
+ }
+
$types = self::getFilteredRestrictionTypes( $this->exists() );
if ( $this->getNamespace() != NS_FILE ) {
$types = $wgRestrictionTypes;
if ( $exists ) {
# Remove the create restriction for existing titles
- $types = array_diff( $types, array( 'create' ) );
+ $types = array_diff( $types, array( 'create' ) );
} else {
# Only the create and upload restrictions apply to non-existing titles
$types = array_intersect( $types, array( 'create', 'upload' ) );