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

PMC bugs #9

Open
squareclouds opened this issue Nov 11, 2022 · 0 comments
Open

PMC bugs #9

squareclouds opened this issue Nov 11, 2022 · 0 comments

Comments

@squareclouds
Copy link

hello,

i am using php 8.1 and kirby 3.8 (dont know if other versions are behaving the same way) and i found that, that the cron function was not working for me:

if (option("bvdputte.kirbyqueue.poormanscron")) {
    $root = kirby()->roots()->site() . '/' . option("bvdputte.kirbyqueue.root");
    $pmcFile = $root . "/.pmc";

    if (!f::exists($pmcFile)) f::write($pmcFile, time());
    $nextRun = f::read($pmcFile) + option("bvdputte.kirbyqueue.poormanscron.interval");

    if( $nextRun < time() ) {
        // Work the queue
        bvdputte\kirbyQueue\Queueworker::work();
        f::write($pmcFile, time());
    }
}

after changing

option("bvdputte.kirbyqueue.root");

to

kirby()->option("bvdputte.kirbyqueue.root");

it started working. so technically the complete IF looks like this:

if (option("bvdputte.kirbyqueue.poormanscron")) {
    $root = kirby()->roots()->site() . '/' . kirby()->option("bvdputte.kirbyqueue.root");
    $pmcFile = $root . "/.pmc";

    if (!f::exists($pmcFile)) f::write($pmcFile, time());
    $nextRun = f::read($pmcFile) + kirby()->option("bvdputte.kirbyqueue.poormanscron.interval");

    if( $nextRun < time() ) {
        // Work the queue
        bvdputte\kirbyQueue\Queueworker::work();
        f::write($pmcFile, time());
    }
}

also, I had to set these options inside the plugin index.php, otherwise from the config.php it was not working either. strangely enough, the 'worker.route' works from the config, but i guess it is because it is called later?

options i had to set in index of plugin

'poormanscron' => true,
'poormanscron.interval' => 30, // in seconds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant