jenkins-bot has submitted this change and it was merged.
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(-)
Approvals:
Alex Monk: Looks good to me, approved
Jforrester: Looks good to me, but someone else must approve
jenkins-bot: Verified
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: merged
Gerrit-Change-Id: Iab06929d7e232a8ecd8eb1eff9d1190c303421c1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Catrope <[email protected]>
Gerrit-Reviewer: Alex Monk <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits