tidyUpBug37714.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. require_once __DIR__ . '/Maintenance.php';
  3. /**
  4. * Fixes all rows affected by https://bugzilla.wikimedia.org/show_bug.cgi?id=37714
  5. */
  6. class TidyUpBug37714 extends Maintenance {
  7. public function execute() {
  8. // Search for all log entries which are about changing the visability of other log entries.
  9. $result = $this->getDB( DB_SLAVE )->select(
  10. 'logging',
  11. [ 'log_id', 'log_params' ],
  12. [
  13. 'log_type' => [ 'suppress', 'delete' ],
  14. 'log_action' => 'event',
  15. 'log_namespace' => NS_SPECIAL,
  16. 'log_title' => SpecialPage::getTitleFor( 'Log' )->getText()
  17. ],
  18. __METHOD__
  19. );
  20. foreach ( $result as $row ) {
  21. $ids = explode( ',', explode( "\n", $row->log_params )[0] );
  22. $result = $this->getDB( DB_SLAVE )->select( // Work out what log entries were changed here.
  23. 'logging',
  24. 'log_type',
  25. [ 'log_id' => $ids ],
  26. __METHOD__,
  27. 'DISTINCT'
  28. );
  29. if ( $result->numRows() === 1 ) {
  30. // If there's only one type, the target title can be set to include it.
  31. $logTitle = SpecialPage::getTitleFor( 'Log', $result->current()->log_type )->getText();
  32. $this->output( 'Set log_title to "' . $logTitle . '" for log entry ' . $row->log_id . ".\n" );
  33. $this->getDB( DB_MASTER )->update(
  34. 'logging',
  35. [ 'log_title' => $logTitle ],
  36. [ 'log_id' => $row->log_id ],
  37. __METHOD__
  38. );
  39. wfWaitForSlaves();
  40. }
  41. }
  42. }
  43. }
  44. $maintClass = 'TidyUpBug37714';
  45. require_once RUN_MAINTENANCE_IF_MAIN;