r80722 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r80721‎ | r80722 | r80723 >
Date:23:00, 21 January 2011
Author:catrope
Status:ok
Tags:
Comment:
Modified paths:
  • /branches/REL1_17/phase3/RELEASE-NOTES (modified) (history)
  • /branches/REL1_17/phase3/includes/Namespace.php (modified) (history)
  • /branches/REL1_17/phase3/includes/User.php (modified) (history)
  • /branches/REL1_17/phase3/includes/api/ApiQueryCategoryMembers.php (modified) (history)
  • /branches/REL1_17/phase3/includes/filerepo/File.php (modified) (history)
  • /branches/REL1_17/phase3/includes/installer/WebInstallerPage.php (modified) (history)

Diff [purge]

Index: branches/REL1_17/phase3/includes/User.php
@@ -660,7 +660,7 @@
661661 [$rfc5322_atext\\.]+ # user part which is liberal :p
662662 @ # 'apostrophe'
663663 [$rfc1034_ldh_str]+ # First domain part
664 - (\\.[$rfc1034_ldh_str]+)+ # Following part prefixed with a dot
 664+ (\\.[$rfc1034_ldh_str]+)* # Following part prefixed with a dot
665665 $ # End of string
666666 /ix" ; // case Insensitive, eXtended
667667
Index: branches/REL1_17/phase3/includes/filerepo/File.php
@@ -901,7 +901,7 @@
902902 $encName = $db->addQuotes( $this->getName() );
903903 $res = $db->select( array( 'page', 'imagelinks'),
904904 array( 'page_namespace', 'page_title', 'page_id', 'page_len', 'page_is_redirect', 'page_latest' ),
905 - array( 'page_id' => 'il_from', 'il_to' => $encName ),
 905+ array( 'page_id=il_from', 'il_to' => $encName ),
906906 __METHOD__,
907907 $options );
908908
Property changes on: branches/REL1_17/phase3/includes/filerepo/File.php
___________________________________________________________________
Modified: svn:mergeinfo
909909 Merged /trunk/phase3/includes/filerepo/File.php:r80324,80326,80328,80339,80350-80351,80355,80358,80362-80363,80371,80442,80540,80679,80685,80694
Index: branches/REL1_17/phase3/includes/installer/WebInstallerPage.php
@@ -809,6 +809,14 @@
810810 $this->addHTML( $extHtml );
811811 }
812812
 813+ // Having / in paths in Windows looks funny :)
 814+ $this->setVar( 'wgDeletedDirectory',
 815+ str_replace(
 816+ '/', DIRECTORY_SEPARATOR,
 817+ $this->getVar( 'wgDeletedDirectory' )
 818+ )
 819+ );
 820+
