Dan-nl has uploaded a new change for review.
https://gerrit.wikimedia.org/r/97676
Change subject: sanitized-exceptions
......................................................................
sanitized-exceptions
chris steipp requested that:
* it would make things easier if you could escape the exception message,
or demonstrate that it's been properly sanitized
* and log, don’t print_r in the exception output, even when it’s only for
display_errors = 1
augmented the GWTException class so that it now takes in wfMessage() keys and
their
parameters and uses its ->parse() method to sanitize the message or assumes a
regular
$message string and sanitizes it before use. adjusted all throw GWTExceptions
in order
to properly use the new functionality.
i also corrected two bugs i found while working on this issue: the re-upload
media file
checkbox wasn’t being picked-up and when no metadata file was provided for
upload, a
MWException was being thrown instead of providing a user message.
Change-Id: Ic5626703262e5782af90d30a3c9aff35a898f35c
---
M GWToolset.i18n.php
M includes/Adapters/Php/MappingPhpAdapter.php
M includes/Adapters/Php/MediawikiTemplatePhpAdapter.php
M includes/Forms/MetadataMappingForm.php
M includes/GWTException.php
M includes/Handlers/Forms/FormHandler.php
M includes/Handlers/Forms/MetadataMappingHandler.php
M includes/Handlers/UploadHandler.php
M includes/Handlers/Xml/XmlDetectHandler.php
M includes/Handlers/Xml/XmlHandler.php
M includes/Helpers/FileChecks.php
M includes/Models/Mapping.php
M includes/Models/MediawikiTemplate.php
M includes/Specials/SpecialGWToolset.php
M includes/Utils.php
15 files changed, 138 insertions(+), 158 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GWToolset
refs/changes/76/97676/1
diff --git a/GWToolset.i18n.php b/GWToolset.i18n.php
index 259f2b0..362b3ca 100644
--- a/GWToolset.i18n.php
+++ b/GWToolset.i18n.php
@@ -60,7 +60,7 @@
'gwtoolset-no-template-url' => 'No template URL provided to parse.',
'gwtoolset-no-text' => 'No text provided.',
'gwtoolset-no-title' => 'No title provided.',
- 'gwtoolset-no-upload-media' =>
"<code>user_options['upload-media']</code> not set.",
+ 'gwtoolset-no-reupload-media' =>
"<code>user_options['gwtoolset-reupload-media']</code> not set.",
'gwtoolset-no-url-to-evaluate' => 'No URL was provided for evaluation.',
'gwtoolset-no-url-to-media' => '<code>url-to-the-media-file</code> not
set.',
'gwtoolset-no-user' => 'no user object provided.',
@@ -98,7 +98,8 @@
'gwtoolset-back-text' => 'Press the browser back button to go back to
the form.',
'gwtoolset-file-interpretation-error' => 'There was a problem
interpretting the metadata file',
'gwtoolset-mediawiki-template' => '$1 Template',
- 'gwtoolset-metadata-user-options-error' => 'The following form field(s)
must be filled in:',
+ 'gwtoolset-metadata-user-options-error' => 'The following form field(s)
must be filled in:
+$1',
'gwtoolset-metadata-invalid-template' => 'No valid MediaWiki template
found.',
'gwtoolset-menu' => '* $1',
'gwtoolset-menu-1' => 'Metadata mapping',
@@ -158,9 +159,9 @@
'gwtoolset-namespace-mismatch' => "The page title given, '''$1''', is
in the wrong namespace, '''$2'''.
It should be in the '''$3''' namespace.",
- 'gwtoolset-no-xml-element-found' => 'No XML element found for mapping.',
- 'gwtoolset-no-xml-element-found-li-1' => 'Did you enter a value in the
form for “What is the XML element that contains each metadata record”?',
- 'gwtoolset-no-xml-element-found-li-2' => 'Is the XML file well-formed?
Try this $1.',
+ 'gwtoolset-no-xml-element-found' => 'No XML element found for mapping.
+* Did you enter a value in the form for “What is the XML element that contains
each metadata record”?
+* Is the XML file well-formed? Try this $1.',
'gwtoolset-page-title-contains-url' => "The page title, $1, contains
the entire wiki URL. Make sure you only refer to the page title, e.g. the part
of the URL after /wiki/",
'gwtoolset-record-element-name' => 'What is the XML element that
contains each metadata record:',
'gwtoolset-step-1-heading' => 'Step 1: Metadata detection',
@@ -365,20 +366,18 @@
'gwtoolset-no-more-records' => 'User message that appears when there
are no more records to process.',
'gwtoolset-no-mwstore-provided' => 'Message that appears when no
mwstore URL is provided.',
'gwtoolset-no-page-title' => 'Appears when no page title was provided.',
+ 'gwtoolset-no-reupload-media' => "Hint to the developer that appears
when user_options['gwtoolset-reupload-media'] is not set.",
'gwtoolset-no-save-as-batch' => "Hint to the developer that appears
when user_options['save-as-batch-job'] is not set.",
'gwtoolset-no-source-array' => 'Developer message that appears when no
source array was provided to a method.',
'gwtoolset-no-summary' => 'Hint to the developer that appears when no
summary is provided.',
'gwtoolset-no-template-url' => 'Hint to the developer that appears when
no template URL is provided to parse.',
'gwtoolset-no-text' => 'Hint to the developer that appears when no text
is provided.',
'gwtoolset-no-title' => 'Hint to the developer that appears when no
title is provided.',
- 'gwtoolset-no-upload-media' => "Hint to the developer that appears when
user_options['upload-media'] is not set.",
'gwtoolset-no-url-to-evaluate' => 'Message that appears when no URL was
provided for evaluation.',
'gwtoolset-no-url-to-media' => 'Hint to the developer that appears when
url-to-the-media-file is not set.',
'gwtoolset-no-user' => 'Hint to the developer that appears when no user
object is provided.',
'gwtoolset-no-xml-element' => 'Hint to the developer that appears when
no XMLReader or DOMElement is provided.',
'gwtoolset-no-xml-element-found' => 'User error message when no XML
element was found for mapping.',
- 'gwtoolset-no-xml-element-found-li-1' => 'Suggestion 1 on how to
correct a no XML element found error.',
- 'gwtoolset-no-xml-element-found-li-2' => 'Suggestion 2 on how to
correct a no XML element found error.',
'gwtoolset-no-xml-source' => 'Hint to the developer that appears when
no local XML source was given',
'gwtoolset-not-string' => 'Developer message that appears when the
value provided to the method was not a string; parameter $1 is the actual type
of the value.',
'gwtoolset-over-max-ini' => 'User error message that appears when the
uploaded file exceeds the upload_max_filesize directive in php.ini.',
diff --git a/includes/Adapters/Php/MappingPhpAdapter.php
b/includes/Adapters/Php/MappingPhpAdapter.php
index 3088541..496f1b4 100644
--- a/includes/Adapters/Php/MappingPhpAdapter.php
+++ b/includes/Adapters/Php/MappingPhpAdapter.php
@@ -37,9 +37,8 @@
if ( $options['Metadata-Mapping-Title'] instanceof Title ) {
if ( !$options['Metadata-Mapping-Title']->isKnown() ) {
throw new GWTException(
- wfMessage(
'gwtoolset-metadata-mapping-not-found' )
- ->params(
$options['gwtoolset-metadata-mapping-url'] )
- ->parse()
+ 'gwtoolset-metadata-mapping-not-found,'
.
+
$options['gwtoolset-metadata-mapping-url']
);
}
diff --git a/includes/Adapters/Php/MediawikiTemplatePhpAdapter.php
b/includes/Adapters/Php/MediawikiTemplatePhpAdapter.php
index 8518ffc..ea4f750 100644
--- a/includes/Adapters/Php/MediawikiTemplatePhpAdapter.php
+++ b/includes/Adapters/Php/MediawikiTemplatePhpAdapter.php
@@ -54,10 +54,9 @@
Config::$mediawiki_templates[Utils::sanitizeString(
$options['mediawiki_template_name'] )] )
) {
throw new GWTException(
- wfMessage(
'gwtoolset-mediawiki-template-not-found' )
- ->rawParams( Utils::sanitizeString(
$options['mediawiki_template_name'] ) )
- ->escaped()
- );
+ 'gwtoolset-mediawiki-template-not-found,' .
+ $options['mediawiki_template_name']
+ );
}
$Title = Utils::getTitle(
@@ -67,9 +66,8 @@
if ( !$Title->isKnown() ) {
throw new GWTException(
- wfMessage(
'gwtoolset-mediawiki-template-does-not-exist' )
- ->params( $Title->getBaseTitle() )
- ->parse()
+ 'gwtoolset-mediawiki-template-does-not-exist,' .
+ $Title->getBaseTitle()
);
}
diff --git a/includes/Forms/MetadataMappingForm.php
b/includes/Forms/MetadataMappingForm.php
index f45f677..2d04f26 100644
--- a/includes/Forms/MetadataMappingForm.php
+++ b/includes/Forms/MetadataMappingForm.php
@@ -533,7 +533,7 @@
'input',
array(
'type' => 'checkbox',
- 'name' =>
'upload-media',
+ 'name' =>
'gwtoolset-reupload-media',
'value' => 'true'
)
) .
diff --git a/includes/GWTException.php b/includes/GWTException.php
index 980b2f9..db8f82d 100644
--- a/includes/GWTException.php
+++ b/includes/GWTException.php
@@ -8,7 +8,55 @@
*/
namespace GWToolset;
-use Exception;
+use Exception,
+ GWToolset\Utils;
class GWTException extends Exception {
+
+ /**
+ * @param {string} $message
+ * allows for the message to contain a simple or complex wfMessage.
+ * - each wfMessage key should be separated by a ;
+ * - each wfMessage parameter should be separated by a ,
+ * - e.g., simple $message = 'gwtoolset-key'
+ * - e.g., complex $message =
'gwtoolset-key,param1,param2;gwtoolset-key2'
+ *
+ * @param {int} code
+ *
+ * @param {Exception} $previous
+ */
+ public function __construct( $message = '', $code = 0, Exception
$previous = null ) {
+ $message = $this->processMessage( $message );
+ parent::__construct( $message, $code, $previous );
+ }
+
+ /**
+ * @param {string} $message
+ * assumes that if the message contains gwtoolset- then it is a simple
or complex wfMessage;
+ * otherwise it is assumed that it is a “regular” message string
+ *
+ * @return {string}
+ */
+ protected function processMessage( $message ) {
+ $result = null;
+
+ if ( strpos( $message, 'gwtoolset-' ) !== false ) {
+ $wiki_messages = explode( ';', $message );
+
+ foreach ( $wiki_messages as $wiki_message ) {
+ if ( strpos( $wiki_message, ',' ) !== false ) {
+ $params = explode( ',', $wiki_message );
+ $msg = array_shift( $params );
+ $result .= wfMessage( $msg )->params(
$params )->parse();
+ } else {
+ $result .= wfMessage( $wiki_message
)->parse();
+ }
+ }
+ } else {
+ $result = Utils::sanitizeString( $message );
+ }
+
+ return $result;
+ }
+
}
diff --git a/includes/Handlers/Forms/FormHandler.php
b/includes/Handlers/Forms/FormHandler.php
index a1ca8a4..c8c280f 100644
--- a/includes/Handlers/Forms/FormHandler.php
+++ b/includes/Handlers/Forms/FormHandler.php
@@ -59,29 +59,25 @@
foreach ( $expected_options as $option ) {
if ( !array_key_exists( $option, $user_options ) ) {
- $msg .= '<li>' . Utils::sanitizeString( $option
) . '</li>';
+ $msg .= '* ' . $option . PHP_EOL;
}
if ( is_array( $user_options[$option] ) ) {
if ( strlen( reset( $user_options[$option] ) )
< 1 ) {
- $msg .= '<li>' . Utils::sanitizeString(
$option ) . '</li>';
+ $msg .= '* ' . $option . PHP_EOL;
}
} else {
if ( strlen( $user_options[$option] ) < 1 ) {
- $msg .= '<li>' . Utils::sanitizeString(
$option ) . '</li>';
+ $msg .= '* ' . $option . PHP_EOL;
}
}
}
if ( $msg !== null ) {
$msg =
- Html::rawElement(
- 'p',
- array( 'class' => 'error' ),
- wfMessage(
'gwtoolset-metadata-user-options-error' )->escaped()
- ) .
- Html::rawElement( 'ul', array(), $msg ) .
- Html::rawElement( 'p', array(),
$this->SpecialPage->getBackToFormLink() );
+ 'gwtoolset-metadata-user-options-error,' .
+ $msg .
+ $this->SpecialPage->getBackToFormLink();
throw new GWTException( $msg );
}
diff --git a/includes/Handlers/Forms/MetadataMappingHandler.php
b/includes/Handlers/Forms/MetadataMappingHandler.php
index acca2bd..12d7139 100644
--- a/includes/Handlers/Forms/MetadataMappingHandler.php
+++ b/includes/Handlers/Forms/MetadataMappingHandler.php
@@ -56,6 +56,7 @@
'gwtoolset-record-begin' => array( 'size' => 255 ),
'gwtoolset-record-count' => array( 'size' => 255 ),
'gwtoolset-record-element-name' => array( 'size' => 255 ),
+ 'gwtoolset-reupload-media' => array( 'size' => 255 ),
'wpEditToken' => array( 'size' => 255 ),
'wpSummary' => array( 'size' => 255 )
);
@@ -240,9 +241,9 @@
?
$this->_whitelisted_post['gwtoolset-title-identifier']
: null,
- 'upload-media' =>
- !empty(
$this->_whitelisted_post['upload-media'] )
- ? (bool)$this->_whitelisted_post['upload-media']
+ 'gwtoolset-reupload-media' =>
+ !empty(
$this->_whitelisted_post['gwtoolset-reupload-media'] )
+ ?
(bool)$this->_whitelisted_post['gwtoolset-reupload-media']
: false,
'gwtoolset-url-to-the-media-file' =>
diff --git a/includes/Handlers/UploadHandler.php
b/includes/Handlers/UploadHandler.php
index 209fb26..eb80cb4 100644
--- a/includes/Handlers/UploadHandler.php
+++ b/includes/Handlers/UploadHandler.php
@@ -291,10 +291,7 @@
$pathinfo = array();
if ( empty( $url ) ) {
- throw new GWTException(
- __METHOD__ . ' ' .
- wfMessage( 'gwtoolset-no-url-to-evaluate'
)->escaped()
- );
+ throw new GWTException( 'gwtoolset-no-url-to-evaluate'
);
}
$Http = MWHttpRequest::factory(
@@ -310,9 +307,7 @@
if ( !$Status->ok ) {
throw new GWTException(
- wfMessage(
'gwtoolset-mapping-media-file-url-bad' )
- ->rawParams( Utils::sanitizeString(
$url ) )
- ->escaped()
+ 'gwtoolset-mapping-media-file-url-bad,' . $url
);
}
@@ -322,9 +317,7 @@
if ( empty( $result['extension'] ) ) {
throw new GWTException(
- wfMessage(
'gwtoolset-mapping-media-file-url-extension-bad' )
- ->rawParams( Utils::sanitizeString(
$url ) )
- ->escaped()
+
'gwtoolset-mapping-media-file-url-extension-bad,' . $url
);
}
@@ -350,17 +343,15 @@
if ( empty( $options['url'] ) ) {
throw new GWTException(
- wfMessage(
'gwtoolset-mapping-media-file-url-bad' )
- ->rawParams( Utils::sanitizeString(
$options['url'] ) )
- ->escaped()
+ 'gwtoolset-mapping-media-file-url-bad,' .
+ $options['url']
);
}
if ( empty( $options['content-type'] ) ) {
throw new GWTException(
- wfMessage(
'gwtoolset-mapping-media-file-no-content-type' )
- ->rawParams( Utils::sanitizeString(
$options['content-type'] ) )
- ->escaped()
+ 'gwtoolset-mapping-media-file-no-content-type,'
.
+ $options['content-type']
);
}
@@ -415,8 +406,8 @@
if ( !( $result instanceof Title ) ) {
throw new GWTException(
- wfMessage( 'gwtoolset-title-bad' )
- ->params( $title )->parse()
+ 'gwtoolset-title-bad,' .
+ $title
);
}
@@ -456,16 +447,19 @@
) {
$result = null;
- if ( !empty( $_FILES[$metadata_file_upload]['name'] ) ) {
- $this->_File->populate( $metadata_file_upload );
- $Status = FileChecks::isUploadedFileValid(
$this->_File, Config::$accepted_metadata_types );
-
- if ( !$Status->ok ) {
- throw new GWTException( $Status->getMessage() );
- }
-
- $result = $this->_GWTFileBackend->saveFile(
$this->_File );
+ if ( empty( $_FILES[$metadata_file_upload]['name'] ) ) {
+ throw new GWTException( 'gwtoolset-no-file' );
}
+
+ $this->_File->populate( $metadata_file_upload );
+ $Status = FileChecks::isUploadedFileValid( $this->_File,
Config::$accepted_metadata_types );
+
+ if ( !$Status->ok ) {
+ throw new GWTException( $Status->getMessage() );
+ }
+
+ $result = $this->_GWTFileBackend->saveFile( $this->_File );
+
return $result;
}
@@ -509,7 +503,7 @@
if ( !$Title->isKnown() ) {
$Status = $this->uploadMediaFileViaUploadFromUrl(
$options, $Title );
} else {
- if ( $this->user_options['upload-media'] === true ) {
+ if ( $this->user_options['gwtoolset-reupload-media']
=== true ) {
// this will re-upload the mediafile, but will
not change the page contents
$Status =
$this->uploadMediaFileViaUploadFromUrl( $options, $Title );
}
@@ -522,7 +516,7 @@
}
if ( !$Status->isOK() ) {
- throw new GWTException( $Status->getWikiText() );
+ throw new GWTException( $Status->getMessage() );
}
return $Title;
@@ -688,10 +682,10 @@
);
}
- if ( !isset( $user_options['upload-media'] ) ) {
+ if ( !isset( $user_options['gwtoolset-reupload-media'] ) ) {
throw new MWException(
wfMessage( 'gwtoolset-developer-issue' )
- ->params( wfMessage(
'gwtoolset-no-upload-media' )->parse() )
+ ->params( wfMessage(
'gwtoolset-no-reupload-media' )->parse() )
->parse()
);
}
diff --git a/includes/Handlers/Xml/XmlDetectHandler.php
b/includes/Handlers/Xml/XmlDetectHandler.php
index 2e1194f..329c983 100644
--- a/includes/Handlers/Xml/XmlDetectHandler.php
+++ b/includes/Handlers/Xml/XmlDetectHandler.php
@@ -459,29 +459,10 @@
}
if ( empty( $this->_metadata_example_dom_element ) ) {
- $msg = wfMessage( 'gwtoolset-no-xml-element-found'
)->escaped() .
- Html::openElement( 'ul' ) .
- Html::rawElement(
- 'li',
- array(),
- wfMessage(
'gwtoolset-no-xml-element-found-li-1' )->escaped()
- ) .
- Html::rawElement(
- 'li',
- array(),
- wfMessage(
'gwtoolset-no-xml-element-found-li-2' )->rawParams(
- Html::rawElement(
- 'a',
- array(
- 'href'
=> 'http://www.w3schools.com/xml/xml_validator.asp',
-
'target' => '_blank'
- ),
- 'XML Validator'
- )
- )->escaped()
- ) .
- Html::closeElement( 'ul' ) .
+ $msg = 'gwtoolset-no-xml-element-found,' .
+
'http://www.w3schools.com/xml/xml_validator.asp' . PHP_EOL .
$this->_SpecialPage->getBackToFormLink();
+
throw new GWTException( $msg );
}
diff --git a/includes/Handlers/Xml/XmlHandler.php
b/includes/Handlers/Xml/XmlHandler.php
index e656e9e..98085f0 100644
--- a/includes/Handlers/Xml/XmlHandler.php
+++ b/includes/Handlers/Xml/XmlHandler.php
@@ -141,7 +141,7 @@
}
}
- throw new GWTException( wfMessage(
'gwtoolset-xml-doctype' ) );
+ throw new GWTException( 'gwtoolset-xml-doctype'
);
}
$read_result = $this->$callback( $XMLReader,
$user_options );
diff --git a/includes/Helpers/FileChecks.php b/includes/Helpers/FileChecks.php
index 76a66e5..0d18f09 100644
--- a/includes/Helpers/FileChecks.php
+++ b/includes/Helpers/FileChecks.php
@@ -36,7 +36,7 @@
&& ( (int)$_SERVER["CONTENT_LENGTH"] > Utils::getBytes(
ini_get('post_max_size') )
|| (int)$_SERVER["CONTENT_LENGTH"] >
Utils::getBytes( ini_get('upload_max_filesize') ) )
) {
- throw new GWTException( wfMessage(
'gwtoolset-over-max-ini' )->parse() );
+ throw new GWTException( 'gwtoolset-over-max-ini' );
}
}
diff --git a/includes/Models/Mapping.php b/includes/Models/Mapping.php
index 7b01544..cece2e6 100644
--- a/includes/Models/Mapping.php
+++ b/includes/Models/Mapping.php
@@ -99,9 +99,8 @@
}
throw new GWTException(
- wfMessage( 'gwtoolset-metadata-mapping-bad' )
- ->rawParams( $error_msg )
- ->parse()
+ 'gwtoolset-metadata-mapping-bad,' .
+ $error_msg
);
}
@@ -140,11 +139,11 @@
Utils::sanitizeString(
Config::$metadata_mapping_subpage ) .
'/user-name/file-name.json';
- $msg = wfMessage(
'gwtoolset-metadata-mapping-invalid-url' )
- ->rawParams( $url, $expected_path )
- ->escaped();
-
- throw new GWTException( $msg );
+ throw new GWTException(
+
'gwtoolset-metadata-mapping-invalid-url,' .
+ $url . ',' .
+ $expected_path
+ );
}
$result = $result[2];
@@ -171,9 +170,8 @@
if ( empty( $result ) ) {
throw new GWTException(
- wfMessage(
'gwtoolset-metadata-mapping-not-found' )
- ->params(
$options['gwtoolset-metadata-mapping-url'] )
- ->parse()
+ 'gwtoolset-metadata-mapping-not-found,'
.
+
$options['gwtoolset-metadata-mapping-url']
);
}
}
diff --git a/includes/Models/MediawikiTemplate.php
b/includes/Models/MediawikiTemplate.php
index ad84a8c..881555e 100644
--- a/includes/Models/MediawikiTemplate.php
+++ b/includes/Models/MediawikiTemplate.php
@@ -341,18 +341,14 @@
$result = null;
if ( empty(
$this->mediawiki_template_array['gwtoolset-title-identifier'] ) ) {
- throw new GWTException(
- wfMessage(
'gwtoolset-mapping-no-title-identifier' )
- ->escaped()
- );
+ throw new GWTException(
'gwtoolset-mapping-no-title-identifier' );
}
if ( empty( $options['evaluated-media-file-extension'] ) ) {
throw new GWTException(
- wfMessage(
'gwtoolset-mapping-media-file-url-extension-bad' )
- ->rawParams( Utils::sanitizeString(
$options['gwtoolset-url-to-the-media-file'] ) )
- ->escaped()
- );
+
'gwtoolset-mapping-media-file-url-extension-bad,' .
+ $options['gwtoolset-url-to-the-media-file']
+ );
}
if ( !empty( $this->mediawiki_template_array['title'] ) ) {
@@ -412,9 +408,7 @@
$this->mediawiki_template_name =
$mediawiki_template_name;
$this->retrieve();
} else {
- throw new GWTException(
- wfMessage(
'gwtoolset-metadata-invalid-template' )->escaped()
- );
+ throw new GWTException(
'gwtoolset-metadata-invalid-template' );
}
}
@@ -444,10 +438,9 @@
if ( empty( $result ) ) {
throw new GWTException(
- wfMessage(
'gwtoolset-mediawiki-template-not-found' )
- ->rawParams( Utils::sanitizeString(
$this->mediawiki_template_name ) )
- ->escaped()
- );
+ 'gwtoolset-mediawiki-template-not-found,' .
+ $this->mediawiki_template_name
+ );
}
$this->mediawiki_template_json =
$result['mediawiki_template_json'];
diff --git a/includes/Specials/SpecialGWToolset.php
b/includes/Specials/SpecialGWToolset.php
index 105b050..f107acf 100644
--- a/includes/Specials/SpecialGWToolset.php
+++ b/includes/Specials/SpecialGWToolset.php
@@ -118,15 +118,10 @@
} catch ( GWTException $e ) {
$html .=
Html::rawElement(
- 'h2',
- array(),
+ 'h2', array(),
wfMessage(
'gwtoolset-technical-error' )->escaped()
) .
- Html::rawElement(
- 'p',
- array( 'class' =>
'error' ),
- Utils::sanitizeString(
$e->getMessage() )
- );
+ Html::rawElement( 'p', array(
'class' => 'error' ), $e->getMessage() );
}
}
} else {
@@ -135,38 +130,23 @@
if ( !( $this->_Handler instanceof FormHandler
) ) {
$msg = wfMessage(
'gwtoolset-developer-issue' )
- ->params( wfMessage(
'gwtoolset-no-form-handler' )->escaped() )
+ ->params(
+ __METHOD__ . ': ' .
+ wfMessage(
'gwtoolset-no-form-handler' )->escaped()
+ )
->parse();
-
- if ( ini_get( 'display_errors' )
- && $this->getUser()->isAllowed(
'gwtoolset-debug' )
- ) {
- $msg .= Html::rawElement( 'br'
) .
- Html::rawElement(
- 'pre',
- array( 'style'
=> 'overflow:auto' ),
- print_r(
error_get_last(), true )
- );
- } else {
- $msg = wfMessage(
'gwtoolset-no-form-handler' )->escaped();
- }
throw new MWException( $msg );
}
$html .= $this->_Handler->execute();
} catch ( GWTException $e ) {
- if ( $e->getCode() === 1000 ) {
- throw new PermissionsError(
$e->getMessage() );
- } else {
- $html .=
- Html::rawElement(
- 'h2',
- array(),
- wfMessage(
'gwtoolset-file-interpretation-error' )->escaped()
- ) .
- Html::rawElement( 'p', array(
'class' => 'error' ), $e->getMessage() );
- }
+ $html .=
+ Html::rawElement(
+ 'h2', array(),
+ wfMessage(
'gwtoolset-file-interpretation-error' )->escaped()
+ ) .
+ Html::rawElement( 'p', array( 'class'
=> 'error' ), $e->getMessage() );
}
}
diff --git a/includes/Utils.php b/includes/Utils.php
index be300bf..286bf60 100644
--- a/includes/Utils.php
+++ b/includes/Utils.php
@@ -119,11 +119,7 @@
}
if ( strpos( $page_title, $wgServer ) !== false ) {
- throw new GWTException(
- wfMessage( 'gwtoolset-page-title-contains-url' )
- ->params( $page_title )
- ->parse()
- );
+ throw new GWTException(
'gwtoolset-page-title-contains-url,' . $page_title );
}
$Title = Title::newFromText( $page_title, $namespace );
@@ -137,13 +133,10 @@
) {
$Language = new Language();
throw new GWTException(
- wfMessage( 'gwtoolset-namespace-mismatch' )
- ->params(
- $page_title,
- $Language->getNsText(
$Title->getNamespace() ),
- $Language->getNsText(
$namespace )
- )
- ->parse()
+ 'gwtoolset-namespace-mismatch,' .
+ $page_title . ',' .
+ $Language->getNsText( $Title->getNamespace() )
. ',' .
+ $Language->getNsText( $namespace )
);
}
--
To view, visit https://gerrit.wikimedia.org/r/97676
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic5626703262e5782af90d30a3c9aff35a898f35c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/GWToolset
Gerrit-Branch: master
Gerrit-Owner: Dan-nl <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits