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.
Description
Details
Status | Subtype | Assigned | Task | ||
---|---|---|---|---|---|
Open | None | T11968 Reduce use of global and public variables | |||
Open | None | T159283 Deprecate non-configuration globals | |||
Open | DannyS712 | T159299 Deprecate and remove $wgUser | |||
Resolved | DannyS712 | 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 |
Event Timeline
I did some more digging:
The callback is for use in Parser::fetchCurrentRevisionOfTitle
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
Compatibility policies:
- 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?
^ I'm not sure why I thought a MutableRevisionRecord was needed, done differently (but the correct way to create it should still be clarified)
Change 587627 had a related patch set uploaded (by DannyS712; owner: DannyS712):
[mediawiki/core@master] Add RevisionRecord alternatives to Parser and ParserOptions methods
Change 587627 merged by jenkins-bot:
[mediawiki/core@master] Add RevisionRecord alternatives to Parser and ParserOptions methods
Change 589644 had a related patch set uploaded (by DannyS712; owner: DannyS712):
[mediawiki/extensions/TemplateStyles@master] Use RevisionRecordCallback in ParserOptions in MW 1.35+
Oh, its needed when the extension wants to pass a RevisionRecord with the fields specified; should it construct the MutableRevisionRecord manually or via RevisionStore?
Change 589646 had a related patch set uploaded (by DannyS712; owner: DannyS712):
[mediawiki/core@master] Follow up I66cbcb963a96cc49c75ca72faa7e439ae6d6614d - update release notes
Change 589646 merged by jenkins-bot:
[mediawiki/core@master] Follow up I66cbcb963a96cc49c75ca72faa7e439ae6d6614d - update release notes
Change 589693 had a related patch set uploaded (by DannyS712; owner: DannyS712):
[mediawiki/extensions/FlaggedRevs@master] Use RevisionRecordCallback in ParserOptions
Change 589697 had a related patch set uploaded (by DannyS712; owner: DannyS712):
[mediawiki/extensions/TemplateSandbox@master] Use RevisionRecordCallback in ParserOptions in MW 1.35+
Change 589699 had a related patch set uploaded (by DannyS712; owner: DannyS712):
[mediawiki/extensions/Scribunto@master] Remove use of Parser::fetchCurrentRevisionOfTitle
Change 589702 had a related patch set uploaded (by DannyS712; owner: DannyS712):
[mediawiki/core@master] Replace uses and hard deprecate Parser::getRevisionObject
Change 589699 merged by jenkins-bot:
[mediawiki/extensions/Scribunto@master] Remove use of Parser::fetchCurrentRevisionOfTitle and Revision::getSha1
Change 589702 merged by jenkins-bot:
[mediawiki/core@master] Replace uses and hard deprecate Parser::getRevisionObject
@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/
Change 589693 merged by jenkins-bot:
[mediawiki/extensions/FlaggedRevs@master] Use RevisionRecordCallback in ParserOptions
Change 601935 had a related patch set uploaded (by DannyS712; owner: DannyS712):
[mediawiki/extensions/TemplateStyles@master] Remove use of Parser::fetchCurrentRevisionOfTitle
Change 589697 merged by jenkins-bot:
[mediawiki/extensions/TemplateSandbox@master] Use RevisionRecordCallback in ParserOptions, require MW 1.35+
Change 589644 merged by jenkins-bot:
[mediawiki/extensions/TemplateStyles@master] Use RevisionRecordCallback in ParserOptions, require MW 1.35+
Change 601935 merged by jenkins-bot:
[mediawiki/extensions/TemplateStyles@master] Remove use of Parser::fetchCurrentRevisionOfTitle
Change 601941 had a related patch set uploaded (by DannyS712; owner: DannyS712):
[mediawiki/core@master] Replace core uses and hard deprecate Parser(Options) Revision methods
Change 601941 merged by jenkins-bot:
[mediawiki/core@master] Replace core uses and hard deprecate Parser(Options) Revision methods