From 3786d3679cd5acd20138054f8dde3ce7a6f1ca23 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Tue, 27 Dec 2016 11:57:46 -0500 Subject: [PATCH] FIX: Always return the latest API version requested --- app/assets/javascripts/discourse.js.es6 | 2 +- app/assets/javascripts/discourse/lib/plugin-api.js.es6 | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse.js.es6 b/app/assets/javascripts/discourse.js.es6 index 140cb5f7eac..5ca85473c5b 100644 --- a/app/assets/javascripts/discourse.js.es6 +++ b/app/assets/javascripts/discourse.js.es6 @@ -137,7 +137,7 @@ const Discourse = Ember.Application.extend({ Discourse.instanceInitializer({ name: "_discourse_plugin_" + (++initCount), after: 'inject-objects', - initialize: function() { + initialize() { withPluginApi(cb.version, cb.code); } }); diff --git a/app/assets/javascripts/discourse/lib/plugin-api.js.es6 b/app/assets/javascripts/discourse/lib/plugin-api.js.es6 index 7419562b747..b8beb0020d9 100644 --- a/app/assets/javascripts/discourse/lib/plugin-api.js.es6 +++ b/app/assets/javascripts/discourse/lib/plugin-api.js.es6 @@ -361,6 +361,11 @@ function getPluginApi(version) { if (!_pluginv01) { _pluginv01 = new PluginApi(version, Discourse.__container__); } + + // We are recycling the compatible object, but let's update to the higher version + if (_pluginv01.version < version) { + _pluginv01.version = version; + } return _pluginv01; } else { console.warn(`Plugin API v${version} is not supported`);