dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge "SpecialUploadStash: Add links to view a thumb of each uploaded file"
[lhc/web/wiklou.git]
/
includes
/
CategoryViewer.php
diff --git
a/includes/CategoryViewer.php
b/includes/CategoryViewer.php
index
e2c31a6
..
f749003
100644
(file)
--- a/
includes/CategoryViewer.php
+++ b/
includes/CategoryViewer.php
@@
-84,14
+84,14
@@
class CategoryViewer extends ContextSource {
* @param array $until An array with 3 keys for until of each section (since 1.17)
* @param array $query
*/
* @param array $until An array with 3 keys for until of each section (since 1.17)
* @param array $query
*/
- function __construct( $title, IContextSource $context, $from =
array()
,
- $until =
array(), $query = array()
+ function __construct( $title, IContextSource $context, $from =
[]
,
+ $until =
[], $query = []
) {
$this->title = $title;
$this->setContext( $context );
) {
$this->title = $title;
$this->setContext( $context );
- $this->getOutput()->addModuleStyles(
array(
+ $this->getOutput()->addModuleStyles(
[
'mediawiki.action.view.categoryPage.styles'
'mediawiki.action.view.categoryPage.styles'
-
)
);
+
]
);
$this->from = $from;
$this->until = $until;
$this->limit = $context->getConfig()->get( 'CategoryPagingLimit' );
$this->from = $from;
$this->until = $until;
$this->limit = $context->getConfig()->get( 'CategoryPagingLimit' );
@@
-138,7
+138,7
@@
class CategoryViewer extends ContextSource {
}
$lang = $this->getLanguage();
}
$lang = $this->getLanguage();
- $langAttribs =
array( 'lang' => $lang->getHtmlCode(), 'dir' => $lang->getDir() )
;
+ $langAttribs =
[ 'lang' => $lang->getHtmlCode(), 'dir' => $lang->getDir() ]
;
# put a div around the headings which are in the user language
$r = Html::openElement( 'div', $langAttribs ) . $r . '</div>';
# put a div around the headings which are in the user language
$r = Html::openElement( 'div', $langAttribs ) . $r . '</div>';
@@
-146,10
+146,10
@@
class CategoryViewer extends ContextSource {
}
function clearCategoryState() {
}
function clearCategoryState() {
- $this->articles =
array()
;
- $this->articles_start_char =
array()
;
- $this->children =
array()
;
- $this->children_start_char =
array()
;
+ $this->articles =
[]
;
+ $this->articles_start_char =
[]
;
+ $this->children =
[]
;
+ $this->children_start_char =
[]
;
if ( $this->showGallery ) {
// Note that null for mode is taken to mean use default.
$mode = $this->getRequest()->getVal( 'gallerymode', null );
if ( $this->showGallery ) {
// Note that null for mode is taken to mean use default.
$mode = $this->getRequest()->getVal( 'gallerymode', null );
@@
-162,8
+162,8
@@
class CategoryViewer extends ContextSource {
$this->gallery->setHideBadImages();
} else {
$this->gallery->setHideBadImages();
} else {
- $this->imgsNoGallery =
array()
;
- $this->imgsNoGallery_start_char =
array()
;
+ $this->imgsNoGallery =
[]
;
+ $this->imgsNoGallery_start_char =
[]
;
}
}
}
}
@@
-190,7
+190,7
@@
class CategoryViewer extends ContextSource {
function generateLink( $type, Title $title, $isRedirect, $html = null ) {
$link = null;
function generateLink( $type, Title $title, $isRedirect, $html = null ) {
$link = null;
- Hooks::run( 'CategoryViewer::generateLink',
array( $type, $title, $html, &$link )
);
+ Hooks::run( 'CategoryViewer::generateLink',
[ $type, $title, $html, &$link ]
);
if ( $link === null ) {
$link = Linker::link( $title, $html );
}
if ( $link === null ) {
$link = Linker::link( $title, $html );
}
@@
-284,24
+284,24
@@
class CategoryViewer extends ContextSource {
function doCategoryQuery() {
$dbr = wfGetDB( DB_SLAVE, 'category' );
function doCategoryQuery() {
$dbr = wfGetDB( DB_SLAVE, 'category' );
- $this->nextPage =
array(
+ $this->nextPage =
[
'page' => null,
'subcat' => null,
'file' => null,
'page' => null,
'subcat' => null,
'file' => null,
-
)
;
- $this->prevPage =
array(
+
]
;
+ $this->prevPage =
[
'page' => null,
'subcat' => null,
'file' => null,
'page' => null,
'subcat' => null,
'file' => null,
-
)
;
+
]
;
- $this->flip =
array( 'page' => false, 'subcat' => false, 'file' => false )
;
+ $this->flip =
[ 'page' => false, 'subcat' => false, 'file' => false ]
;
- foreach (
array( 'page', 'subcat', 'file' )
as $type ) {
+ foreach (
[ 'page', 'subcat', 'file' ]
as $type ) {
# Get the sortkeys for start/end, if applicable. Note that if
# the collation in the database differs from the one
# set in $wgCategoryCollation, pagination might go totally haywire.
# Get the sortkeys for start/end, if applicable. Note that if
# the collation in the database differs from the one
# set in $wgCategoryCollation, pagination might go totally haywire.
- $extraConds =
array( 'cl_type' => $type )
;
+ $extraConds =
[ 'cl_type' => $type ]
;
if ( isset( $this->from[$type] ) && $this->from[$type] !== null ) {
$extraConds[] = 'cl_sortkey >= '
. $dbr->addQuotes( $this->collation->getSortKey( $this->from[$type] ) );
if ( isset( $this->from[$type] ) && $this->from[$type] !== null ) {
$extraConds[] = 'cl_sortkey >= '
. $dbr->addQuotes( $this->collation->getSortKey( $this->from[$type] ) );
@@
-312,28
+312,28
@@
class CategoryViewer extends ContextSource {
}
$res = $dbr->select(
}
$res = $dbr->select(
-
array( 'page', 'categorylinks', 'category' )
,
-
array(
'page_id', 'page_title', 'page_namespace', 'page_len',
+
[ 'page', 'categorylinks', 'category' ]
,
+
[
'page_id', 'page_title', 'page_namespace', 'page_len',
'page_is_redirect', 'cl_sortkey', 'cat_id', 'cat_title',
'cat_subcats', 'cat_pages', 'cat_files',
'page_is_redirect', 'cl_sortkey', 'cat_id', 'cat_title',
'cat_subcats', 'cat_pages', 'cat_files',
- 'cl_sortkey_prefix', 'cl_collation'
)
,
- array_merge(
array( 'cl_to' => $this->title->getDBkey() )
, $extraConds ),
+ 'cl_sortkey_prefix', 'cl_collation'
]
,
+ array_merge(
[ 'cl_to' => $this->title->getDBkey() ]
, $extraConds ),
__METHOD__,
__METHOD__,
- array(
- 'USE INDEX' =>
array( 'categorylinks' => 'cl_sortkey' )
,
+ [
+ 'USE INDEX' =>
[ 'categorylinks' => 'cl_sortkey' ]
,
'LIMIT' => $this->limit + 1,
'ORDER BY' => $this->flip[$type] ? 'cl_sortkey DESC' : 'cl_sortkey',
'LIMIT' => $this->limit + 1,
'ORDER BY' => $this->flip[$type] ? 'cl_sortkey DESC' : 'cl_sortkey',
-
)
,
- array(
- 'categorylinks' =>
array( 'INNER JOIN', 'cl_from = page_id' )
,
- 'category' =>
array( 'LEFT JOIN', array(
+
]
,
+ [
+ 'categorylinks' =>
[ 'INNER JOIN', 'cl_from = page_id' ]
,
+ 'category' =>
[ 'LEFT JOIN', [
'cat_title = page_title',
'page_namespace' => NS_CATEGORY
'cat_title = page_title',
'page_namespace' => NS_CATEGORY
- ) )
- )
+ ] ]
+ ]
);
);
- Hooks::run( 'CategoryViewer::doCategoryQuery',
array( $type, $res )
);
+ Hooks::run( 'CategoryViewer::doCategoryQuery',
[ $type, $res ]
);
$count = 0;
foreach ( $res as $row ) {
$count = 0;
foreach ( $res as $row ) {
@@
-387,6
+387,7
@@
class CategoryViewer extends ContextSource {
$r = '';
$rescnt = count( $this->children );
$dbcnt = $this->cat->getSubcatCount();
$r = '';
$rescnt = count( $this->children );
$dbcnt = $this->cat->getSubcatCount();
+ // This function should be called even if the result isn't used, it has side-effects
$countmsg = $this->getCountMessage( $rescnt, $dbcnt, 'subcat' );
if ( $rescnt > 0 ) {
$countmsg = $this->getCountMessage( $rescnt, $dbcnt, 'subcat' );
if ( $rescnt > 0 ) {
@@
-417,6
+418,7
@@
class CategoryViewer extends ContextSource {
$dbcnt = $this->cat->getPageCount() - $this->cat->getSubcatCount()
- $this->cat->getFileCount();
$rescnt = count( $this->articles );
$dbcnt = $this->cat->getPageCount() - $this->cat->getSubcatCount()
- $this->cat->getFileCount();
$rescnt = count( $this->articles );
+ // This function should be called even if the result isn't used, it has side-effects
$countmsg = $this->getCountMessage( $rescnt, $dbcnt, 'article' );
if ( $rescnt > 0 ) {
$countmsg = $this->getCountMessage( $rescnt, $dbcnt, 'article' );
if ( $rescnt > 0 ) {
@@
-437,10
+439,11
@@
class CategoryViewer extends ContextSource {
function getImageSection() {
$r = '';
$rescnt = $this->showGallery ? $this->gallery->count() : count( $this->imgsNoGallery );
function getImageSection() {
$r = '';
$rescnt = $this->showGallery ? $this->gallery->count() : count( $this->imgsNoGallery );
- if ( $rescnt > 0 ) {
- $dbcnt = $this->cat->getFileCount();
-
$countmsg = $this->getCountMessage( $rescnt, $dbcnt, 'file' );
+ $dbcnt = $this->cat->getFileCount();
+ // This function should be called even if the result isn't used, it has side-effects
+ $countmsg = $this->getCountMessage( $rescnt, $dbcnt, 'file' );
+ if ( $rescnt > 0 ) {
$r .= "<div id=\"mw-category-media\">\n";
$r .= '<h2>' .
$this->msg(
$r .= "<div id=\"mw-category-media\">\n";
$r .= '<h2>' .
$this->msg(
@@
-517,8
+520,8
@@
class CategoryViewer extends ContextSource {
}
$pageLang = $this->title->getPageLanguage();
}
$pageLang = $this->title->getPageLanguage();
- $attribs =
array(
'lang' => $pageLang->getHtmlCode(), 'dir' => $pageLang->getDir(),
- 'class' => 'mw-content-' . $pageLang->getDir()
)
;
+ $attribs =
[
'lang' => $pageLang->getHtmlCode(), 'dir' => $pageLang->getDir(),
+ 'class' => 'mw-content-' . $pageLang->getDir()
]
;
$list = Html::rawElement( 'div', $attribs, $list );
return $list;
$list = Html::rawElement( 'div', $attribs, $list );
return $list;
@@
-541,15
+544,15
@@
class CategoryViewer extends ContextSource {
static function columnList( $articles, $articles_start_char ) {
$columns = array_combine( $articles, $articles_start_char );
static function columnList( $articles, $articles_start_char ) {
$columns = array_combine( $articles, $articles_start_char );
- $ret = Html::openElement( 'div',
array( 'class' => 'mw-category' )
);
+ $ret = Html::openElement( 'div',
[ 'class' => 'mw-category' ]
);
- $colContents =
array()
;
+ $colContents =
[]
;
# Kind of like array_flip() here, but we keep duplicates in an
# array instead of dropping them.
foreach ( $columns as $article => $char ) {
if ( !isset( $colContents[$char] ) ) {
# Kind of like array_flip() here, but we keep duplicates in an
# array instead of dropping them.
foreach ( $columns as $article => $char ) {
if ( !isset( $colContents[$char] ) ) {
- $colContents[$char] =
array()
;
+ $colContents[$char] =
[]
;
}
$colContents[$char][] = $article;
}
}
$colContents[$char][] = $article;
}
@@
-612,7
+615,7
@@
class CategoryViewer extends ContextSource {
$prevLink = Linker::linkKnown(
$this->addFragmentToTitle( $this->title, $type ),
$prevLink,
$prevLink = Linker::linkKnown(
$this->addFragmentToTitle( $this->title, $type ),
$prevLink,
-
array()
,
+
[]
,
$prevQuery
);
}
$prevQuery
);
}
@@
-626,7
+629,7
@@
class CategoryViewer extends ContextSource {
$nextLink = Linker::linkKnown(
$this->addFragmentToTitle( $this->title, $type ),
$nextLink,
$nextLink = Linker::linkKnown(
$this->addFragmentToTitle( $this->title, $type ),
$nextLink,
-
array()
,
+
[]
,
$lastQuery
);
}
$lastQuery
);
}
@@
-713,7
+716,7
@@
class CategoryViewer extends ContextSource {
// quick due to the small number of entries.
$totalcnt = $rescnt;
$category = $this->cat;
// quick due to the small number of entries.
$totalcnt = $rescnt;
$category = $this->cat;
-
wfGetDB( DB_MASTER )->onTransactionIdl
e( function () use ( $category ) {
+
DeferredUpdates::addCallableUpdat
e( function () use ( $category ) {
$category->refreshCounts();
} );
} else {
$category->refreshCounts();
} );
} else {