Use PageProps for fetching newsectionlink flag

Now we don't require the ParserOutput to be available.

As a result, we now check the flag on the latest revision of the page,
rather than the one being viewed.

Change-Id: Id77a332643cb8ad95afc5cec6713fa0a3636a5ce
This commit is contained in:
Ed Sanders 2020-12-16 16:08:56 +00:00 committed by Bartosz Dziewoński
parent bc04783341
commit 3bb2d25a74

View file

@ -15,6 +15,7 @@ use ExtensionRegistry;
use MediaWiki\MediaWikiServices;
use MWExceptionHandler;
use OutputPage;
use PageProps;
use RecentChange;
use RequestContext;
use Skin;
@ -106,13 +107,16 @@ class Hooks {
)
);
$props = PageProps::getInstance()->getProperties( $title, 'newsectionlink' );
$hasNewSectionLink = isset( $props[ $title->getArticleId() ] );
// Finally check the user has the tool enabled and that the page
// supports discussions.
return $userEnabled && (
// `wantSignatures` includes talk pages
$services->getNamespaceInfo()->wantSignatures( $title->getNamespace() ) ||
// Treat pages with __NEWSECTIONLINK__ as talk pages (T245890)
$output->showNewSectionLink()
$hasNewSectionLink
// TODO: Consider not loading if forceHideNewSectionLink is true.
);
}