https://www.mediawiki.org/wiki/Special:Code/MediaWiki/114374

Revision: 114374
Author:   reedy
Date:     2012-03-21 16:57:59 +0000 (Wed, 21 Mar 2012)
Log Message:
-----------
MFT r113412, r113441, r113601, r113617, r113782

Modified Paths:
--------------
    branches/REL1_19/phase3/includes/Linker.php
    branches/REL1_19/phase3/includes/db/Database.php
    branches/REL1_19/phase3/includes/filerepo/FileRepo.php
    branches/REL1_19/phase3/includes/filerepo/backend/FileBackend.php
    branches/REL1_19/phase3/includes/filerepo/backend/FileOp.php
    branches/REL1_19/phase3/includes/filerepo/file/ForeignAPIFile.php
    branches/REL1_19/phase3/includes/filerepo/file/LocalFile.php
    branches/REL1_19/phase3/resources/mediawiki/mediawiki.js
    branches/REL1_19/phase3/tests/parser/parserTests.txt
    branches/REL1_19/phase3/tests/phpunit/includes/filerepo/FileBackendTest.php

Property Changed:
----------------
    branches/REL1_19/phase3/
    branches/REL1_19/phase3/includes/
    branches/REL1_19/phase3/includes/db/Database.php


Property changes on: branches/REL1_19/phase3
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/JSTesting:100352-107913
/branches/REL1_15/phase3:51646
/branches/REL1_17/phase3:81445,81448
/branches/new-installer/phase3:43664-66004
/branches/sqlite:58211-58321
/branches/wmf/1.18wmf1:97508,111667
/trunk/phase3:111002,111029,111034,111062,111067,111076,111085,111128,111144,111251,111380,111427,111478,111571,111574,111580,111597,111647,111658,111673,111695,111697,111795,111809,111832,111881,111920,111983,112021,112034,112037,112045-112046,112049,112061,112066,112079,112128,112152,112169-112170,112172-112173,112179,112184,112290,112313,112347,112374,112383-112384,112400,112408,112451,112456,112474,112526,112533-112534,112538,112563,112566-112567,112573,112700,112750,112838,112855,112872-112873,112918,112988,112995,113001,113024,113039,113046,113085,113099,113169,113171,113195,113211,113214,113268,113277,113312,113415,113454,113737,113758,113775,113892
   + /branches/JSTesting:100352-107913
/branches/REL1_15/phase3:51646
/branches/REL1_17/phase3:81445,81448
/branches/new-installer/phase3:43664-66004
/branches/sqlite:58211-58321
/branches/wmf/1.18wmf1:97508,111667
/trunk/phase3:111002,111029,111034,111062,111067,111076,111085,111128,111144,111251,111380,111427,111478,111571,111574,111580,111597,111647,111658,111673,111695,111697,111795,111809,111832,111881,111920,111983,112021,112034,112037,112045-112046,112049,112061,112066,112079,112128,112152,112169-112170,112172-112173,112179,112184,112290,112313,112347,112374,112383-112384,112400,112408,112451,112456,112474,112526,112533-112534,112538,112563,112566-112567,112573,112700,112750,112838,112855,112872-112873,112918,112988,112995,113001,113024,113039,113046,113085,113099,113169,113171,113195,113211,113214,113268,113277,113312,113412,113415,113441,113454,113601,113617,113737,113758,113775,113782,113892


Property changes on: branches/REL1_19/phase3/includes
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/JSTesting/includes:100352-107913
/branches/REL1_15/phase3/includes:51646
/branches/new-installer/phase3/includes:43664-66004
/branches/sqlite/includes:58211-58321
/branches/wmf/1.18wmf1/includes:97508,111667
/branches/wmf-deployment/includes:53381
/trunk/phase3/includes:111029,111034,111067,111085,111128,111144,111251,111380,111427,111571,111574,111597,111647,111658,111673,111695,111697,111809,111832,111983,112021,112034,112037,112045-112046,112049,112061,112066,112079,112128,112152,112184,112290,112313,112347,112374,112383,112408,112451,112456,112474,112526,112533-112534,112538,112563,112566-112567,112700,112750,112838,112855,112872-112873,112918,112988,112995,113001,113024,113039,113046,113099,113169,113171,113195,113211,113214,113268,113277,113312,113415,113454,113737,113758,113892
   + /branches/JSTesting/includes:100352-107913
