Suppress LinkCache warning about "non-proper" pages
Every special page link handled by LinkRenderer::makeKnownLink() would generate a warning in LinkCache about the target being a "non-proper" page. Duplicate LinkCache's sanity checks to avoid this. Also improve LinkCache warning messages. Change-Id: Ia2dc9136cc2edf5ee57e8f1ee54819f891b41a1c
This commit is contained in:
parent
701565a9c6
commit
62bdc0fb60
2 changed files with 6 additions and 2 deletions
4
includes/cache/LinkCache.php
vendored
4
includes/cache/LinkCache.php
vendored
|
|
@ -155,7 +155,7 @@ class LinkCache implements LoggerAwareInterface {
|
|||
if ( $page instanceof PageIdentity && !$page->canExist() ) {
|
||||
// Non-proper page, perhaps a special page or interwiki link or relative section link.
|
||||
$this->logger->warning(
|
||||
'non-proper page reference',
|
||||
'non-proper page reference: {page-reference}',
|
||||
[ 'page-reference' => $this->titleFormatter->getFullText( $page ) ]
|
||||
);
|
||||
return null;
|
||||
|
|
@ -167,7 +167,7 @@ class LinkCache implements LoggerAwareInterface {
|
|||
// Interwiki link or relative section link. These do not have a page ID, so they
|
||||
// can neither be "good" nor "bad" in the sense of this class.
|
||||
$this->logger->warning(
|
||||
'link to non-proper page',
|
||||
'link to non-proper page: {page-link}',
|
||||
[ 'page-link' => $this->titleFormatter->getFullText( $page ) ]
|
||||
);
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -424,6 +424,10 @@ class LinkRenderer {
|
|||
public function getLinkClasses( $target ) {
|
||||
Assert::parameterType( [ LinkTarget::class, PageReference::class ], $target, '$target' );
|
||||
$target = $this->castToLinkTarget( $target );
|
||||
// Don't call LinkCache if the target is "non-proper"
|
||||
if ( $target->isExternal() || $target->getText() === '' || $target->getNamespace() < 0 ) {
|
||||
return '';
|
||||
}
|
||||
// Make sure the target is in the cache
|
||||
$id = $this->linkCache->addLinkObj( $target );
|
||||
if ( $id == 0 ) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue