mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
NEW Add param $nolog to avoid logging into dol_delete_recursive_dir()
This commit is contained in:
parent
0325b68bfb
commit
fdffc0c13a
|
|
@ -1159,10 +1159,11 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable
|
|||
* @param object $object Current object in use
|
||||
* @param boolean $allowdotdot Allow to delete file path with .. inside. Never use this, it is reserved for migration purpose.
|
||||
* @param int $indexdatabase Try to remove also index entries.
|
||||
* @param int $nolog Disable log file
|
||||
* @return boolean True if no error (file is deleted or if glob is used and there's nothing to delete), False if error
|
||||
* @see dol_delete_dir()
|
||||
*/
|
||||
function dol_delete_file($file, $disableglob = 0, $nophperrors = 0, $nohook = 0, $object = null, $allowdotdot = false, $indexdatabase = 1)
|
||||
function dol_delete_file($file, $disableglob = 0, $nophperrors = 0, $nohook = 0, $object = null, $allowdotdot = false, $indexdatabase = 1, $nolog = 0)
|
||||
{
|
||||
global $db, $conf, $user, $langs;
|
||||
global $hookmanager;
|
||||
|
|
@ -1170,7 +1171,9 @@ function dol_delete_file($file, $disableglob = 0, $nophperrors = 0, $nohook = 0,
|
|||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('other', 'errors'));
|
||||
|
||||
dol_syslog("dol_delete_file file=".$file." disableglob=".$disableglob." nophperrors=".$nophperrors." nohook=".$nohook);
|
||||
if (empty($nolog)) {
|
||||
dol_syslog("dol_delete_file file=".$file." disableglob=".$disableglob." nophperrors=".$nophperrors." nohook=".$nohook);
|
||||
}
|
||||
|
||||
// Security:
|
||||
// We refuse transversal using .. and pipes into filenames.
|
||||
|
|
@ -1304,11 +1307,15 @@ function dol_delete_dir($dir, $nophperrors = 0)
|
|||
* @param int $nophperrors Disable all PHP output errors
|
||||
* @param int $onlysub Delete only files and subdir, not main directory
|
||||
* @param int $countdeleted Counter to count nb of elements found really deleted
|
||||
* @param int $indexdatabase Try to remove also index entries.
|
||||
* @param int $nolog Disable log files (too verbose when making recursive directories)
|
||||
* @return int Number of files and directory we try to remove. NB really removed is returned into var by reference $countdeleted.
|
||||
*/
|
||||
function dol_delete_dir_recursive($dir, $count = 0, $nophperrors = 0, $onlysub = 0, &$countdeleted = 0)
|
||||
function dol_delete_dir_recursive($dir, $count = 0, $nophperrors = 0, $onlysub = 0, &$countdeleted = 0, $indexdatabase = 1, $nolog = 0)
|
||||
{
|
||||
dol_syslog("functions.lib:dol_delete_dir_recursive ".$dir, LOG_DEBUG);
|
||||
if (empty($nolog)) {
|
||||
dol_syslog("functions.lib:dol_delete_dir_recursive ".$dir, LOG_DEBUG);
|
||||
}
|
||||
if (dol_is_dir($dir)) {
|
||||
$dir_osencoded = dol_osencode($dir);
|
||||
if ($handle = opendir("$dir_osencoded")) {
|
||||
|
|
@ -1319,9 +1326,9 @@ function dol_delete_dir_recursive($dir, $count = 0, $nophperrors = 0, $onlysub =
|
|||
|
||||
if ($item != "." && $item != "..") {
|
||||
if (is_dir(dol_osencode("$dir/$item")) && !is_link(dol_osencode("$dir/$item"))) {
|
||||
$count = dol_delete_dir_recursive("$dir/$item", $count, $nophperrors, 0, $countdeleted);
|
||||
$count = dol_delete_dir_recursive("$dir/$item", $count, $nophperrors, 0, $countdeleted, $indexdatabase, $nolog);
|
||||
} else {
|
||||
$result = dol_delete_file("$dir/$item", 1, $nophperrors);
|
||||
$result = dol_delete_file("$dir/$item", 1, $nophperrors, 0, null, false, $indexdatabase, $nolog);
|
||||
$count++;
|
||||
if ($result) {
|
||||
$countdeleted++;
|
||||
|
|
@ -1332,6 +1339,7 @@ function dol_delete_dir_recursive($dir, $count = 0, $nophperrors = 0, $onlysub =
|
|||
}
|
||||
closedir($handle);
|
||||
|
||||
// Delete also the main directory
|
||||
if (empty($onlysub)) {
|
||||
$result = dol_delete_dir($dir, $nophperrors);
|
||||
$count++;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user