Last modified: 2011-03-13 17:46:04 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T3547, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 1547 - Patch for CategoryPage.php: allows resetting limit
Patch for CategoryPage.php: allows resetting limit
Status: RESOLVED WONTFIX
Product: MediaWiki
Classification: Unclassified
Categories (Other open bugs)
1.4.x
PC Linux
: Lowest normal (vote)
: ---
Assigned To: Nobody - You can work on this!
: patch
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2005-02-16 19:29 UTC by Daniel Herding
Modified: 2011-03-13 17:46 UTC (History)
0 users

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Daniel Herding 2005-02-16 19:29:34 UTC
Hallo!

The PyWikipedia bot which can be used to handle categories doesn't work anymore
since beta4 because categories are now split up into lists of 200 articles each. 

I created this is patch which allows calling URLs like this:

http://en.wikipedia.org/wiki/Category:American_actors?limit=500

to get more articles per page, allowing the bot to work again.

I have tested it on my local wiki, but it's the first patch I submitted for
MediaWiki, and it's the first time I did something with PHP, hope everything is OK.


Daniel


daniel@athene:/tmp/mediawiki/phase3> cvs diff -bud includes/CategoryPage.php

Index: includes/CategoryPage.php
===================================================================
RCS file: /cvsroot/wikipedia/phase3/includes/CategoryPage.php,v
retrieving revision 1.16
diff -b -u -d -r1.16 CategoryPage.php
--- includes/CategoryPage.php   3 Feb 2005 08:44:59 -0000       1.16
+++ includes/CategoryPage.php   16 Feb 2005 18:59:26 -0000
@@ -10,7 +10,6 @@
        die();

 if( $wgCategoryMagicGallery )
-       /** */
        require_once('ImageGallery.php');

 /**
@@ -49,7 +48,8 @@
                $pageConditions = array();
                $from = $wgRequest->getVal( 'from' );
                $until = $wgRequest->getVal( 'until' );
-               $wgOut->addHTML( $this->doCategoryMagic( $from, $until ) );
+               $limit = $wgRequest->getVal( 'limit' );
+        $wgOut->addHTML( $this->doCategoryMagic( $from, $until, $limit ) );
        }

        /**
@@ -60,7 +60,7 @@
         * @return string HTML output
         * @access private
         */
-       function doCategoryMagic( $from = '', $until = '' ) {
+       function doCategoryMagic( $from = '', $until = '', $limit = '') {
                global $wgContLang,$wgUser, $wgCategoryMagicGallery;
                $fname = 'CategoryPage::doCategoryMagic';
                wfProfileIn( $fname );
@@ -85,14 +85,16 @@
                        $pageCondition = '1';
                        $flip = false;
                }
+        if ($limit == '')  {
                $limit = 200;
+        }
                $res = $dbr->select(
-                       array( 'page', 'categorylinks' ),
-                       array( 'page_title', 'page_namespace', 'cl_sortkey' ),
+                       array( 'cur', 'categorylinks' ),
+                       array( 'cur_title', 'cur_namespace', 'cl_sortkey' ),
                        array( $pageCondition,
-                              'cl_from          =  page_id',
+                              'cl_from          =  cur_id',
                               'cl_to'           => $this->mTitle->getDBKey(),
-                              'page_is_redirect' => 0),
+                              'cur_is_redirect' => 0),
                        #+ $pageCondition,
                        $fname,
                        array( 'ORDER BY' => $flip ? 'cl_sortkey DESC' :
'cl_sortkey',
@@ -110,7 +112,7 @@
                                break;
                        }

-                       $title = Title::makeTitle( $x->page_namespace,
$x->page_title );
+                       $title = Title::makeTitle( $x->cur_namespace,
$x->cur_title );

                        if( $title->getNamespace() == NS_CATEGORY ) {
                                // Subcategory; strip the 'Category' namespace
from the link text.
@@ -121,7 +123,7 @@
                                // Workaround: If sortkey == "Category:".$title,
than use $title for sorting,
                                // else use sortkey...
                                if( $title->getPrefixedText() == $x->cl_sortkey ) {
-                                       array_push( $children_start_char,
$wgContLang->firstChar( $x->page_title ) );
+                                       array_push( $children_start_char,
$wgContLang->firstChar( $x->cur_title ) );
                                } else {
                                        array_push( $children_start_char,
$wgContLang->firstChar( $x->cl_sortkey ) ) ;
                                }
@@ -311,12 +313,12 @@
                $prevLink = htmlspecialchars( wfMsg( 'prevn', $limitText ) );
                if( $first != '' ) {
                        $prevLink = $sk->makeLinkObj( $title, $prevLink,
-                               wfArrayToCGI( $query + array( 'until' => $first
) ) );
+                               wfArrayToCGI( $query + array( 'until' => $first,
'limit' => $limit ) ) );
                }
                $nextLink = htmlspecialchars( wfMsg( 'nextn', $limitText ) );
                if( $last != '' ) {
                        $nextLink = $sk->makeLinkObj( $title, $nextLink,
-                               wfArrayToCGI( $query + array( 'from' => $last ) ) );
+                               wfArrayToCGI( $query + array( 'from' => $last,
'limit' => $limit ) ) );
                }

                return "($prevLink) ($nextLink)";
Comment 1 Brion Vibber 2005-02-16 19:34:07 UTC
The limit is there for a reason; letting clients arbitrarily increase it would create an abuse vector unnecessarily. You also 
should be validating input if you do do something like this.

The bot should be fixed to page correctly, or work in some other way.
Comment 2 Mark A. Hershberger 2011-03-13 17:46:04 UTC
Changing all WONTFIX high priority bugs to lowest priority (no mail should be generated since I turned it off for this.)

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links