Revert "Don't hit the DB unnecessarily"

We forgot how namespaces work:
Catchable fatal error: Argument 1 passed to RelatedArticles\FooterHooks::isDisambiguationPage() must be an instance of RelatedArticles\Title, Title given in /srv/mediawiki/php-master/extensions/RelatedArticles/includes/FooterHooks.php on line 48

This reverts commit 9ede8913c7.

Change-Id: If0f1481854815c12613771041685c7837a95ec65
This commit is contained in:
Jdlrobson 2016-08-31 18:57:41 +00:00
parent 9ede8913c7
commit 9e67ef6590

View file

@ -34,19 +34,6 @@ class FooterHooks {
return true; return true;
} }
/**
* Uses the Disambiguator extension to test whether the page is a disambiguation page.
*
* If the Disambiguator extension isn't installed, then the test always fails, i.e. the page is
* never a disambiguation page.
*
* @return boolean
*/
private static function isDisambiguationPage( Title $title ) {
return class_exists( 'DisambiguatorHooks' ) &&
DisambiguatorHooks::isDisambiguationPage( $title );
}
/** /**
* Handler for the <code>BeforePageDisplay</code> hook. * Handler for the <code>BeforePageDisplay</code> hook.
* *
@ -54,12 +41,12 @@ class FooterHooks {
* to the output when: * to the output when:
* *
* <ol> * <ol>
* <li>The page is not a disambiguation page</li>
* <li><code>$wgRelatedArticlesShowInFooter</code> is truthy</li> * <li><code>$wgRelatedArticlesShowInFooter</code> is truthy</li>
* <li>On mobile, the output is being rendered with * <li>On mobile, the output is being rendered with
* <code>SkinMinervaBeta<code></li> * <code>SkinMinervaBeta<code></li>
* <li>On desktop, the beta feature has been enabled</li> * <li>On desktop, the beta feature has been enabled</li>
* <li>The page is in mainspace</li> * <li>The page is in mainspace</li>
* <li>The page is not a disambiguation page</li>
* </ol> * </ol>
* *
* @param OutputPage $out * @param OutputPage $out
@ -67,6 +54,10 @@ class FooterHooks {
* @return boolean Always <code>true</code> * @return boolean Always <code>true</code>
*/ */
public static function onBeforePageDisplay( OutputPage $out, Skin $skin ) { public static function onBeforePageDisplay( OutputPage $out, Skin $skin ) {
if ( class_exists( 'DisambiguatorHooks' ) &&
DisambiguatorHooks::isDisambiguationPage( $out->getTitle() ) ) {
return true;
}
$config = ConfigFactory::getDefaultInstance()->makeConfig( 'RelatedArticles' ); $config = ConfigFactory::getDefaultInstance()->makeConfig( 'RelatedArticles' );
$showReadMore = $config->get( 'RelatedArticlesShowInFooter' ); $showReadMore = $config->get( 'RelatedArticlesShowInFooter' );
@ -75,8 +66,7 @@ class FooterHooks {
if ( if (
$showReadMore && $showReadMore &&
$title->inNamespace( NS_MAIN ) && $title->inNamespace( NS_MAIN ) &&
!$title->isMainPage() && !$title->isMainPage()
!self::isDisambiguationPage( $title )
) { ) {
if ( if (
get_class( $skin ) === 'SkinMinervaBeta' || get_class( $skin ) === 'SkinMinervaBeta' ||