From 1e4c845aabd8650026e6d7b12606299b43f5698e Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 19 Apr 2012 13:18:00 +0000 Subject: [PATCH] call notification hook for unlink/rmdir only after successful removal, but with (not longer existing) stat data --- phpgwapi/inc/class.vfs_stream_wrapper.inc.php | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/phpgwapi/inc/class.vfs_stream_wrapper.inc.php b/phpgwapi/inc/class.vfs_stream_wrapper.inc.php index 4b66b9378f..c82389b1e6 100644 --- a/phpgwapi/inc/class.vfs_stream_wrapper.inc.php +++ b/phpgwapi/inc/class.vfs_stream_wrapper.inc.php @@ -450,17 +450,22 @@ class vfs_stream_wrapper implements iface_stream_wrapper { return false; } - // call "vfs_unlink" hook, before unlink - if (isset($GLOBALS['egw']) && isset($GLOBALS['egw']->hooks)) + $stat = self::url_stat($path, STREAM_URL_STAT_LINK); + + self::symlinkCache_remove($path); + $ok = unlink($url); + + // call "vfs_unlink" hook only after successful unlink, with data from (not longer possible) stat call + if ($ok && isset($GLOBALS['egw']) && isset($GLOBALS['egw']->hooks)) { $GLOBALS['egw']->hooks->process(array( 'location' => 'vfs_unlink', 'path' => $path[0] == '/' ? $path : parse_url($path, PHP_URL_PATH), 'url' => $url, + 'stat' => $stat, ),'',true); } - self::symlinkCache_remove($path); - return unlink($url); + return $ok; } /** @@ -564,17 +569,22 @@ class vfs_stream_wrapper implements iface_stream_wrapper { return false; } - // call "vfs_rmdir" hook, before removing - if (isset($GLOBALS['egw']) && isset($GLOBALS['egw']->hooks)) + $stat = self::url_stat($path, STREAM_URL_STAT_LINK); + + self::symlinkCache_remove($path); + $ok = rmdir($url); + + // call "vfs_rmdir" hook, only after successful rmdir + if ($ok && isset($GLOBALS['egw']) && isset($GLOBALS['egw']->hooks)) { $GLOBALS['egw']->hooks->process(array( 'location' => 'vfs_rmdir', 'path' => $path[0] == '/' ? $path : parse_url($path, PHP_URL_PATH), 'url' => $url, + 'stat' => $stat, ),'',true); } - self::symlinkCache_remove($path); - return rmdir($url); + return $ok; } /**