From 9e67ef659067ab5cb23443c0ea6fa3ed275bb685 Mon Sep 17 00:00:00 2001 From: Jdlrobson Date: Wed, 31 Aug 2016 18:57:41 +0000 Subject: [PATCH] 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 9ede8913c7b628d2cc74e6f269e6d12115b1a206. Change-Id: If0f1481854815c12613771041685c7837a95ec65 --- includes/FooterHooks.php | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/includes/FooterHooks.php b/includes/FooterHooks.php index 54e6284f..862a9b79 100644 --- a/includes/FooterHooks.php +++ b/includes/FooterHooks.php @@ -34,19 +34,6 @@ class FooterHooks { 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 BeforePageDisplay hook. * @@ -54,12 +41,12 @@ class FooterHooks { * to the output when: * *
    + *
  1. The page is not a disambiguation page
  2. *
  3. $wgRelatedArticlesShowInFooter is truthy
  4. *
  5. On mobile, the output is being rendered with * SkinMinervaBeta
  6. *
  7. On desktop, the beta feature has been enabled
  8. *
  9. The page is in mainspace
  10. - *
  11. The page is not a disambiguation page
  12. *
* * @param OutputPage $out @@ -67,6 +54,10 @@ class FooterHooks { * @return boolean Always true */ public static function onBeforePageDisplay( OutputPage $out, Skin $skin ) { + if ( class_exists( 'DisambiguatorHooks' ) && + DisambiguatorHooks::isDisambiguationPage( $out->getTitle() ) ) { + return true; + } $config = ConfigFactory::getDefaultInstance()->makeConfig( 'RelatedArticles' ); $showReadMore = $config->get( 'RelatedArticlesShowInFooter' ); @@ -75,8 +66,7 @@ class FooterHooks { if ( $showReadMore && $title->inNamespace( NS_MAIN ) && - !$title->isMainPage() && - !self::isDisambiguationPage( $title ) + !$title->isMainPage() ) { if ( get_class( $skin ) === 'SkinMinervaBeta' ||