When In my backend of joomla site I go to System -> Database I get the error:
An error has occurred.
0 count(): Argument #1 ($value) must be of type Countable|array, false given
The backend System Database menu is shown properly
Error trace:
0 count(): Argument #1 ($value) must be of type Countable|array, false given
Call Stack
1 () JROOT/libraries/src/Schema/ChangeItem/MysqlChangeItem.php:61
2 Joomla\CMS\Schema\ChangeItem\MysqlChangeItem->buildCheckQuery() JROOT/libraries/src/Schema/ChangeItem.php:132
3 Joomla\CMS\Schema\ChangeItem->__construct() JROOT/libraries/src/Schema/ChangeItem.php:156
4 Joomla\CMS\Schema\ChangeItem::getInstance() JROOT/libraries/src/Schema/ChangeSet.php:84
5 Joomla\CMS\Schema\ChangeSet->__construct() JROOT/administrator/components/com_installer/src/Model/DatabaseModel.php:192
6 Joomla\Component\Installer\Administrator\Model\DatabaseModel->fetchSchemaCache() JROOT/administrator/components/com_installer/src/Model/DatabaseModel.php:307
7 Joomla\Component\Installer\Administrator\Model\DatabaseModel->getItems() JROOT/administrator/components/com_installer/src/View/Database/HtmlView.php:92
8 Joomla\Component\Installer\Administrator\View\Database\HtmlView->display() JROOT/administrator/components/com_installer/src/Controller/DisplayController.php:75
9 Joomla\Component\Installer\Administrator\Controller\DisplayController->display() JROOT/libraries/src/MVC/Controller/BaseController.php:730
10 Joomla\CMS\MVC\Controller\BaseController->execute() JROOT/libraries/src/Dispatcher/ComponentDispatcher.php:143
11 Joomla\CMS\Dispatcher\ComponentDispatcher->dispatch() JROOT/libraries/src/Component/ComponentHelper.php:361
12 Joomla\CMS\Component\ComponentHelper::renderComponent() JROOT/libraries/src/Application/AdministratorApplication.php:150
13 Joomla\CMS\Application\AdministratorApplication->dispatch() JROOT/libraries/src/Application/AdministratorApplication.php:205
14 Joomla\CMS\Application\AdministratorApplication->doExecute() JROOT/libraries/src/Application/CMSApplication.php:304
15 Joomla\CMS\Application\CMSApplication->execute() JROOT/administrator/includes/app.php:58
16 require_once() JROOT/administrator/index.php:32
Joomla version 5.3.1 and PHP Version 8.3.12
I think the lines
61 -> if (\count($wordArray) < 5) {
should be changed to:
if (\count((array)$wordArray) < 5) {
I think the line
82 -> if (\count($wordArray) < 6) {
should be changed to:
if (\count((array)$wordArray) < 6) {
Labels |
Removed:
?
|
Labels |
Added:
No Code Attached Yet
|
How to check the database version and manifest version? Could you guide me??
administrator/logs -> joomla_update.php
The current database version (schema) is 5.2.2-2024-09-24.
Look for something like:
Ran query from file ...
End of SQL updates.
...
Update to version ... is complete.
https://docs.joomla.org/J4.x:Pre-Update_Check
https://docs.joomla.org/Joomla_4.4.x_to_5.x_Planning_and_Upgrade_Step_by_Step
Contains information about activities to be performed before the upgrade.
See especially those related to database maintenance.
**Is in catalan:
**
INFO 172.18.1.136 update The current database version (schema) is 5.2.2-2024-09-24.
2025-05-28T12:47:11+00:00 update Executada petició de larxiu 5.2.3-2025-01-09. Text de la petició: UPDATE
#__mail_templatesSET
params = '{"tags":["messages","message","date",. 2025-05-28T12:47:11+00:00 update Executada petició de l
arxiu 5.3.0-2024-10-13. Text de la petició: ALTER TABLE #__fields
MODIFY fieldparams
MEDIUMTEXT NOT NULL;.
2025-05-28T12:47:11+00:00 update Executada petició de larxiu 5.3.0-2024-10-26. Text de la petició: CREATE TABLE IF NOT EXISTS
#__scheduler_logs(
id int unsigned NOT NULL AU. 2025-05-28T12:47:11+00:00 update Executada petició de l
arxiu 5.3.0-2024-12-09. Text de la petició: INSERT INTO #__action_log_config
(type_title
, type_alias
, id_holder
, ti. 2025-05-28T12:47:11+00:00 update Executada petició de l
arxiu 5.3.0-2025-02-09. Text de la petició: ALTER TABLE #__action_logs_users
DROP COLUMN exclude_self
;.
2025-05-28T12:47:11+00:00 update Executada petició de larxiu 5.3.0-2025-02-22. Text de la petició: INSERT INTO
#__extensions (
package_id,
name,
type,
element,
folder, . 2025-05-28T12:47:11+00:00 update Executada petició de l
arxiu 5.3.0-2025-03-14. Text de la petició: UPDATE #__guidedtours
SET autostart
= 0 WHERE uid
= 'joomla-whatsnew-5-2';.
2025-05-28T12:47:11+00:00 update Executada petició de larxiu 5.3.0-2025-03-14. Text de la petició: INSERT INTO
#__guidedtours (
title,
description,
extensions,
url,
publ.
2025-05-28T12:47:11+00:00 update Executada petició de larxiu 5.3.0-2025-03-14. Text de la petició: INSERT INTO
#__guidedtour_steps (
title,
description,
position,
target`,.
We did the steps in documentation to migrate.
Any new about this issue??
@aberenguer78 It would be good to know what's in $wordArray after line 57. Could you check that?
Labels |
Added:
Information Required
|
I can not check because I can not modify the code of a joomla core class in our development server in local I don't have the issue.
I have suggested a solution to the issue. Is related to the treatment of arrays and new versions of PHP I think. You should always check possible errors.
I have given a response to your information required. I have a question, are you going to include in a new release of joomla the libraries class that is giving this issue with some solution as the provided?
Nothing will be done unless the bug can be replicated. php 8.3.12 is not a new version of php so it is unlikely to be related to that version of php
You say it only has a problem on your live site and not on your development server. Are they both using the same version of php?
What about the sql versions on those servers
PHP 8.3.12 is not a new version of php I'm not saying that. What I'm saying is that in version 8 the arrays are treated in a different way.
The versions of PHP in local and development are the same and also database version:
Setting Value
PHP Built On Linux slx107 6.1.0-26-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.112-1 (2024-09-30) x86_64
Database Type mysql
Database Version 10.11.6-MariaDB-0+deb12u1
Database Collation utf8mb3_general_ci
Database Connection Collation utf8mb4_general_ci
Database Connection Encryption None
Database Server Supports Connection Encryption No
PHP Version 8.3.12
Web Server Apache
WebServer to PHP Interface fpm-fcgi
Joomla! Version Joomla! 5.3.1 Stable [ Timu ] 27-May-2025 16:00 GMT
Joomla Backward Compatibility Plugin Enabled ()
User Agent Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0
The versions of PHP in local and development are the same and also database version:
Then how can your problem be because of the php version. If it was then you would have the same error on both
No because the scripts for migration of database probably are different
Error trace:
0 count(): Argument #1 ($value) must be of type Countable|array, false given
Call Stack
1 () JROOT/libraries/src/Schema/ChangeItem/MysqlChangeItem.php:61
@aberenguer78 This can only happen if the file was modified by someone or something (virus scanner?) or there are weird PHP settings regarding regular expressions (but I can't imagine any setting doing that, except of having preg_split
in the list of prohibited PHP functions, which would be really weird).
If you check the code of that file here https://github.com/joomla/joomla-cms/blob/5.3-dev/libraries/src/Schema/ChangeItem/MysqlChangeItem.php#L57-L64 you will see that the statement before line 61 is a call to preg_split
.
That returns only false if an error happens because the first parameter does not resolve to a valid regular expression.
See the PHP documentation here: https://www.php.net/manual/en/function.preg-split.php
You can also try the following code piece from MysqlChangeItem.php in PHP sandbox here https://onlinephp.io/ :
<?php
$find = ['#((\s*)\(\s*([^)\s]+)\s*)(\))#', '#(\s)(\s*)#'];
$replace = ['($3)', '$1'];
$updateQuery = preg_replace($find, $replace, 'BLABLA');
$wordArray = preg_split("~'[^']*'(*SKIP)(*F)|\s+~u", trim($updateQuery, "; \t\n\r\0\x0B"));
var_dump($wordArray);
Replace the 'BLABLA'
by any string which comes into your mind, or by an empty string or null
or false
.
In any case you will get an array, in case of an empty string or null
or false
it will always be an array with one element which is an empty string.
Only if you modify the regular expression pattern "~'[^']*'(*SKIP)(*F)|\s+~u"
you will get $wordArray
being boolean false
.
So if possible please download the libraries/src/Schema/ChangeItem/MysqlChangeItem.php
file from the server where you have the problem - you should be able to do that, e.g. with ftp or with the provider's web space UI, otherwise you would not have been able to upload the Joomla installation package there - and compare that file with the same file from your local environment where you don't have the issue, and report back the result.
Thanks in advance.
No because the scripts for migration of database probably are different
@aberenguer78 No, they are not different for different PHP versions.
P.S.: The regular expression pattern used for the preg_split
call has not been changed since it has been introduced 7 years ago with PR #17351 , and as said, preg_split
only returns false if the regular expression pattern is not valid, so we should have gotten a gazillion of issue reports for this in the last 7 years if that was the case.
Hello Richard I explained before but for policies of the company I can not download this file or modify to do a var_dump and send you the result. The only thing I have been suggesting from the beginning that when the function returns false in $wordArray you are doing a count and that produces an exception so I think it should be checked in code:
61 -> if (\count($wordArray) < 5) {
should be changed to:
if (\count((array)$wordArray) < 5) {
Thanks, please do not ask me again to send code, I can not send more information about this issue if no I had been done before, thanks in advance and have a good day.
As explained before there is nothing further we can do
We should definitely not change the code as suggested because that would mask an error which ONLY can happen when the regular expression pattern in the file was modified.
We haven't changed any regular expression in the file, we don't modify the joomla core code
We haven't changed any regular expression in the file, we don't modify the joomla core code
@aberenguer78 But how can you be sure that the file has not been modified by someone else or something else like e.g. a virus scanner if you can't check the file?
I have checked the original file from the download code of Joomla 5 core files with winmerge and the code is the same.
I have checked the original file from the download code of Joomla 5 core files with winmerge and the code is the same.
I've investigated deeper and found out that preg_split also returns false if the regexp is used in UTF-8 mode (which is the case) and the string to be split contains invalid unicode sequences, or if some PHP limits are exceeded. See the return values documented here for the different possibilities: https://www.php.net/manual/en/function.preg-last-error.php .
@aberenguer78 Could you let us know which 3rd party extensions you have installed on that site?
Beginning with Joomla 4, the database checker checks not only the core but also 3rd party extensions which come with update SQL scripts.
It is very unlikely that an update SQL script of the CMS core causes that issue, otherwise we would have lots of reports.
So either a core update SQL script has been modified, or it is an update SQL script of a 3rd party extension which causes the issue.
Hello @richard67 one thing we have done is disable all the extensions that are custom or not original from Joomla application, and specially the pluguins and components but we still have the problem. thanks
Hello @richard67 one thing we have done is disable all the extensions that are custom or not original from Joomla application, and specially the pluguins and components but we still have the problem. thanks
@aberenguer78 Disable the extensions does not prevent them to be checked in the database checker if these extensions have update SQL scripts. So again: Please tell us which extensions you have.
@richard67 as they have stated they have custom extensions installed and we obviously cannot debug those nothing @aberenguer78 will say will be of any use. This issue is clearly not a core issue and should be closed. This is not the place to provide custom support
@brianteeman If I knew what causes the error I could maybe improve error handling for that case in the schema checker, including a useful error message.
Just ignoring the complete script like it would be with @aberenguer78 's suggested code is not really a good solution.
@aberenguer78 What also could be helpful: Search for files with name suffix ".sql" which are not located in folder administrator/components/com_admin/sql/updates/mysql
or administrator/components/com_admin/sql/updates/postgresql
, and then download these files, pack them into a zip and provide a download for me. You can send me the download information by email to richard.fath<at>t-online.de
. If you can compare the file from your site with winmerge you should also be able to download files.
Hello @richard67 thanks for your help, the problem we have is that we don't have permisions to access and download this scripts in development environment. We have only access to them locally but in local environment I'm not having the issue.
What database version (Database Version and Manifest Version) does Joomla show? Maybe the structure needs to be updated?