From: Aaron Schulz Date: Tue, 24 Jan 2012 18:49:53 +0000 (+0000) Subject: r109904: worked around PHP < 5.3 suckage to keep this compatible X-Git-Tag: 1.31.0-rc.0~25100 X-Git-Url: http://git.cyclocoop.org/%24href?a=commitdiff_plain;h=859982819d9a7718a4517e99e0f4418817a11817;p=lhc%2Fweb%2Fwiklou.git r109904: worked around PHP < 5.3 suckage to keep this compatible --- diff --git a/includes/filerepo/backend/FileOp.php b/includes/filerepo/backend/FileOp.php index b74213347f..08242da5c3 100644 --- a/includes/filerepo/backend/FileOp.php +++ b/includes/filerepo/backend/FileOp.php @@ -28,10 +28,6 @@ abstract class FileOp { protected $sourceSha1; // string protected $destSameAsSource; // boolean - /* Operation parameters */ - protected static $requiredParams = array(); - protected static $optionalParams = array(); - /* Object life-cycle */ const STATE_NEW = 1; const STATE_CHECKED = 2; @@ -50,15 +46,15 @@ abstract class FileOp { */ final public function __construct( FileBackendBase $backend, array $params ) { $this->backend = $backend; - $class = get_class( $this ); // simulate LSB - foreach ( $class::$requiredParams as $name ) { + list( $required, $optional ) = $this->allowedParams(); + foreach ( $required as $name ) { if ( isset( $params[$name] ) ) { $this->params[$name] = $params[$name]; } else { throw new MWException( "File operation missing parameter '$name'." ); } } - foreach ( $class::$optionalParams as $name ) { + foreach ( $optional as $name ) { if ( isset( $params[$name] ) ) { $this->params[$name] = $params[$name]; } @@ -216,6 +212,15 @@ abstract class FileOp { return $status; } + /** + * Get required operation parameters + * + * @return Array (required params list, optional params list) + */ + protected function allowedParams() { + return array( array(), array() ); + } + /** * Get a list of storage paths read from for this operation * @@ -387,8 +392,9 @@ class FileOpScopedPHPTimeout { * overwriteSame : override any existing file at destination */ class StoreFileOp extends FileOp { - protected static $requiredParams = array( 'src', 'dst' ); - protected static $optionalParams = array( 'overwrite', 'overwriteSame' ); + protected function allowedParams() { + return array( array( 'src', 'dst' ), array( 'overwrite', 'overwriteSame' ) ); + } protected function doPrecheck( array &$predicates ) { $status = Status::newGood(); @@ -448,8 +454,9 @@ class StoreFileOp extends FileOp { * overwriteSame : override any existing file at destination */ class CreateFileOp extends FileOp { - protected static $requiredParams = array( 'content', 'dst' ); - protected static $optionalParams = array( 'overwrite', 'overwriteSame' ); + protected function allowedParams() { + return array( array( 'content', 'dst' ), array( 'overwrite', 'overwriteSame' ) ); + } protected function doPrecheck( array &$predicates ) { $status = Status::newGood(); @@ -499,8 +506,9 @@ class CreateFileOp extends FileOp { * overwriteSame : override any existing file at destination */ class CopyFileOp extends FileOp { - protected static $requiredParams = array( 'src', 'dst' ); - protected static $optionalParams = array( 'overwrite', 'overwriteSame' ); + protected function allowedParams() { + return array( array( 'src', 'dst' ), array( 'overwrite', 'overwriteSame' ) ); + } protected function doPrecheck( array &$predicates ) { $status = Status::newGood(); @@ -553,8 +561,9 @@ class CopyFileOp extends FileOp { * overwriteSame : override any existing file at destination */ class MoveFileOp extends FileOp { - protected static $requiredParams = array( 'src', 'dst' ); - protected static $optionalParams = array( 'overwrite', 'overwriteSame' ); + protected function allowedParams() { + return array( array( 'src', 'dst' ), array( 'overwrite', 'overwriteSame' ) ); + } protected function doPrecheck( array &$predicates ) { $status = Status::newGood(); @@ -611,8 +620,9 @@ class MoveFileOp extends FileOp { * ignoreMissingSource : don't return an error if the file does not exist */ class DeleteFileOp extends FileOp { - protected static $requiredParams = array( 'src' ); - protected static $optionalParams = array( 'ignoreMissingSource' ); + protected function allowedParams() { + return array( array( 'src' ), array( 'ignoreMissingSource' ) ); + } protected $needsDelete = true;