Aaron Schulz has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/311347

Change subject: Move some FileBackend related classes to /libs
......................................................................

Move some FileBackend related classes to /libs

Change-Id: I0c3a84c2ed8b869519f4d38475a77539c24a88a8
---
M autoload.php
M includes/filebackend/FileBackendGroup.php
R includes/libs/filebackend/FileBackend.php
A includes/libs/filebackend/FileBackendException.php
R includes/libs/filebackend/filejournal/FileJournal.php
A includes/libs/filebackend/filejournal/NullFileJournal.php
R includes/libs/lockmanager/LockManager.php
R includes/libs/lockmanager/QuorumLockManager.php
R includes/libs/lockmanager/ScopedLock.php
9 files changed, 88 insertions(+), 82 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/47/311347/1

diff --git a/autoload.php b/autoload.php
index a07df96..7ef9381 100644
--- a/autoload.php
+++ b/autoload.php
@@ -454,10 +454,10 @@
        'Field' => __DIR__ . '/includes/libs/rdbms/field/Field.php',
        'File' => __DIR__ . '/includes/filerepo/file/File.php',
        'FileAwareNodeVisitor' => __DIR__ . '/maintenance/findDeprecated.php',
-       'FileBackend' => __DIR__ . '/includes/filebackend/FileBackend.php',
+       'FileBackend' => __DIR__ . '/includes/libs/filebackend/FileBackend.php',
        'FileBackendDBRepoWrapper' => __DIR__ . 
'/includes/filerepo/FileBackendDBRepoWrapper.php',
-       'FileBackendError' => __DIR__ . '/includes/filebackend/FileBackend.php',
-       'FileBackendException' => __DIR__ . 
'/includes/filebackend/FileBackend.php',
+       'FileBackendError' => __DIR__ . 
'/includes/libs/filebackend/FileBackendException.php',
+       'FileBackendException' => __DIR__ . 
'/includes/libs/filebackend/FileBackendException.php',
        'FileBackendGroup' => __DIR__ . 
'/includes/filebackend/FileBackendGroup.php',
        'FileBackendMultiWrite' => __DIR__ . 
'/includes/filebackend/FileBackendMultiWrite.php',
        'FileBackendStore' => __DIR__ . 
'/includes/filebackend/FileBackendStore.php',
@@ -471,7 +471,7 @@
        'FileDeleteForm' => __DIR__ . '/includes/FileDeleteForm.php',
        'FileDependency' => __DIR__ . '/includes/cache/CacheDependency.php',
        'FileDuplicateSearchPage' => __DIR__ . 
'/includes/specials/SpecialFileDuplicateSearch.php',
-       'FileJournal' => __DIR__ . 
'/includes/filebackend/filejournal/FileJournal.php',
+       'FileJournal' => __DIR__ . 
'/includes/libs/filebackend/filejournal/FileJournal.php',
        'FileOp' => __DIR__ . '/includes/filebackend/FileOp.php',
        'FileOpBatch' => __DIR__ . '/includes/filebackend/FileOpBatch.php',
        'FileRepo' => __DIR__ . '/includes/filerepo/FileRepo.php',
@@ -747,7 +747,7 @@
        'LocalSettingsGenerator' => __DIR__ . 
'/includes/installer/LocalSettingsGenerator.php',
        'LocalisationCache' => __DIR__ . 
'/includes/cache/localisation/LocalisationCache.php',
        'LocalisationCacheBulkLoad' => __DIR__ . 
'/includes/cache/localisation/LocalisationCacheBulkLoad.php',
-       'LockManager' => __DIR__ . 
'/includes/filebackend/lockmanager/LockManager.php',
+       'LockManager' => __DIR__ . '/includes/libs/lockmanager/LockManager.php',
        'LockManagerGroup' => __DIR__ . 
'/includes/filebackend/lockmanager/LockManagerGroup.php',
        'LogEntry' => __DIR__ . '/includes/logging/LogEntry.php',
        'LogEntryBase' => __DIR__ . '/includes/logging/LogEntry.php',
@@ -975,11 +975,11 @@
        'NotRecursiveIterator' => __DIR__ . 
'/includes/utils/iterators/NotRecursiveIterator.php',
        'NukeNS' => __DIR__ . '/maintenance/nukeNS.php',
        'NukePage' => __DIR__ . '/maintenance/nukePage.php',
-       'NullFileJournal' => __DIR__ . 
'/includes/filebackend/filejournal/FileJournal.php',
+       'NullFileJournal' => __DIR__ . 
'/includes/libs/filebackend/filejournal/NullFileJournal.php',
        'NullFileOp' => __DIR__ . '/includes/filebackend/FileOp.php',
        'NullIndexField' => __DIR__ . '/includes/search/NullIndexField.php',
        'NullJob' => __DIR__ . '/includes/jobqueue/jobs/NullJob.php',
-       'NullLockManager' => __DIR__ . 
'/includes/filebackend/lockmanager/LockManager.php',
+       'NullLockManager' => __DIR__ . 
'/includes/libs/lockmanager/LockManager.php',
        'NullRepo' => __DIR__ . '/includes/filerepo/NullRepo.php',
        'NullStatsdDataFactory' => __DIR__ . 
'/includes/libs/stats/NullStatsdDataFactory.php',
        'NumericUppercaseCollation' => __DIR__ . 
'/includes/collation/NumericUppercaseCollation.php',
@@ -1110,7 +1110,7 @@
        'PurgeParserCache' => __DIR__ . '/maintenance/purgeParserCache.php',
        'QueryPage' => __DIR__ . '/includes/specialpage/QueryPage.php',
        'QuickTemplate' => __DIR__ . '/includes/skins/QuickTemplate.php',
-       'QuorumLockManager' => __DIR__ . 
'/includes/filebackend/lockmanager/QuorumLockManager.php',
+       'QuorumLockManager' => __DIR__ . 
'/includes/libs/lockmanager/QuorumLockManager.php',
        'RCCacheEntry' => __DIR__ . '/includes/changes/RCCacheEntry.php',
        'RCCacheEntryFactory' => __DIR__ . 
'/includes/changes/RCCacheEntryFactory.php',
        'RCDatabaseLogEntry' => __DIR__ . '/includes/logging/LogEntry.php',
@@ -1228,7 +1228,7 @@
        'Sanitizer' => __DIR__ . '/includes/Sanitizer.php',
        'SavepointPostgres' => __DIR__ . '/includes/db/DatabasePostgres.php',
        'ScopedCallback' => __DIR__ . '/includes/libs/ScopedCallback.php',
-       'ScopedLock' => __DIR__ . 
'/includes/filebackend/lockmanager/ScopedLock.php',
+       'ScopedLock' => __DIR__ . '/includes/libs/lockmanager/ScopedLock.php',
        'SearchApi' => __DIR__ . '/includes/api/SearchApi.php',
        'SearchDatabase' => __DIR__ . '/includes/search/SearchDatabase.php',
        'SearchDump' => __DIR__ . '/maintenance/dumpIterator.php',
diff --git a/includes/filebackend/FileBackendGroup.php 
b/includes/filebackend/FileBackendGroup.php
index 57461a4..0bae5ff 100644
--- a/includes/filebackend/FileBackendGroup.php
+++ b/includes/filebackend/FileBackendGroup.php
@@ -167,6 +167,7 @@
                                : FileJournal::factory( [ 'class' => 
'NullFileJournal' ], $name );
                        $config['wanCache'] = ObjectCache::getMainWANInstance();
                        $config['mimeCallback'] = [ $this, 'guessMimeInternal' 
];
+                       $config['statusWrapper'] = [ 'Status', 'wrap' ];
 
                        $this->backends[$name]['instance'] = new $class( 
$config );
                }
diff --git a/includes/filebackend/FileBackend.php 
b/includes/libs/filebackend/FileBackend.php
similarity index 98%
rename from includes/filebackend/FileBackend.php
rename to includes/libs/filebackend/FileBackend.php
index 1f91b3f..be7a873 100644
--- a/includes/filebackend/FileBackend.php
+++ b/includes/libs/filebackend/FileBackend.php
@@ -159,8 +159,11 @@
                $this->concurrency = isset( $config['concurrency'] )
                        ? (int)$config['concurrency']
                        : 50;
-               // @TODO: dependency inject this
-               $this->statusWrapper = [ 'Status', 'wrap' ];
+               $this->statusWrapper = isset( $config['statusWrapper'] )
+                       ? $config['statusWrapper']
+                       : function ( $status ) {
+                               return $status;
+                       };
        }
 
        /**
@@ -1564,22 +1567,4 @@
        final protected function wrapStatus( StatusValue $sv ) {
                return $this->statusWrapper ? call_user_func( 
$this->statusWrapper, $sv ) : $sv;
        }
-}
-
-/**
- * Generic file backend exception for checked and unexpected (e.g. config) 
exceptions
- *
- * @ingroup FileBackend
- * @since 1.23
- */
-class FileBackendException extends Exception {
-}
-
-/**
- * File backend exception for checked exceptions (e.g. I/O errors)
- *
- * @ingroup FileBackend
- * @since 1.22
- */
-class FileBackendError extends FileBackendException {
 }
