TableDiffFormatter: Don't repeatedly call array_shift()
[lhc/web/wiklou.git] / includes / logging / PatrolLogFormatter.php
index 74ab196..e6f9fb6 100644 (file)
@@ -20,7 +20,7 @@
  * @file
  * @author Niklas Laxström
  * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
- * @since 1.21
+ * @since 1.22
  */
 
 /**
@@ -33,8 +33,10 @@ class PatrolLogFormatter extends LogFormatter {
                $key = parent::getMessageKey();
                $params = $this->getMessageParameters();
                if ( isset( $params[5] ) && $params[5] ) {
+                       // Messages: logentry-patrol-patrol-auto
                        $key .= '-auto';
                }
+
                return $key;
        }
 
@@ -48,16 +50,39 @@ 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 );
                }
 
                $params[3] = Message::rawParam( $revlink );
+
+               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;
        }
 }