TableDiffFormatter: Don't repeatedly call array_shift()
[lhc/web/wiklou.git] / includes / logging / PatrolLogFormatter.php
index 2abaf17..e6f9fb6 100644 (file)
@@ -33,6 +33,7 @@ class PatrolLogFormatter extends LogFormatter {
                $key = parent::getMessageKey();
                $params = $this->getMessageParameters();
                if ( isset( $params[5] ) && $params[5] ) {
+                       // Messages: logentry-patrol-patrol-auto
                        $key .= '-auto';
                }
 
@@ -49,11 +50,11 @@ class PatrolLogFormatter extends LogFormatter {
                if ( $this->plaintext ) {
                        $revlink = $revision;
                } elseif ( $target->exists() ) {
-                       $query = array(
+                       $query = [
                                'oldid' => $oldid,
                                'diff' => 'prev'
-                       );
-                       $revlink = Linker::link( $target, htmlspecialchars( $revision ), array(), $query );
+                       ];
+                       $revlink = Linker::link( $target, htmlspecialchars( $revision ), [], $query );
                } else {
                        $revlink = htmlspecialchars( $revision );
                }
@@ -62,4 +63,26 @@ class PatrolLogFormatter extends LogFormatter {
 
                return $params;
        }
+
+       protected function getParametersForApi() {
+               $entry = $this->entry;
+               $params = $entry->getParameters();
+
+               static $map = [
+                       '4:number:curid',
+                       '5:number:previd',
+                       '6:bool:auto',
+                       '4::curid' => '4:number:curid',
+                       '5::previd' => '5:number:previd',
+                       '6::auto' => '6:bool:auto',
+               ];
+               foreach ( $map as $index => $key ) {
+                       if ( isset( $params[$index] ) ) {
+                               $params[$key] = $params[$index];
+                               unset( $params[$index] );
+                       }
+               }
+
+               return $params;
+       }
 }