Discussion
ApiBlockInfoTrait is used by many modules to convert a Block object, typically from User::getBlock(), to an associative array. If User::getBlock() returns a CompositeBlock, the unmodified code would just show composite block placeholder messages, which would lead to an unsatisfying result for client-side tools that depend on this information.
The policy for displaying block information on the client side should follow T349826: Show multiple block messages on UserBlockedError page. ApiBlockInfoTrait should include sufficient information to display a similar message to that which would be shown on the server side. I imagine that would mean at least adding the return value of CompositeBlock::getOriginalBlocks() to the output.
ApiQueryBlockInfoTrait::addBlockInfoToQuery() adds a join to the main query with ipb_user=user_id. In the case of $showBlockInfo = false, it just filters out hidden users, which can be done in the multiblocks schema in a backwards-compatible way. But in the case of $showBlockInfo = true, trying to return multiple blocks in a join would duplicate the result rows, which is not acceptable. So this interface needs to be deprecated.
Plan
- In ApiBlockInfoTrait::getBlockDetails(), conditionally add an original block array.
- In core and WMF-deployed extensions, review client-side usages of block information from ApiBlockInfoTrait and note any that may need better composite block formatting.
- Deprecate ApiQueryBlockInfoTrait::addBlockInfoToQuery()
- Add, say, ApiQueryBlockInfoTrait::addDeletedUserFilter(), which will behave like ApiQueryBlockInfoTrait::addBlockInfoToQuery( false ), except that an alias should be used for the ipb_deleted field.
- Add, say, ApiQueryBlockInfoTrait::getBlockDetailsForRows(), which will take a result set with a user_id field, and do a batch query for those users, returning an array of block infos indexed by user_id, each block info array being the return value of ApiBlockInfoTrait::getBlockDetails(), possibly including an original block array.
- Migrate ApiQueryBlockInfoTrait callers in core. There are no callers in WMF-deployed extensions. The trait is used by OOJSPlus but apparently no methods are called.