PluginModule interface Crash on Custom Module Insert
- Status
- Closed
- Subject
- PluginModule interface Crash on Custom Module Insert
- Version
- 10.x
11.x - Category
- Usability
- Feature
- Modules
Wiki Plugin (extends basic syntax) - Resolution status
- New
- Submitted by
- jcarter
- Volunteered to solve
- manivannans
- Lastmod by
- Pascal St-Jean
- Rating
- Description
Summary
The plugin for inserting modules into a wiki page has a bug where it crashes whenever it encounters custom modules. The following JS applies some duct-tape to the issue, and prevents the crash. I didn't get too deep into the workings of it, just got it to work. Someone who has worked on it before probably has a better understanding of the whole system, and could determine if this was the way to do it or not (the change could have cascading effects on behavior of pluginModule and how it deals with custom modules?)Note: crash outputs the following error in js console:
Uncaught TypeError: Cannot read property 'params' of undefined tiki-js.js:1304Procedure
To fix the issue, one can do the following:Modify
lib/tiki-js.jsline 1303. Change the else statement to an else if, checking for the undefined object which would break things.Note that the code in the examples below if from tiki 10, not 11, and may be a little bit different in 11, but the problem remains in 11 and the line changed is the same, and fixes it in 11 too.
So, in this block
Copy to clipboard//For PluginModule, add selected module parameters to the plugin edit form if (type == 'module') { //isolate the module parameter object so it will be shown first in the form var onlymod = {"params":{"module": meta.params.module}}; //user has not changed the module selection since opening the form if (typeof selectedMod == 'undefined') { //pick up the parameters of the saved module parameter if (typeof pluginArgs.module != 'undefined') { //this orders the module parameter first, module related parameters second, other PluginModule parameters besides module last meta.params = $.extend(onlymod.params, tiki_module_params[pluginArgs.module].params, meta.params); //Use the module description meta.params.module.description = tiki_module_params[pluginArgs.module].description; //otherwise pick up the parameters of the first module option since that will be selected automatically } else { meta.params = $.extend(onlymod.params, tiki_module_params[meta.params.module.options[0].value].params, meta.params); meta.params.module.description = tiki_module_params[meta.params.module.options[0].value].description; } //user has selected another module while the form was open - pick up parameters for the selected module } else { meta.params = $.extend(onlymod.params, tiki_module_params[selectedMod].params, meta.params); meta.params.module.description = tiki_module_params[selectedMod].description; } }
change this statementCopy to clipboard} else { meta.params = $.extend(onlymod.params, tiki_module_params[selectedMod].params, meta.params); meta.params.module.description = tiki_module_params[selectedMod].description; }
toCopy to clipboard} else if (typeof tiki_module_params[selectedMod] != 'undefined') { meta.params = $.extend(onlymod.params, tiki_module_params[selectedMod].params, meta.params); meta.params.module.description = tiki_module_params[selectedMod].description; }
Context
The issue is caused because the module plugin tries to get the parameters for the object to display in the interface, but for custom modules there are none. The tiki_module_params object stores a parameters object for each module as the value for an attribute named after the module (e.g.,tiki_module_params[mymodule]would return the params object for[mymodule]). The problem is that the if there are no parameters for the object, it sets the value for the module attribute to false, and the unmodified else statement above fromlib/tiki-js.jswill try to read the attribute .params from the false object, which will fail, and the js will crash.Another possible solution to this issue could be to populate the value as an empty object instead of false, in
tiki-jsmodule.php.- Solution
I had fixed "pluginModule interface Crash" issue in 12.x.
Please check this commit id: 48363
Thanks jcarter.
Updated:
commit backported to 11.x and 10.x
11.x -> commit id: 48657
10.x -> commit id: 48658- Importance
- 8
- Easy to solve?
- 8
- Priority
- 64
- Demonstrate Bug on Tiki 19+
-
This bug has been demonstrated on show2.tiki.org
Please demonstrate your bug on show2.tiki.org
- Demonstrate Bug (older Tiki versions)
-
This bug has been demonstrated on show.tikiwiki.org
Please demonstrate your bug on show.tikiwiki.org
Show.tiki.org is currently unavailableUnable to connect to show.tikiwiki.org. Please let us know of the problem so that we can do something about it. Thanks.
- Ticket ID
- 4668
- Created
- Monday 19 August, 2013 19:50:26 UTC
by jcarter - LastModif
- Saturday 23 November, 2013 22:33:33 UTC