API: Add reference to the mailing list in errors and deprecation warnings
This was suggested at a Developer Summit session as a way to get people to know about the mailing list. This also adds a hook so ApiFeatureUsage can mention itself in deprecation warnings too. Bug: T148855 Change-Id: I04a7cf89e87e48f6504803dd173e779017a205d0
This commit is contained in:
parent
000a4ecf68
commit
f70c7a06de
6 changed files with 30 additions and 3 deletions
|
|
@ -365,6 +365,11 @@ $user: Current user
|
|||
* 1.27+: IApiMessage, or a key or key+parameters in ApiBase::$messageMap.
|
||||
* Earlier: A key or key+parameters in ApiBase::$messageMap.
|
||||
|
||||
'ApiDeprecationHelp': Add messages to the 'deprecation-help' warning generated
|
||||
from ApiBase::addDeprecation().
|
||||
&$msgs: Message[] Messages to include in the help. Multiple messages will be
|
||||
joined with spaces.
|
||||
|
||||
'APIEditBeforeSave': DEPRECATED! Use EditFilterMergedContent instead.
|
||||
Before saving a page with api.php?action=edit, after
|
||||
processing request parameters. Return false to let the request fail, returning
|
||||
|
|
|
|||
|
|
@ -1718,6 +1718,18 @@ abstract class ApiBase extends ContextSource {
|
|||
$this->logFeatureUsage( $feature );
|
||||
}
|
||||
$this->addWarning( $msg, 'deprecation', $data );
|
||||
|
||||
// No real need to deduplicate here, ApiErrorFormatter does that for
|
||||
// us (assuming the hook is deterministic).
|
||||
$msgs = [ $this->msg( 'api-usage-mailinglist-ref' ) ];
|
||||
Hooks::run( 'ApiDeprecationHelp', [ &$msgs ] );
|
||||
if ( count( $msgs ) > 1 ) {
|
||||
$key = '$' . join( ' $', range( 1, count( $msgs ) ) );
|
||||
$msg = ( new RawMessage( $key ) )->params( $msgs );
|
||||
} else {
|
||||
$msg = reset( $msgs );
|
||||
}
|
||||
$this->getMain()->addWarning( $msg, 'deprecation-help' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1109,7 +1109,11 @@ class ApiMain extends ApiBase {
|
|||
$result->addContentValue(
|
||||
$path,
|
||||
'docref',
|
||||
$this->msg( 'api-usage-docref', $link )->inLanguage( $formatter->getLanguage() )->text()
|
||||
trim(
|
||||
$this->msg( 'api-usage-docref', $link )->inLanguage( $formatter->getLanguage() )->text()
|
||||
. ' '
|
||||
. $this->msg( 'api-usage-mailinglist-ref' )->inLanguage( $formatter->getLanguage() )->text()
|
||||
)
|
||||
);
|
||||
} else {
|
||||
if ( $config->get( 'ShowExceptionDetails' ) ) {
|
||||
|
|
|
|||
|
|
@ -1795,6 +1795,7 @@
|
|||
|
||||
"api-feed-error-title": "Error ($1)",
|
||||
"api-usage-docref": "See $1 for API usage.",
|
||||
"api-usage-mailinglist-ref": "Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes.",
|
||||
"api-exception-trace": "$1 at $2($3)\n$4",
|
||||
"api-credits-header": "Credits",
|
||||
"api-credits": "API developers:\n* Yuri Astrakhan (creator, lead developer Sep 2006–Sep 2007)\n* Roan Kattouw (lead developer Sep 2007–2009)\n* Victor Vasiliev\n* Bryan Tong Minh\n* Sam Reed\n* Brad Jorsch (lead developer 2013–present)\n\nPlease send your comments, suggestions and questions to mediawiki-api@lists.wikimedia.org\nor file a bug report at https://phabricator.wikimedia.org/."
|
||||
|
|
|
|||
|
|
@ -1685,6 +1685,7 @@
|
|||
"apiwarn-wgDebugAPI": "{{doc-apierror}}",
|
||||
"api-feed-error-title": "Used as a feed item title when an error occurs in <kbd>action=feedwatchlist</kbd>.\n\nParameters:\n* $1 - API error code\n{{Identical|Error}}",
|
||||
"api-usage-docref": "\n\nParameters:\n* $1 - URL of the API auto-generated documentation.",
|
||||
"api-usage-mailinglist-ref": "{{doc-apierror}} Also used in the error response.",
|
||||
"api-exception-trace": "\n\nParameters:\n* $1 - Exception class.\n* $2 - File from which the exception was thrown.\n* $3 - Line number from which the exception was thrown.\n* $4 - Exception backtrace.",
|
||||
"api-credits-header": "Header for the API credits section in the API help output\n{{Identical|Credit}}",
|
||||
"api-credits": "API credits text, displayed in the API help output"
|
||||
|
|
|
|||
|
|
@ -546,7 +546,9 @@ class ApiMainTest extends ApiTestCase {
|
|||
[ 'code' => 'existing-error', 'text' => 'existing error', 'module' => 'main' ],
|
||||
[ 'code' => 'ue', 'text' => "Usage exception!", 'data' => [ 'foo' => 'bar' ] ]
|
||||
],
|
||||
'docref' => "See $doclink for API usage.",
|
||||
'docref' => "See $doclink for API usage. Subscribe to the mediawiki-api-announce mailing " .
|
||||
"list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> " .
|
||||
"for notice of API deprecations and breaking changes.",
|
||||
'servedby' => wfHostname(),
|
||||
]
|
||||
],
|
||||
|
|
@ -564,7 +566,9 @@ class ApiMainTest extends ApiTestCase {
|
|||
[ 'code' => 'sv-error1', 'text' => 'An error', 'module' => 'foo+bar' ],
|
||||
[ 'code' => 'sv-error2', 'text' => 'Another error', 'module' => 'foo+bar' ],
|
||||
],
|
||||
'docref' => "See $doclink for API usage.",
|
||||
'docref' => "See $doclink for API usage. Subscribe to the mediawiki-api-announce mailing " .
|
||||
"list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> " .
|
||||
"for notice of API deprecations and breaking changes.",
|
||||
'servedby' => wfHostname(),
|
||||
]
|
||||
],
|
||||
|
|
|
|||
Loading…
Reference in a new issue