Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XOOPS reads blocks from deactivated modules #1335

Closed
mambax7 opened this issue Apr 14, 2023 · 9 comments
Closed

XOOPS reads blocks from deactivated modules #1335

mambax7 opened this issue Apr 14, 2023 · 9 comments
Assignees
Labels

Comments

@mambax7
Copy link
Collaborator

mambax7 commented Apr 14, 2023

I was getting the same error as in #1329

I deactivated all modules, but the error was still there. From the error report, I saw that it complained about a block from a deactivated module. I had to go and deactivate the block, and then the error went away.

We should make sure that XOOPS doesn't read any blocks from deactivated modules. It's a waste of time as it reads blocks that are not going to be displayed, but also it will continue to report errors, incl. fatal errors, even if we deactivate a module because it was buggy

@mambax7 mambax7 added the bug label Apr 14, 2023
@alain01
Copy link
Contributor

alain01 commented Apr 14, 2023

Nice find!

@GregMage
Copy link
Contributor

Indeed, this behaviour is not good.
Can you give me more details so that I can look at the problem in detail?

@mambax7
Copy link
Collaborator Author

mambax7 commented Apr 14, 2023

I didn't have the time to investigate it in detail, because the module was outdated, so I just wanted to get XOOPS to work.
But based on what I've experienced, I assume that you could do following:

  1. Select an installed module that has active blocks, and deactivate it
  2. Go to one of the module's block code, or to the block's template and introduce a fatal error
  3. Go to the front page and see if it works

In my case, it was crashing, until I went to the module's block and deactivated

If you can't replicate it this way, let me know, and I'll try to investigate in more depth on my end

@GregMage
Copy link
Contributor

Okay, I'll take a look and let you know if I have a problem

@GregMage GregMage self-assigned this Apr 14, 2023
@GregMage
Copy link
Contributor

I added an error in the templates of a block of the xmnews module and the site does not work anymore. I deactivate the module and the site works. I can't reproduce the problem...

@mambax7
Copy link
Collaborator Author

mambax7 commented Apr 14, 2023

OK, I'll take a look here this weekend.

@GregMage
Copy link
Contributor

GregMage commented May 1, 2023

Do you have any other information? Because I couldn't reproduce your problem!

@mambax7
Copy link
Collaborator Author

mambax7 commented May 1, 2023

Still on my TODO list, and didn't have the time to get to it yet :(

@mambax7
Copy link
Collaborator Author

mambax7 commented Jan 8, 2025

@GregMage

OK, I finally was able to identify the issue - the problem was in this method in \kernel\block.php:

public function getAllByGroupModule($groupid, $module_id = 0, $toponlyblock = false, $visible = null, $orderby = 'b.weight, m.block_id', $isactive = 1)

in this query:

$sql = 'SELECT b.* FROM ' . $db->prefix('newblocks') . ' b, ' . $db->prefix('block_module_link') . ' m WHERE m.block_id=b.bid';
$sql .= ' AND b.isactive=' . $isactive;

because it was selecting all blocks in the newblocks table that were set as active in the "isactive" column, regardless of whether the module was active or not.
When the module was not active but XOOPS was trying to display a block from that module, then XOOPS was crashing.

Once I've added a check if the module is active:

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

it is working now correctly.

Next step is to check if there are any parts of XOOPS or XOOPS modules that use this method and if it breaks them

If you could do any tests on your part, that would be great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants