jenkins-bot has submitted this change and it was merged.

Change subject: filebackend-user-access
......................................................................


filebackend-user-access

based on irc conversations with aaron schulz and chris steipp:

* use basePath instead of containerPaths
* moved $wgGWTFBMetadataContainer into Config::$filebackend_metadata_container
* the filebackend path in the forms are now relative instead of complete 
filebackend paths.
* added user name to filebackend path in order to add a layer of user access 
control and organize user uploaded metadata files

Change-Id: I278d9f3b1332f7a2e1ee6a2d759569ba322db390
---
M GWToolset.i18n.php
M INSTALL
M includes/Config.php
M includes/Forms/MetadataMappingForm.php
M includes/Handlers/Forms/MetadataDetectHandler.php
M includes/Handlers/Forms/MetadataMappingHandler.php
M includes/Handlers/Xml/XmlHandler.php
M includes/Helpers/GWTFileBackend.php
M includes/Hooks/Hooks.php
M includes/Jobs/GWTFileBackendCleanupJob.php
M maintenance/cleanupGWTFileBackend.php
11 files changed, 225 insertions(+), 88 deletions(-)

Approvals:
  BryanDavis: Looks good to me, approved
  Aaron Schulz: Looks good to me, but someone else must approve
  Siebrand: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/GWToolset.i18n.php b/GWToolset.i18n.php
index 37c383d..1490e23 100644
--- a/GWToolset.i18n.php
+++ b/GWToolset.i18n.php
@@ -52,7 +52,8 @@
        'gwtoolset-no-mapping-json' => 'No <code>mapping_json</code> provided.',
        'gwtoolset-no-mediawiki-template' => 'No 
<code>mediawiki-template-name</code> provided.',
        'gwtoolset-no-module' => 'No module name was specified.',
-       'gwtoolset-no-mwstore-provided' => 'No mwstore URL provided.',
+       'gwtoolset-no-mwstore-complete-path' => 'No mwstore complete file path 
provied.',
+       'gwtoolset-no-mwstore-relative-path' => 'No mwstore relative path 
provided.',
        'gwtoolset-no-page-title' => 'No page title provided.',
        'gwtoolset-no-save-as-batch' => 
"<code>user_options['save-as-batch-job']</code> not set.",
        'gwtoolset-no-source-array' => 'No source array was provided.',
@@ -366,7 +367,8 @@
        'gwtoolset-no-mediawiki-template' => 'Hint to the developer that 
appears when no mediawiki-template-name is provided.',
        'gwtoolset-no-module' => 'Hint to the developer that appears when no 
module name was specified.',
        'gwtoolset-no-more-records' => 'User message that appears when there 
are no more records to process.',
-       'gwtoolset-no-mwstore-provided' => 'Message that appears when no 
mwstore URL is provided.',
+       'gwtoolset-no-mwstore-complete-path' => 'Developer message that appears 
when no mwstore complete file path provied.',
+       'gwtoolset-no-mwstore-relative-path' => 'Developer message that appears 
when no mwstore relative path is provided.',
        'gwtoolset-no-page-title' => 'Appears when no page title was provided.',
        'gwtoolset-no-reupload-media' => "Hint to the developer that appears 
when user_options['gwtoolset-reupload-media'] is not set.",
        'gwtoolset-no-save-as-batch' => "Hint to the developer that appears 
when user_options['save-as-batch-job'] is not set.",
diff --git a/INSTALL b/INSTALL
index b9c6735..7c51bc6 100644
--- a/INSTALL
+++ b/INSTALL
@@ -72,20 +72,14 @@
 configuration below can be used as a default local file system backend.
 
 $wgFileBackends[] = array(
-   'name'           => 'gwtoolset-backend',
-   'class'          => 'FSFileBackend',
-   'lockManager'    => 'nullLockManager',
-   'fileMode'       => 0644,
-   'containerPaths' => array(
-         'gwtoolset-metadata' => $IP . DIRECTORY_SEPARATOR .
-                'images' . DIRECTORY_SEPARATOR .
-                'gwtoolset' . DIRECTORY_SEPARATOR .
-                'metadata'
-   )
+       'name'           => 'gwtoolset-backend',
+       'class'          => 'FSFileBackend',
+       'lockManager'    => 'nullLockManager',
+       'fileMode'       => 0644,
+       'basePath'       => $IP . '/images/gwtoolset'
 );
 
 $wgGWTFileBackend = 'gwtoolset-backend';
-$wgGWTFBMetadataContainer = 'gwtoolset-metadata';
 $wgGWTFBMaxAge = '1 week';
 
 
diff --git a/includes/Config.php b/includes/Config.php
index 323f69c..2702747 100644
--- a/includes/Config.php
+++ b/includes/Config.php
@@ -39,6 +39,11 @@
        public static $category_separator = '|';
 
        /**
+        * @var {string}
+        */
+       public static $filebackend_metadata_container = 'gwtoolset-metadata';
+
+       /**
         * @var {int}
         * 20 minutes, 25 seconds default
         */
diff --git a/includes/Forms/MetadataMappingForm.php 
b/includes/Forms/MetadataMappingForm.php
index 2d04f26..d0fb8c1 100644
--- a/includes/Forms/MetadataMappingForm.php
+++ b/includes/Forms/MetadataMappingForm.php
@@ -193,8 +193,8 @@
                                'input',
                                array(
                                        'type' => 'hidden',
-                                       'name' => 
'gwtoolset-metadata-file-mwstore',
-                                       'value' => Utils::sanitizeUrl( 
$user_options['gwtoolset-metadata-file-mwstore'] )
+                                       'name' => 
'gwtoolset-metadata-file-relative-path',
+                                       'value' => Utils::sanitizeUrl( 
$user_options['gwtoolset-metadata-file-relative-path'] )
                                )
                        ) .
 
diff --git a/includes/Handlers/Forms/MetadataDetectHandler.php 
b/includes/Handlers/Forms/MetadataDetectHandler.php
index 1386c95..5dd7fa1 100644
--- a/includes/Handlers/Forms/MetadataDetectHandler.php
+++ b/includes/Handlers/Forms/MetadataDetectHandler.php
@@ -165,12 +165,12 @@
                        )
                );
 
-               global $wgGWTFileBackend, $wgGWTFBMetadataContainer;
+               global $wgGWTFileBackend;
 
                $this->_GWTFileBackend = new GWTFileBackend(
                        array(
+                               'container' => 
Config::$filebackend_metadata_container,
                                'file-backend-name' => $wgGWTFileBackend,
-                               'container' => $wgGWTFBMetadataContainer,
                                'User' => $this->User
                        )
                );
@@ -192,10 +192,13 @@
                );
 
                // upload the metadata file and get an mwstore reference to it
-               $user_options['gwtoolset-metadata-file-mwstore'] = 
$this->_UploadHandler->saveMetadataToFileBackend();
+               $user_options['gwtoolset-metadata-file-relative-path'] =
+                       $this->_UploadHandler->saveMetadataToFileBackend();
 
                // retrieve the metadata file, the FileBackend will return an 
