leucosticte has uploaded a new change for review. https://gerrit.wikimedia.org/r/113523
Change subject: Implement way to get the ID of a deleted page from deletion logs. WikiPage::doDeleteArticleReal will tell ManualLogEntry::insert() what the page_id is, so it can be stored in log_page; then ApiQueryLogEvents will provide that data. ...................................................................... Implement way to get the ID of a deleted page from deletion logs. WikiPage::doDeleteArticleReal will tell ManualLogEntry::insert() what the page_id is, so it can be stored in log_page; then ApiQueryLogEvents will provide that data. Bug: 26122 Change-Id: I4724684287ed9abde9f504425c931b4b38dea5e2 --- M includes/WikiPage.php M includes/api/ApiQueryLogEvents.php M includes/logging/LogEntry.php 3 files changed, 18 insertions(+), 5 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/23/113523/1 diff --git a/includes/WikiPage.php b/includes/WikiPage.php index bcd0f69..920199a 100644 --- a/includes/WikiPage.php +++ b/includes/WikiPage.php @@ -2786,7 +2786,7 @@ $logEntry->setPerformer( $user ); $logEntry->setTarget( $this->mTitle ); $logEntry->setComment( $reason ); - $logid = $logEntry->insert(); + $logid = $logEntry->insert( null, $id ); $logEntry->publish( $logid ); if ( $commit ) { diff --git a/includes/api/ApiQueryLogEvents.php b/includes/api/ApiQueryLogEvents.php index 1578775..b7246a3 100644 --- a/includes/api/ApiQueryLogEvents.php +++ b/includes/api/ApiQueryLogEvents.php @@ -81,6 +81,9 @@ ) ); $this->addFieldsIf( array( 'log_id', 'page_id' ), $this->fld_ids ); + $this->addFieldsIf( array( 'log_page' ), $this->fld_ids + && ( !$fld_action || $fld_action === 'delete' ) + && ( !$fld_type || $fld_type === 'delete' ) ); $this->addFieldsIf( array( 'log_user', 'log_user_text', 'user_name' ), $this->fld_user ); $this->addFieldsIf( 'log_user', $this->fld_userid ); $this->addFieldsIf( @@ -328,8 +331,15 @@ if ( $this->fld_title ) { ApiQueryBase::addTitleInfo( $vals, $title ); } + $vals['pageid'] = 0; if ( $this->fld_ids ) { - $vals['pageid'] = intval( $row->page_id ); + if ( intval( $row->page_id ) ) { + $vals['pageid'] = intval( $row->page_id ); + } else { + if ( intval( $row->log_page ) ) { + $vals['pageid'] = intval( $row->log_page ); + } + } } if ( $this->fld_details && $row->log_params !== '' ) { self::addLogParams( diff --git a/includes/logging/LogEntry.php b/includes/logging/LogEntry.php index 71b4fc2..5477b7f 100644 --- a/includes/logging/LogEntry.php +++ b/includes/logging/LogEntry.php @@ -475,7 +475,7 @@ * @return int ID of the log entry * @throws MWException */ - public function insert( IDatabase $dbw = null ) { + public function insert( IDatabase $dbw = null, $pageId = null ) { global $wgContLang; $dbw = $dbw ?: wfGetDB( DB_MASTER ); @@ -491,7 +491,10 @@ # Truncate for whole multibyte characters. $comment = $wgContLang->truncate( $comment, 255 ); - $data = array( + if ( $pageId === null ) { + $pageId = $this->getTarget()->getArticleID(); + } + $data = array( 'log_id' => $id, 'log_type' => $this->getType(), 'log_action' => $this->getSubtype(), @@ -500,7 +503,7 @@ 'log_user_text' => $this->getPerformer()->getName(), 'log_namespace' => $this->getTarget()->getNamespace(), 'log_title' => $this->getTarget()->getDBkey(), - 'log_page' => $this->getTarget()->getArticleID(), + 'log_page' => $pageId, 'log_comment' => $comment, 'log_params' => serialize( (array)$this->getParameters() ), ); -- To view, visit https://gerrit.wikimedia.org/r/113523 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4724684287ed9abde9f504425c931b4b38dea5e2 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: leucosticte <nathanlarson3...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits