ParserOptions has a callable variable, currentRevisionCallback, that is set and retrieved via ::getCurrentRevisionCallback and ::setCurrentRevisionCallback. The callbacks uses return Revision objects, which are being deprecated. However, no alternative currently exists to replace the uses.
|Open||None||T11968 Reduce use of global and public variables|
|Open||None||T159283 Deprecate non-configuration globals|
|Open||DannyS712||T159299 Deprecate and remove $wgUser|
|Open||None||T267861 [GOAL] Emit deprecation warnings reading from $wgUser|
|Open||DannyS712||T243708 Mediawiki core needs uses of global $wgUser removed|
|Resolved||DannyS712||T246284 Hard deprecate the Revision class|
|Resolved||DannyS712||T249393 Deprecate methods returning Revision objects|
|Resolved||DannyS712||T249384 ParserOptions' currentRevisionCallback uses Revision objects|
The extensions that use either of these:
- fetchCurrentRevisionOfTitle is used in Scribunto and TemplateStyles
- statelessFetchRevision (the default callback) is only used in core
- getCurrentRevisionCallback and setCurrentRevisionCallback are only used in TemplateStyles, FlaggedRevs, TemplateSandbox, and Parsoid
- Scribunto: 1.35+
- TemplateStyles: MW 1.31+
- FlaggedRevs: MW 1.35+
- TemplateSandbox: MW 1.33+
- Parsoid: MW ^1.34 (i.e. doesn't support current version and can be ignored)
In short, 4 extensions need to be updated, and 2 updates need to be version dependent (i.e. behaviour switch based on version) to be able to hard deprecate the old system in 1.35
I started looking into this, and found that:
Documentation for Revision::newFromRow says MCR migration note: replaced by RevisionStore::newRevisionFromRow(). Note that newFromRow() also accepts arrays, while newRevisionFromRow() does not. Instead, a MutableRevisionRecord should be constructed directly. RevisionStore::newMutableRevisionFromArray() can be used as a temporary replacement, but should be avoided.
Documentation for MutableRevisionRecord::__construct says @note Avoid calling this constructor directly. Use the appropriate methods in RevisionStore instead.
The relevant documentation in for both methods was added by @daniel in T174025: Revision::newFromRow had the note added in https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/core/+/6af796f3e0cf3e66cd7d7e59af8445f5712d68fe%5E%21/#F2 and MutableRevisionRecord::__construct had the note added in https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/core/+/e61a1caaddb58cc26bf5f912940afbb2a6f65355%5E%21/#F4 when the class was originally created.
Given that the replacement here needs to be able to return a RevisionRecord that is not known to be in the database, MutableRevisionRecord seems like the ideal object, but its unclear how it should be created. @daniel, can you clarify how the object should be created?
@cscott would you mind taking a look at the patches I submitted for the extensions? Since you are familiar with this part of the code and gave the go-ahead to the new implementation at https://gerrit.wikimedia.org/r/#/c/mediawiki/core/+/587627/