Catrope has uploaded a new change for review.
https://gerrit.wikimedia.org/r/177086
Change subject: Make LinkCache fail more gracefully when given undefined
......................................................................
Make LinkCache fail more gracefully when given undefined
If you tried to do styleElement( undefined, $element ), you'd
get an exception in the mw.Title constructor from a setTimeout.
That's not very nice, and there's no point sending non-strings
through the queue and other data structures in LinkCache, so
instead just make get() return a rejected promise when given
non-string values.
Change-Id: Iab06929d7e232a8ecd8eb1eff9d1190c303421c1
---
M modules/ve-mw/init/ve.init.mw.LinkCache.js
1 file changed, 6 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor
refs/changes/86/177086/1
diff --git a/modules/ve-mw/init/ve.init.mw.LinkCache.js
b/modules/ve-mw/init/ve.init.mw.LinkCache.js
index 5df146f..87b85a3 100644
--- a/modules/ve-mw/init/ve.init.mw.LinkCache.js
+++ b/modules/ve-mw/init/ve.init.mw.LinkCache.js
@@ -62,6 +62,12 @@
* @returns {jQuery.Promise} Promise that will be resolved with the
data once it's available
*/
ve.init.mw.LinkCache.prototype.get = function ( name ) {
+ if ( typeof name !== 'string' ) {
+ // Don't bother letting things like undefined or null
make it all the way through,
+ // just reject them here. Otherwise they'll cause
problems or exceptions at random
+ // other points in this file.
+ return $.Deferred().reject().promise();
+ }
if ( !hasOwn.call( this.cache, name ) ) {
this.cache[name] = $.Deferred();
this.queue.push( name );
--
To view, visit https://gerrit.wikimedia.org/r/177086
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iab06929d7e232a8ecd8eb1eff9d1190c303421c1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Catrope <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits