humanmade/backupwordpress — pull request #433 by pdewouters (2014-01-23 08:29:18+00:00)
Title: PHP Warning in class-schedule.php

An [intercom user](https://www.intercom.io/apps/7f1l4qyq/messages/1093518) reported the following error

````
Warning: Invalid argument supplied for foreach() in /var/www/web796/html/www/wp-content/plugins/backupwordpress/classes/class-schedule.php on line 930
````

I've asked the OP for a var_dump of `$haystack` as I'd like to understand the contents of the arg that is being passed to the `foreach`.

Regardless though there are a couple of things we should do to avoid this situation:

- [ ] in [L930](https://github.com/humanmade/backupwordpress/blob/master/classes/class-schedule.php#L930) check that `glob( $haystack . '/*', GLOB_ONLYDIR | GLOB_NOSORT )` returns a valid array before trying to `foreach` it.
- [ ] in [L885](https://github.com/humanmade/backupwordpress/blob/master/classes/class-schedule.php#L885) use [`wp_upload_dir`](http://codex.wordpress.org/Function_Reference/wp_upload_dir) to get the path to the uploads directory (and ensure it actually exists etc.).