*/
class CategoryViewer extends ContextSource {
- var $limit, $from, $until,
- $articles, $articles_start_char,
- $children, $children_start_char,
- $showGallery, $imgsNoGalley,
- $imgsNoGallery_start_char,
- $imgsNoGallery;
+ /** @var int */
+ public $limit;
- /**
- * @var array
- */
- var $nextPage;
+ /** @var array */
+ protected $from;
- /**
- * @var array
- */
- var $flip;
+ /** @var array */
+ protected $until;
- /**
- * @var Title
- */
- var $title;
+ /** @var string[] */
+ public $articles;
- /**
- * @var Collation
- */
- var $collation;
+ /** @var array */
+ public $articles_start_char;
- /**
- * @var ImageGallery
- */
- var $gallery;
+ /** @var array */
+ protected $children;
- /**
- * Category object for this page
- * @var Category
- */
+ /** @var array */
+ protected $children_start_char;
+
+ /** @var bool */
+ protected $showGallery;
+
+ /** @var array */
+ protected $imgsNoGallery_start_char;
+
+ /** @var array */
+ protected $imgsNoGallery;
+
+ /** @var array */
+ protected $nextPage;
+
+ /** @var array */
+ protected $prevPage;
+
+ /** @var array */
+ protected $flip;
+
+ /** @var Title */
+ protected $title;
+
+ /** @var Collation */
+ protected $collation;
+
+ /** @var ImageGallery */
+ protected $gallery;
+
+ /** @var Category Category object for this page. */
private $cat;
- /**
- * The original query array, to be used in generating paging links.
- * @var array
- */
+ /** @var array The original query array, to be used in generating paging links. */
private $query;
/**
- * Constructor
- *
* @since 1.19 $context is a second, required parameter
* @param Title $title
* @param IContextSource $context
'subcat' => null,
'file' => null,
);
+ $this->prevPage = array(
+ 'page' => null,
+ 'subcat' => null,
+ 'file' => null,
+ );
+
$this->flip = array( 'page' => false, 'subcat' => false, 'file' => false );
foreach ( array( 'page', 'subcat', 'file' ) as $type ) {
$this->nextPage[$type] = $humanSortkey;
break;
}
+ if ( $count == $this->limit ) {
+ $this->prevPage[$type] = $humanSortkey;
+ }
if ( $title->getNamespace() == NS_CATEGORY ) {
$cat = Category::newFromRow( $row, $title );
*/
private function getSectionPagingLinks( $type ) {
if ( isset( $this->until[$type] ) && $this->until[$type] !== null ) {
- return $this->pagingLinks( $this->nextPage[$type], $this->until[$type], $type );
+ // The new value for the until parameter should be pointing to the first
+ // result displayed on the page which is the second last result retrieved
+ // from the database.The next link should have a from parameter pointing
+ // to the until parameter of the current page.
+ if ( $this->nextPage[$type] !== null ) {
+ return $this->pagingLinks( $this->prevPage[$type], $this->until[$type], $type );
+ } else {
+ // If the nextPage variable is null, it means that we have reached the first page
+ // and therefore the previous link should be disabled.
+ return $this->pagingLinks( null, $this->until[$type], $type );
+ }
} elseif ( $this->nextPage[$type] !== null
|| ( isset( $this->from[$type] ) && $this->from[$type] !== null )
) {
// to refresh the incorrect category table entry -- which should be
// quick due to the small number of entries.
$totalcnt = $rescnt;
- $this->cat->refreshCounts();
+ $category = $this->cat;
+ wfGetDB( DB_MASTER )->onTransactionIdle( function () use ( $category ) {
+ $category->refreshCounts();
+ } );
} else {
// Case 3: hopeless. Don't give a total count at all.
// Messages: category-subcat-count-limited, category-article-count-limited,