Remove wfDebugLog() dependency from FileOp classes
authorAaron Schulz <aschulz@wikimedia.org>
Sun, 18 Sep 2016 23:07:34 +0000 (16:07 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Fri, 23 Sep 2016 21:30:08 +0000 (21:30 +0000)
Change-Id: Ib8ab9edd1afdb28f7444f5e13cf34a696a066234

includes/filebackend/FileBackendStore.php
includes/filebackend/FileOp.php

index 3fd1ce6..66f0737 100644 (file)
@@ -1020,7 +1020,7 @@ abstract class FileBackendStore extends FileBackend {
                                // Get params for this operation
                                $params = $operation;
                                // Append the FileOp class
-                               $performOps[] = new $class( $this, $params );
+                               $performOps[] = new $class( $this, $params, $this->logger );
                        } else {
                                throw new FileBackendError( "Operation '$opName' is not supported." );
                        }
index 480ebdf..8207b12 100644 (file)
@@ -21,6 +21,7 @@
  * @ingroup FileBackend
  * @author Aaron Schulz
  */
+use Psr\Log\LoggerInterface;
 
 /**
  * FileBackend helper class for representing operations.
@@ -39,6 +40,8 @@ abstract class FileOp {
 
        /** @var FileBackendStore */
        protected $backend;
+       /** @var LoggerInterface */
+       protected $logger;
 
        /** @var int */
        protected $state = self::STATE_NEW;
@@ -74,10 +77,14 @@ abstract class FileOp {
         *
         * @param FileBackendStore $backend
         * @param array $params
+        * @param LoggerInterface $logger PSR logger instance
         * @throws FileBackendError
         */
-       final public function __construct( FileBackendStore $backend, array $params ) {
+       final public function __construct(
+               FileBackendStore $backend, array $params, LoggerInterface $logger
+       ) {
                $this->backend = $backend;
+               $this->logger = $logger;
                list( $required, $optional, $paths ) = $this->allowedParams();
                foreach ( $required as $name ) {
                        if ( isset( $params[$name] ) ) {
@@ -454,7 +461,7 @@ abstract class FileOp {
                $params = $this->params;
                $params['failedAction'] = $action;
                try {
-                       wfDebugLog( 'FileOperation', get_class( $this ) .
+                       $this->logger->error( get_class( $this ) .
                                " failed (batch #{$this->batchId}): " . FormatJson::encode( $params ) );
                } catch ( Exception $e ) {
                        // bad config? debug log error?