X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fapi%2FApiQueryBlocks.php;h=698c13c53d4939aff639238503d4e3e75fb59cb9;hp=076a09efdf138e993d1f8cf3bbd8ca88cdde8895;hb=1d7a1bf8bddf0908e4f572c82268733f63126a13;hpb=6c9a2923fe1ee3a65cb027be5e781772f2b12fbd diff --git a/includes/api/ApiQueryBlocks.php b/includes/api/ApiQueryBlocks.php index 076a09efdf..698c13c53d 100644 --- a/includes/api/ApiQueryBlocks.php +++ b/includes/api/ApiQueryBlocks.php @@ -37,6 +37,7 @@ class ApiQueryBlocks extends ApiQueryBase { public function execute() { $db = $this->getDB(); + $commentStore = new CommentStore( 'ipb_reason' ); $params = $this->extractRequestParams(); $this->requireMaxOneParameter( $params, 'users', 'ip' ); @@ -61,12 +62,18 @@ class ApiQueryBlocks extends ApiQueryBase { $this->addFieldsIf( 'ipb_by_text', $fld_by ); $this->addFieldsIf( 'ipb_by', $fld_byid ); $this->addFieldsIf( 'ipb_expiry', $fld_expiry ); - $this->addFieldsIf( 'ipb_reason', $fld_reason ); $this->addFieldsIf( [ 'ipb_range_start', 'ipb_range_end' ], $fld_range ); $this->addFieldsIf( [ 'ipb_anon_only', 'ipb_create_account', 'ipb_enable_autoblock', 'ipb_block_email', 'ipb_deleted', 'ipb_allow_usertalk' ], $fld_flags ); + if ( $fld_reason ) { + $commentQuery = $commentStore->getJoin(); + $this->addTables( $commentQuery['tables'] ); + $this->addFields( $commentQuery['fields'] ); + $this->addJoinConds( $commentQuery['joins'] ); + } + $this->addOption( 'LIMIT', $params['limit'] + 1 ); $this->addTimestampWhereRange( 'ipb_timestamp', @@ -205,7 +212,7 @@ class ApiQueryBlocks extends ApiQueryBase { $block['expiry'] = ApiResult::formatExpiry( $row->ipb_expiry ); } if ( $fld_reason ) { - $block['reason'] = $row->ipb_reason; + $block['reason'] = $commentStore->getComment( $row )->text; } if ( $fld_range && !$row->ipb_auto ) { $block['rangestart'] = IP::formatHex( $row->ipb_range_start );