mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Linter
synced 2024-11-30 18:44:24 +00:00
Link to detailed Special:LintErrors from action=info
action=info has a summary table of number of lint errors by category, but we have richer information available via Special:LintErrors. If there is a "Lint errors" section, provide a link below the table to Special:LintErrors for the errors on this page. Update ApiRecordLint for the new Hooks constructor and leave a FIXME to eliminate the coupling. Bug: T301374 Change-Id: Ic1fcf42b50d1392ac53201ceb256691133cf62ff
This commit is contained in:
parent
b5a7aaf7e0
commit
cb84f3a872
|
@ -26,7 +26,10 @@
|
|||
},
|
||||
"HookHandlers": {
|
||||
"main": {
|
||||
"class": "MediaWiki\\Linter\\Hooks"
|
||||
"class": "MediaWiki\\Linter\\Hooks",
|
||||
"services": [
|
||||
"LinkRenderer"
|
||||
]
|
||||
},
|
||||
"schema": {
|
||||
"class": "MediaWiki\\Linter\\SchemaHooks"
|
||||
|
|
|
@ -83,5 +83,6 @@
|
|||
"linterrors-subpage": "Lint errors: $1",
|
||||
"linterrors-summary": "<strong>Note:</strong> The counts for categories are not accurate counts, but are based on estimates.",
|
||||
"multi-part-template-block": "Output not from a single template",
|
||||
"pageinfo-linter": "Lint errors"
|
||||
"pageinfo-linter": "Lint errors",
|
||||
"pageinfo-linter-moreinfo": "View detailed information on the lint errors."
|
||||
}
|
||||
|
|
|
@ -91,5 +91,6 @@
|
|||
"linterrors-subpage": "Page title for Special:LintErrors, $1 is the localized category description",
|
||||
"linterrors-summary": "Summary message for Special:LintErrors",
|
||||
"multi-part-template-block": "Table cell on [[Special:LintErrors]] indicating that content block is not produced by a single template",
|
||||
"pageinfo-linter": "Heading on ?action=info for a page if it has lint errors"
|
||||
"pageinfo-linter": "Heading on ?action=info for a page if it has lint errors",
|
||||
"pageinfo-linter-moreinfo": "Link text below a summary table on ?action=info that goes to Special:LintErrors for that specific page"
|
||||
}
|
||||
|
|
|
@ -46,7 +46,9 @@ class ApiRecordLint extends ApiBase {
|
|||
if ( !is_array( $data ) ) {
|
||||
$this->dieWithError( 'apierror-linter-invalid-data', 'invalid-data' );
|
||||
}
|
||||
if ( ( new Hooks )->onParserLogLinterData(
|
||||
// FIXME: Don't call Hooks like this, refactor it into a common method
|
||||
$hooks = new Hooks( MediaWikiServices::getInstance()->getLinkRenderer() );
|
||||
if ( $hooks->onParserLogLinterData(
|
||||
$params['page'], $params['revision'], $data
|
||||
) ) {
|
||||
$this->getResult()->addValue( $this->getModuleName(), 'success', true );
|
||||
|
|
|
@ -27,6 +27,7 @@ use MediaWiki\Api\Hook\APIQuerySiteInfoGeneralInfoHook;
|
|||
use MediaWiki\Hook\BeforePageDisplayHook;
|
||||
use MediaWiki\Hook\InfoActionHook;
|
||||
use MediaWiki\Hook\ParserLogLinterDataHook;
|
||||
use MediaWiki\Linker\LinkRenderer;
|
||||
use MediaWiki\Logger\LoggerFactory;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Page\Hook\RevisionFromEditCompleteHook;
|
||||
|
@ -36,6 +37,7 @@ use MediaWiki\User\UserIdentity;
|
|||
use MWCallableUpdate;
|
||||
use OutputPage;
|
||||
use Skin;
|
||||
use SpecialPage;
|
||||
use Title;
|
||||
use WikiPage;
|
||||
|
||||
|
@ -47,6 +49,16 @@ class Hooks implements
|
|||
RevisionFromEditCompleteHook,
|
||||
WikiPageDeletionUpdatesHook
|
||||
{
|
||||
/** @var LinkRenderer */
|
||||
private $linkRenderer;
|
||||
|
||||
/**
|
||||
* @param LinkRenderer $linkRenderer
|
||||
*/
|
||||
public function __construct( LinkRenderer $linkRenderer ) {
|
||||
$this->linkRenderer = $linkRenderer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook: BeforePageDisplay
|
||||
*
|
||||
|
@ -158,7 +170,8 @@ class Hooks implements
|
|||
* @param array &$pageInfo
|
||||
*/
|
||||
public function onInfoAction( $context, &$pageInfo ) {
|
||||
$pageId = $context->getTitle()->getArticleID();
|
||||
$title = $context->getTitle();
|
||||
$pageId = $title->getArticleID();
|
||||
if ( !$pageId ) {
|
||||
return;
|
||||
}
|
||||
|
@ -175,6 +188,16 @@ class Hooks implements
|
|||
htmlspecialchars( (string)$count )
|
||||
];
|
||||
}
|
||||
|
||||
$pageInfo['linter'][] = [
|
||||
'below',
|
||||
$this->linkRenderer->makeKnownLink(
|
||||
SpecialPage::getTitleFor( 'LintErrors' ),
|
||||
$context->msg( 'pageinfo-linter-moreinfo' )->text(),
|
||||
[],
|
||||
[ 'namespace' => $title->getNamespace(), 'titlesearch' => $title->getText(), 'exactmatch' => 1 ]
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue