phpbbcli not finding cron tasks

Get help with installation and running phpBB 3.3.x here. Please do not post bug reports, feature requests, or extension related questions here.
Post Reply
User avatar
gregorlove
Registered User
Posts: 25
Joined: Thu Sep 18, 2003 3:13 am
Location: San Diego, CA
Name: gRegor Morrill
Contact:

phpbbcli not finding cron tasks

Post by gregorlove »

Support Request Template
What version of phpBB are you using? phpBB 3.3.1 with PHP 7.4
What is your board's URL? not publicly available
Who do you host your board with? pair.com
How did you install your board? I used the download package from phpBB.com
What is the most recent action performed on your board? Fresh Install
Is registration required to reproduce this issue? No
Do you have any MODs installed? No
Do you have any extensions installed? Yes
What extensions do you have installed? phpBB Skeleton Extension 1.1.4
MAPP Example 1.0.0-dev (created by phpBB Skeleton)
What styles do you currently have installed? prosilver 3.3.1
What language(s) is your board currently using? British English
Which database type/version are you using? MySQL 5.6.48
What is your level of experience? Experienced with PHP and phpBB
What actions did you take (updating your board; installing a MOD, style or extension; etc.) prior to this problem becoming noticeable? Installed the phpBB Skeleton Extension and generated the MAPP Example extension. See below for more information and source code.
Please describe your problem. I have been running into an issue where the phpbbcli.php commands `cron:run` and `cron:list` seem to not be aware of cron tasks within extensions, even though everything appears to be correct in the extensions. I wrote some details about this in another thread, but in attempt to reduce the amount of possible issues, I decided to do a fresh phpBB 3.3.1 install and use the phpBB Skeleton extension to create a minimum viable extension.

This extension (github) is set to run every 60 seconds and each of the functions is_runnable(), should_run(), and run() writes a message to the admin log so I can check if they've been called. Installing this extension goes smoothly and the config option `example_cron_last_run` appears in the config table.

I am not yet attempting to run this task via crontab. All commands below I've been manually running.

When I run the `cron:list` command, this task does not appear. I would expect `mapp.example.cron.task.sample` to appear as either Ready or Not Ready:

Code: Select all

% php74 ./bin/phpbbcli.php cron:list -vvv

Ready tasks:
============

 * cron.task.core.prune_all_forums
 * cron.task.core.prune_notifications
 * cron.task.core.tidy_cache
 * cron.task.core.tidy_search
 * cron.task.core.tidy_sessions
 * cron.task.core.tidy_warnings
 * cron.task.text_reparser.pm_text
 * cron.task.text_reparser.poll_option

Not ready tasks:
================

 * cron.task.core.prune_forum
 * cron.task.core.prune_shadow_topics
 * cron.task.core.queue
 * cron.task.core.tidy_database
 * cron.task.core.tidy_plupload
 * cron.task.text_reparser.poll_title
 * cron.task.text_reparser.post_text
 * cron.task.text_reparser.user_signature
 * cron.task.core.update_hashes
When I run `cron:run` it does not run the task. I would expect the task to run at least the first time since the initial last_run value is 0. No log messages are written by this extension and the last_run timestamp is not updated in the config table:

Code: Select all

% php74 ./bin/phpbbcli.php cron:run -vvv
Running task: cron.task.core.prune_all_forums.
Running task: cron.task.core.prune_notifications.
Running task: cron.task.core.tidy_cache.
Running task: cron.task.core.tidy_search.
Running task: cron.task.core.tidy_sessions.
Running task: cron.task.core.tidy_warnings.
Running task: cron.task.text_reparser.pm_text.
Running task: cron.task.text_reparser.poll_option.
I saw that `cron:run` also supports running an individual task by name. I get an exception unable to find the task name, though. I shortened the file paths to "forum_root" below to make this a bit more readable:

Code: Select all

% php74 ./bin/phpbbcli.php cron:run mapp.example.cron.task.sample  -vvv

In exception_subscriber.php line 51:

  [RuntimeException (2)]
  Could not find cron task “mapp.example.cron.task.sample”.


Exception trace:
  at forum_root/phpbb/console/exception_subscriber.php:51
 phpbb\console\exception_subscriber->on_error() at forum_root/vendor/symfony/event-dispatcher/EventDispatcher.php:214
 Symfony\Component\EventDispatcher\EventDispatcher->doDispatch() at forum_root/vendor/symfony/event-dispatcher/EventDispatcher.php:44
 Symfony\Component\EventDispatcher\EventDispatcher->dispatch() at forum_root/phpbb/event/dispatcher.php:62
 phpbb\event\dispatcher->dispatch() at forum_root/vendor/symfony/console/Application.php:1023
 Symfony\Component\Console\Application->doRunCommand() at forum_root/vendor/symfony/console/Application.php:255
 Symfony\Component\Console\Application->doRun() at forum_root/phpbb/console/application.php:137
 phpbb\console\application->doRun() at forum_root/vendor/symfony/console/Application.php:148
 Symfony\Component\Console\Application->run() at forum_root/bin/phpbbcli.php:90

In run.php line 170:

  [phpbb\exception\runtime_exception (2)]
  CRON_NO_SUCH_TASK


Exception trace:
  at forum_root/phpbb/console/command/cron/run.php:170
 phpbb\console\command\cron\run->run_one() at forum_root/phpbb/console/command/cron/run.php:85
 phpbb\console\command\cron\run->execute() at forum_root/vendor/symfony/console/Command/Command.php:255
 Symfony\Component\Console\Command\Command->run() at forum_root/vendor/symfony/console/Application.php:1005
 Symfony\Component\Console\Application->doRunCommand() at forum_root/vendor/symfony/console/Application.php:255
 Symfony\Component\Console\Application->doRun() at forum_root/phpbb/console/application.php:137
 phpbb\console\application->doRun() at forum_root/vendor/symfony/console/Application.php:148
 Symfony\Component\Console\Application->run() at forum_root/bin/phpbbcli.php:90
The constructor has a line to add a message to the admin log (commented out currently). When un-commented, that writes a log message on every ACP page load and when calling the the `cron:run` and `cron:list` commands. So it seems the class is being instantiated correctly, but none of the methods in the extension are being called and somehow phpBB core is not able to find the task by name?

Edit 1: I did find this tracker ticket, but it was resolved in 2014. I don't know Symfony very well, but the current phpbbcli.php seems in line with those updates? Hm.

Any help would be greatly appreciated!
Generated by SRT Generator
User avatar
AlfredoRamos
Recognised Extension Developer
Posts: 1241
Joined: Wed Dec 25, 2013 9:06 pm
Location: /dev/null
Name: Alfredo
Contact:

Re: phpbbcli not finding cron tasks

Post by AlfredoRamos »

gregorlove wrote: Tue Aug 25, 2020 11:41 pm I have been running into an issue where the phpbbcli.php commands `cron:run` and `cron:list` seem to not be aware of cron tasks within extensions, even though everything appears to be correct in the extensions.
It was definitely working on phpBB 3.2.x, can't remember the exact version, because that's how I debugged my extension back then.

I just checked with phpBB 3.3.0 and 3.27, and none of them shows my cron task through phpbbcli.php:

Image

Although it's working just fine using phpBB's cron (not system cron) triggered by the user activity.

Image
gregorlove wrote: Tue Aug 25, 2020 11:41 pm When I run the `cron:list` command, this task does not appear. I would expect `mapp.example.cron.task.sample` to appear as either Ready or Not Ready:
In fact, it should appear as cron.task.{CLASS_NAME} where {CLASS_NAME} is, you guessed it, the name of your class, sample in your case.

It seems, indeed, like a phpbbcli.php issue, because it was listing cron tasks from extensions before.

P.S.: I believe this topic should be in the Extension Writers Discussion forum.
Some of my phpBB extensions:
Image Imgur | :chart_with_upwards_trend: SEO Metadata | Image Markdown | :shield: hCaptcha
:trophy: Check out all my validated extensions :trophy:

:penguin: Arch Linux user :penguin:
User avatar
gregorlove
Registered User
Posts: 25
Joined: Thu Sep 18, 2003 3:13 am
Location: San Diego, CA
Name: gRegor Morrill
Contact:

Re: phpbbcli not finding cron tasks

Post by gregorlove »

Glad to have confirmation so it's not just me! :D

I posted in that forum initially when I was still thinking it was an issue with my extension. Seems like it's an issue with core, though. I'll dig into phpbbcli more and see if I can get it working / open a ticket.
User avatar
david63
Registered User
Posts: 20411
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Contact:

Re: phpbbcli not finding cron tasks

Post by david63 »

