Skip to content

Conversation

@mambax7
Copy link
Collaborator

@mambax7 mambax7 commented Mar 10, 2025

fix for #1519: New block doesn't show

@mambax7 mambax7 requested a review from ForXoops March 10, 2025 08:21
@mambax7 mambax7 merged commit 16c0c83 into XOOPS:master Mar 10, 2025
4 checks passed
@ihackcode
Copy link
Contributor

Do we also need to handle module id -1 (_AM_SYSTEM_BLOCKS_TOPPAGE)

@mambax7
Copy link
Collaborator Author

mambax7 commented Mar 11, 2025

Good point! Any code suggestions? Could you make PR?

@ggoffy
Copy link
Contributor

ggoffy commented Mar 11, 2025

there is a problem: if we allow module id -1 or module id 0 without checking the module activeness then we have the same as in past time (blocks of inactive modules causing problems)
I will check it and try to find a solution

@ihackcode
Copy link
Contributor

I haven't looked into blocks for a while. Maybe we are handling module_id -1 correctly.

For the tables, is:

  • newblocks b ,is the blocks table
  • block_module_link m ,links the blocks to which module, and page they are shown
  • modules mo ,is the modules table.

b.mid of 0 are custom/new blocks?
m.module_id is what module the block should appear on. (specific module, all pages, top page)

@ggoffy
Copy link
Contributor

ggoffy commented Mar 12, 2025

the new code is fine. we have two possibilities:

  1. custom block, which is active ( WHERE b.isactive =' . $isactive . ' AND (mo.isactive =' . $isactive . ' OR b.mid = 0)';
  2. system or user block, which is active and where the module itself is active ( WHERE b.isactive =' . $isactive . ' AND (mo.isactive =' . $isactive . ' OR b.mid = 0)';

at this stage it doesn't matter where it is to show (top page, all pages,...) because this is handled by the next lines

@mambax7
Copy link
Collaborator Author

mambax7 commented Mar 12, 2025

How about this:

        $sql = 'SELECT b.* FROM ' . $db->prefix('newblocks') . ' b ' .
               'JOIN ' . $db->prefix('block_module_link') . ' m ON m.block_id = b.bid ' .
               'LEFT JOIN ' . $db->prefix('modules') . ' mo ON mo.mid = b.mid ' .
               'WHERE b.isactive = ' . $isactive . ' ' .
               'AND ( (b.mid = 0) OR (b.mid > 0 AND mo.mid IS NOT NULL AND mo.isactive = ' . $isactive . ') )';

This ensures:

  • Custom blocks (b.mid = 0) are always allowed, regardless of the modules table.
  • Module-specific blocks (b.mid > 0) only appear if their module exists (mo.mid IS NOT NULL) and is active (mo.isactive = 1).

Fixes the inactive module issue: blocks tied to inactive modules won’t show, even if m.module_id = -1 or 0.

@ggoffy
Copy link
Contributor

ggoffy commented Mar 12, 2025

more in detail, but it is very fine :)

@alain01
Copy link
Contributor

alain01 commented Mar 12, 2025

This request is crazy !!!
You've got a hell of level !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants