From c675784ce919ad6d9578807a5ac88642a4b9a6b7 Mon Sep 17 00:00:00 2001 From: Marius Hoch Date: Sat, 15 Sep 2012 02:02:16 +0200 Subject: [PATCH] (bug 40257) action=info no longer shows subpages where disabled action=info no longer shows the number of sub pages if sub pages are disabled in the current namespace (using $wgNamespacesWithSubpages). Change-Id: Ide68fd89d7220ca6cd4fdf5d170e839c091bcb92 --- includes/actions/InfoAction.php | 68 ++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 31 deletions(-) diff --git a/includes/actions/InfoAction.php b/includes/actions/InfoAction.php index 9e5cd9909e..8f40f8b4db 100644 --- a/includes/actions/InfoAction.php +++ b/includes/actions/InfoAction.php @@ -157,16 +157,18 @@ class InfoAction extends FormlessAction { ->numParams( count( $title->getRedirectsHere() ) )->escaped() ); - // Subpages of this page - $prefixIndex = SpecialPage::getTitleFor( 'Prefixindex', $title->getPrefixedText() . '/' ); - $table = $this->addRow( $table, - Linker::link( $prefixIndex, $this->msg( 'pageinfo-subpages-name' )->escaped() ), - $this->msg( 'pageinfo-subpages-value' ) - ->numParams( - $pageInfo['subpages']['total'], - $pageInfo['subpages']['redirects'], - $pageInfo['subpages']['nonredirects'] )->escaped() - ); + // Subpages of this page, if subpages are enabled for the current NS + if ( MWNamespace::hasSubpages( $title->getNamespace() ) ) { + $prefixIndex = SpecialPage::getTitleFor( 'Prefixindex', $title->getPrefixedText() . '/' ); + $table = $this->addRow( $table, + Linker::link( $prefixIndex, $this->msg( 'pageinfo-subpages-name' )->escaped() ), + $this->msg( 'pageinfo-subpages-value' ) + ->numParams( + $pageInfo['subpages']['total'], + $pageInfo['subpages']['redirects'], + $pageInfo['subpages']['nonredirects'] )->escaped() + ); + } // Page protection $content = $this->addTable( $content, $table ); @@ -404,28 +406,32 @@ class InfoAction extends FormlessAction { ); $result['recent_authors'] = $authors; - $conds = array( 'page_namespace' => $title->getNamespace(), 'page_is_redirect' => 1 ); - $conds[] = 'page_title ' . $dbr->buildLike( $title->getDBkey() . '/', $dbr->anyString() ); - - // Subpages of this page (redirects) - $result['subpages']['redirects'] = (int) $dbr->selectField( - 'page', - 'COUNT(page_id)', - $conds, - __METHOD__ ); - - // Subpages of this page (non-redirects) - $conds['page_is_redirect'] = 0; - $result['subpages']['nonredirects'] = (int) $dbr->selectField( - 'page', - 'COUNT(page_id)', - $conds, - __METHOD__ - ); + // Subpages (if enabled) + if ( MWNamespace::hasSubpages( $title->getNamespace() ) ) { + $conds = array( 'page_namespace' => $title->getNamespace() ); + $conds[] = 'page_title ' . $dbr->buildLike( $title->getDBkey() . '/', $dbr->anyString() ); - // Subpages of this page (total) - $result['subpages']['total'] = $result['subpages']['redirects'] - + $result['subpages']['nonredirects']; + // Subpages of this page (redirects) + $conds['page_is_redirect'] = 1; + $result['subpages']['redirects'] = (int) $dbr->selectField( + 'page', + 'COUNT(page_id)', + $conds, + __METHOD__ ); + + // Subpages of this page (non-redirects) + $conds['page_is_redirect'] = 0; + $result['subpages']['nonredirects'] = (int) $dbr->selectField( + 'page', + 'COUNT(page_id)', + $conds, + __METHOD__ + ); + + // Subpages of this page (total) + $result['subpages']['total'] = $result['subpages']['redirects'] + + $result['subpages']['nonredirects']; + } // Latest editor + date of latest edit $options = array( 'ORDER BY' => 'rev_timestamp ASC', 'LIMIT' => 1 ); -- 2.20.1