r50617 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50616‎ | r50617 | r50618 >
Date:03:46, 15 May 2009
Author:laner
Status:deferred
Tags:
Comment:
Added some basic error checking.
Modified paths:
  • /trunk/extensions/Plotters/Plotters.i18n.php (modified) (history)
  • /trunk/extensions/Plotters/PlottersClass.php (modified) (history)
  • /trunk/extensions/Plotters/PlottersParser.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Plotters/PlottersClass.php
@@ -35,9 +35,25 @@
3636 }
3737
3838 function checkForErrors() {
 39+ wfLoadExtensionMessages( 'Plotters' );
 40+
 41+ $errors = '';
 42+
3943 // Check for a script
 44+ if ( $this->argumentArray["script"] == "" ) {
 45+ $errors .= wfMsg( "plotters-missing-script" ) . "<br />";
 46+ } else if ( strlen( $this->argumentArray["script"] ) > 255 ) {
 47+ // Check to ensure scriptname is < 255 characters
 48+ $errors .= wfMsg( "plotters-excessively-long-scriptname" ) . "<br />";
 49+ }
4050 // Check for data
41 - return '';
 51+ if ( count( $this->dataArray ) == 0 ) {
 52+ $errors .= wfMsg( "plotters-no-data" ) . "<br />";
 53+ }
 54+
 55+ if ( $errors != '' ) {
 56+ $this->errors = wfMsg( "plotters-errors" ) . " " . $errors;
 57+ }
4258 }
4359
4460 function toHTML() {
Index: trunk/extensions/Plotters/PlottersParser.php
@@ -109,6 +109,13 @@
110110 }
111111
112112 function parseData( $input, $parser ) {
 113+ $this->dataArray = array();
 114+
 115+ Plotter::debug( 'plot script input: ', $this->argumentArray["scriptarguments"] );
 116+ if ( trim( $input ) == '' ) {
 117+ return;
 118+ }
 119+
113120 // Replace escaped separators
114121 $sep = $this->argumentArray["datasep"];
115122 $input = preg_replace( "/\\\\$sep/", '§UNIQ§', $input );
Index: trunk/extensions/Plotters/Plotters.i18n.php
@@ -23,6 +23,10 @@
2424 'plotters-pagetext' => "Below is a list of special plotters users can use in their jsplot tags, as defined by [[MediaWiki:Plotters-definition]].
2525 This overview provides easy access to the system message pages that define each plotter's description and code.",
2626 'plotters-uses' => 'Uses',
 27+ 'plotters-missing-script' => 'No script was defined.',
 28+ 'plotters-excessively-long-scriptname' => 'The script name is too long. Please define a script that is less than 255 characters.',
 29+ 'plotters-no-data' => 'No data was provided.',
 30+ 'plotters-errors' => '<b>Plotters error(s):</b>',
2731 );
2832
2933 /** Arabic (العربية)

Status & tagging log