Code Monkey home page Code Monkey logo

Comments (5)

rmccue avatar rmccue commented on August 23, 2024

We should do this as soon as possible, but I think that's likely to be when the command's callback fires. We can't really hook in any earlier.

from cavalcade.

dd32 avatar dd32 commented on August 23, 2024

Perhaps an option would be to enhance WP-CLI to accept certain constants on the command line? ie. wp --debug=true --cron=on

from cavalcade.

rmccue avatar rmccue commented on August 23, 2024

wp-cli itself only sets the constant late, so I'm fine with also setting it late.

from cavalcade.

joehoyle avatar joehoyle commented on August 23, 2024

FWIW this just bit me too!

from cavalcade.

onnimonni avatar onnimonni commented on August 23, 2024

I think the most earliest it can be currently set in WP-CLI bootstrap is with the --require flag:
https://github.com/wp-cli/wp-cli/blob/104ccf37da491465b8d42bc73695865440ebd333/php/bootstrap.php#L26

In case you'll want to use that the cavalcade runner should have a file which can be required with wp-cli:

$ echo "<?php define( 'DOING_CRON', true );" > /tmp/define-cron.php
$ wp cavalcade run <id> --require /tmp/define-cron.php

Another hacky option is to use auto_prepend_file in the cavalcade runner:

$ echo "<?php define( 'DOING_CRON', true );" > /tmp/define-cron.php
$ php -d auto_prepend_file="/tmp/define-cron.php" /usr/local/bin/wp cavalcade run <id>

This is kinda hacky and it shouldn't make a big difference if it's defined just before running the cron job.

from cavalcade.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.