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:1304
Procedure
To fix the issue, one can do the following:
Modify lib/tiki-js.js
line 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
//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 statement
} else { meta.params = $.extend(onlymod.params, tiki_module_params[selectedMod].params, meta.params); meta.params.module.description = tiki_module_params[selectedMod].description; }
to
} 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 from lib/tiki-js.js
will 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
.
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
To help developers solve the bug, we kindly request that you demonstrate your bug on a show2.tiki.org instance. To start, simply select a version and click on "Create show2.tiki.org instance". Once the instance is ready (in a minute or two), as indicated in the status window below, you can then access that instance, login (the initial admin username/password is "admin") and configure the Tiki to demonstrate your bug. Priority will be given to bugs that have been demonstrated on show2.tiki.org.
Unable to connect to show.tikiwiki.org. Please let us know of the problem so that we can do something about it. Thanks.
filename | created | hits | comment | version | filetype | ||
---|---|---|---|---|---|---|---|
No attachments for this item |