1
rlankford
2.0.16 Block Bug (with fix)
  • 2007/6/27 15:56

  • rlankford

  • Not too shy to talk

  • Posts: 158

  • Since: 2004/8/27


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.

2
rlankford
Re: 2.0.16 Block Bug (with fix)
  • 2007/6/27 16:14

  • rlankford

  • Not too shy to talk

  • Posts: 158

  • Since: 2004/8/27


Quote:

Please remember to report the bug here as well


Got it (link).

Thanks!

3
Dave_L
Re: 2.0.16 Block Bug (with fix)
  • 2007/6/27 16:37

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


Thanks for the report. I added a reply there with a slightly different fix, using "foreach" instead of "for", so that the array indices are ignored completely.

4
rlankford
Re: 2.0.16 Block Bug (with fix)
  • 2007/6/27 16:56

  • rlankford

  • Not too shy to talk

  • Posts: 158

  • Since: 2004/8/27



Login

Who's Online

401 user(s) are online (268 user(s) are browsing Support Forums)


Members: 0


Guests: 401


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits