X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fapi%2FApiQueryRecentChanges.php;h=517cf1f8608f050eaed76637d53f0f072d5af032;hp=0dc01aabc249a7ff441f60789205beee34b5ddfe;hb=74426f3cf796b149f1ae445e41815bbe148640b2;hpb=a4943f548be4cfc8f286f00fc8064ff0e377f2ba diff --git a/includes/api/ApiQueryRecentChanges.php b/includes/api/ApiQueryRecentChanges.php index 0dc01aabc2..517cf1f860 100644 --- a/includes/api/ApiQueryRecentChanges.php +++ b/includes/api/ApiQueryRecentChanges.php @@ -1,9 +1,5 @@ @gmail.com" * * This program is free software; you can redistribute it and/or modify @@ -36,6 +32,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, @@ -63,7 +61,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { } $this->tokenFunctions = [ - 'patrol' => [ 'ApiQueryRecentChanges', 'getPatrolToken' ] + 'patrol' => [ self::class, 'getPatrolToken' ] ]; Hooks::run( 'APIQueryRecentChangesTokens', [ &$this->tokenFunctions ] ); @@ -274,7 +272,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 ); @@ -351,6 +348,15 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { } $this->token = $params['token']; + + if ( $this->fld_comment || $this->fld_parsedcomment || $this->token ) { + $this->commentStore = new CommentStore( 'rc_comment' ); + $commentQuery = $this->commentStore->getJoin(); + $this->addTables( $commentQuery['tables'] ); + $this->addFields( $commentQuery['fields'] ); + $this->addJoinConds( $commentQuery['joins'] ); + } + $this->addOption( 'LIMIT', $params['limit'] + 1 ); $hookData = []; @@ -500,12 +506,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 ); } } }