From: Matthew Flaschen Date: Sat, 15 Feb 2014 07:14:21 +0000 (-0500) Subject: Store page_id in logging table for deletions and make queryable X-Git-Tag: 1.31.0-rc.0~15601^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22brouteur%22%2C%28%24id_rubrique%20?a=commitdiff_plain;h=d5cc04641dc48b5c7cf0ca158382135279c64c29;p=lhc%2Fweb%2Fwiklou.git Store page_id in logging table for deletions and make queryable * 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 --- diff --git a/RELEASE-NOTES-1.24 b/RELEASE-NOTES-1.24 index b5b3f8ec2d..03e6980817 100644 --- a/RELEASE-NOTES-1.24 +++ b/RELEASE-NOTES-1.24 @@ -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 === diff --git a/includes/WikiPage.php b/includes/WikiPage.php index 9a26c15b05..5722af2cb7 100644 --- a/includes/WikiPage.php +++ b/includes/WikiPage.php @@ -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 ); diff --git a/includes/api/ApiQueryLogEvents.php b/includes/api/ApiQueryLogEvents.php index bb424ee458..0977439752 100644 --- a/includes/api/ApiQueryLogEvents.php +++ b/includes/api/ApiQueryLogEvents.php @@ -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(