X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiQueryBlocks.php;h=08c13e7aabf8841c75e481de66068fe940381c49;hb=a2c8c2969420a0f150c03f76e3a0bf9028fcda43;hp=076a09efdf138e993d1f8cf3bbd8ca88cdde8895;hpb=eb72adcb4e28eedc1806d845355856bd6f97dadb;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiQueryBlocks.php b/includes/api/ApiQueryBlocks.php index 076a09efdf..08c13e7aab 100644 --- a/includes/api/ApiQueryBlocks.php +++ b/includes/api/ApiQueryBlocks.php @@ -1,9 +1,5 @@ .@gmail.com" * * This program is free software; you can redistribute it and/or modify @@ -37,6 +33,7 @@ class ApiQueryBlocks extends ApiQueryBase { public function execute() { $db = $this->getDB(); + $commentStore = CommentStore::getStore(); $params = $this->extractRequestParams(); $this->requireMaxOneParameter( $params, 'users', 'ip' ); @@ -58,15 +55,25 @@ class ApiQueryBlocks extends ApiQueryBase { $this->addFields( [ 'ipb_auto', 'ipb_id', 'ipb_timestamp' ] ); $this->addFieldsIf( [ 'ipb_address', 'ipb_user' ], $fld_user || $fld_userid ); - $this->addFieldsIf( 'ipb_by_text', $fld_by ); - $this->addFieldsIf( 'ipb_by', $fld_byid ); + if ( $fld_by || $fld_byid ) { + $actorQuery = ActorMigration::newMigration()->getJoin( 'ipb_by' ); + $this->addTables( $actorQuery['tables'] ); + $this->addFields( $actorQuery['fields'] ); + $this->addJoinConds( $actorQuery['joins'] ); + } $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( 'ipb_reason' ); + $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( 'ipb_reason', $row )->text; } if ( $fld_range && !$row->ipb_auto ) { $block['rangestart'] = IP::formatHex( $row->ipb_range_start );