Mattflaschen has uploaded a new change for review. https://gerrit.wikimedia.org/r/210749
Change subject: Allow customizing Flow AJAX timeout ...................................................................... Allow customizing Flow AJAX timeout Change-Id: I8264f2b2e5558b2291130407546fc8b1a753e593 --- M Flow.php M Hooks.php M modules/engine/misc/flow-api.js 3 files changed, 16 insertions(+), 6 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow refs/changes/49/210749/1 diff --git a/Flow.php b/Flow.php index e58ce32..717fe7a 100644 --- a/Flow.php +++ b/Flow.php @@ -377,6 +377,9 @@ $wgFlowAbuseFilterEmergencyDisableCount = 50; $wgFlowAbuseFilterEmergencyDisableAge = 86400; // One day. +// Timeout for Flow's AJAX requests (only affects ones that go through flow-api.js), in seconds +$wgFlowAjaxTimeout = 30; + // Actions that must pass through to MediaWiki on Flow-enabled pages $wgFlowCoreActionWhitelist = array( 'info', 'protect', 'unprotect', 'unwatch', 'watch', 'history', 'wikilove', 'move', 'delete' ); diff --git a/Hooks.php b/Hooks.php index 83e72e8..245bca3 100644 --- a/Hooks.php +++ b/Hooks.php @@ -588,13 +588,14 @@ return true; } - // Static variables that do not vary by request + // Static variables that do not vary by request; delivered through startup module public static function onResourceLoaderGetConfigVars( &$vars ) { - global $wgFlowEditorList; + global $wgFlowEditorList, $wgFlowAjaxTimeout; $vars['wgFlowEditorList'] = $wgFlowEditorList; $vars['wgFlowMaxTopicLength'] = Flow\Model\PostRevision::MAX_TOPIC_LENGTH; $vars['wgFlowMentionTemplate'] = wfMessage( 'flow-ve-mention-template' )->inContentLanguage()->plain(); + $vars['wgFlowAjaxTimeout'] = $wgFlowAjaxTimeout; return true; } diff --git a/modules/engine/misc/flow-api.js b/modules/engine/misc/flow-api.js index d87ac01..1256d80 100644 --- a/modules/engine/misc/flow-api.js +++ b/modules/engine/misc/flow-api.js @@ -40,18 +40,24 @@ */ function flowApiCall( params, method ) { var mwApi, tokenType, - $deferred = $.Deferred(); + $deferred = $.Deferred(), + ajaxTimeoutSec = mw.config.get( 'wgFlowAjaxTimeout' ), + apiConstructorParams = { ajax: {} }; + + if ( ajaxTimeoutSec !== null && ajaxTimeoutSec > 0 ) { + apiConstructorParams.ajax.timeout = ajaxTimeoutSec * 1000; + } // IE8 caches POST under some conditions, prevent that here. // IE8 is most likely the only browser we support that doesn't // have addEventListener, and anything else that gets caught // up isn't that bad off. if ( !document.addEventListener ) { - mwApi = new mw.Api( { ajax: { cache: false } } ); - } else { - mwApi = new mw.Api(); + apiConstructorParams.ajax.cache = false; } + mwApi = new mw.Api( apiConstructorParams ); + params = params || {}; // Server is using page instead of title // @todo this should not be necessary -- To view, visit https://gerrit.wikimedia.org/r/210749 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8264f2b2e5558b2291130407546fc8b1a753e593 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Flow Gerrit-Branch: master Gerrit-Owner: Mattflaschen <mflasc...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits