Ori.livneh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/51812


Change subject: Make default params to CategoryViewer usable as defaults.
......................................................................

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
---
M includes/CategoryViewer.php
1 file changed, 6 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/12/51812/1

diff --git a/includes/CategoryViewer.php b/includes/CategoryViewer.php
index 7678ffe..a9e0ae7 100644
--- a/includes/CategoryViewer.php
+++ b/includes/CategoryViewer.php
@@ -288,10 +288,10 @@
                        # 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 @@
         * @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,8 @@
                }
 
                $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;
                }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/51812
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I78793d13745d1fc1010b8e6861bdc3a89a39a87f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <o...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to