Title: PHP Errors Fill Log on CLI CRON Requests
Last modified: September 12, 2017

---

# PHP Errors Fill Log on CLI CRON Requests

 *  [rsm-support](https://wordpress.org/support/users/rsm-support/)
 * (@rsm-support)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/php-errors-fill-log-on-cli-cron-requests/)
 * We usually disable the built-in WP Cron and use server CLI cron jobs instead 
   to trigger the WP Cron tasks.
 * We run WP_DEBUG in logging mode.
 * This PHP error (NOTICE level, but still an error) is filling up logs when CLI
   cron jobs run:
 *     ```
       PHP Warning:  strpos(): Empty needle in {DOCUMENT_ROOT}/wp-content/plugins/wp-super-cache/wp-cache-phase1.php on line 636
       ```
   
 * It’s an easy fix. In line 636, change it from this
 *     ```
       if ( false === strpos( $permalink, $WPSC_HTTP_HOST ) ) {
       ```
   
 * to this
 *     ```
       if ( empty( $WPSC_HTTP_HOST ) || false === strpos( $permalink, $WPSC_HTTP_HOST ) ) {
       ```
   
 * Just a note: In general, when you use a variable as the needle in a `strpos()`
   directive, test to make sure it’s not `empty()` first, otherwise PHP will throw
   errors.

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Saša](https://wordpress.org/support/users/stodorovic/)
 * (@stodorovic)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/php-errors-fill-log-on-cli-cron-requests/#post-9491922)
 * Hi [@rsm-support](https://wordpress.org/support/users/rsm-support/)
 * I’ve noticed some similar issues and I’ll try to group them. After this, I’ll
   open new issue on [https://github.com/Automattic/wp-super-cache/issues](https://github.com/Automattic/wp-super-cache/issues).
 * Regarding to wp-cli and PHP CLI scripts, I’ve already prepared some proposals
   and I’ll try to make PR for this.
 * I’m also running wp-cron with php-cli script, but there are more plugins which
   aren’t compatible with this method. So, I’ve created this workaround:
 *     ```
       # Set server and execution environment information
       export REMOTE_ADDR="127.0.0.1"
       export REQUEST_METHOD="GET"
       export SERVER_PROTOCOL="HTTP/1.1"
       export SERVER_PORT="80"
       export HTTP_USER_AGENT="Wp-cron/ver 1.0 (php-cli; Linux)"
       export REQUEST_URI=/wp-cron.php
       export HTTP_HOST="www.example.com"
       export SERVER_NAME="www.example.com"
       ```
   
 * It’s based on [https://github.com/szepeviktor/debian-server-tools/blob/master/webserver/wp-cron-cli.sh](https://github.com/szepeviktor/debian-server-tools/blob/master/webserver/wp-cron-cli.sh)
   I’m trying to make better version which will support multisite installation.
 * I hope that helps.
 * Regards,
    Sasa
    -  This reply was modified 8 years, 8 months ago by [Saša](https://wordpress.org/support/users/stodorovic/).
 *  [Saša](https://wordpress.org/support/users/stodorovic/)
 * (@stodorovic)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/php-errors-fill-log-on-cli-cron-requests/#post-9501172)
 * Hi [@rsm-support](https://wordpress.org/support/users/rsm-support/)
 * I updated [https://github.com/Automattic/wp-super-cache/pull/384](https://github.com/Automattic/wp-super-cache/pull/384)
   which improves support for PHP cli. Could you look it and test how it works?
 * Regards,
    Sasa

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘PHP Errors Fill Log on CLI CRON Requests’ is closed to new replies.

 * ![](https://ps.w.org/wp-super-cache/assets/icon-256x256.png?rev=3506220)
 * [WP Super Cache](https://wordpress.org/plugins/wp-super-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-super-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-super-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-super-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-super-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-super-cache/reviews/)

## Tags

 * [cli](https://wordpress.org/support/topic-tag/cli/)
 * [PHP errors](https://wordpress.org/support/topic-tag/php-errors/)

 * 2 replies
 * 2 participants
 * Last reply from: [Saša](https://wordpress.org/support/users/stodorovic/)
 * Last activity: [8 years, 8 months ago](https://wordpress.org/support/topic/php-errors-fill-log-on-cli-cron-requests/#post-9501172)
 * Status: not resolved