diff --git a/includes/libs/filebackend/FileBackendException.php 
b/includes/libs/filebackend/FileBackendException.php
new file mode 100644
index 0000000..949bce8
--- /dev/null
+++ b/includes/libs/filebackend/FileBackendException.php
@@ -0,0 +1,18 @@
+<?php
+/**
+ * Generic file backend exception for checked and unexpected (e.g. config) 
exceptions
+ *
+ * @ingroup FileBackend
+ * @since 1.23
+ */
+class FileBackendException extends Exception {
+}
+
+/**
+ * File backend exception for checked exceptions (e.g. I/O errors)
+ *
+ * @ingroup FileBackend
+ * @since 1.22
+ */
+class FileBackendError extends FileBackendException {
+}
diff --git a/includes/filebackend/filejournal/FileJournal.php 
b/includes/libs/filebackend/filejournal/FileJournal.php
similarity index 83%
rename from includes/filebackend/filejournal/FileJournal.php
rename to includes/libs/filebackend/filejournal/FileJournal.php
index f0bb92d..116c303 100644
--- a/includes/filebackend/filejournal/FileJournal.php
+++ b/includes/libs/filebackend/filejournal/FileJournal.php
@@ -64,7 +64,7 @@
                $class = $config['class'];
                $jrn = new $class( $config );
                if ( !$jrn instanceof self ) {
-                       throw new Exception( "Class given is not an instance of 
FileJournal." );
+                       throw new InvalidArgumentException( "Class given is not 
an instance of FileJournal." );
                }
                $jrn->backend = $backend;
 
@@ -197,55 +197,4 @@
         * @return StatusValue
         */
        abstract protected function doPurgeOldLogs();
-}
-
-/**
- * Simple version of FileJournal that does nothing
- * @since 1.20
- */
-class NullFileJournal extends FileJournal {
-       /**
-        * @see FileJournal::doLogChangeBatch()
-        * @param array $entries
-        * @param string $batchId
-        * @return StatusValue
-        */
-       protected function doLogChangeBatch( array $entries, $batchId ) {
-               return StatusValue::newGood();
-       }
-
-       /**
-        * @see FileJournal::doGetCurrentPosition()
-        * @return int|bool
-        */
-       protected function doGetCurrentPosition() {
-               return false;
-       }
-
-       /**
-        * @see FileJournal::doGetPositionAtTime()
-        * @param int|string $time Timestamp
-        * @return int|bool
-        */
-       protected function doGetPositionAtTime( $time ) {
-               return false;
-       }
-
-       /**
-        * @see FileJournal::doGetChangeEntries()
-        * @param int $start
-        * @param int $limit
-        * @return array
-        */
-       protected function doGetChangeEntries( $start, $limit ) {
-               return [];
-       }
-
-       /**
-        * @see FileJournal::doPurgeOldLogs()
-        * @return StatusValue
-        */
-       protected function doPurgeOldLogs() {
-               return StatusValue::newGood();
-       }
 }
diff --git a/includes/libs/filebackend/filejournal/NullFileJournal.php 
b/includes/libs/filebackend/filejournal/NullFileJournal.php
new file mode 100644
index 0000000..8d472ab
--- /dev/null
+++ b/includes/libs/filebackend/filejournal/NullFileJournal.php
@@ -0,0 +1,51 @@
+<?php
+/**
+ * Simple version of FileJournal that does nothing
+ * @since 1.20
+ */
+class NullFileJournal extends FileJournal {
+       /**
+        * @see FileJournal::doLogChangeBatch()
+        * @param array $entries
+        * @param string $batchId
+        * @return StatusValue
+        */
+       protected function doLogChangeBatch( array $entries, $batchId ) {
+               return StatusValue::newGood();
+       }
+
+       /**
+        * @see FileJournal::doGetCurrentPosition()
+        * @return int|bool
+        */
+       protected function doGetCurrentPosition() {
+               return false;
+       }
+
+       /**
+        * @see FileJournal::doGetPositionAtTime()
+        * @param int|string $time Timestamp
+        * @return int|bool
+        */
+       protected function doGetPositionAtTime( $time ) {
+               return false;
+       }
+
+       /**
+        * @see FileJournal::doGetChangeEntries()
+        * @param int $start
+        * @param int $limit
+        * @return array
+        */
+       protected function doGetChangeEntries( $start, $limit ) {
+               return [];
+       }
+
+       /**
+        * @see FileJournal::doPurgeOldLogs()
+        * @return StatusValue
+        */
+       protected function doPurgeOldLogs() {
+               return StatusValue::newGood();
+       }
+}
diff --git a/includes/filebackend/lockmanager/LockManager.php 
b/includes/libs/lockmanager/LockManager.php
similarity index 100%
rename from includes/filebackend/lockmanager/LockManager.php
rename to includes/libs/lockmanager/LockManager.php
diff --git a/includes/filebackend/lockmanager/QuorumLockManager.php 
b/includes/libs/lockmanager/QuorumLockManager.php
similarity index 100%
rename from includes/filebackend/lockmanager/QuorumLockManager.php
rename to includes/libs/lockmanager/QuorumLockManager.php
diff --git a/includes/filebackend/lockmanager/ScopedLock.php 
b/includes/libs/lockmanager/ScopedLock.php
similarity index 96%
rename from includes/filebackend/lockmanager/ScopedLock.php
rename to includes/libs/lockmanager/ScopedLock.php
index 05ab289..ac8bee8 100644
--- a/includes/filebackend/lockmanager/ScopedLock.php
+++ b/includes/libs/lockmanager/ScopedLock.php
@@ -46,7 +46,9 @@
         * @param array $pathsByType Map of lock types to path lists
         * @param StatusValue $status
         */
-       protected function __construct( LockManager $manager, array 
$pathsByType, StatusValue $status ) {
+       protected function __construct(
+               LockManager $manager, array $pathsByType, StatusValue $status
+       ) {
                $this->manager = $manager;
                $this->pathsByType = $pathsByType;
                $this->status = $status;

-- 
To view, visit https://gerrit.wikimedia.org/r/311347
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0c3a84c2ed8b869519f4d38475a77539c24a88a8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to