Merge "Fix MediaWiki.Commenting.LicenseComment.InvalidLicenseTag errors"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 24 May 2018 00:27:01 +0000 (00:27 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 24 May 2018 00:27:01 +0000 (00:27 +0000)
RELEASE-NOTES-1.32
maintenance/deleteAutoPatrolLogs.php
tests/phpunit/maintenance/deleteAutoPatrolLogsTest.php

index b474d15..f1efd4f 100644 (file)
@@ -26,8 +26,8 @@ production.
 * (T112474) Generalized the ResourceLoader mechanism for overriding modules
   using a particular page during edit previews.
 * Added 'ApiParseMakeOutputPage' hook.
-* (T174313) Added checkbox on Special:ListUsers to display only users in temporary
-  user groups.
+* (T174313) Added checkbox on Special:ListUsers to display only users in
+  temporary user groups.
 
 === External library changes in 1.32 ===
 * …
@@ -97,15 +97,15 @@ because of Phabricator reports.
 * mw.util.updateTooltipAccessKeys(), deprecated in 1.24, was removed. Use
   jquery.accessKeyLabel instead.
 * The SqlDataUpdate class, deprecated in 1.28, has been removed.
-* The Html5Internal and Html5Depurate tidy driver classes were removed, along with the
-  Balancer tidy implementation. Both implementations were experimental, and were replaced
-  by RemexHtml.
+* The Html5Internal and Html5Depurate tidy driver classes were removed, along
+  with the Balancer tidy implementation. Both implementations were experimental,
+  and were replaced by RemexHtml.
 * (T179624) Job::insert() and ::batchInsert(), deprecated in 1.21, were both
   removed. Use JobQueueGroup::singleton()->push() instead.
 * The jquery.footHovzer module, for mediawiki.debug, was removed.
 * The es5-shim module, empty and deprecated since 1.29, was removed.
-* The mediawiki.widgets.visibleByteLimit module, deprecated in 1.32, was removed.
-  Use mediawiki.widgets.visibleLengthLimit instead.
+* The mediawiki.widgets.visibleByteLimit module alias, deprecated in 1.32, was
+  removed. Use mediawiki.widgets.visibleLengthLimit instead.
 * The jquery.farbtastic module, unused since 1.18, was removed.
 
 === Deprecations in 1.32 ===
index c1935a7..82bb928 100644 (file)
@@ -31,8 +31,7 @@ class DeleteAutoPatrolLogs extends Maintenance {
                $this->addOption( 'dry-run', 'Print debug info instead of actually deleting' );
                $this->addOption(
                        'check-old',
-                       'Check old patrol logs (for deleting old format autopatrols).' .
-                               'Note that this will not delete rows older than 2011 (MediaWiki 1.18).'
+                       'Check old patrol logs (for deleting old format autopatrols).'
                );
                $this->addOption(
                        'before',
@@ -156,17 +155,27 @@ class DeleteAutoPatrolLogs extends Maintenance {
                $autopatrols = [];
                foreach ( $result as $row ) {
                        $last = $row->log_id;
-                       Wikimedia\suppressWarnings();
-                       $params = unserialize( $row->log_params );
-                       Wikimedia\restoreWarnings();
+                       $logEntry = DatabaseLogEntry::newFromRow( $row );
+                       $params = $logEntry->getParameters();
+                       if ( !is_array( $params ) ) {
+                               continue;
+                       }
 
-                       // Skipping really old rows, before 2011
-                       if ( !is_array( $params ) || !array_key_exists( '6::auto', $params ) ) {
+                       // This logic belongs to PatrolLogFormatter::getMessageKey
+                       // and LogFormatter::extractParameters the 'auto' value is logically presented as key [5].
+                       // For legacy case the logical key is index + 3, meaning [2].
+                       // For the modern case, the logical key is index - 1 meaning [6].
+                       if ( array_key_exists( '6::auto', $params ) ) {
+                               // Between 2011-2016 autopatrol logs
+                               $auto = $params['6::auto'] === true;
+                       } elseif ( $logEntry->isLegacy() === true && array_key_exists( 2, $params ) ) {
+                               // Pre-2011 autopatrol logs
+                               $auto = $params[2] === '1';
+                       } else {
                                continue;
                        }
 
-                       $auto = $params['6::auto'];
-                       if ( $auto ) {
+                       if ( $auto === true ) {
                                $autopatrols[] = $row->log_id;
                        }
                }
index c141817..cd68fa5 100644 (file)
@@ -92,6 +92,24 @@ class DeleteAutoPatrolLogsTest extends MaintenanceBaseTestCase {
                        'log_timestamp' => 20091223210426
                ];
 
+               // Autopatrol #4 very old way
+               $logs[] = [
+                       'log_type' => 'patrol',
+                       'log_action' => 'patrol',
+                       'log_user' => 7257,
+                       'log_params' => "9227851\n0\n1",
+                       'log_timestamp' => 20081223210426
+               ];
+
+               // Manual patrol #3 very old way
+               $logs[] = [
+                       'log_type' => 'patrol',
+                       'log_action' => 'patrol',
+                       'log_user' => 7258,
+                       'log_params' => "9227851\n0\n0",
+                       'log_timestamp' => 20091223210426
+               ];
+
                wfGetDB( DB_MASTER )->insert( 'logging', $logs );
        }
 
@@ -132,6 +150,16 @@ class DeleteAutoPatrolLogsTest extends MaintenanceBaseTestCase {
                                'log_action' => 'patrol',
                                'log_user' => '7256',
                        ],
+                       (object)[
+                               'log_type' => 'patrol',
+                               'log_action' => 'patrol',
+                               'log_user' => '7257',
+                       ],
+                       (object)[
+                               'log_type' => 'patrol',
+                               'log_action' => 'patrol',
+                               'log_user' => '7258',
+                       ],
                ];
 
                $cases = [
@@ -146,6 +174,8 @@ class DeleteAutoPatrolLogsTest extends MaintenanceBaseTestCase {
                                        $allRows[3],
                                        $allRows[5],
                                        $allRows[6],
+                                       $allRows[7],
+                                       $allRows[8],
                                ],
                                [ '--sleep', '0', '-q' ]
                        ],
@@ -157,6 +187,8 @@ class DeleteAutoPatrolLogsTest extends MaintenanceBaseTestCase {
                                        $allRows[4],
                                        $allRows[5],
                                        $allRows[6],
+                                       $allRows[7],
+                                       $allRows[8],
                                ],
                                [ '--sleep', '0', '--before', '20060123210426', '-q' ]
                        ],
@@ -168,6 +200,7 @@ class DeleteAutoPatrolLogsTest extends MaintenanceBaseTestCase {
                                        $allRows[3],
                                        $allRows[4],
                                        $allRows[6],
+                                       $allRows[8],
                                ],
                                [ '--sleep', '0', '--check-old', '-q' ]
                        ],