FSFile object
-               $FSFile = $this->_GWTFileBackend->retrieveFile( 
$user_options['gwtoolset-metadata-file-mwstore'] );
+               $FSFile = $this->_GWTFileBackend->retrieveFileFromRelativePath(
+                       $user_options['gwtoolset-metadata-file-relative-path']
+               );
 
                if ( !( $FSFile instanceof FSFile ) ) {
                        throw new MWException(
@@ -203,7 +206,7 @@
                                        ->params(
                                                __METHOD__ . ': ' .
                                                wfMessage( 
'gwtoolset-fsfile-retrieval-failure' )
-                                                       ->params( 
$user_options['gwtoolset-metadata-file-mwstore'] )
+                                                       ->params( 
$user_options['gwtoolset-metadata-file-relative-path'] )
                                                        ->parse()
                                        )
                                        ->parse()
diff --git a/includes/Handlers/Forms/MetadataMappingHandler.php 
b/includes/Handlers/Forms/MetadataMappingHandler.php
index 5532b52..4734e1a 100644
--- a/includes/Handlers/Forms/MetadataMappingHandler.php
+++ b/includes/Handlers/Forms/MetadataMappingHandler.php
@@ -45,7 +45,7 @@
                'gwtoolset-form' => array( 'size' => 255 ),
                'gwtoolset-preview' => array( 'size' => 255 ),
                'gwtoolset-mediawiki-template-name' => array( 'size' => 255 ),
-               'gwtoolset-metadata-file-mwstore' => array( 'size' => 255 ),
+               'gwtoolset-metadata-file-relative-path' => array( 'size' => 255 
),
                'gwtoolset-metadata-file-sha1' => array( 'size' => 255 ),
                'gwtoolset-metadata-file-url' => array( 'size' => 255 ),
                'gwtoolset-metadata-mapping-name' => array( 'size' => 255 ),
@@ -195,9 +195,9 @@
                                ? 
$this->_whitelisted_post['gwtoolset-metadata-file-url']
                                : null,
 
-                       'gwtoolset-metadata-file-mwstore' =>
-                               !empty( 
$this->_whitelisted_post['gwtoolset-metadata-file-mwstore'] )
-                               ? 
$this->_whitelisted_post['gwtoolset-metadata-file-mwstore']
+                       'gwtoolset-metadata-file-relative-path' =>
+                               !empty( 
$this->_whitelisted_post['gwtoolset-metadata-file-relative-path'] )
+                               ? 
$this->_whitelisted_post['gwtoolset-metadata-file-relative-path']
                                : null,
 
                        'gwtoolset-metadata-file-sha1' =>
@@ -323,12 +323,12 @@
 
                $this->_Metadata = new Metadata( new MetadataPhpAdapter() );
 
-               global $wgGWTFileBackend, $wgGWTFBMetadataContainer;
+               global $wgGWTFileBackend;
 
                $this->_GWTFileBackend = new GWTFileBackend(
                        array(
+                               'container' => 
Config::$filebackend_metadata_container,
                                'file-backend-name' => $wgGWTFileBackend,
-                               'container' => $wgGWTFBMetadataContainer,
                                'User' => $this->User
                        )
                );
@@ -352,8 +352,8 @@
                );
 
                // retrieve the metadata file, the FileBackend will return an 
FSFile object
-               $FSFile = $this->_GWTFileBackend->retrieveFile(
-                       $user_options['gwtoolset-metadata-file-mwstore']
+               $FSFile = $this->_GWTFileBackend->retrieveFileFromRelativePath(
+                       $user_options['gwtoolset-metadata-file-relative-path']
                );
 
                if ( !( $FSFile instanceof FSFile ) ) {
@@ -362,7 +362,7 @@
                                        ->params(
                                                __METHOD__ . ': ' .
                                                wfMessage( 
'gwtoolset-fsfile-retrieval-failure' )
-                                                       ->params( 
$user_options['gwtoolset-metadata-file-mwstore'] )
+                                                       ->params( 
$user_options['gwtoolset-metadata-file-relative-path'] )
                                                        ->parse()
                                        )
                                        ->parse()
@@ -431,7 +431,7 @@
                                // no more UploadMediafileJobs need to be 
created
                                // create a GWTFileBackendCleanupJob that will 
delete the metadata file in the mwstore
                                $Status = 
$this->_GWTFileBackend->createCleanupJob(
-                                       
$user_options['gwtoolset-metadata-file-mwstore']
+                                       
$user_options['gwtoolset-metadata-file-relative-path']
                                );
 
                                if ( !$Status->ok ) {
@@ -492,7 +492,7 @@
                                'gwtoolset-record-element-name',
                                'gwtoolset-title-identifier',
                                'gwtoolset-url-to-the-media-file',
-                               'gwtoolset-metadata-file-mwstore'
+                               'gwtoolset-metadata-file-relative-path'
                        )
                );
 
diff --git a/includes/Handlers/Xml/XmlHandler.php 
b/includes/Handlers/Xml/XmlHandler.php
index 98085f0..ed3f749 100644
--- a/includes/Handlers/Xml/XmlHandler.php
+++ b/includes/Handlers/Xml/XmlHandler.php
@@ -134,10 +134,10 @@
                while ( $XMLReader->read() ) {
                        if ( $XMLReader->nodeType === XMLReader::DOC_TYPE ) {
                                if ( $this->_GWTFileBackend instanceof 
\GWToolset\Helpers\GWTFileBackend ) {
-                                       $file_mwstore_path = 
$this->_GWTFileBackend->getMWStorePath();
+                                       $mwstore_relative_path = 
$this->_GWTFileBackend->getMWStoreRelativePath();
 
-                                       if ( $file_mwstore_path !== null ) {
-                                               
$this->_GWTFileBackend->deleteFile( $file_mwstore_path );
+                                       if ( $mwstore_relative_path !== null ) {
+                                               
$this->_GWTFileBackend->deleteFileFromRelativePath( $mwstore_relative_path );
                                        }
                                }
 
diff --git a/includes/Helpers/GWTFileBackend.php 
b/includes/Helpers/GWTFileBackend.php
index 98e20f7..997c324 100644
--- a/includes/Helpers/GWTFileBackend.php
+++ b/includes/Helpers/GWTFileBackend.php
@@ -61,19 +61,23 @@
        /**
         * creates a GWTFileBackendCleanupJob that will delete the mwstore file 
in the FileBackend
         *
-        * @param {string} $mwstore_path
+        * @param {string} $mwstore_relative_path
         * @throws {MWException}
         * @return {bool}
         */
-       public function createCleanupJob( $mwstore_path = null ) {
+       public function createCleanupJob( $mwstore_relative_path = null ) {
                $result = false;
 
-               if ( empty( $mwstore_path ) ) {
+               if ( empty( $mwstore_relative_path ) ) {
                        throw new MWException(
                                wfMessage( 'gwtoolset-developer-issue' )
-                                       ->params( __METHOD__ . ': ' . 
wfMessage( 'gwtoolset-no-mwstore' ) )
+                                       ->params( __METHOD__ . ': ' . 
wfMessage( 'gwtoolset-no-mwstore-relative-path' ) )
                                        ->parse()
                                );
+               }
+
+               if ( empty( $this->_User ) ) {
+                       throw new MWException( wfMessage( 'gwtoolset-no-user' ) 
);
                }
 
                $job = new GWTFileBackendCleanupJob(
@@ -85,7 +89,8 @@
                                NS_USER
                        ),
                        array(
-                               'gwtoolset-metadata-file-mwstore' => 
Utils::sanitizeString( $mwstore_path )
+                               'gwtoolset-metadata-file-relative-path' => 
Utils::sanitizeString( $mwstore_relative_path ),
+                               'user-name' => $this->_User->getName()
                        )
                );
 
@@ -105,23 +110,23 @@
        }
 
        /**
-        * deletes a file, based on an mwstore path, from the FileBackend
+        * deletes a file, based on an mwstore complete file path, from the 
FileBackend
         *
-        * @param {string} $mwstore_file_path
+        * @param {string} $mwstore_complete_file_path
         * @return {Status}
         */
-       public function deleteFile( $mwstore_file_path = null ) {
+       public function deleteFile( $mwstore_complete_file_path = null ) {
                $result = Status::newGood();
 
-               if ( empty( $mwstore_file_path ) ) {
+               if ( empty( $mwstore_complete_file_path ) ) {
                        throw new MWException(
                                wfMessage( 'gwtoolset-developer-issue' )
-                                       ->params( __METHOD__ . ': ' . 
wfMessage( 'gwtoolset-no-mwstore' ) )
+                                       ->params( __METHOD__ . ': ' . 
wfMessage( 'gwtoolset-no-mwstore-complete-path' ) )
                                        ->parse()
                        );
                }
 
-               $src = array( 'src' => Utils::sanitizeString( 
$mwstore_file_path ) );
+               $src = array( 'src' => Utils::sanitizeString( 
$mwstore_complete_file_path ) );
 
                if ( $this->FileBackend->fileExists( $src ) ) {
                        $result = $this->FileBackend->quickDelete( $src );
@@ -133,37 +138,57 @@
        }
 
        /**
-        * gets path to store hashes in
-        *
-        * @return {null|string} storage directory
+        * @param {string} $mwstore_relative_path
+        * @throws {MWException}
+        * @return {string}
         */
-       protected function getHashPath() {
+       public function deleteFileFromRelativePath( $mwstore_relative_path = 
null ) {
+               if ( empty( $mwstore_relative_path ) ) {
+                       throw new MWException(
+                               wfMessage( 'gwtoolset-developer-issue' )
+                                       ->params( __METHOD__ . ': ' . 
wfMessage( 'gwtoolset-no-mwstore-relative-path' ) )
+                                       ->parse()
+                       );
+               }
+
+               return $this->deleteFile(
+                       $this->getMWStoreCompleteFilePath( 
$mwstore_relative_path )
+               );
+       }
+
+       /**
+        * create a filename based on the md5 hash of the tmp_filename.
+        * add the file extension if it exists
+        *
+        * @return {null|string}
+        */
+       protected function getFilename() {
                $result = null;
-               $hash_sub_path = $this->getHashSubPath();
 
-               $result =
-                       $this->FileBackend->getRootStoragePath() . 
DIRECTORY_SEPARATOR .
-                       $this->_container;
-
-               if ( !empty( $hash_sub_path ) ) {
-                       $result .= DIRECTORY_SEPARATOR . $hash_sub_path;
+               if ( !empty( $this->_hash ) ) {
+                       $result =
+                               $this->_hash .
+                               ( !empty( $this->_file_extension )
+                                       ? '.' . Utils::sanitizeString( 
$this->_file_extension )
+                                       : null );
                }
 
                return $result;
        }
 
        /**
-        * gets relative directory for this specific hash
+        * based on the md5 hash of the tmp_filename, create a hash mapped 
directory structure
+        * using the first 3 characters of the md5 hash
         *
-        * @return {null|string} relative directory
+        * @return {null|string}
         */
-       protected function getHashSubPath() {
+       protected function getHashPath() {
                $result = null;
 
                if ( !empty( $this->_hash ) ) {
                        $result =
-                               substr( $this->_hash, 0, 1 ) . 
DIRECTORY_SEPARATOR .
-                               substr( $this->_hash, 1, 1 ) . 
DIRECTORY_SEPARATOR .
+                               substr( $this->_hash, 0, 1 ) . '/' .
+                               substr( $this->_hash, 1, 1 ) . '/' .
                                substr( $this->_hash, 2, 1 );
                }
 
@@ -171,17 +196,99 @@
        }
 
        /**
-        * retrieves the mwstore path to the FileBackend file
+        * the complete MWStore path to the file.
+        *
+        * includes:
+        * - root storage path
+        * - container name
+        * - user name
+        * - hash path
+        * - filename
+        *
+        * @param {string} $mwstore_relative_path
+        * should contain:
+        * - hash path
+        * - filename
         *
         * @return {string}
         */
-       public function getMWStorePath() {
+       protected function getMWStoreCompleteFilePath( $mwstore_relative_path = 
null ) {
+               if ( !empty( $mwstore_relative_path ) ) {
+                       return
+                               $this->getMWStorePath() . '/' .
+                               $this->getUserPath() . '/' .
+                               $mwstore_relative_path;
+               } else {
+                       return
+                               $this->getMWStoreFileDirectory() . '/' .
+                               $this->getFilename();
+               }
+       }
+
+       /**
+        * the MWStore directory path to where the file is stored.
+        *
+        * includes
+        * - root storage path
+        * - container name
+        * - user name
+        * - hash path
+        *
+        * @return {string}
+        */
+       protected function getMWStoreFileDirectory() {
                return
-                       $this->getHashPath() . DIRECTORY_SEPARATOR .
-                       $this->_hash .
-                       ( ( !empty( $this->_file_extension ) )
-                               ? '.' . Utils::sanitizeString( 
$this->_file_extension )
-                               : null );
+                       $this->getMWStorePath() . '/' .
+                       $this->getUserPath() . '/' .
+                       $this->getHashPath();
+       }
+
+       /**
+        * includes:
+        * - root storage path
+        * - container name
+        *
+        * the User name is used in order to help limit file access and indicate
+        * which user submitted the file.
+        *
+        * @throws {MWException}
+        * @return {string}
+        */
+       public function getMWStorePath() {
+               $result = $this->FileBackend->getRootStoragePath();
+
+               if ( !empty( $this->_container ) ) {
+                       $result .= '/' . $this->_container;
+               }
+
+               return $result;
+       }
+
+       /**
+        * includes:
+        * - hash path
+        * - filename
+        *
+        * @return {string}
+        */
+       public function getMWStoreRelativePath() {
+               return
+                       $this->getHashPath() . '/' .
+                       $this->getFilename();
+       }
+
+       /**
+        * includes:
+        * - user name
+        *
+        * @throws {MWException}
+        */
+       protected function getUserPath() {
+               if ( empty( $this->_User ) ) {
+                       throw new MWException( wfMessage( 'gwtoolset-no-user' ) 
);
+               }
+
+               return wfStripIllegalFilenameChars( $this->_User->getName() );
        }
 
        /**
@@ -192,7 +299,7 @@
        protected function prepare() {
                return $this->FileBackend->prepare(
                        array(
-                               'dir' => $this->getHashPath(),
+                               'dir' => $this->getMWStoreFileDirectory(),
                                'noAccess' => true,
                                'noListing' => true
                        )
@@ -210,31 +317,31 @@
        protected function quickStore( $tmp_file_path = null ) {
                $params = array(
                        'src' => Utils::sanitizeString( $tmp_file_path ),
-                       'dst' => Utils::sanitizeString( $this->getMWStorePath() 
)
+                       'dst' => Utils::sanitizeString( 
$this->getMWStoreCompleteFilePath() )
                );
 
                return $this->FileBackend->quickStore( $params );
        }
 
        /**
-        * retrieves a file, based on an mwstore path, from the FileBackend
+        * retrieves a file, based on an mwstore complete file path, from the 
FileBackend
         *
-        * @param {string} $mwstore_file_path
+        * @param {string} $mwstore_complete_file_path
         * @throws {MWException}
         * @return {null|FSFile}
         */
-       public function retrieveFile( $mwstore_file_path = null ) {
+       public function retrieveFile( $mwstore_complete_file_path = null ) {
                $result = null;
 
-               if ( empty( $mwstore_file_path ) ) {
+               if ( empty( $mwstore_complete_file_path ) ) {
                        throw new MWException(
                                wfMessage( 'gwtoolset-developer-issue' )
-                                       ->params( __METHOD__ . ': ' . 
wfMessage( 'gwtoolset-no-mwstore' ) )
+                                       ->params( __METHOD__ . ': ' . 
wfMessage( 'gwtoolset-no-mwstore-complete-path' ) )
                                        ->parse()
                        );
                }
 
-               $src = array( 'src' => Utils::sanitizeString( 
$mwstore_file_path ) );
+               $src = array( 'src' => Utils::sanitizeString( 
$mwstore_complete_file_path ) );
 
                if ( $this->FileBackend->fileExists( $src ) ) {
                        if ( $this->FileBackend->getFileSize( $src ) === 0 ) {
@@ -251,6 +358,25 @@
                }
 
                return $result;
+       }
+
+       /**
+        * @param {string} $mwstore_relative_path
+        * @throws {MWException}
+        * @return {null|FSFile}
+        */
+       public function retrieveFileFromRelativePath( $mwstore_relative_path = 
null ) {
+               if ( empty( $mwstore_relative_path ) ) {
+                       throw new MWException(
+                               wfMessage( 'gwtoolset-developer-issue' )
+                                       ->params( __METHOD__ . ': ' . 
wfMessage( 'gwtoolset-no-mwstore-relative-path' ) )
+                                       ->parse()
+                       );
+               }
+
+               return $this->retrieveFile(
+                       $this->getMWStoreCompleteFilePath( 
$mwstore_relative_path )
+               );
        }
 
        /**
@@ -295,7 +421,7 @@
                        );
                }
 
-               $result = $this->getMWStorePath();
+               $result = $this->getMWStoreRelativePath();
 
                return $result;
        }
diff --git a/includes/Hooks/Hooks.php b/includes/Hooks/Hooks.php
index e251ffe..e12ef53 100644
--- a/includes/Hooks/Hooks.php
+++ b/includes/Hooks/Hooks.php
@@ -22,8 +22,7 @@
 
        public static function onUnitTestsList( &$files ) {
                global $wgGWToolsetDir;
-               $testDir = $wgGWToolsetDir . DIRECTORY_SEPARATOR . 'tests' . 
DIRECTORY_SEPARATOR . 'phpunit';
-               $files = array_merge( $files, glob( $testDir . 
DIRECTORY_SEPARATOR . '*Test.php' ) );
+               $files = array_merge( $files, glob( $wgGWToolsetDir . 
'/tests/phpunit/*Test.php' ) );
                return true;
        }
 }
diff --git a/includes/Jobs/GWTFileBackendCleanupJob.php 
b/includes/Jobs/GWTFileBackendCleanupJob.php
index ffc70cc..1c89531 100644
--- a/includes/Jobs/GWTFileBackendCleanupJob.php
+++ b/includes/Jobs/GWTFileBackendCleanupJob.php
@@ -30,16 +30,19 @@
         */
        protected function processJob() {
                $result = true;
-               global $wgGWTFileBackend, $wgGWTFBMetadataContainer;
+               global $wgGWTFileBackend;
 
                $GWTFileBackend = new GWTFileBackend(
                        array(
+                               'container' => 
Config::$filebackend_metadata_container,
                                'file-backend-name' => $wgGWTFileBackend,
-                               'container' => $wgGWTFBMetadataContainer,
+                               'User' => User::newFromName( 
$this->params['user-name'] )
                        )
                );
 
-               $Status = $GWTFileBackend->deleteFile( 
$this->params['gwtoolset-metadata-file-mwstore'] );
+               $Status = $GWTFileBackend->deleteFileFromRelativePath(
+                       $this->params['gwtoolset-metadata-file-relative-path']
+               );
 
                if ( !$Status->ok ) {
                        $this->setLastError( __METHOD__ . ': ' . 
$Status->getMessage() );
@@ -75,13 +78,18 @@
        protected function validateParams() {
                $result = true;
 
-               if ( empty( $this->params['gwtoolset-metadata-file-mwstore'] ) 
) {
+               if ( empty( 
$this->params['gwtoolset-metadata-file-relative-path'] ) ) {
                        $this->setLastError(
-                               __METHOD__ . ': no 
$this->params[\'gwtoolset-metadata-file-mwstore\'] provided'
+                               __METHOD__ . ': no 
$this->params[\'gwtoolset-metadata-file-relative-path\'] provided'
                        );
                        $result = false;
                }
 
+               if ( empty( $this->params['user-name'] ) ) {
+                       $this->setLastError( __METHOD__ . ': no 
$this->params[\'user-name\'] provided' );
+                       $result = false;
+               }
+
                return $result;
        }
 }
diff --git a/maintenance/cleanupGWTFileBackend.php 
b/maintenance/cleanupGWTFileBackend.php
index 91e19b6..4437543 100644
--- a/maintenance/cleanupGWTFileBackend.php
+++ b/maintenance/cleanupGWTFileBackend.php
@@ -32,12 +32,12 @@
        }
 
        public function execute() {
-               global $wgGWTFileBackend, $wgGWTFBMetadataContainer, 
$wgGWTFBMaxAge;
+               global $wgGWTFileBackend, $wgGWTFBMaxAge;
 
                $GWTFileBackend = new GWTFileBackend(
                        array(
-                               'file-backend-name' => $wgGWTFileBackend,
-                               'container' => $wgGWTFBMetadataContainer
+                               'container' => 
Config::$filebackend_metadata_container,
+                               'file-backend-name' => $wgGWTFileBackend
                        )
                );
 
@@ -61,7 +61,7 @@
                        '...' . PHP_EOL
                );
 
-               $mwstore_path = $GWTFileBackend->getMWStorePath();
+               $mwstore_path = $GWTFileBackend->getMWStorePath() . '/';
 
                $FSFileBackendFileList = 
$GWTFileBackend->FileBackend->getFileList(
                        array( 'dir' => $mwstore_path, 'adviseStat' => true )

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I278d9f3b1332f7a2e1ee6a2d759569ba322db390
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/GWToolset
Gerrit-Branch: master
Gerrit-Owner: Dan-nl <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: BryanDavis <[email protected]>
Gerrit-Reviewer: CSteipp <[email protected]>
Gerrit-Reviewer: Dan-nl <[email protected]>
Gerrit-Reviewer: GergÅ‘ Tisza <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to