r105156 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105155‎ | r105156 | r105157 >
Date:07:34, 5 December 2011
Author:aaron
Status:deferred
Tags:
Comment:
* Fixed errors in NewParserTests.php
* Use proper temp dir in FileBackendTests.php
* Added FileBackendGroup::destroySingleton()
* Minor code cleanups
Modified paths:
  • /branches/FileBackend/phase3/includes/filerepo/backend/FileBackendGroup.php (modified) (history)
  • /branches/FileBackend/phase3/includes/filerepo/file/LocalFile.php (modified) (history)
  • /branches/FileBackend/phase3/tests/phpunit/includes/filerepo/FileBackendTest.php (modified) (history)
  • /branches/FileBackend/phase3/tests/phpunit/includes/parser/NewParserTest.php (modified) (history)

Diff [purge]

Index: branches/FileBackend/phase3/tests/phpunit/includes/filerepo/FileBackendTest.php
@@ -9,8 +9,8 @@
1010 'name' => 'localtesting',
1111 'lockManager' => 'fsLockManager',
1212 'containerPaths' => array(
13 - 'cont1' => "/testdir/localtesting/cont1",
14 - 'cont2' => "/testdir/localtesting/cont2" )
 13+ 'cont1' => wfTempDir() . '/localtesting/cont1',
 14+ 'cont2' => wfTempDir() . '/localtesting/cont2' )
1515 ) );
1616 $this->filesToPrune = array();
1717 $this->pathsToPrune = array();
Index: branches/FileBackend/phase3/tests/phpunit/includes/parser/NewParserTest.php
@@ -32,10 +32,6 @@
3333
3434 protected $file = false;
3535
36 - /*function __construct($a = null,$b = array(),$c = null ) {
37 - parent::__construct($a,$b,$c);
38 - }*/
39 -
4036 function setUp() {
4137 global $wgContLang, $wgNamespaceProtection, $wgNamespaceAliases;
4238 global $wgHooks, $IP;
@@ -62,13 +58,12 @@
6359 $tmpGlobals['wgLocalFileRepo'] = array(
6460 'class' => 'LocalRepo',
6561 'name' => 'local',
66 - 'directory' => wfTempDir() . '/test-repo',
6762 'url' => 'http://example.com/images',
68 - 'deletedDir' => wfTempDir() . '/test-repo/delete',
6963 'hashLevels' => 2,
7064 'transformVia404' => false,
 65+ 'backend' => 'local-backend'
7166 );
72 -
 67+ $tmpGlobals['wgForeignFileRepos'] = array();
7368 $tmpGlobals['wgEnableParserCache'] = false;
7469 $tmpGlobals['wgHooks'] = $wgHooks;
7570 $tmpGlobals['wgDeferredUpdateList'] = array();
@@ -104,7 +99,6 @@
105100 $wgNamespaceProtection[NS_MEDIAWIKI] = 'editinterface';
106101 $wgNamespaceAliases['Image'] = NS_FILE;
107102 $wgNamespaceAliases['Image_talk'] = NS_FILE_TALK;
108 -
109103 }
110104
111105 public function tearDown() {
@@ -118,6 +112,10 @@
119113 $wgNamespaceProtection[NS_MEDIAWIKI] = $this->savedWeirdGlobals['mw_namespace_protection'];
120114 $wgNamespaceAliases['Image'] = $this->savedWeirdGlobals['image_alias'];
121115 $wgNamespaceAliases['Image_talk'] = $this->savedWeirdGlobals['image_talk_alias'];
 116+
 117+ // Restore backends
 118+ FileBackendGroup::destroySingleton();
 119+ FileBackendGroup::singleton()->register( $GLOBALS['wgFileBackends'] );
122120 }
123121
124122 function addDBData() {
@@ -236,10 +234,10 @@
237235 'wgLocalFileRepo' => array(
238236 'class' => 'LocalRepo',
239237 'name' => 'local',
240 - 'directory' => $this->uploadDir,
241238 'url' => 'http://example.com/images',
242239 'hashLevels' => 2,
243240 'transformVia404' => false,
 241+ 'backend' => 'local-backend'
244242 ),
245243 'wgEnableUploads' => self::getOptionValue( 'wgEnableUploads', $opts, true ),
246244 'wgStylePath' => '/skins',
@@ -315,12 +313,24 @@
316314 $GLOBALS['wgOut'] = $context->getOutput();
317315 $GLOBALS['wgUser'] = $context->getUser();
318316
 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+
319328 global $wgHooks;
320329
321330 $wgHooks['ParserTestParser'][] = 'ParserTestParserHook::setup';
322331 $wgHooks['ParserGetVariableValueTs'][] = 'ParserTest::getFakeTimestamp';
323332
324333 MagicWord::clearCache();
 334+ RepoGroup::destroySingleton();
325335
326336 # Publish the articles after we have the final language set
327337 $this->publishTestArticles();
Index: branches/FileBackend/phase3/includes/filerepo/file/LocalFile.php
@@ -1001,11 +1001,10 @@
10021002 );
10031003
10041004 if ( $dbw->affectedRows() == 0 ) {
1005 - $reupload = true;
10061005 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?" );
10091007 }
 1008+ $reupload = true;
10101009 # Collision, this is an update of a file
10111010 # Insert previous contents into oldimage
10121011 $dbw->insertSelect( 'oldimage', 'image',
Index: branches/FileBackend/phase3/includes/filerepo/backend/FileBackendGroup.php
@@ -26,6 +26,14 @@
2727 }
2828
2929 /**
 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+ /**
3038 * Register an array of file backend configurations
3139 *
3240 * @param $configs Array

Status & tagging log