r83856 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83855‎ | r83856 | r83857 >
Date:21:43, 13 March 2011
Author:reedy
Status:resolved (Comments)
Tags:
Comment:
* (bug 27020) API: Allow title prefix search of logevents (only when not in miser mode)

Won't work on WMF wiki's as miser mode is enabled, but won't show as an available option either
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryLogEvents.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryLogEvents.php
@@ -148,6 +148,20 @@
149149 $index['logging'] = is_null( $user ) ? 'page_time' : array( 'page_time', 'user_time' );
150150 }
151151
 152+ global $wgMiserMode;
 153+ if ( !$wgMiserMode ) {
 154+ $prefix = $params['prefix'];
 155+
 156+ if ( !is_null( $prefix ) ) {
 157+ $title = Title::newFromText( $prefix );
 158+ if ( is_null( $title ) ) {
 159+ $this->dieUsage( "Bad title value '$prefix'", 'param_prefix' );
 160+ }
 161+ $this->addWhereFld( 'log_namespace', $title->getNamespace() );
 162+ $this->addWhere( 'log_title ' . $db->buildLike( $title->getDBkey(), $db->anyString() ) );
 163+ }
 164+ }
 165+
152166 $this->addOption( 'USE INDEX', $index );
153167
154168 // Paranoia: avoid brute force searches (bug 17342)
@@ -334,7 +348,7 @@
335349
336350 public function getAllowedParams() {
337351 global $wgLogTypes, $wgLogActions;
338 - return array(
 352+ $ret = array(
339353 'prop' => array(
340354 ApiBase::PARAM_ISMULTI => true,
341355 ApiBase::PARAM_DFLT => 'ids|title|type|user|timestamp|comment|details',
@@ -381,11 +395,17 @@
382396 ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
383397 )
384398 );
 399+ global $wgMiserMode;
 400+ if ( !$wgMiserMode ) {
 401+ $ret['prefix'] = null;
 402+ }
 403+
 404+ return $ret;
385405 }
386406
387407 public function getParamDescription() {
388408 $p = $this->getModulePrefix();
389 - return array(
 409+ $ret = array(
390410 'prop' => array(
391411 'Which properties to get',
392412 ' ids - Adds the ID of the log event',
@@ -409,6 +429,13 @@
410430 'limit' => 'How many total event entries to return',
411431 'tag' => 'Only list event entries tagged with this tag',
412432 );
 433+
 434+ global $wgMiserMode;
 435+ if ( !$wgMiserMode ) {
 436+ $ret['prefix'] = 'Filter entries that start with this prefix';
 437+ }
 438+
 439+ return $ret;
413440 }
414441
415442 public function getDescription() {
@@ -419,6 +446,7 @@
420447 return array_merge( parent::getPossibleErrors(), array(
421448 array( 'code' => 'param_user', 'info' => 'User name $user not found' ),
422449 array( 'code' => 'param_title', 'info' => 'Bad title value \'title\'' ),
 450+ array( 'code' => 'param_prefix', 'info' => 'Bad title value \'prefix\'' ),
423451 ) );
424452 }
425453
Index: trunk/phase3/RELEASE-NOTES
@@ -253,6 +253,8 @@
254254 * (bug 27203) add fato param to list=filearchive
255255 * (bug 27341) Add drto param to list=deletedrevs
256256 * (bug 26630) Add api for Special:ActiveUsers
 257+* (bug 27020) API: Allow title prefix search of logevents (only when not in
 258+ miser mode)
257259
258260 === Languages updated in 1.18 ===
259261

Follow-up revisions

RevisionCommit summaryAuthorDate
r83858Followup r83856...reedy22:12, 13 March 2011

Comments

#Comment by Bryan (talk | contribs)   22:02, 13 March 2011

Note that there has been a discussion about whether or not conditional parameters are a good idea.

Status & tagging log