No Code Attached Yet
avatar ghicar
ghicar
13 Jan 2025

Steps to reproduce the issue

  1. Have a prefixed table with the checked_out column with NULL not allowed.
  2. Have the globalcheckin task enabled and running on a schedule
  3. Do some backend admin to checkout an item from this table and leave it checked out for long enough for globalcheckin to be triggered on it.

Expected result

The "item" is checked in by the scheduled task.

Actual result

The task returns error code -2, resulting in task failure email if configured to send emails on failure.

System information (as much as possible)

Joomla 5.3.2
MySQL 8.0.36
GlobalCheckin plugin 5.0.0
PHP 8.3.15

Additional comments

The globalcheckin plugin (version 5.0.0) does not cater properly for tables with "NULL not allowed" in the checked_out column. The code ~/plugins/task/globalcheckin/src/Extension/GlobalCheckin.php caters for both "not NULL" and null allowed in the WHERE clause but tries to set the checked_out column field value to NULL when expired checked out rows are found irrespective of NULL being allowed or not.

Changing the code:

$query = $db->getQuery(true)
    ->update($db->quoteName($tn))
    ->set($db->quoteName('checked_out') . ' = NULL')
    ->set($db->quoteName('checked_out_time') . ' = NULL');

if ($fields['checked_out']->Null === 'YES') {
    $query->where($db->quoteName('checked_out') . ' IS NOT NULL');
} else {
    $query->where($db->quoteName('checked_out') . ' > 0');
}

to:

$query = $db->getQuery(true)
    ->update($db->quoteName($tn))
    ->set($db->quoteName('checked_out_time') . ' = NULL');

if ($fields['checked_out']->Null === 'YES') {
    $query->set($db->quoteName('checked_out') . ' = NULL')               
          ->where($db->quoteName('checked_out') . ' IS NOT NULL');
} else {
    $query->set($db->quoteName('checked_out') . ' = 0')
          ->where($db->quoteName('checked_out') . ' > 0');
}

Fixes the problem

avatar ghicar ghicar - open - 13 Jan 2025
avatar ghicar ghicar - change - 13 Jan 2025
Labels Removed: ?
avatar joomla-cms-bot joomla-cms-bot - change - 13 Jan 2025
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 13 Jan 2025
avatar alikon
alikon - comment - 13 Jan 2025

the nature of that field is to allow NULL value, so declaring NOT NULL is wrong imho

avatar chmst
chmst - comment - 20 Jan 2025

We use default NULL in the core, but extension developers could declare NOT NULL.

@ghicar would you like to make a PR as you already have a solution? Then maintainers can decide.

avatar chmst chmst - change - 21 Jan 2025
Status New Closed
Closed_Date 0000-00-00 00:00:00 2025-01-21 10:30:55
Closed_By chmst
avatar chmst chmst - close - 21 Jan 2025
avatar chmst
chmst - comment - 21 Jan 2025

Closed as there is a PR #44762

Add a Comment

Login with GitHub to post a comment