Ermal Luçi wrote:
I think for packages is not neccessary to do this.
For config.xml i committed some fixes.
Sorry but this fix does not improve the situation. The problem lies in sync_package
from pkg-utils.inc
and not the in some package code (tinydns). I'll try to explain the situation using the following exceprt of sync_package
:
320 if($sync_depends == true) {
321 $depends = get_pkg_depends($pkg_name, ".xml", "files", 1); // Call dependency handler and do a little more error checking.
322 if(is_array($depends)) {
323 foreach($depends as $item) {
324 if(!file_exists($item)) {
325 file_notice($package['name'], "The {$package['name']} package is missing required dependencies and
must be reinstalled.", "Packages", "/pkg_mgr_install.php?mode=reinstallpkg&pkg={$package['name']}", 1);
326 log_error("Could not find {$item}. Reinstalling package.");
327 install_package($pkg_name);
328 uninstall_package_from_name($pkg_name);
329 install_package($pkg_name);
330 } else {
331 $item_config = parse_xml_config_pkg($item, "packagegui");
332 if(isset($item_config['nosync'])) continue;
333 if($item_config['custom_php_command_before_form'] <> "") {
334 eval($item_config['custom_php_command_before_form']);
335 }
336 if($item_config['custom_php_resync_config_command'] <> "") {
337 eval($item_config['custom_php_resync_config_command']);
338 }
339 if($show_message == true) print " " . $item_config['name'];
340 }
341 }
342 }
343 }
The array returned by get_pkg_depends
on line 321 contains every XML file specified by the additional_files_needed
tag of the package master XML file (say tinydns.xml). Later on Line 331 parse_xml_config_pkg
is called with "packagegui" as the expected rootobj. If any package includes XML files other than packagegui the script calling sync_packages
will die as soon as such files get parsed.
I suggest the following approach:
- Create
class XMLUnexpectedRootObject extends Exception
- Replace
die
with throw new XMLUnexpectedRootObejct('blabla')
- Catch and ignore those exceptions in the code in
pkg-utils.inc
This approach will not have any side effect on other parts of the system because unhandled exception lead to program termination - just like die
.
By the way, there is another problem with sync_package
. The sanitation (reinstall pkg) and the execution of the custom hooks must be seperated into two loops (actually reinstallation should not be in the loop at all). Otherwise custom php functions aren't executed for files which triggered a packag reinstallation.