export_cleanup_old_exports cron causes exception and long-running cron if export directory doesn't exist

Bug #685633 reported by Andrew Nicols
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
Low
Andrew Nicols

Bug Description

If export directory doesn't exist (e.g. because no exports have been run), then the cron goes bang.

When the cron goes bang, the lock isn't removed and so the cron can't be run again until the lock expires.

Master on postgres.

Trace follows:

[Sun Dec 05 21:13:32 2010] [error] [client 192.168.254.230] [DBG] 3e (lib/cron.php:146) Running core cron export_cleanup_old_exports
[Sun Dec 05 21:13:32 2010] [error] [client 192.168.254.230] [WAR] 3e (export/lib.php:377) DirectoryIterator::__construct(/var/cache/mahara/uploaddir/export/) [directoryiterator.--construct]: failed to open dir: No such file or directory
[Sun Dec 05 21:13:32 2010] [error] [client 192.168.254.230] Call stack (most recent first):
[Sun Dec 05 21:13:32 2010] [error] [client 192.168.254.230] * log_message("DirectoryIterator::__construct(/var/cache/mahara/u...", 8, true, true, "/home/nicols/mahara/htdocs/export/lib.php", 377) at /home/nicols/mahara/htdocs/lib/errors.php:444
[Sun Dec 05 21:13:32 2010] [error] [client 192.168.254.230] * error(2, "DirectoryIterator::__construct(/var/cache/mahara/u...", "/home/nicols/mahara/htdocs/export/lib.php", 377, array(size 1)) at Unknown:0
[Sun Dec 05 21:13:32 2010] [error] [client 192.168.254.230] * DirectoryIterator->__construct("/var/cache/mahara/uploaddir/export/") at /home/nicols/mahara/htdocs/export/lib.php:377
[Sun Dec 05 21:13:32 2010] [error] [client 192.168.254.230] * export_cleanup_old_exports() at /home/nicols/mahara/htdocs/lib/cron.php:149
[Sun Dec 05 21:13:32 2010] [error] [client 192.168.254.230]

Tags: cron exports
Revision history for this message
Andrew Nicols (dobedobedoh) wrote :

Check whether the directory exists before instantiating the DirectoryIterator.

I considered using check_dir_exists, which would create the directory and then allow the cron to be run, but felt that the cron probably wasn't the best place to create the directory -- it's a little counter intuitive to create the directory in the cleanup cron. As a result, I've opted for checking that the directory exists, and if it doesn't, returning from the function at that point.

Changed in mahara:
status: New → Fix Committed
Revision history for this message
Richard Mansfield (richard-mansfield) wrote :

There are also a whole bunch of check_dir_exists calls for all the dataroot subdirectories in the check_sanity function in lib/mahara.php. Maybe import and export should be added in there too, and then none of this would happen.

Changed in mahara:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.