/branches/REL1_15/phase3/includes:51646
/branches/new-installer/phase3/includes:43664-66004
/branches/sqlite/includes:58211-58321
/branches/wmf/1.18wmf1/includes:97508,111667
/branches/wmf-deployment/includes:53381
/trunk/phase3/includes:111029,111034,111067,111085,111128,111144,111251,111380,111427,111571,111574,111597,111647,111658,111673,111695,111697,111809,111832,111983,112021,112034,112037,112045-112046,112049,112061,112066,112079,112128,112152,112184,112290,112313,112347,112374,112383,112408,112451,112456,112474,112526,112533-112534,112538,112563,112566-112567,112700,112750,112838,112855,112872-112873,112918,112988,112995,113001,113024,113039,113046,113099,113169,113171,113195,113211,113214,113268,113277,113312,113412,113415,113441,113454,113601,113617,113737,113758,113782,113892

Modified: branches/REL1_19/phase3/includes/Linker.php
===================================================================
--- branches/REL1_19/phase3/includes/Linker.php 2012-03-21 16:17:26 UTC (rev 
114373)
+++ branches/REL1_19/phase3/includes/Linker.php 2012-03-21 16:57:59 UTC (rev 
114374)
@@ -1182,7 +1182,7 @@
                }
                if ( $pre ) {
                        # written summary $presep autocomment (summary /* 
section */)
-                       $auto = wfMsgExt( 'autocomment-prefix', array( 
'escapenoentities', 'content' ) ) . $auto;
+                       $pre .= wfMsgExt( 'autocomment-prefix', array( 
'escapenoentities', 'content' ) );
                }
                if ( $post ) {
                        # autocomment $postsep written summary (/* section */ 
summary)

Modified: branches/REL1_19/phase3/includes/db/Database.php
===================================================================
--- branches/REL1_19/phase3/includes/db/Database.php    2012-03-21 16:17:26 UTC 
(rev 114373)
+++ branches/REL1_19/phase3/includes/db/Database.php    2012-03-21 16:57:59 UTC 
(rev 114374)
@@ -677,7 +677,7 @@
                $dbType = strtolower( $dbType );
                $class = 'Database' . ucfirst( $dbType );
 
-               if( in_array( $dbType, $canonicalDBTypes ) ) {
+               if( in_array( $dbType, $canonicalDBTypes ) || ( class_exists( 
$class ) && is_subclass_of( $class, 'DatabaseBase' ) ) ) {
                        return new $class(
                                isset( $p['host'] ) ? $p['host'] : false,
                                isset( $p['user'] ) ? $p['user'] : false,
@@ -686,8 +686,6 @@
                                isset( $p['flags'] ) ? $p['flags'] : 0,
                                isset( $p['tablePrefix'] ) ? $p['tablePrefix'] 
: 'get from global'
                        );
-               } elseif ( class_exists( $class ) && is_subclass_of( $class, 
'DatabaseBase' ) ) {
-                       return new $class( $p );
                } else {
                        return null;
                }


Property changes on: branches/REL1_19/phase3/includes/db/Database.php
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/JSTesting/includes/db/Database.php:100352-107913
/branches/REL1_15/phase3/includes/db/Database.php:51646
/branches/new-installer/phase3/includes/db/Database.php:43664-66004
/branches/querypage-work2/phase3/includes/db/Database.php:65475
/branches/sqlite/includes/db/Database.php:58211-58321
/branches/wmf/1.16wmf4/includes/db/Database.php:67177
/branches/wmf-deployment/includes/db/Database.php:53381
   + /branches/JSTesting/includes/db/Database.php:100352-107913
/branches/REL1_15/phase3/includes/db/Database.php:51646
/branches/new-installer/phase3/includes/db/Database.php:43664-66004
/branches/querypage-work2/phase3/includes/db/Database.php:65475
/branches/sqlite/includes/db/Database.php:58211-58321
/branches/wmf/1.16wmf4/includes/db/Database.php:67177
/branches/wmf-deployment/includes/db/Database.php:53381
/trunk/phase3/includes/db/Database.php:113601,113617,113782

Modified: branches/REL1_19/phase3/includes/filerepo/FileRepo.php
===================================================================
--- branches/REL1_19/phase3/includes/filerepo/FileRepo.php      2012-03-21 
16:17:26 UTC (rev 114373)
+++ branches/REL1_19/phase3/includes/filerepo/FileRepo.php      2012-03-21 
16:57:59 UTC (rev 114374)
@@ -733,9 +733,11 @@
         * It will try to delete each file, but ignores any errors that may 
occur.
         *
         * @param $pairs array List of files to delete
+        * @param $flags Integer: bitwise combination of the following flags:
+        *     self::SKIP_LOCKING      Skip any file locking when doing the 
deletions
         * @return void
         */
-       public function cleanupBatch( $files ) {
+       public function cleanupBatch( $files, $flags = 0 ) {
                $operations = array();
                $sourceFSFilesToDelete = array(); // cleanup for disk source 
files
                foreach ( $files as $file ) {
@@ -765,6 +767,9 @@
                }
                // Actually delete files from storage...
                $opts = array( 'force' => true );
+               if ( $flags & self::SKIP_LOCKING ) {
+                       $opts['nonLocking'] = true;
+               }
                $this->backend->doOperations( $operations, $opts );
                // Cleanup for disk source files...
                foreach ( $sourceFSFilesToDelete as $file ) {

Modified: branches/REL1_19/phase3/includes/filerepo/backend/FileBackend.php
===================================================================
--- branches/REL1_19/phase3/includes/filerepo/backend/FileBackend.php   
2012-03-21 16:17:26 UTC (rev 114373)
+++ branches/REL1_19/phase3/includes/filerepo/backend/FileBackend.php   
2012-03-21 16:57:59 UTC (rev 114374)
@@ -184,8 +184,9 @@
         * Return value:
         * This returns a Status, which contains all warnings and fatals that 
occured
         * during the operation. The 'failCount', 'successCount', and 'success' 
members
-        * will reflect each operation attempted. The status will be "OK" 
unless any
-        * of the operations failed and the 'force' parameter was not set.
+        * will reflect each operation attempted. The status will be "OK" 
unless:
+        *     a) unexpected operation errors occurred (network partitions, 
disk full...)
+        *     b) significant operation errors occured and 'force' was not set
         * 
         * @param $ops Array List of operations to execute in order
         * @param $opts Array Batch operation options

Modified: branches/REL1_19/phase3/includes/filerepo/backend/FileOp.php
===================================================================
--- branches/REL1_19/phase3/includes/filerepo/backend/FileOp.php        
2012-03-21 16:17:26 UTC (rev 114373)
+++ branches/REL1_19/phase3/includes/filerepo/backend/FileOp.php        
2012-03-21 16:57:59 UTC (rev 114374)
@@ -81,6 +81,10 @@
         * 'allowStale' : Don't require the latest available data.
         *                This can increase performance for non-critical writes.
         *                This has no effect unless the 'force' flag is set.
+        *
+        * The resulting Status will be "OK" unless:
+        *     a) unexpected operation errors occurred (network partitions, 
disk full...)
+        *     b) significant operation errors occured and 'force' was not set
         * 
         * @param $performOps Array List of FileOp operations
         * @param $opts Array Batch operation options
@@ -115,6 +119,11 @@
                        }
                }
 
+               if ( $ignoreErrors ) {
+                       # Treat all precheck() fatals as merely warnings
+                       $status->setResult( true, $status->value );
+               }
+
                // Restart PHP's execution timer and set the timeout to safe 
amount.
                // This handles cases where the operations take a long time or 
where we are
                // already running low on time left. The old timeout is 
restored afterwards.

Modified: branches/REL1_19/phase3/includes/filerepo/file/ForeignAPIFile.php
===================================================================
--- branches/REL1_19/phase3/includes/filerepo/file/ForeignAPIFile.php   
2012-03-21 16:17:26 UTC (rev 114373)
+++ branches/REL1_19/phase3/includes/filerepo/file/ForeignAPIFile.php   
2012-03-21 16:57:59 UTC (rev 114374)
@@ -245,7 +245,7 @@
                }
 
                # Delete the thumbnails
-               $this->repo->cleanupBatch( $purgeList );
+               $this->repo->cleanupBatch( $purgeList, FileRepo::SKIP_LOCKING );
                # Clear out the thumbnail directory if empty
                $this->repo->getBackend()->clean( array( 'dir' => $dir ) );
        }

Modified: branches/REL1_19/phase3/includes/filerepo/file/LocalFile.php
===================================================================
--- branches/REL1_19/phase3/includes/filerepo/file/LocalFile.php        
2012-03-21 16:17:26 UTC (rev 114373)
+++ branches/REL1_19/phase3/includes/filerepo/file/LocalFile.php        
2012-03-21 16:57:59 UTC (rev 114374)
@@ -763,7 +763,7 @@
                }
 
                # Delete the thumbnails
-               $this->repo->cleanupBatch( $purgeList );
+               $this->repo->cleanupBatch( $purgeList, FileRepo::SKIP_LOCKING );
                # Clear out the thumbnail directory if empty
                $this->repo->getBackend()->clean( array( 'dir' => $dir ) );
        }

Modified: branches/REL1_19/phase3/resources/mediawiki/mediawiki.js
===================================================================
--- branches/REL1_19/phase3/resources/mediawiki/mediawiki.js    2012-03-21 
16:17:26 UTC (rev 114373)
+++ branches/REL1_19/phase3/resources/mediawiki/mediawiki.js    2012-03-21 
16:57:59 UTC (rev 114374)
@@ -586,11 +586,12 @@
                                                        filter( 'ready', 
jobs[j].dependencies ),
                                                        jobs[j].dependencies ) )
                                                {
-                                                       if ( $.isFunction( 
jobs[j].ready ) ) {
-                                                               jobs[j].ready();
-                                                       }
+                                                       var callback = 
jobs[j].ready;
                                                        jobs.splice( j, 1 );
                                                        j -= 1;
+                                                       if ( $.isFunction( 
callback ) ) {
+                                                               callback();
+                                                       }
                                                }
                                        }
                                        // Execute modules whose dependencies 
have just been met

Modified: branches/REL1_19/phase3/tests/parser/parserTests.txt
===================================================================
--- branches/REL1_19/phase3/tests/parser/parserTests.txt        2012-03-21 
16:17:26 UTC (rev 114373)
+++ branches/REL1_19/phase3/tests/parser/parserTests.txt        2012-03-21 
16:57:59 UTC (rev 114374)
@@ -8483,6 +8483,16 @@
 !!end
 
 !! test
+Edit comment with section link and text before it (non-local, eg in history 
list)
+!! options
+comment title=[[Main Page]]
+!! input
+pre-comment text /* External links */ removed bogus entries
+!! result
+pre-comment text - <a href="/wiki/Main_Page#External_links" title="Main 
Page">→</a>‎<span dir="auto"><span class="autocomment">External links: </span> 
removed bogus entries</span>
+!!end
+
+!! test
 Edit comment with section link (local, eg in diff view)
 !! options
 comment local title=[[Main Page]]

Modified: 
branches/REL1_19/phase3/tests/phpunit/includes/filerepo/FileBackendTest.php
===================================================================
--- branches/REL1_19/phase3/tests/phpunit/includes/filerepo/FileBackendTest.php 
2012-03-21 16:17:26 UTC (rev 114373)
+++ branches/REL1_19/phase3/tests/phpunit/includes/filerepo/FileBackendTest.php 
2012-03-21 16:57:59 UTC (rev 114374)
@@ -1034,6 +1034,16 @@
                $this->doTestDoOperations();
                $this->tearDownFiles();
 
+               $this->backend = $this->singleBackend;
+               $this->tearDownFiles();
+               $this->doTestDoOperationsFailing();
+               $this->tearDownFiles();
+
+               $this->backend = $this->multiBackend;
+               $this->tearDownFiles();
+               $this->doTestDoOperationsFailing();
+               $this->tearDownFiles();
+
                // @TODO: test some cases where the ops should fail
        }
 
@@ -1057,9 +1067,9 @@
 
                $status = $this->backend->doOperations( array(
                        array( 'op' => 'copy', 'src' => $fileA, 'dst' => 
$fileC, 'overwrite' => 1 ),
-                       // Now: A:<A>, B:<B>, C:<A>, D:<D> (file:<orginal 
contents>)
+                       // Now: A:<A>, B:<B>, C:<A>, D:<empty> (file:<orginal 
contents>)
                        array( 'op' => 'copy', 'src' => $fileC, 'dst' => 
$fileA, 'overwriteSame' => 1 ),
-                       // Now: A:<A>, B:<B>, C:<A>, D:<D>
+                       // Now: A:<A>, B:<B>, C:<A>, D:<empty>
                        array( 'op' => 'move', 'src' => $fileC, 'dst' => 
$fileD, 'overwrite' => 1 ),
                        // Now: A:<A>, B:<B>, C:<empty>, D:<A>
                        array( 'op' => 'move', 'src' => $fileB, 'dst' => $fileC 
),
@@ -1109,6 +1119,68 @@
                        "Correct file SHA-1 of $fileC" );
        }
 
+       function doTestDoOperationsFailing() {
+               $base = $this->baseStorePath();
+
+               $fileA = "$base/unittest-cont2/a/b/fileA.txt";
+               $fileAContents = '3tqtmoeatmn4wg4qe-mg3qt3 tq';
+               $fileB = "$base/unittest-cont2/a/b/fileB.txt";
+               $fileBContents = 'g-jmq3gpqgt3qtg q3GT ';
+               $fileC = "$base/unittest-cont2/a/b/fileC.txt";
+               $fileCContents = 'eigna[ogmewt 3qt g3qg flew[ag';
+               $fileD = "$base/unittest-cont2/a/b/fileD.txt";
+
+               $this->prepare( array( 'dir' => dirname( $fileA ) ) );
+               $this->backend->create( array( 'dst' => $fileA, 'content' => 
$fileAContents ) );
+               $this->prepare( array( 'dir' => dirname( $fileB ) ) );
+               $this->backend->create( array( 'dst' => $fileB, 'content' => 
$fileBContents ) );
+               $this->prepare( array( 'dir' => dirname( $fileC ) ) );
+               $this->backend->create( array( 'dst' => $fileC, 'content' => 
$fileCContents ) );
+
+               $status = $this->backend->doOperations( array(
+                       array( 'op' => 'copy', 'src' => $fileA, 'dst' => 
$fileC, 'overwrite' => 1 ),
+                       // Now: A:<A>, B:<B>, C:<A>, D:<empty> (file:<orginal 
contents>)
+                       array( 'op' => 'copy', 'src' => $fileC, 'dst' => 
$fileA, 'overwriteSame' => 1 ),
+                       // Now: A:<A>, B:<B>, C:<A>, D:<empty>
+                       array( 'op' => 'copy', 'src' => $fileB, 'dst' => 
$fileD, 'overwrite' => 1 ),
+                       // Now: A:<A>, B:<B>, C:<A>, D:<B>
+                       array( 'op' => 'move', 'src' => $fileC, 'dst' => $fileD 
),
+                       // Now: A:<A>, B:<B>, C:<A>, D:<empty> (failed)
+                       array( 'op' => 'move', 'src' => $fileB, 'dst' => 
$fileC, 'overwriteSame' => 1 ),
+                       // Now: A:<A>, B:<B>, C:<A>, D:<empty> (failed)
+                       array( 'op' => 'move', 'src' => $fileB, 'dst' => 
$fileA, 'overwrite' => 1 ),
+                       // Now: A:<B>, B:<empty>, C:<A>, D:<empty>
+                       array( 'op' => 'delete', 'src' => $fileD ),
+                       // Now: A:<B>, B:<empty>, C:<A>, D:<empty>
+                       array( 'op' => 'null' ),
+                       // Does nothing
+               ), array( 'force' => 1 ) );
+
+               $this->assertNotEquals( array(), $status->errors, "Operation 
had warnings" );
+               $this->assertEquals( true, $status->isOK(), "Operation batch 
succeeded" );
+               $this->assertEquals( 8, count( $status->success ),
+                       "Operation batch has correct success array" );
+
+               $this->assertEquals( false, $this->backend->fileExists( array( 
'src' => $fileB ) ),
+                       "File does not exist at $fileB" );
+               $this->assertEquals( false, $this->backend->fileExists( array( 
'src' => $fileD ) ),
+                       "File does not exist at $fileD" );
+
+               $this->assertEquals( true, $this->backend->fileExists( array( 
'src' => $fileA ) ),
+                       "File does not exist at $fileA" );
+               $this->assertEquals( true, $this->backend->fileExists( array( 
'src' => $fileC ) ),
+                       "File exists at $fileC" );
+               $this->assertEquals( $fileBContents,
+                       $this->backend->getFileContents( array( 'src' => $fileA 
) ),
+                       "Correct file contents of $fileA" );
+               $this->assertEquals( strlen( $fileBContents ),
+                       $this->backend->getFileSize( array( 'src' => $fileA ) ),
+                       "Correct file size of $fileA" );
+               $this->assertEquals( wfBaseConvert( sha1( $fileBContents ), 16, 
36, 31 ),
+                       $this->backend->getFileSha1Base36( array( 'src' => 
$fileA ) ),
+                       "Correct file SHA-1 of $fileA" );
+       }
+
        public function testGetFileList() {
                $this->backend = $this->singleBackend;
                $this->tearDownFiles();


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to