* (bug 30192) Thumbnails of archived files are now deleted
* (bug 30843) mediawiki.Title should not convert extensions (anything after the
last full stop) to lower case)
+* (bug 31213) Exception thrown when trying to move file cross-namespace
=== API changes in 1.18 ===
* BREAKING CHANGE: action=watch now requires POST and token.
$errors = array();
- if ( $nt->getNamespace() != NS_FILE ) {
- $errors[] = array( 'imagenocrossnamespace' );
- }
-
+ // wfFindFile( $nt ) / wfLocalFile( $nt ) is not allowed until below
+
$file = wfLocalFile( $this );
if ( $file->exists() ) {
if ( $nt->getText() != wfStripIllegalFilenameChars( $nt->getText() ) ) {
$errors[] = array( 'imagetypemismatch' );
}
}
+
+ if ( $nt->getNamespace() != NS_FILE ) {
+ $errors[] = array( 'imagenocrossnamespace' );
+ // From here we want to do checks on a file object, so if we can't
+ // create one, we must return.
+ return $errors;
+ }
+
+ // wfFindFile( $nt ) / wfLocalFile( $nt ) is allowed below here
$destFile = wfLocalFile( $nt );
if ( !$wgUser->isAllowed( 'reupload-shared' ) && !$destFile->exists() && wfFindFile( $nt ) ) {
array( 'Special:Version/param', 'param' ),
);
}
+
+ /**
+ * Auth-less test of Title::isValidMoveOperation
+ *
+ * @param string $source
+ * @param string $target
+ * @param array|string|true $requiredErrors
+ * @dataProvider dataTestIsValidMoveOperation
+ */
+ function testIsValidMoveOperation( $source, $target, $expected ) {
+ $title = Title::newFromText( $source );
+ $nt = Title::newFromText( $target );
+ $errors = $title->isValidMoveOperation( $nt, false );
+ if ( $expected === true ) {
+ $this->assertTrue( $errors );
+ } else {
+ $errors = $this->flattenErrorsArray( $errors );
+ foreach ( (array)$expected as $error ) {
+ $this->assertContains( $error, $errors );
+ }
+ }
+ }
+
+ function flattenErrorsArray( $errors ) {
+ $result = array();
+ foreach ( $errors as $error ) {
+ $result[] = $error[0];
+ }
+ return $result;
+ }
+
+ function dataTestIsValidMoveOperation() {
+ return array(
+ array( 'Test', 'Test', 'selfmove' ),
+ array( 'File:Test.jpg', 'Page', 'imagenocrossnamespace' )
+ );
+ }
+
+
}