From 2553ad1bccbbc62e4e520af6fcc39142d10a002a Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 27 Feb 2012 14:33:42 +0000 Subject: [PATCH] some fixes for sqlfs fsck: caseinsensitive GROUP BY for MySQL, deleting files direct in DB, as self::unlink() fails if fs_active=0, and some more --- .../class.admin_prefs_sidebox_hooks.inc.php | 2 +- .../inc/class.sqlfs_stream_wrapper.inc.php | 2 +- phpgwapi/inc/class.sqlfs_utils.inc.php | 26 ++++++++++++------- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/admin/inc/class.admin_prefs_sidebox_hooks.inc.php b/admin/inc/class.admin_prefs_sidebox_hooks.inc.php index fb51a56d23..47a695263d 100644 --- a/admin/inc/class.admin_prefs_sidebox_hooks.inc.php +++ b/admin/inc/class.admin_prefs_sidebox_hooks.inc.php @@ -173,7 +173,7 @@ class admin_prefs_sidebox_hooks $content .= html::form('

'.($check_only&&is_array($msgs)?html::submit_button('fix', lang('Fix reported problems')):''). html::submit_button('cancel', lang('Cancel'), "window.location.href='".egw::link('/admin/index.php')."'; return false;").'

', - '',egw::link('/index.php',array('menuaction'=>'admin.admin_prefs_sidebox_hooks.fsck'))); + '','/index.php',array('menuaction'=>'admin.admin_prefs_sidebox_hooks.fsck')); $GLOBALS['egw']->framework->render($content, lang('Admin').' - '.lang('Check virtual filesystem'), true); } diff --git a/phpgwapi/inc/class.sqlfs_stream_wrapper.inc.php b/phpgwapi/inc/class.sqlfs_stream_wrapper.inc.php index a9defc523b..602278872c 100644 --- a/phpgwapi/inc/class.sqlfs_stream_wrapper.inc.php +++ b/phpgwapi/inc/class.sqlfs_stream_wrapper.inc.php @@ -1540,7 +1540,7 @@ class sqlfs_stream_wrapper implements iface_stream_wrapper return $stat; } - private static $pdo_type; + public static $pdo_type; /** * Case sensitive comparison operator, for mysql we use ' COLLATE utf8_bin =' * diff --git a/phpgwapi/inc/class.sqlfs_utils.inc.php b/phpgwapi/inc/class.sqlfs_utils.inc.php index b4bc41518c..f20baaf30e 100644 --- a/phpgwapi/inc/class.sqlfs_utils.inc.php +++ b/phpgwapi/inc/class.sqlfs_utils.inc.php @@ -127,23 +127,30 @@ class sqlfs_utils extends sqlfs_stream_wrapper { if (!file_exists($phy_path=self::_fs_path($row['fs_id']))) { - egw_vfs::$is_root = true; $path = self::id2path($row['fs_id']); if ($check_only) { $msgs[] = lang('File %1 has no content in physical filesystem %2!', $path.' (#'.$row['fs_id'].')',$phy_path); } - elseif (self::unlink($path.'?storage=db')) // storage=db to not try to delete not existing phy. file - { - $msgs[] = lang('File %1 has no content in physical filesystem %2 --> file removed!',$path,$phy_path); - } else { - $msgs[] = lang('File %1 has no content in physical filesystem %2 --> failed to remove file!', - $path.' (#'.$row['fs_id'].')',$phy_path); + if (!isset($stmt)) + { + $stmt = self::$pdo->prepare('DELETE FROM '.self::TABLE.' WHERE fs_id=:fs_id'); + $stmt_props = self::$pdo->prepare('DELETE FROM '.self::PROPS_TABLE.' WHERE fs_id=:fs_id'); + } + if ($stmt->execute(array('fs_id' => $row['fs_id'])) && + $stmt_props->execute(array('fs_id' => $row['fs_id']))) + { + $msgs[] = lang('File %1 has no content in physical filesystem %2 --> file removed!',$path,$phy_path); + } + else + { + $msgs[] = lang('File %1 has no content in physical filesystem %2 --> failed to remove file!', + $path.' (#'.$row['fs_id'].')',$phy_path); + } } - egw_vfs::$is_root = false; } } if ($check_only && $msgs) @@ -226,7 +233,6 @@ class sqlfs_utils extends sqlfs_stream_wrapper if ($check_only && $msgs) { $msgs[] = lang('Unconnected nodes will be moved to %1.',self::LOST_N_FOUND); - continue; } return $msgs; } @@ -242,7 +248,7 @@ class sqlfs_utils extends sqlfs_stream_wrapper $msgs = array(); foreach(self::$pdo->query('SELECT fs_dir,fs_name,COUNT(*) FROM '.self::TABLE. ' WHERE fs_active='.self::_pdo_boolean(true). - ' GROUP BY fs_dir,fs_name'. + ' GROUP BY fs_dir,'.(self::$pdo_type == 'mysql' ? 'BINARY ' : '').'fs_name'. // fs_name is casesensitive! ' HAVING COUNT(*) > 1') as $row) { if (!isset($stmt))