I'm working on an enhanced database backup plugin. I changed it from a hack to a plugin which was an experience in itself.
Rather than loading all the code upfront initially, I load the alternate backup portion (which is much longer) only if the user selects this option. There are two submit buttons -- one for the main backup (which is the current routine and uses mysqldump) and one for the alternate. When I do a conditional include_once for the alternate, I receive the following error message:
Fatal error: Cannot redeclare store_temp() (previously declared in
/var/www/html/weather/phpweather.inc:22) in
/var/www/html/weather/phpweather.inc on line 22
This problem is caused because the weather block is using "include" vice "include_once" in display_weather.php and array.php. When changed to include_once, everything works okay. I don't have all the blocks installed on my system. So, I don't know if there's a similar conflict with other ones. The utility works fine with all the standard blocks that come with Geeklog.
Question: Is the onus on block/plugin writers to use include_once and require_once (like the new plugin manual says) or should we not use conditional includes? I don't know if I should rework my code in case some other block used include and require instead of include_once and require_once or let people test it out and see if any other blocks are affected and let the other developers change how they include files.