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

Closed
ghicar opened this issue Jan 13, 2025 · 3 comments
Closed

Globalcheckin task plugin error #44727

ghicar opened this issue Jan 13, 2025 · 3 comments

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

@chmst
Copy link
Contributor

chmst commented Jan 20, 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.

ghicar added a commit to ghicar/joomla-cms that referenced this issue Jan 21, 2025
This edit, allows the globalcheckin plugin task to work with 3rd party plugins that use "NOT NULL" in the checkout_out column.

The previous code only half catered for this case and resulted in -2 error code when run.

Note the behaviour of the scheduled globalcheckin task is inconsistent with a global checkin done from the admin control panel which works ok with "nut null".

See joomla#44727
@chmst
Copy link
Contributor

chmst commented Jan 21, 2025

Closed as there is a PR #44762

@chmst chmst closed this as completed Jan 21, 2025
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

4 participants