Use modern coding constructs and a better var name
authorAryeh Gregor <simetrical@users.mediawiki.org>
Fri, 23 Jul 2010 20:01:53 +0000 (20:01 +0000)
committerAryeh Gregor <simetrical@users.mediawiki.org>
Fri, 23 Jul 2010 20:01:53 +0000 (20:01 +0000)
foreach ( $res as $row ), Title::newFromRow(), $row instead of $x.

includes/CategoryPage.php

index e07ae77..16e6ed2 100644 (file)
@@ -262,23 +262,23 @@ class CategoryViewer {
                $count = 0;
                $this->nextPage = null;
 
                $count = 0;
                $this->nextPage = null;
 
-               while ( $x = $dbr->fetchObject ( $res ) ) {
+               foreach ( $res as $row ) {
                        if ( ++$count > $this->limit ) {
                                // We've reached the one extra which shows that there are
                                // additional pages to be had. Stop here...
                        if ( ++$count > $this->limit ) {
                                // We've reached the one extra which shows that there are
                                // additional pages to be had. Stop here...
-                               $this->nextPage = $x->cl_sortkey;
+                               $this->nextPage = $row->cl_sortkey;
                                break;
                        }
 
                                break;
                        }
 
-                       $title = Title::makeTitle( $x->page_namespace, $x->page_title );
+                       $title = Title::newFromRow( $row );
 
                        if ( $title->getNamespace() == NS_CATEGORY ) {
 
                        if ( $title->getNamespace() == NS_CATEGORY ) {
-                               $cat = Category::newFromRow( $x, $title );
-                               $this->addSubcategoryObject( $cat, $x->cl_sortkey, $x->page_len );
+                               $cat = Category::newFromRow( $row, $title );
+                               $this->addSubcategoryObject( $cat, $row->cl_sortkey, $row->page_len );
                        } elseif ( $this->showGallery && $title->getNamespace() == NS_FILE ) {
                        } elseif ( $this->showGallery && $title->getNamespace() == NS_FILE ) {
-                               $this->addImage( $title, $x->cl_sortkey, $x->page_len, $x->page_is_redirect );
+                               $this->addImage( $title, $row->cl_sortkey, $row->page_len, $row->page_is_redirect );
                        } else {
                        } else {
-                               $this->addPage( $title, $x->cl_sortkey, $x->page_len, $x->page_is_redirect );
+                               $this->addPage( $title, $row->cl_sortkey, $row->page_len, $row->page_is_redirect );
                        }
                }
 
                        }
                }