813821 $this->addHTML(
814822 # Uploading
815823 $this->getFieldSetStart( 'config-upload-settings' ) .
Property changes on: branches/REL1_17/phase3/includes/installer/WebInstallerPage.php
___________________________________________________________________
Modified: svn:mergeinfo
816824 Merged /trunk/phase3/includes/installer/WebInstallerPage.php:r80324,80326,80328,80339,80350-80351,80355,80358,80362-80363,80371,80442,80540,80679,80685,80694
Index: branches/REL1_17/phase3/includes/api/ApiQueryCategoryMembers.php
@@ -65,28 +65,28 @@
6666 $fld_ids = isset( $prop['ids'] );
6767 $fld_title = isset( $prop['title'] );
6868 $fld_sortkey = isset( $prop['sortkey'] );
 69+ $fld_sortkeyprefix = isset( $prop['sortkeyprefix'] );
6970 $fld_timestamp = isset( $prop['timestamp'] );
 71+ $fld_type = isset( $prop['type'] );
7072
7173 if ( is_null( $resultPageSet ) ) {
72 - $this->addFields( array( 'cl_from', 'cl_sortkey', 'page_namespace', 'page_title' ) );
 74+ $this->addFields( array( 'cl_from', 'page_namespace', 'page_title' ) );
7375 $this->addFieldsIf( 'page_id', $fld_ids );
 76+ $this->addFieldsIf( 'cl_sortkey_prefix', $fld_sortkeyprefix );
 77+ $this->addFieldsIf( 'cl_sortkey', $fld_sortkey );
7478 } else {
7579 $this->addFields( $resultPageSet->getPageTableFields() ); // will include page_ id, ns, title
7680 $this->addFields( array( 'cl_from', 'cl_sortkey' ) );
7781 }
7882
7983 $this->addFieldsIf( 'cl_timestamp', $fld_timestamp || $params['sort'] == 'timestamp' );
 84+ $this->addFieldsIf( 'cl_type', $fld_type );
 85+
8086 $this->addTables( array( 'page', 'categorylinks' ) ); // must be in this order for 'USE INDEX'
81 - // Not needed after bug 10280 is applied to servers
82 - if ( $params['sort'] == 'timestamp' ) {
83 - $this->addOption( 'USE INDEX', 'cl_timestamp' );
84 - } else {
85 - $this->addOption( 'USE INDEX', 'cl_sortkey' );
86 - }
8787
88 - $this->addWhere( 'cl_from=page_id' );
89 - $this->setContinuation( $params['continue'], $params['dir'] );
9088 $this->addWhereFld( 'cl_to', $categoryTitle->getDBkey() );
 89+ $this->addWhereFld( 'cl_type', $params['type'] );
 90+
9191 // Scanning large datasets for rare categories sucks, and I already told
9292 // how to have efficient subcategory access :-) ~~~~ (oh well, domas)
9393 global $wgMiserMode;
@@ -96,18 +96,35 @@
9797 } else {
9898 $this->addWhereFld( 'page_namespace', $params['namespace'] );
9999 }
 100+
 101+ $dir = $params['dir'] == 'asc' ? 'newer' : 'older';
 102+
100103 if ( $params['sort'] == 'timestamp' ) {
101 - $this->addWhereRange( 'cl_timestamp', ( $params['dir'] == 'asc' ? 'newer' : 'older' ), $params['start'], $params['end'] );
 104+ $this->addWhereRange( 'cl_timestamp',
 105+ $dir,
 106+ $params['start'],
 107+ $params['end'] );
 108+
 109+ $this->addOption( 'USE INDEX', 'cl_timestamp' );
102110 } else {
103 - $this->addWhereRange( 'cl_sortkey', ( $params['dir'] == 'asc' ? 'newer' : 'older' ), $params['startsortkey'], $params['endsortkey'] );
104 - $this->addWhereRange( 'cl_from', ( $params['dir'] == 'asc' ? 'newer' : 'older' ), null, null );
 111+ // The below produces ORDER BY cl_type, cl_sortkey, cl_from, possibly with DESC added to each of them
 112+ $this->addWhereRange( 'cl_type', $dir, null, null );
 113+ $this->addWhereRange( 'cl_sortkey',
 114+ $dir,
 115+ $params['startsortkey'],
 116+ $params['endsortkey'] );
 117+ $this->addWhereRange( 'cl_from', $dir, null, null );
 118+ $this->addOption( 'USE INDEX', 'cl_sortkey' );
105119 }
106120
 121+ $this->setContinuation( $params['continue'], $params['dir'] );
 122+
 123+ $this->addWhere( 'cl_from=page_id' );
 124+
107125 $limit = $params['limit'];
108126 $this->addOption( 'LIMIT', $limit + 1 );
109127
110128 $count = 0;
111 - $lastSortKey = null;
112129 $res = $this->select( __METHOD__ );
113130 foreach ( $res as $row ) {
114131 if ( ++ $count > $limit ) {
@@ -116,7 +133,7 @@
117134 if ( $params['sort'] == 'timestamp' ) {
118135 $this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->cl_timestamp ) );
119136 } else {
120 - $this->setContinueEnumParameter( 'continue', $this->getContinueStr( $row, $lastSortKey ) );
 137+ $this->setContinueEnumParameter( 'continue', $row->cl_from );
121138 }
122139 break;
123140 }
@@ -141,6 +158,12 @@
142159 if ( $fld_sortkey ) {
143160 $vals['sortkey'] = $row->cl_sortkey;
144161 }
 162+ if ( $fld_sortkeyprefix ) {
 163+ $vals['sortkeyprefix'] = $row->cl_sortkey_prefix;
 164+ }
 165+ if ( $fld_type ) {
 166+ $vals['type'] = $row->cl_type;
 167+ }
