Cron not working in chrooted environment with PHP-FPM

Just noticed that there is a problem the ownCloud's cron.php in case it is installed in an chrooted environment.

Lets consider the following setup:
chroot = /var/www/localhost
'datadirectory' => '/data'
mount /dev/sda3 /var/www/localhost/data (not really relevant)
doc_root = /htdocs
(P.S. getting ownCloud to work in chroot is a real PITA)

Since I am using PHP-FPM, then all configuration is done for the FPM, but cron uses PHP-CLI:
*/15 * * * * php -f /var/www/localhost/htdocs/cron.php

What happens when the cron is executed is that PHP-CLI reads the config.php and sees "/data", which is the ABSOLUTE path for it.
This results in PHP checking for the wrong directory and fails.

There are few options how to fix it on your own.
- you could chroot the PHP-CLI to the same directory (not a good idea)
- you could create a cron script that requests cron.php, like wget and use the webcron option. (a bit better solution)

When using webcron, ownCloud alerts you that this may impact your performance. On certain configurations webcron option will spawn a new child process and if the child count is limited then this will impact the overall performance.

Devs could add an option to config.php like:
'chroot_path' => '/var/www/localhost',
(and make cron.php to account the chroot path too).

Maybe someone else has a better idea?

My current solution:
*/15 * * * * wget -qO- https://owncloud.lan/cron.php &> /dev/null

In the past i've stumbled over the following for occ which might also work for the cron:

Works like a charm!

'datadirectory' => ((php_sapi_name() != 'cli') ? '/data' : '/var/www/localhost/data'),


This might be overriden on ownCloud upgrade, so it would still be nice to have a permanent solution.