Articles in this section

Unable to scan websites with Joomla! Toolkit: Array size are inconsistent

kb: technical ext: jtk joomla

Before opening a 3rd line: Ask customer if they had customized Joomla plugins.
Ask customer if and how they removed Joomla extensions?

Symptoms

  • Unable to scan websites in Joomla! Toolkit from Joomla! > Find Joomla! Websites with the following error in Plesk Panel:

    The task ext-joomla-toolkit\scan failed
    Array size are inconsistent

  • The following error shows up in /var/log/plesk/panel.log:

    DEBUG [extension/joomla-toolkit] [64a6caae2979d] Starting: '/opt/psa/admin/bin/filemng' 'jdoe' 'exec' '/var/www/vhosts/example.com/httpdocs' '/opt/plesk/php/8.0/bin/php' '-d' 'open_basedir=' '/opt/psa/admin/plib/modules/joomla-toolkit/vendor/joomlatools/console/bin/joomla' 'site:extensions' '--www=/var/www/vhosts/example.com' 'httpdocs', stdin:


    ERR [panel] Task failed: id=2193, pid=15460, type=ext-joomla-toolkit-task\scan, error=Array sizes are inconsistent, clientRemoteAddr=203.0.113.2, referrer=/modules/joomla-toolkit/index.php/index/index, runTaskUnderLogin=admin 
    ERR [panel] ValueError: Array sizes are inconsistent

  • Joomla! Toolkit scheduled tasks may fail with the same error, for example:

    Task "/usr/local/psa/admin/bin/php -dauto_prepend_file=sdk.php '/usr/local/psa/admin/plib/modules/joomla-toolkit/scripts/update-cache.php'" completed with error in 2 seconds, output:
    ERROR: ValueError: Array sizes are inconsistent (Extensions.php:86)

Cause

There is one or more records on the <prefix>_extensions table with empty name values within the Joomla! site database.

Resolution

  1. Login into Plesk
  2. Navigate to Domains > example.com > Databases and identify the name of the Joomla instance database.
  3. Create a database backup dump as instructed here
  4. Connect to the server via SSH
  5. Use the database name from the previous steps to check for the database prefix as follows:  e.g. ji0w5

    # plesk db "SHOW TABLES FROM example_joomladb WHERE Tables_in_example_joomladb LIKE '%extensions%';"
    +-------------------------------+ 
    | Tables_in_example_joomladb
    +-------------------------------+ 
    | ji0w5_action_logs_extensions | 
    | ji0w5_extensions | 
    | ji0w5_update_sites_extensions | 
    +-------------------------------+ 
     

  6. Look for any empty name value of the prefix_extensions table using the Joomla! database and its prefix as follow:

    # plesk db "SELECT extension_id, name, type FROM example_joomladb.ji0w5_extensions WHERE name LIKE '';"
    +--------------+------+---------+ 
    | extension_id | name | type | 
    +--------------+------+---------+ 
    | 321 |  |   | 
    +--------------+------+---------+ 
    1 row in set (0.001 sec)

  7. Remove the invalid row(s) from database by using the found id(s) as follow:

    # plesk db "DELETE FROM example_joomladb.ji0w5_extensions WHERE extension_id=321;"

Also the following script can be used if the database name and table are not known:

#!/bin/bash
plesk db -e "SHOW DATABASES" | while read dbname; do
if [[ $dbname != "information_schema" ]] && [[ $dbname != "performance_schema" ]] && [[ $dbname != "mysql" ]] && [[ $dbname != "sys" ]]; then
plesk db -e "USE $dbname; SHOW TABLES LIKE '%_extensions';" | while read tblname; do
echo "Running query on database: $dbname, table: $tblname"
plesk db -e "SELECT * FROM $dbname.$tblname WHERE name LIKE ''\G;"
done
fi
done

Use command as follow to determine empty name value on prefix_extensions table for all domains:

Warning: command will need to be adjusted for each environment, don't run it blindly (mind that some instances might have a subdirectory below httpdocs)

# for i in `ls -ltra /var/www/vhosts/*/httpdocs/configuration.php |awk '{print $9}'`; do pref=$(cat ${i} |grep "public \$dbprefix = " |cut -d "'" -f2 |tr -d "'"); db=$(cat ${i} |grep "public \$db = " |cut -d "'" -f2 |tr -d "'"); ext_id=$(plesk db -Ne "select extension_id from ${db}.${pref}extensions where name like '' and type like 'sef_ext'"); if [ -n "$ext_id" ]; then echo -e "\n$i"; echo -e "extension_id: $ext_id\ndatabase: $db\ntable: ${pref}extensions"; fi; done;

/var/www/vhosts/example.com/httpdocs/configuration.php 
extension_id: 10065 
database: joomla_database 
table: prefix_ 

/var/www/vhosts/example2.com/httpdocs/configuration.php 
extension_id: 10110 
database: joomla_database2 
table: prefix2_

In case there are multiple domains with this problem, this command will help to build a query to delete these rows.
Use something like:

# plesk db "DELETE FROM joomla_database.prefix_extensions WHERE extension_id=10065"
# plesk db "DELETE FROM joomla_database2.prefix2_extensions WHERE extension_id=10110"

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.