Page MenuHomePhabricator

Multiblocks support in ApiBlockInfoTrait and ApiQueryBlockInfoTrait
Closed, ResolvedPublic

Description

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.

Details

Related Changes in Gerrit:

Event Timeline

Change 972064 had a related patch set uploaded (by HMonroy; author: HMonroy):

[mediawiki/core@master] Bug: T349883

https://gerrit.wikimedia.org/r/972064

Change 972064 abandoned by HMonroy:

[mediawiki/core@master] Bug: T349883

Reason:

https://gerrit.wikimedia.org/r/972064

Change 971343 had a related patch set uploaded (by Tim Starling; author: Tim Starling):

[mediawiki/core@master] Support new block schema

https://gerrit.wikimedia.org/r/971343

Change 971343 merged by jenkins-bot:

[mediawiki/core@master] Support new block schema

https://gerrit.wikimedia.org/r/971343