Project

General

Profile

Actions

Bug #14303

closed

func_delete: error-message false

Added by Christian Hernmarck over 19 years ago. Updated almost 18 years ago.

Status:
Closed
Priority:
Should have
Category:
Backend API
Target version:
-
Start date:
2004-09-01
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
3.6.2
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

Whe trying to delete a single empty directory, without exec_commands enabled a message appears:
"The item was not a file or directory"
But it is!
The error is on line 636 - see additional information.

the detection if file or directory:
00625 if (@is_file($theFile)) {
...
00636 } elseif (@is_dir($theFile) && !$this->dont_use_exec_commands) {
...
00661 } else $this->writelog(4,2,130,"The item was not a file or directory! '%s'",Array($theFile));

do, the message should be:
"The item was not a file or directory or exec_commands are disabled" - better: test the exec_commands only if they are used (recursively deleting).

(issue imported from #M335)

Actions #1

Updated by Christian Hernmarck over 19 years ago

Bug still exists in 3.7. (Line numbers are not the same)
I have a proposal, in version 3.70:

from line 419 in class.t3lib_extfilefunc.php, old lines are marked "//"

// } elseif (@is_dir($theFile) && !$this->dont_use_exec_commands) {
} elseif (@is_dir($theFile) ) {
if ($this->actionPerms['deleteFolder']) {
$theFile = $this->is_directory($theFile);
if ($theFile) {
if ($this->checkPathAgainstMounts($theFile)) {
// if ($this->actionPerms['deleteFolderRecursively']) {
if ($this->actionPerms['deleteFolderRecursively'] && !$this->dont_use_exec_commands) {

so I put the check if exec-commands are allowed further down to where they really would be used (delete recursively).

Form me this seems to work - can someone check this and evt. put this into the project (ingmar???)

Regards Christian

Actions #2

Updated by Schmid Valentin over 19 years ago

Hello,
We have the same problem with 3.7.0 (in safe_mode of course).
I think it should also be possible to delete folders recursively
without the ugly 'exec("rm -Rf ...")'-stuff.

Heres a way to remove the directory, and all sub content. (from php.net)

function deldir($dir) {
$dh=opendir($dir);
while ($file=readdir($dh)) {
if($file!="." && $file!="..") {
$fullpath=$dir."/".$file;
if(!is_dir($fullpath)) {
unlink($fullpath);
} else {
deldir($fullpath);
}
}
}

closedir($dh);
if(rmdir($dir)) {
return true;
} else {
return false;
}
}

There are also some other exec's in class.t3lib_extfilefunc.php
line 438: exec of cp
use copy() instead

line 514: exec of cp -R
use coyr instead:
function copyr($source, $dest) {
// Simple copy for a file
if (is_file($source)) {
return copy($source, $dest);
}

// Make destination directory
if (!is_dir($dest)) {
mkdir($dest);
}
// Loop through the folder
$dir = dir($source);
while (false !== $entry = $dir->read()) {
// Skip pointers
if ($entry '.' || $entry '..') {
continue;
}
// Deep copy directories
if ($dest !== "$source/$entry") {
copyr("$source/$entry", "$dest/$entry");
}
}
// Clean up
$dir->close();
return true;
}

line 573: exec of mv
use rename() instead

line 606: exec of mv
use rename() instead

There's no nedd for all this exec's in this file.
I think you can completely replace all this exec-stuff.
Will be better for all safe_mode and non-safe_mode users.

Thanks

Actions #3

Updated by Ingmar Schlecht about 19 years ago

Fixed in HEAD CVS with fix from Christian/hernmarck.

However, I didn't close the bug yet, as I would like to see a better solution like the one valli suggested.

Actions

Also available in: Atom PDF