r63378 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63377‎ | r63378 | r63379 >
Date:00:25, 8 March 2010
Author:jeroendedauw
Status:resolved (Comments)
Tags:
Comment:
DB Table update and added edit token check to storysubmission form
Modified paths:
  • /trunk/extensions/Storyboard/storyboard.pg.sql (modified) (history)
  • /trunk/extensions/Storyboard/storyboard.sql (modified) (history)
  • /trunk/extensions/Storyboard/tags/Storysubmission/Storysubmission_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Storyboard/storyboard.sql
@@ -1,16 +1,19 @@
22 -- MySQL version of the database schema for the Storyboard extension.
33
44 CREATE TABLE /*$wgDBprefix*/storyboard (
5 - story_id INT(8) unsigned NOT NULL auto_increment PRIMARY KEY,
6 - story_author_id INT unsigned NULL,
7 - story_author_name VARCHAR(255) NULL,
8 - story_hit_count INT(8) unsigned NOT NULL,
9 - story_title VARCHAR(255) NOT NULL,
10 - story_text MEDIUMBLOB NULL,
11 - story_modified CHAR(14) binary NOT NULL default '',
12 - story_created CHAR(14) binary NOT NULL default '',
13 - story_is_published TINYINT NOT NULL default '0',
14 - story_is_hidden TINYINT NOT NULL default '0'
 5+ story_id INT(8) unsigned NOT NULL auto_increment PRIMARY KEY,
 6+ story_author_id INT unsigned NULL,
 7+ story_author_name VARCHAR(100) NOT NULL,
 8+ story_author_location VARCHAR(150) NOT NULL,
 9+ story_author_occupation VARCHAR(100) NOT NULL,
 10+ story_author_image VARCHAR(50) NULL, -- TODO: find out if this is an acceptible way to refer to an image
 11+ story_hit_count INT(8) unsigned NOT NULL,
 12+ story_title VARCHAR(255) NOT NULL,
 13+ story_text MEDIUMBLOB NOT NULL,
 14+ story_modified CHAR(14) binary NOT NULL default '',
 15+ story_created CHAR(14) binary NOT NULL default '',
 16+ story_is_published TINYINT NOT NULL default '0',
 17+ story_is_hidden TINYINT NOT NULL default '0'
1518 ) /*$wgDBTableOptions*/;
1619
1720 CREATE INDEX story_published_modified ON /*$wgDBprefix*/storyboard (story_is_published, story_modified);
Index: trunk/extensions/Storyboard/storyboard.pg.sql
@@ -1,4 +1,5 @@
22 -- Postgres version of the database schema for the Storyboard extension.
 3+-- TODO: update to equivalent of latest MySQL sql
34
45 BEGIN;
56
Index: trunk/extensions/Storyboard/tags/Storysubmission/Storysubmission_body.php
@@ -23,11 +23,9 @@
2424 public static function render( $input, $args, $parser, $frame ) {
2525 wfProfileIn( __METHOD__ );
2626
27 - global $wgRequest;
 27+ global $wgRequest, $wgUser;
2828
29 - var_dump($wgRequest->wasPosted()); die();
30 -
31 - if ( $wgRequest->wasPosted() ) {
 29+ if ( $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) {
3230 $output = self::doSubmissionAndGetResult();
3331 } else {
3432 $output = self::getFrom( $parser, $args );
@@ -39,7 +37,7 @@
4038 }
4139
4240 private static function getFrom( $parser, $args ) {
43 - global $wgOut, $wgJsMimeType, $wgSc, $egStoryboardScriptPath, $egStorysubmissionWidth, $egStoryboardMaxStoryLen, $egStoryboardMinStoryLen;
 41+ global $wgOut, $wgUser, $wgJsMimeType, $wgSc, $egStoryboardScriptPath, $egStorysubmissionWidth, $egStoryboardMaxStoryLen, $egStoryboardMinStoryLen;
4442
4543 $wgOut->addStyle( $egStoryboardScriptPath . '/tags/Storysubmission/storysubmission.css' );
4644 $wgOut->addScriptFile( $egStoryboardScriptPath . '/tags/Storysubmission/storysubmission.js' );
@@ -50,7 +48,7 @@
5149 $maxLen = array_key_exists('maxlength', $args) && is_numeric($args['maxlength']) ? $args['maxlength'] : $egStoryboardMaxStoryLen;
5250 $minLen = array_key_exists('minlength', $args) && is_numeric($args['minlength']) ? $args['minlength'] : $egStoryboardMinStoryLen;
5351
54 - $submissionUrl = $parser->getTitle()->getLocalURL( '' ); // TODO: fix parameters
 52+ $submissionUrl = $parser->getTitle()->getLocalURL( 'action=purge' ); // TODO: fix parameters
5553
5654 $formBody = "<table width='$width'>";
5755
@@ -107,6 +105,8 @@
108106
109107 $formBody .= '</table>';
110108
 109+ $formBody .= Html::hidden( 'wpEditToken', $wgUser->editToken() );
 110+
111111 $formHtml = Html::rawElement(
112112 'form',
113113 array(
@@ -125,8 +125,13 @@
126126 return $formHtml . $formJs;
127127 }
128128
 129+ /**
 130+ * Store the submitted story in the database, and return a page telling the user his story has been submitted.
 131+ */
129132 private static function doSubmissionAndGetResult() {
 133+ global $wgRequest, $wgUser;
130134
 135+
131136 }
132137
133138 }
\ No newline at end of file

Follow-up revisions

RevisionCommit summaryAuthorDate
r63391Follow up to r63378 and r63377. Added stuff to storysubmission tag.jeroendedauw14:17, 8 March 2010

Comments

#Comment by Catrope (talk | contribs)   12:38, 8 March 2010
+  story_author_name        VARCHAR(100)      NOT NULL,
+  story_author_location    VARCHAR(150)      NOT NULL,
+  story_author_occupation  VARCHAR(100)      NOT NULL,

Instead of using arbitrary and unpredictable sizes here, I'd recommend just using VARCHAR(255) throughout.

+  story_author_image       VARCHAR(50)           NULL,  -- TODO: find out if this is an acceptible way to refer to an image

Depends on what kind of image: is it an external URL (50 chars is way too few), an image on the local wiki (255 chars for a title field, namespace=6 is implied), an uploaded image, or what?

#Comment by Jeroen De Dauw (talk | contribs)   13:10, 8 March 2010

> I'd recommend just using VARCHAR(255) throughout. Yeah sure.

> Depends on what kind of image The users will need to be able to upload an image via storysubmission form, which should then get cropped to the right dimensions, and stored on the wiki. That's what this field is for - Since I'm not familiar with how regular images are stored in mw yet, I can't determine what the best approach here would be, in particular how much of the existing infrastructure can be used. Can you point me to some useful docs on this?

#Comment by Catrope (talk | contribs)   14:06, 8 March 2010

For referring to the image, you should just use the title of the image then, which is a varchar(255) referring to image.img_name .

#Comment by Jeroen De Dauw (talk | contribs)   14:17, 8 March 2010

Fixed in r63391

Status & tagging log