145168 if ( $fld_timestamp ) {
146169 $vals['timestamp'] = wfTimestamp( TS_ISO_8601, $row->cl_timestamp );
147170 }
@@ -150,14 +173,13 @@
151174 if ( $params['sort'] == 'timestamp' ) {
152175 $this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->cl_timestamp ) );
153176 } else {
154 - $this->setContinueEnumParameter( 'continue', $this->getContinueStr( $row, $lastSortKey ) );
 177+ $this->setContinueEnumParameter( 'continue', $row->cl_from );
155178 }
156179 break;
157180 }
158181 } else {
159182 $resultPageSet->processDbRow( $row );
160183 }
161 - $lastSortKey = $row->cl_sortkey; // detect duplicate sortkeys
162184 }
163185
164186 if ( is_null( $resultPageSet ) ) {
@@ -166,14 +188,6 @@
167189 }
168190 }
169191
170 - private function getContinueStr( $row, $lastSortKey ) {
171 - $ret = $row->cl_sortkey . '|';
172 - if ( $row->cl_sortkey == $lastSortKey ) { // duplicate sort key, add cl_from
173 - $ret .= $row->cl_from;
174 - }
175 - return $ret;
176 - }
177 -
178192 /**
179193 * Add DB WHERE clause to continue previous query based on 'continue' parameter
180194 */
@@ -182,26 +196,11 @@
183197 return; // This is not a continuation request
184198 }
185199
186 - $pos = strrpos( $continue, '|' );
187 - $sortkey = substr( $continue, 0, $pos );
188 - $fromstr = substr( $continue, $pos + 1 );
189 - $from = intval( $fromstr );
 200+ $encFrom = $this->getDB()->addQuotes( intval( $continue ) );
190201
191 - if ( $from == 0 && strlen( $fromstr ) > 0 ) {
192 - $this->dieUsage( 'Invalid continue param. You should pass the original value returned by the previous query', 'badcontinue' );
193 - }
 202+ $op = ( $dir == 'desc' ? '<=' : '>=' );
194203
195 - $encSortKey = $this->getDB()->addQuotes( $sortkey );
196 - $encFrom = $this->getDB()->addQuotes( $from );
197 -
198 - $op = ( $dir == 'desc' ? '<' : '>' );
199 -
200 - if ( $from != 0 ) {
201 - // Duplicate sort key continue
202 - $this->addWhere( "cl_sortkey$op$encSortKey OR (cl_sortkey=$encSortKey AND cl_from$op=$encFrom)" );
203 - } else {
204 - $this->addWhere( "cl_sortkey$op=$encSortKey" );
205 - }
 204+ $this->addWhere( "cl_from $op $encFrom" );
206205 }
207206
208207 public function getAllowedParams() {
@@ -217,6 +216,8 @@
218217 'ids',
219218 'title',
220219 'sortkey',
 220+ 'sortkeyprefix',
 221+ 'type',
221222 'timestamp',
222223 )
223224 ),
@@ -224,6 +225,15 @@
225226 ApiBase::PARAM_ISMULTI => true,
226227 ApiBase::PARAM_TYPE => 'namespace',
227228 ),
 229+ 'type' => array(
 230+ ApiBase::PARAM_ISMULTI => true,
 231+ ApiBase::PARAM_DFLT => 'page|subcat|file',
 232+ ApiBase::PARAM_TYPE => array(
 233+ 'page',
 234+ 'subcat',
 235+ 'file'
 236+ )
 237+ ),
