Deprecate the use of nonserializable arguments to ParserOutput::addWarningMsg()
Bug: T343048 Change-Id: If026926405b96d76faec6ad40f6cd45c4ec5d4a0
This commit is contained in:
parent
7a8dd531b2
commit
bc9c20c733
2 changed files with 16 additions and 2 deletions
|
|
@ -454,6 +454,8 @@ because of Phabricator reports.
|
|||
are now deprecated.
|
||||
* The XmlJsCode wrapper class has been renamed to MediaWiki\Html\HtmlJsCode,
|
||||
and the old name is now deprecated.
|
||||
* The use of non-serializable arguments to ParserOutput::addWarningMsg() has
|
||||
been deprecated and will emit deprecation warnings.
|
||||
* MediaWiki\ResourceLoader\Module::getDeprecationInformation() is deprecated.
|
||||
Use ::getDeprecationWarning() instead.
|
||||
* …
|
||||
|
|
|
|||
|
|
@ -1037,12 +1037,24 @@ class ParserOutput extends CacheTime implements ContentMetadataCollector {
|
|||
/**
|
||||
* Add a warning to the output for this page.
|
||||
* @param string $msg The localization message key for the warning
|
||||
* @param mixed ...$args Optional arguments for the message
|
||||
* @param mixed|JsonUnserializable ...$args Optional arguments for the
|
||||
* message. These arguments must be serializable/unserializable with
|
||||
* JsonCodec; see the @note on ParserOutput::setExtensionData()
|
||||
* @since 1.38
|
||||
*/
|
||||
public function addWarningMsg( string $msg, ...$args ): void {
|
||||
// preserve original arguments in $mWarningMsgs to allow merge
|
||||
// @todo: these aren't serialized/unserialized
|
||||
// @todo: these aren't serialized/unserialized yet -- before we
|
||||
// turn on serialization of $this->mWarningMsgs we need to ensure
|
||||
// callers aren't passing nonserializable arguments: T343048.
|
||||
$jsonCodec = MediaWikiServices::getInstance()->getJsonCodec();
|
||||
$path = $jsonCodec->detectNonSerializableData( $args, true );
|
||||
if ( $path !== null ) {
|
||||
wfDeprecatedMsg(
|
||||
"ParserOutput::addWarningMsg() called with nonserializable arguments: $path",
|
||||
'1.41'
|
||||
);
|
||||
}
|
||||
$this->mWarningMsgs[$msg] = $args;
|
||||
$s = wfMessage( $msg, ...$args )
|
||||
// some callers set the title here?
|
||||
|
|
|
|||
Loading…
Reference in a new issue