http://www.mediawiki.org/wiki/Special:Code/MediaWiki/88094
Revision: 88094
Author: hashar
Date: 2011-05-14 15:25:27 +0000 (Sat, 14 May 2011)
Log Message:
-----------
make the dialog disappear even if log write did not work.
When the wiki administrator did not install the wikilove_log table, the ajax
answer triggers an error and the dialog did not disappear.
This patch let the dialog disappear, even when logging did not happen. So you
can now skip updating the database <:-)
Modified Paths:
--------------
trunk/extensions/WikiLove/WikiLove.api.php
trunk/extensions/WikiLove/wikiLove.css
trunk/extensions/WikiLove/wikiLove.js
Modified: trunk/extensions/WikiLove/WikiLove.api.php
===================================================================
--- trunk/extensions/WikiLove/WikiLove.api.php 2011-05-14 15:18:37 UTC (rev
88093)
+++ trunk/extensions/WikiLove/WikiLove.api.php 2011-05-14 15:25:27 UTC (rev
88094)
@@ -62,7 +62,12 @@
'wl_message' => $text,
'wl_email' => 0,
);
- $dbw->insert( 'wikilove_log', $values, __METHOD__ );
+ try{
+ $dbw->insert( 'wikilove_log', $values, __METHOD__ );
+ } catch( DBQueryError $dbqe ) {
+ $this->dieUsage( 'Warning: action was not logged!',
'nologging' );
+ return false;
+ }
}
public function getAllowedParams() {
@@ -119,6 +124,10 @@
public function getPossibleErrors() {
return array_merge( parent::getPossibleErrors(), array(
array( 'invalidtitle', 'title' ),
+ array(
+ 'code' => 'nologging',
+ 'info' => 'Warning: action was not logged!'
+ ),
) );
}
Modified: trunk/extensions/WikiLove/wikiLove.css
===================================================================
--- trunk/extensions/WikiLove/wikiLove.css 2011-05-14 15:18:37 UTC (rev
88093)
+++ trunk/extensions/WikiLove/wikiLove.css 2011-05-14 15:25:27 UTC (rev
88094)
@@ -322,3 +322,7 @@
background-position: center;
background-repeat: no-repeat;
}
+
+#wikiLoveDialog .wlError {
+ color: red;
+}
Modified: trunk/extensions/WikiLove/wikiLove.js
===================================================================
--- trunk/extensions/WikiLove/wikiLove.js 2011-05-14 15:18:37 UTC (rev
88093)
+++ trunk/extensions/WikiLove/wikiLove.js 2011-05-14 15:25:27 UTC (rev
88094)
@@ -369,7 +369,7 @@
type: 'POST',
success: function( data ) {
mw.log( data );
- mw.log( mw.config.get( 'wgPageName' ) );
+ mw.log( 'wgPageName: ' + mw.config.get(
'wgPageName' ) );
if ( notify && $.wikiLove.emailable ) {
$.wikiLove.sendEmail(
$.wikiLove.currentTypeOrSubtype.title, $.wikiLove.currentTypeOrSubtype.message
);
@@ -377,12 +377,17 @@
$( '#wlPreview .wlSpinner' ).fadeOut( 200 );
- if ( data.redirect.pageName == mw.config.get(
'wgPageName' ) ) {
+ if ( typeof data.redirect !== 'undefined'
+ && data.redirect.pageName ==
mw.config.get( 'wgPageName' ) ) {
// unfortunately, when on the talk page
we cannot reload and then
// jump to the correct section, because
when we set the hash (#...)
// the page won't reload...
window.location.reload();
}
+ else if ( typeof data.error !== 'undefined' ) {
+ $( '<div class="wlError">' +
data.error.info + '<div>' ).insertBefore( '#wlSendForm' );
+ window.location.reload();
+ }
else {
window.location = mw.config.get(
'wgArticlePath' ).replace('$1', data.redirect.pageName)
+ data.redirect.fragment;
@@ -403,4 +408,4 @@
}
};
$.wikiLove.init();
-} ) ( jQuery );
\ No newline at end of file
+} ) ( jQuery );
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs