Title: Issue using plugin via WP-CLI &amp; Cron
Last modified: August 31, 2016

---

# Issue using plugin via WP-CLI & Cron

 *  Resolved [Greg Marshall](https://wordpress.org/support/users/timeassistant/)
 * (@timeassistant)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/issue-using-plugin-via-wp-cli-cron/)
 * Hello,
 * I was having issues with the automatic optimisation settings (web server would
   occasionally lock up during image upload)
 * So my webhost advised that they can set up WP-CLI and a cron job to run EWWW 
   however the hosts have came back to me advising of a problem with your plugin,
   he made some changes to your code but this was lost during plugin upgrade, can
   you please review and action the change he has made? the message from my web 
   host is below:
 * Fatal error: Call to a member function get_col() on a non-object in /home/{directory}/
   public_html/wp-content/plugins/ewww-image-optimizer/iocli.php on line 192
 * “It looks like it’s an issue with this line in the script:
 * else {
    // load up all the image attachments we can find $attachments = $wpdb-
   >get_col( “SELECT ID FROM $wpdb->posts WHERE (post_type = ‘attachment’ OR post_type
   = ‘ims_image’) AND post_mime_type LIKE ‘%%image%%'” ); }
 * And it’s because $wpdb isn’t being instantiated in that function. I’ve added 
   that to the function on line 183 now, but it might be something the developer
   isn’t aware of perhaps.”
 * [https://wordpress.org/plugins/ewww-image-optimizer/](https://wordpress.org/plugins/ewww-image-optimizer/)

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

 *  Plugin Author [Shane Bishop](https://wordpress.org/support/users/nosilver4u/)
 * (@nosilver4u)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/issue-using-plugin-via-wp-cli-cron/#post-7246132)
 * Thanks for letting me know, the fix will be in the next release!
 * You could also use the deferred optimization which would probably be a bit gentler
   on the server.
 *  Thread Starter [Greg Marshall](https://wordpress.org/support/users/timeassistant/)
 * (@timeassistant)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/issue-using-plugin-via-wp-cli-cron/#post-7246137)
 * Hi thanks for the quick response – love it !
 * I think I did try deferred optimisation but it was decided at the time that this
   was the best method for our set up.
 * Although if you could possibly add some sort of way to schedule optimisations(
   like a cron) this would be great as I would love to run it around 3am or something
   when there is little or no site activity

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

The topic ‘Issue using plugin via WP-CLI & Cron’ is closed to new replies.

 * ![](https://ps.w.org/ewww-image-optimizer/assets/icon-256x256.png?rev=1582276)
 * [EWWW Image Optimizer](https://wordpress.org/plugins/ewww-image-optimizer/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ewww-image-optimizer/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ewww-image-optimizer/)
 * [Active Topics](https://wordpress.org/support/plugin/ewww-image-optimizer/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ewww-image-optimizer/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ewww-image-optimizer/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Greg Marshall](https://wordpress.org/support/users/timeassistant/)
 * Last activity: [10 years, 2 months ago](https://wordpress.org/support/topic/issue-using-plugin-via-wp-cli-cron/#post-7246137)
 * Status: resolved