X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fapi%2FApiQueryRecentChanges.php;h=9af4e3e4a2633ee7b4cf19e528f98a48ab5eea16;hp=2c76e971058b53c8bfbcae2912a0d9ab24ae1989;hb=d19826aa35b206847a568a4b2c1c9ffaa615fca5;hpb=892b17237bb44630fa6f508c5bf85374a62def13 diff --git a/includes/api/ApiQueryRecentChanges.php b/includes/api/ApiQueryRecentChanges.php index 2c76e97105..9af4e3e4a2 100644 --- a/includes/api/ApiQueryRecentChanges.php +++ b/includes/api/ApiQueryRecentChanges.php @@ -36,6 +36,8 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { parent::__construct( $query, $moduleName, 'rc' ); } + private $commentStore; + private $fld_comment = false, $fld_parsedcomment = false, $fld_user = false, $fld_userid = false, $fld_flags = false, $fld_timestamp = false, $fld_title = false, $fld_ids = false, $fld_sizes = false, $fld_redirect = false, $fld_patrolled = false, $fld_loginfo = false, @@ -147,7 +149,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { /* Build our basic query. Namely, something along the lines of: * SELECT * FROM recentchanges WHERE rc_timestamp > $start - * AND rc_timestamp < $end AND rc_namespace = $namespace + * AND rc_timestamp < $end AND rc_namespace = $namespace */ $this->addTables( 'recentchanges' ); $this->addTimestampWhereRange( 'rc_timestamp', $params['dir'], $params['start'], $params['end'] ); @@ -274,7 +276,6 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { /* Add fields to our query if they are specified as a needed parameter. */ $this->addFieldsIf( [ 'rc_this_oldid', 'rc_last_oldid' ], $this->fld_ids ); - $this->addFieldsIf( 'rc_comment', $this->fld_comment || $this->fld_parsedcomment ); $this->addFieldsIf( 'rc_user', $this->fld_user || $this->fld_userid ); $this->addFieldsIf( 'rc_user_text', $this->fld_user ); $this->addFieldsIf( [ 'rc_minor', 'rc_type', 'rc_bot' ], $this->fld_flags ); @@ -286,6 +287,14 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { ); $showRedirects = $this->fld_redirect || isset( $show['redirect'] ) || isset( $show['!redirect'] ); + + if ( $this->fld_comment || $this->fld_parsedcomment ) { + $this->commentStore = new CommentStore( 'rc_comment' ); + $commentQuery = $this->commentStore->getJoin(); + $this->addTables( $commentQuery['tables'] ); + $this->addFields( $commentQuery['fields'] ); + $this->addJoinConds( $commentQuery['joins'] ); + } } $this->addFieldsIf( [ 'rc_this_oldid' ], $resultPageSet && $params['generaterevisions'] ); @@ -320,7 +329,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { $this->addWhereFld( 'ct_tag', $params['tag'] ); } - // Paranoia: avoid brute force searches (bug 17342) + // Paranoia: avoid brute force searches (T19342) if ( !is_null( $params['user'] ) || !is_null( $params['excludeuser'] ) ) { if ( !$user->isAllowed( 'deletedhistory' ) ) { $bitmask = Revision::DELETED_USER; @@ -500,12 +509,13 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { $anyHidden = true; } if ( Revision::userCanBitfield( $row->rc_deleted, Revision::DELETED_COMMENT, $user ) ) { - if ( $this->fld_comment && isset( $row->rc_comment ) ) { - $vals['comment'] = $row->rc_comment; + $comment = $this->commentStore->getComment( $row )->text; + if ( $this->fld_comment ) { + $vals['comment'] = $comment; } - if ( $this->fld_parsedcomment && isset( $row->rc_comment ) ) { - $vals['parsedcomment'] = Linker::formatComment( $row->rc_comment, $title ); + if ( $this->fld_parsedcomment ) { + $vals['parsedcomment'] = Linker::formatComment( $comment, $title ); } } } @@ -699,6 +709,6 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { } public function getHelpUrls() { - return 'https://www.mediawiki.org/wiki/API:Recentchanges'; + return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Recentchanges'; } }