I gotta believe this has been mentioned somewhere else already ... but I couldn't find it so I am posting anyway.
I'm writing a module with a simple block defined in my module's xoops_version.php:
// options[0] - NumberToDisplay: any positive integer
// This example has only 1 block option. Multiple options are separated with the pipe ("|") character.
$modversion['blocks'][] = array(
'file' => 'b_sm_newwidgets.php',
'name' => _MI_BLOCK_NAME_1,
'description' => _MI_BLOCK_DESC_1,
'show_func' => 'b_sm_newwidgets_show',
'template' => 'b_sm_newwidgets.html',
'edit_func' => 'b_sm_newwidgets__edit',
'options' => '4');
Installing the module goes fine. Then, when updating the module, I get a message about my block template being deprecated. The block is then removed. I have to uninstall and reinstall the module to get the block to show back up again. Trying to update the module again doesn't work since the block was removed during the previous update attempt.
What's the problem? Well, the fact that I'm appending my block definition onto the 'block' array above means that it is in the zeroth position (since I only have 1 block defined). This block is getting skipped by the update process (Note: but not by the installation process). You can find the following code around line 337 of file 'xoops\modules\system\admin\modulesadmin\main.php':
for ( $i = 1; $i <= $count; $i++ ) {
The loop that checks the blocks starts looking at array position 1. Since the install process starts at 0 (and correctly installs the block initially), I presume this to be a bug here during the update process.
Instead, the line should look like this:
for ( $i = 0; $i <= $count; $i++ ) {
After making this change, my module seems to install, update, and uninstall correctly without incident.
I know XOOPS development seems to have stopped, but if a new version is ever released, please consider making this small change to the core.