Store page_id in logging table for deletions and make queryable
authorMatthew Flaschen <mflaschen@wikimedia.org>
Sat, 15 Feb 2014 07:14:21 +0000 (02:14 -0500)
committerMatthew Flaschen <mflaschen@wikimedia.org>
Tue, 20 May 2014 03:02:44 +0000 (23:02 -0400)
* Clone title so page_id is not 0 at log time.
* Change ApiQueryLogEvents to provide log_page as logpage (for all
  rows, not just deletions) if ids are requested.

Bug: 26122
Change-Id: I1c7f3a84f10df05d6b37dccbad4c8232edf51580

RELEASE-NOTES-1.24
includes/WikiPage.php
includes/api/ApiQueryLogEvents.php

index b5b3f8e..03e6980 100644 (file)
@@ -51,6 +51,8 @@ production.
 * action=query&meta=siteinfo&siprop=interwikimap returns a new "protorel"
   field which is true iff protocol-relative urls can be used to access
   a particular interwiki map entry.
+* ApiQueryLogEvents now provides logpage, which is the page ID from the
+  logging table, if ids are requested and the user has the permissions.
 
 === Languages updated in 1.24 ===
 
index 9a26c15..5722af2 100644 (file)
@@ -2831,6 +2831,9 @@ class WikiPage implements Page, IDBAccessObject {
                        $dbw->delete( 'revision', array( 'rev_page' => $id ), __METHOD__ );
                }
 
+               // Clone the title, so we have the information we need when we log
+               $logTitle = clone $this->mTitle;
+
                $this->doDeleteUpdates( $id, $content );
 
                // Log the deletion, if the page was suppressed, log it at Oversight instead
@@ -2838,7 +2841,7 @@ class WikiPage implements Page, IDBAccessObject {
 
                $logEntry = new ManualLogEntry( $logtype, 'delete' );
                $logEntry->setPerformer( $user );
-               $logEntry->setTarget( $this->mTitle );
+               $logEntry->setTarget( $logTitle );
                $logEntry->setComment( $reason );
                $logid = $logEntry->insert();
                $logEntry->publish( $logid );
index bb424ee..0977439 100644 (file)
@@ -81,6 +81,10 @@ class ApiQueryLogEvents extends ApiQueryBase {
                ) );
 
                $this->addFieldsIf( 'page_id', $this->fld_ids );
+               // log_page is the page_id saved at log time, whereas page_id is from a
+               // join at query time.  This leads to different results in various
+               // scenarios, e.g. deletion, recreation.
+               $this->addFieldsIf( 'log_page', $this->fld_ids );
                $this->addFieldsIf( array( 'log_user', 'log_user_text', 'user_name' ), $this->fld_user );
                $this->addFieldsIf( 'log_user', $this->fld_userid );
                $this->addFieldsIf(
@@ -364,6 +368,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
                                }
                                if ( $this->fld_ids ) {
                                        $vals['pageid'] = intval( $row->page_id );
+                                       $vals['logpage'] = intval( $row->log_page );
                                }
                                if ( $this->fld_details && $row->log_params !== '' ) {
                                        self::addLogParams(