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

Globalcheckin task plugin error #44727

Open
ghicar opened this issue Jan 13, 2025 · 1 comment
Open

Globalcheckin task plugin error #44727

ghicar opened this issue Jan 13, 2025 · 1 comment

Comments

@ghicar
Copy link

ghicar commented Jan 13, 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

@alikon
Copy link
Contributor

alikon commented Jan 13, 2025

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

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

No branches or pull requests

3 participants