Index: branches/FileBackend/phase3/tests/phpunit/includes/filerepo/FileBackendTest.php |
— | — | @@ -9,8 +9,8 @@ |
10 | 10 | 'name' => 'localtesting', |
11 | 11 | 'lockManager' => 'fsLockManager', |
12 | 12 | 'containerPaths' => array( |
13 | | - 'cont1' => "/testdir/localtesting/cont1", |
14 | | - 'cont2' => "/testdir/localtesting/cont2" ) |
| 13 | + 'cont1' => wfTempDir() . '/localtesting/cont1', |
| 14 | + 'cont2' => wfTempDir() . '/localtesting/cont2' ) |
15 | 15 | ) ); |
16 | 16 | $this->filesToPrune = array(); |
17 | 17 | $this->pathsToPrune = array(); |
Index: branches/FileBackend/phase3/tests/phpunit/includes/parser/NewParserTest.php |
— | — | @@ -32,10 +32,6 @@ |
33 | 33 | |
34 | 34 | protected $file = false; |
35 | 35 | |
36 | | - /*function __construct($a = null,$b = array(),$c = null ) { |
37 | | - parent::__construct($a,$b,$c); |
38 | | - }*/ |
39 | | - |
40 | 36 | function setUp() { |
41 | 37 | global $wgContLang, $wgNamespaceProtection, $wgNamespaceAliases; |
42 | 38 | global $wgHooks, $IP; |
— | — | @@ -62,13 +58,12 @@ |
63 | 59 | $tmpGlobals['wgLocalFileRepo'] = array( |
64 | 60 | 'class' => 'LocalRepo', |
65 | 61 | 'name' => 'local', |
66 | | - 'directory' => wfTempDir() . '/test-repo', |
67 | 62 | 'url' => 'http://example.com/images', |
68 | | - 'deletedDir' => wfTempDir() . '/test-repo/delete', |
69 | 63 | 'hashLevels' => 2, |
70 | 64 | 'transformVia404' => false, |
| 65 | + 'backend' => 'local-backend' |
71 | 66 | ); |
72 | | - |
| 67 | + $tmpGlobals['wgForeignFileRepos'] = array(); |
73 | 68 | $tmpGlobals['wgEnableParserCache'] = false; |
74 | 69 | $tmpGlobals['wgHooks'] = $wgHooks; |
75 | 70 | $tmpGlobals['wgDeferredUpdateList'] = array(); |
— | — | @@ -104,7 +99,6 @@ |
105 | 100 | $wgNamespaceProtection[NS_MEDIAWIKI] = 'editinterface'; |
106 | 101 | $wgNamespaceAliases['Image'] = NS_FILE; |
107 | 102 | $wgNamespaceAliases['Image_talk'] = NS_FILE_TALK; |
108 | | - |
109 | 103 | } |
110 | 104 | |
111 | 105 | public function tearDown() { |
— | — | @@ -118,6 +112,10 @@ |
119 | 113 | $wgNamespaceProtection[NS_MEDIAWIKI] = $this->savedWeirdGlobals['mw_namespace_protection']; |
120 | 114 | $wgNamespaceAliases['Image'] = $this->savedWeirdGlobals['image_alias']; |
121 | 115 | $wgNamespaceAliases['Image_talk'] = $this->savedWeirdGlobals['image_talk_alias']; |
| 116 | + |
| 117 | + // Restore backends |
| 118 | + FileBackendGroup::destroySingleton(); |
| 119 | + FileBackendGroup::singleton()->register( $GLOBALS['wgFileBackends'] ); |
122 | 120 | } |
123 | 121 | |
124 | 122 | function addDBData() { |
— | — | @@ -236,10 +234,10 @@ |
237 | 235 | 'wgLocalFileRepo' => array( |
238 | 236 | 'class' => 'LocalRepo', |
239 | 237 | 'name' => 'local', |
240 | | - 'directory' => $this->uploadDir, |
241 | 238 | 'url' => 'http://example.com/images', |
242 | 239 | 'hashLevels' => 2, |
243 | 240 | 'transformVia404' => false, |
| 241 | + 'backend' => 'local-backend' |
244 | 242 | ), |
245 | 243 | 'wgEnableUploads' => self::getOptionValue( 'wgEnableUploads', $opts, true ), |
246 | 244 | 'wgStylePath' => '/skins', |
— | — | @@ -315,12 +313,24 @@ |
316 | 314 | $GLOBALS['wgOut'] = $context->getOutput(); |
317 | 315 | $GLOBALS['wgUser'] = $context->getUser(); |
318 | 316 | |
| 317 | + FileBackendGroup::destroySingleton(); // reset |
| 318 | + $backend = array( |
| 319 | + 'name' => 'local-backend', |
| 320 | + 'class' => 'FSFileBackend', |
| 321 | + 'lockManager' => 'fsLockManager', |
| 322 | + 'containerPaths' => array( |
| 323 | + 'images-public' => $this->uploadDir, |
| 324 | + 'images-thumb' => $this->uploadDir . '/thumb' ) |
| 325 | + ); |
| 326 | + FileBackendGroup::singleton()->register( array( $backend ) ); |
| 327 | + |
319 | 328 | global $wgHooks; |
320 | 329 | |
321 | 330 | $wgHooks['ParserTestParser'][] = 'ParserTestParserHook::setup'; |
322 | 331 | $wgHooks['ParserGetVariableValueTs'][] = 'ParserTest::getFakeTimestamp'; |
323 | 332 | |
324 | 333 | MagicWord::clearCache(); |
| 334 | + RepoGroup::destroySingleton(); |
325 | 335 | |
326 | 336 | # Publish the articles after we have the final language set |
327 | 337 | $this->publishTestArticles(); |
Index: branches/FileBackend/phase3/includes/filerepo/file/LocalFile.php |
— | — | @@ -1001,11 +1001,10 @@ |
1002 | 1002 | ); |
1003 | 1003 | |
1004 | 1004 | if ( $dbw->affectedRows() == 0 ) { |
1005 | | - $reupload = true; |
1006 | 1005 | if ( $oldver == '' ) { |
1007 | | - throw new MWException( |
1008 | | - "Bogus oi_archive_name given. Database and storage out of sync?" ); |
| 1006 | + throw new MWException( "Empty oi_archive_name. Database and storage out of sync?" ); |
1009 | 1007 | } |
| 1008 | + $reupload = true; |
1010 | 1009 | # Collision, this is an update of a file |
1011 | 1010 | # Insert previous contents into oldimage |
1012 | 1011 | $dbw->insertSelect( 'oldimage', 'image', |
Index: branches/FileBackend/phase3/includes/filerepo/backend/FileBackendGroup.php |
— | — | @@ -26,6 +26,14 @@ |
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
| 30 | + * Destroy the singleton instance, so that a new one will be created next |
| 31 | + * time singleton() is called. |
| 32 | + */ |
| 33 | + public static function destroySingleton() { |
| 34 | + self::$instance = null; |
| 35 | + } |
| 36 | + |
| 37 | + /** |
30 | 38 | * Register an array of file backend configurations |
31 | 39 | * |
32 | 40 | * @param $configs Array |