228238 'continue' => null,
229239 'limit' => array(
230240 ApiBase::PARAM_TYPE => 'limit',
@@ -264,12 +274,15 @@
265275 'title' => 'Which category to enumerate (required). Must include Category: prefix',
266276 'prop' => array(
267277 'What pieces of information to include',
268 - ' ids - Adds the page id',
269 - ' title - Adds the title and namespace id of the page',
270 - ' sortkey - Adds the sortkey used for the category',
271 - ' timestamp - Adds the timestamp of when the page was included',
 278+ ' ids - Adds the page ID',
 279+ ' title - Adds the title and namespace ID of the page',
 280+ ' sortkey - Adds the sortkey used for sorting in the category (may not be human-readble)',
 281+ ' sortkeyprefix - Adds the sortkey prefix used for sorting in the category (human-readable part of the sortkey)',
 282+ ' type - Adds the type that the page has been categorised as (page, subcat or file)',
 283+ ' timestamp - Adds the timestamp of when the page was included',
272284 ),
273285 'namespace' => 'Only include pages in these namespaces',
 286+ 'type' => 'What type of category members to include',
274287 'sort' => 'Property to sort by',
275288 'dir' => 'In which direction to sort',
276289 'start' => "Timestamp to start listing from. Can only be used with {$p}sort=timestamp",
Index: branches/REL1_17/phase3/includes/Namespace.php
@@ -128,12 +128,10 @@
129129 static $namespaces = null;
130130 if ( $namespaces === null ) {
131131 global $wgExtraNamespaces, $wgCanonicalNamespaceNames;
 132+ $namespaces = array( NS_MAIN => '' ) + $wgCanonicalNamespaceNames;
132133 if ( is_array( $wgExtraNamespaces ) ) {
133 - $namespaces = $wgCanonicalNamespaceNames + $wgExtraNamespaces;
134 - } else {
135 - $namespaces = $wgCanonicalNamespaceNames;
 134+ $namespaces += $wgExtraNamespaces;
136135 }
137 - $namespaces[NS_MAIN] = '';
138136 wfRunHooks( 'CanonicalNamespaces', array( &$namespaces ) );
139137 }
140138 return $namespaces;
Index: branches/REL1_17/phase3/RELEASE-NOTES
@@ -492,6 +492,7 @@
493493 === API changes in 1.17 ===
494494 * BREAKING CHANGE: action=patrol now requires POST
495495 * BREAKING CHANGE: patrol token is no longer the same as edit token
 496+* (bug 24650) Fix API to work with categorylinks changes
496497
497498 * (bug 22738) Allow filtering by action type on query=logevent.
498499 * (bug 22764) uselang parameter for action=parse.
Property changes on: branches/REL1_17/phase3/RELEASE-NOTES
___________________________________________________________________
Modified: svn:mergeinfo
499500 Merged /trunk/phase3/RELEASE-NOTES:r80324,80326,80328,80339,80350-80351,80355,80358,80362-80363,80371,80442,80540,80679,80685,80694

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r80324Start of bug 24650 Fix API to work with categorylinks changes...reedy21:08, 14 January 2011
r80326Followup r80324, add type property descriptionreedy21:15, 14 January 2011
r80328Remove ancient comment, collapse if, move USE INDEX into if further down doin...reedy21:24, 14 January 2011
r80339Fix indenting, rearrange some where statementsreedy22:37, 14 January 2011
r80350More query reorganisation, in an attempt to be index friendlyreedy23:20, 14 January 2011
r80351Bleh, didn't press save again (r80350)reedy23:24, 14 January 2011
r80355Bye bye filesorts. Making order by cl_type, and then addWhereRange adds cl_so...reedy23:45, 14 January 2011
r80358More for bug 24650. Update continue to be usable unique thingreedy00:00, 15 January 2011
r80362Last bits of bug 24650 Fix API to work with categorylinks changes...reedy00:10, 15 January 2011
r80363* (bug 24650) Fix API to work with categorylinks changes...reedy00:13, 15 January 2011
r80371Fix spaes from r80362reedy00:50, 15 January 2011
r80442Fix broken query in File::getLinksTo()tstarling13:35, 17 January 2011
r80540Various fixes for API category changes:...catrope00:13, 19 January 2011
r80679(bug 26762) Fix order of namespace listcatrope03:48, 21 January 2011
r80685(bug 26288) $wgDeletedDirectory looks funny on Windows because / should be \ ...demon14:37, 21 January 2011
r80694Hack invalid w3 spec to validate @localhost email...hashar18:01, 21 January 2011

Status & tagging log