block: Fix inadequate GROUP BY in HideUserUtils::addFieldToBuilder()
With the new schema and sql_mode=ONLY_FULL_GROUP_BY, we get an error from LocalIdLookup::lookupCentralIds() due to user_name not being in the GROUP BY. So, just use a subquery, identical to the one used by getExpression(). Change-Id: If22561b5ce5762a33fc8aa13ee9406990c8ae8ce
This commit is contained in:
parent
b7986c183a
commit
6abb5aa080
1 changed files with 13 additions and 11 deletions
|
|
@ -99,17 +99,19 @@ class HideUserUtils {
|
|||
[ "ipb_user=$userIdField", 'ipb_deleted' => 1 ]
|
||||
);
|
||||
} else {
|
||||
$group = $qb->newJoinGroup()
|
||||
->table( 'block_target' )
|
||||
->join( 'block', 'hide_user_block', 'bl_target=bt_id' );
|
||||
$qb
|
||||
->select( [ $deletedFieldAlias => 'bl_deleted IS NOT NULL' ] )
|
||||
->leftJoin(
|
||||
$group,
|
||||
'hide_user_block_group',
|
||||
[ "bt_user=$userIdField", 'bl_deleted' => 1 ]
|
||||
)
|
||||
->groupBy( $userIdField );
|
||||
$cond = '(' .
|
||||
$qb->newSubquery()
|
||||
->select( '1' )
|
||||
// $userIdField may be e.g. block_target.bt_user so an inner table
|
||||
// alias is necessary to ensure that that refers to the outer copy
|
||||
// of the block_target table.
|
||||
->from( 'block_target', 'hu_block_target' )
|
||||
->join( 'block', 'hu_block', 'hu_block.bl_target=hu_block_target.bt_id' )
|
||||
->where( [ "hu_block_target.bt_user=$userIdField", 'hu_block.bl_deleted' => 1 ] )
|
||||
->caller( __METHOD__ )
|
||||
->getSQL() .
|
||||
') IS NOT NULL';
|
||||
$qb->select( [ $deletedFieldAlias => $cond ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue