SOLVED Unable to Perform Module Updates

Joined
Mar 10, 2025
Messages
27
Reaction score
3
When running almost any command that starts with "fwconsole ma", I encounter this error:

In modulefunctions.class.php line 215:
foreach() argument must be of type array|object, bool given

followed by what appears to be usage options for the moduleadmin command. Here is a screenshot of what the error looks like:

1793285144551.png

I run OS (Debian-based -- LMDE) and module updates once a day, and this is the first time I remember encountering this issue. Has anyone seen this before? Has the syntax for the command changed? Is something broken on my end?
 
I ran into this today working on a module.

I think I have pinpointed it to Clearly IP repo.

The error occurs when FreePBX retrieves security-advisory information from the ClearlyIP repository. The response contains an empty entry that FreePBX interprets as a boolean instead of a list. When FreePBX tries to process that value, it raises the “foreach() argument must be of type array|object, bool given” error.

Because Module Admin performs this check for different modules, the same repository-response problem can interrupt installations and updates across the system.

@wardmundy @Tonyclewis
 
If the error remains in the GUI, this will clear it out:


Bash:
php <<'PHP'
<?php
require '/etc/freepbx.conf';
$pdo = FreePBX::Database();
$row = $pdo->query("SELECT * FROM module_xml WHERE id='security'")
    ->fetch(PDO::FETCH_ASSOC);
$data = json_decode($row['data'] ?? '', true);

if (!is_array($data) || !array_key_exists('issue', $data) || $data['issue'] !== false) {
    exit("Cache does not contain the diagnosed value; nothing changed.\n");
}

umask(0077);
$backup = '/root/freepbx-security-cache-'.date('Ymd-His').'.json';
if (file_put_contents($backup, json_encode($row)) === false) {
    exit("Backup failed; nothing changed.\n");
}

$data['issue'] = [];
$stmt = $pdo->prepare("UPDATE module_xml SET data=? WHERE id='security'");
$stmt->execute([json_encode($data)]);
echo "Security cache repaired. Backup: $backup\n";
PHP
 
Here is @KNERD fix converted into self-executing script. Download it here. Then make it executable and run it.
That is only to make the error go away. Once you run the the "fwconole ma" command and that error appears, it is stuck forever. My script only gets rid of the error. But once you try to run the "fwconsole am updateall" again it will reappear.

ClearlyIP needs to fix their repo and why I tagged Tony.
 
It seems that the problem has been corrected and all is OK now. I've run the command-line "fwconsole ma upgrade" command on my installations without issue today. These systems are iPBX2026 and iPBX2027 - no issues. I have an old iPBX 2020.1 (Asterisk 18.7, GUI 15.0.22.39, CentOS 7) as well as the newer systems. ALL of them exhibited the error that the OP had posted yesterday. All now report "Up to Date".
(And I KNOW that the old 2020.1/CentOS7 system should be upgraded, but there are some tools that are installed on that VPS that will require some time to move to an upgraded Debian13 system.)
 
Sorry that I haven't gotten back to this until now.

I didn't get to see the initial Php snippet until 2am, the morning after it was posted.

It's been a bit hectic this week for me.

But it seems that the issue resolved itself. ClearlyIP repo issue?
 

Forum statistics

Threads
26,848
Messages
175,536
Members
20,393
Latest member
mchiampo
Get 3CX - Absolutely Free!

Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.
Back
Top