? Pending

User tests: Successful: Unsuccessful:

avatar nikosdion
nikosdion
14 Feb 2022

Summary of Changes

Fix the following immediate fatal error when running php ./joomla.php scheduler:run --all:

In OptionsResolver.php line 1060:
                                                                               
  The option "id" with value "1" is expected to be of type "int", but is of type "string".                                                                

Tagging @bembelimen

Testing Instructions

Create a scheduled task

From a terminal go to your site's CLI directory and run php ./joomla.php scheduler:run --all

Actual result BEFORE applying this Pull Request

Fatal error:

In OptionsResolver.php line 1060:
                                                                               
  The option "id" with value "1" is expected to be of type "int", but is of type "string".                                                                

Expected result AFTER applying this Pull Request

The task runs correctly.

Documentation Changes Required

None.

Further information

While this solves the immediate problem observed I believe a better place to address it is Joomla\Component\Scheduler\Administrator\Scheduler\Scheduler::runTask. Since the ID will always have to be an integer shouldn't you check if it's a numeric value and type–cast to integer?

PS: Yes, I have now started writing real-world code for Joomla's scheduled tasks. Sorry it took me so long, everything got pushed back by a month while our kid was sick and out of school. We are finally back to normal and trying to catch up!

avatar nikosdion nikosdion - open - 14 Feb 2022
avatar nikosdion nikosdion - change - 14 Feb 2022
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 14 Feb 2022
Category Libraries
avatar chmst chmst - test_item - 14 Feb 2022 - Tested successfully
avatar chmst
chmst - comment - 14 Feb 2022

I have tested this item successfully on fc415d0

Tested on xampp, php 8.0.
Set Database to MSQL (PDO) in com_config and Lazy Scheduler to "disabled in scheduler options.

Then followed the testing instructions.
Before Patch: The option "id" with value "2" is expected to be of type "int", but is of type "string".
After Patch: Tasks run without errors but warning Task#02 'toggle offline' failed to run. Is it already running? #37036


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/37034.
avatar softforge softforge - test_item - 14 Feb 2022 - Tested successfully
avatar softforge
softforge - comment - 14 Feb 2022

I have tested this item successfully on fc415d0

Here I have set the database driver to PDO and then tested. Bug confirmed adn when the patch applied it resolves the issue revealing the next issue
https://issues.joomla.org/tracker/joomla-cms/37036


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/37034.

avatar bembelimen
bembelimen - comment - 14 Feb 2022

Hello @nikosdion thanks for this important finding. Based on your suggestion, I've build: #37039 probably you could check?

avatar khu5h1 khu5h1 - test_item - 14 Feb 2022 - Tested successfully
avatar khu5h1
khu5h1 - comment - 14 Feb 2022

I have tested this item successfully on fc415d0


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/37034.

avatar bembelimen
bembelimen - comment - 14 Feb 2022

I will close this in favour of the other PR, so a user, who types in "abc" as an ID still gets the error of the wrong type here.

Thanks again for finding, rescued me from a lot of problems tomorrow :)

avatar bembelimen bembelimen - change - 14 Feb 2022
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2022-02-14 19:15:43
Closed_By bembelimen
Labels Added: ?
avatar bembelimen bembelimen - close - 14 Feb 2022
avatar nikosdion
nikosdion - comment - 14 Feb 2022

Cheers! I am glad I could help :)

avatar ditsuke
ditsuke - comment - 15 Feb 2022

This could've been troublesome! Thanks @nikosdion

avatar nikosdion
nikosdion - comment - 15 Feb 2022

@ditsuke No worries! It seems that all my scheduler woes are in one way or another related to using PDO MySQL. My 4.1-dev site (on mysqli and PHP 8.0) was working fine with scheduled tasks but my main dev site on 4.1.0-rc4 (on PDO MySQL and PHP 8.0) would throw an error. Off the top of my head, it looks like the former was returning an int for integer db fields, the latter was returning strings for the same integer db fields. One more thing to keep in mind, I guess.

avatar ditsuke
ditsuke - comment - 15 Feb 2022

@ditsuke No worries! It seems that all my scheduler woes are in one way or another related to using PDO MySQL. My 4.1-dev site (on mysqli and PHP 8.0) was working fine with scheduled tasks but my main dev site on 4.1.0-rc4 (on PDO MySQL and PHP 8.0) would throw an error. Off the top of my head, it looks like the former was returning an int for integer db fields, the latter was returning strings for the same integer db fields. One more thing to keep in mind, I guess.

Interesting, I don't think I'll forget not to rely on types from DB drivers now ?

Add a Comment

Login with GitHub to post a comment