Merge "Make sure Parsoid doesn't get snobbish and treat non-html5 tags badly."
[lhc/web/wiklou.git] / includes / CategoryViewer.php
index b59b4e1..878c371 100644 (file)
@@ -71,11 +71,12 @@ class CategoryViewer extends ContextSource {
         * @since 1.19 $context is a second, required parameter
         * @param $title Title
         * @param $context IContextSource
-        * @param $from String
-        * @param $until String
+        * @param $from Array An array with keys page, subcat,
+        *        and file for offset of results of each section (since 1.17)
+        * @param $until Array An array with 3 keys for until of each section (since 1.17)
         * @param $query Array
         */
-       function __construct( $title, IContextSource $context, $from = '', $until = '', $query = array() ) {
+       function __construct( $title, IContextSource $context, $from = array(), $until = array(), $query = array() ) {
                global $wgCategoryPagingLimit;
                $this->title = $title;
                $this->setContext( $context );
@@ -287,10 +288,10 @@ class CategoryViewer extends ContextSource {
                        # the collation in the database differs from the one
                        # set in $wgCategoryCollation, pagination might go totally haywire.
                        $extraConds = array( 'cl_type' => $type );
-                       if ( $this->from[$type] !== null ) {
+                       if ( isset( $this->from[$type] ) && $this->from[$type] !== null ) {
                                $extraConds[] = 'cl_sortkey >= '
                                        . $dbr->addQuotes( $this->collation->getSortKey( $this->from[$type] ) );
-                       } elseif ( $this->until[$type] !== null ) {
+                       } elseif ( isset( $this->until[$type] ) && $this->until[$type] !== null ) {
                                $extraConds[] = 'cl_sortkey < '
                                        . $dbr->addQuotes( $this->collation->getSortKey( $this->until[$type] ) );
                                $this->flip[$type] = true;
@@ -311,7 +312,10 @@ class CategoryViewer extends ContextSource {
                                ),
                                array(
                                        'categorylinks' => array( 'INNER JOIN', 'cl_from = page_id' ),
-                                       'category' => array( 'LEFT JOIN', 'cat_title = page_title AND page_namespace = ' . NS_CATEGORY )
+                                       'category' => array( 'LEFT JOIN', array(
+                                               'cat_title = page_title',
+                                               'page_namespace' => NS_CATEGORY
+                                       ))
                                )
                        );
 
@@ -441,9 +445,9 @@ class CategoryViewer extends ContextSource {
         * @return String: HTML output, possibly empty if there are no other pages
         */
        private function getSectionPagingLinks( $type ) {
-               if ( $this->until[$type] !== null ) {
+               if ( isset( $this->until[$type] ) && $this->until[$type] !== null ) {
                        return $this->pagingLinks( $this->nextPage[$type], $this->until[$type], $type );
-               } elseif ( $this->nextPage[$type] !== null || $this->from[$type] !== null ) {
+               } elseif ( $this->nextPage[$type] !== null || ( isset( $this->from[$type] ) && $this->from[$type] !== null ) ) {
                        return $this->pagingLinks( $this->from[$type], $this->nextPage[$type], $type );
                } else {
                        return '';
@@ -673,7 +677,9 @@ class CategoryViewer extends ContextSource {
                }
 
                $fromOrUntil = false;
-               if ( $this->from[$pagingType] !== null || $this->until[$pagingType] !== null ) {
+               if ( ( isset( $this->from[$pagingType] ) && $this->from[$pagingType] !== null ) ||
+                       ( isset( $this->until[$pagingType] ) && $this->until[$pagingType] !== null )
+               ) {
                        $fromOrUntil = true;
                }