User tests: Successful: Unsuccessful:
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
Create a scheduled task
From a terminal go to your site's CLI directory and run php ./joomla.php scheduler:run --all
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".
The task runs correctly.
None.
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!
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries |
I have tested this item
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
Hello @nikosdion thanks for this important finding. Based on your suggestion, I've build: #37039 probably you could check?
I have tested this item
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 :)
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2022-02-14 19:15:43 |
Closed_By | ⇒ | bembelimen | |
Labels |
Added:
?
|
Cheers! I am glad I could help :)
This could've been troublesome! Thanks @nikosdion
@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.
@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
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.