From: Ori Livneh Date: Sat, 2 Mar 2013 00:34:09 +0000 (-0800) Subject: Make default params to CategoryViewer usable as defaults. X-Git-Tag: 1.31.0-rc.0~20459 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22articles%22%2C%22id_article=%24id_article%22%29%20.%20%22?a=commitdiff_plain;h=538014185ac0ebdbc67decb8c958eab81c4ed558;p=lhc%2Fweb%2Fwiklou.git Make default params to CategoryViewer usable as defaults. If the '$from' and '$to' parameters to the CategoryViewer constructor are left off, they default to empty arrays. This makes later checks for $from['page'], etc. issue an 'Undefined index' notice. Using 'empty' would be more concise but could hide bugs. Change-Id: I78793d13745d1fc1010b8e6861bdc3a89a39a87f --- diff --git a/includes/CategoryViewer.php b/includes/CategoryViewer.php index 7678ffe080..878c37184a 100644 --- a/includes/CategoryViewer.php +++ b/includes/CategoryViewer.php @@ -288,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; @@ -445,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 ''; @@ -677,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; }