Not sure if this is anything to do with the problem but I noticed this line
$this->config->set('example_cron_last_run', time(), false);
it should be
$this->config->set('example_cron_last_run', time(), true);
The false means that the config value is not being updated in the cache therefore it is using the original value.

Have you tried setting public function should_run() to just return true;?
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored
User avatar
gregorlove
Registered User
Posts: 25
Joined: Thu Sep 18, 2003 3:13 am
Location: San Diego, CA
Name: gRegor Morrill
Contact:

Re: phpbbcli not finding cron tasks

Post by gregorlove »

david63 wrote: Wed Aug 26, 2020 7:20 am Not sure if this is anything to do with the problem but I noticed this line
$this->config->set('example_cron_last_run', time(), false);
it should be
$this->config->set('example_cron_last_run', time(), true);
The false means that the config value is not being updated in the cache therefore it is using the original value.

Have you tried setting public function should_run() to just return true;?
I think I had done both on previous tests. I just switched them back (updated on github), cleared cache and cron_lock and tried again. Unfortunately no difference; still no log messages. Appreciate the pointers though.
User avatar
gregorlove
Registered User
Posts: 25
Joined: Thu Sep 18, 2003 3:13 am
Location: San Diego, CA
Name: gRegor Morrill
Contact:

Re: phpbbcli not finding cron tasks

Post by gregorlove »

User avatar
david63
Registered User
Posts: 20411
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Contact:

Re: phpbbcli not finding cron tasks

Post by david63 »

There is no problem with running that code from within the board
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored
User avatar
gregorlove
Registered User
Posts: 25
Joined: Thu Sep 18, 2003 3:13 am
Location: San Diego, CA
Name: gRegor Morrill
Contact:

Re: phpbbcli not finding cron tasks

Post by gregorlove »

I've successfully run this via the cron.php method (page load triggering the task) as well, so definitely looks like a phpbbcli bug.
User avatar
gregorlove
Registered User
Posts: 25
Joined: Thu Sep 18, 2003 3:13 am
Location: San Diego, CA
Name: gRegor Morrill
Contact:

Re: phpbbcli not finding cron tasks

Post by gregorlove »

Bumping because I don't know how else to get eyes on the ticket I filed. Someone linked to a PR that supposedly fixed it and was merged into 3.3.2, but it still doesn't work for me in 3.3.4. Thanks for any assistance: https://tracker.phpbb.com/browse/PHPBB3-16591
User avatar
david63
Registered User
Posts: 20411
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Contact:

Re: phpbbcli not finding cron tasks

Post by david63 »

gregorlove wrote: Tue Jun 29, 2021 5:18 am Bumping because I don't know how else to get eyes on the ticket I filed. Someone linked to a PR that supposedly fixed it and was merged into 3.3.2, but it still doesn't work for me in 3.3.4. Thanks for any assistance: https://tracker.phpbb.com/browse/PHPBB3-16591
The correct place to post is in the ticket if the fix is not working.
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored
chrishecker
Registered User
Posts: 6
Joined: Sun Mar 02, 2014 2:21 am

Re: phpbbcli not finding cron tasks

Post by chrishecker »

I am having simillar trouble with getting the CLI to recognize CLI commands in the ext tree. The skeleton shows up, runs through the UI, but doesn't register its CLI command. If I hack a CLI command into the phpbb tree it works fine. Is there something phpbbcli needs to do to load this stuff up from the ext tree?

This is also on 3.3.4

Chris
User avatar
gregorlove
Registered User
Posts: 25
Joined: Thu Sep 18, 2003 3:13 am
Location: San Diego, CA
Name: gRegor Morrill
Contact:

Re: phpbbcli not finding cron tasks

Post by gregorlove »

I did a month prior to the bump. It didn't seem anyone was looking at the issue and I didn't want it to get lost.
chrishecker
Registered User
Posts: 6
Joined: Sun Mar 02, 2014 2:21 am

Re: phpbbcli not finding cron tasks

Post by chrishecker »

I updated the github bug you're watching, but I think I figured this out, it's a cache/production permissions problem between the user running phpbbcli and the webserver. See the thread for more detailed info: https://github.com/phpbb-extensions/php ... -928516406

The bug should probably be modified to say the phpbbcli should error if it doesn't have the permissions it needs, instead of silently failing but reporting success for a bunch of commands like it does now.

Chris
Post Reply

Return to “[3.3.x] Support Forum”