r65334 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65333‎ | r65334 | r65335 >
Date:18:24, 20 April 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Fixed title validation on Special:Story
Modified paths:
  • /trunk/extensions/Storyboard/api/ApiStoryExists.php (modified) (history)
  • /trunk/extensions/Storyboard/specials/Story/Story_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Storyboard/specials/Story/Story_body.php
@@ -286,8 +286,6 @@
287287 )
288288 ) . '</td></tr>';
289289
290 - // TODO: further fix this
291 - // Need to extend the validator plugin to work with api results, and also send over the current srory id to exclude it.
292290 $formBody .= '<tr>' .
293291 '<td width="100%"><label for="storytitle">' .
294292 htmlspecialchars( wfMsg( 'storyboard-storytitle' ) ) .
@@ -302,7 +300,7 @@
303301 'minlength' => 2,
304302 'id' => 'storytitle',
305303 'class' => 'required storytitle',
306 - 'remote' => "$wgScriptPath/api.php?format=json&action=storyexists"
 304+ 'remote' => "$wgScriptPath/api.php?format=json&action=storyexists&currentid=$story->story_id"
307305 )
308306 ) . '</td></tr>';
309307
Index: trunk/extensions/Storyboard/api/ApiStoryExists.php
@@ -48,10 +48,18 @@
4949
5050 $dbr = wfGetDB( DB_SLAVE );
5151
 52+ $conditions = array(
 53+ 'story_title' => str_replace( array( '_', '+' ), ' ', $params['storytitle'] ),
 54+ );
 55+
 56+ if ( array_key_exists( 'currentid', $params ) && is_integer( $params['currentid'] ) ) {
 57+ $conditions[] = "story_id != $params[currentid]";
 58+ }
 59+
5260 $story = $dbr->selectRow(
5361 'storyboard',
5462 array( 'story_id' ),
55 - array( 'story_title' => str_replace( array( '_', '+' ), ' ', $params['storytitle'] ) )
 63+ $conditions
5664 );
5765
5866 $result = array(
@@ -70,6 +78,9 @@
7179 'storytitle' => array(
7280 ApiBase :: PARAM_TYPE => 'string',
7381 ),
 82+ 'currentid' => array(
 83+ ApiBase :: PARAM_TYPE => 'integer',
 84+ ),
7485 );
7586 }
7687
@@ -94,6 +105,7 @@
95106 protected function getExamples() {
96107 return array(
97108 'api.php?action=storyexists&storytitle=oHai there!',
 109+ 'api.php?action=storyexists&storytitle=oHai there!&currentid=42',
98110 );
99111 }
100112

Follow-up revisions

RevisionCommit summaryAuthorDate
r65338Follow up to r65334 and r65335 - also fixed title validation in storysubmissi...jeroendedauw19:10, 20 April 2010

Status & tagging log