# HG changeset patch # User Dan # Date 1185402324 14400 # Node ID 10d663f5ed888c64a06cc2709a3be8ab61e05bb1 # Parent 88c954d2846c3896871a2fff9914b3ec5abb0440 Added check in upload wizard to prevent folders from being added to one of their children or to themselves (fatal error: maximum execution time of 600 seconds exceeded anyone?) diff -r 88c954d2846c -r 10d663f5ed88 plugins/gallery/upload.php --- a/plugins/gallery/upload.php Wed Jul 25 18:15:14 2007 -0400 +++ b/plugins/gallery/upload.php Wed Jul 25 18:25:24 2007 -0400 @@ -228,6 +228,15 @@ if ( $target_folder ) { + // Make sure we're not trying to move a folder to itself or a subdirectory of itself + + $children = gal_fetch_all_children(intval($img_data['id'])); + if ( $img_data['id'] == $target_folder || in_array($target_folder, $children) ) + { + $errors[] = 'You are trying to move a folder to itself, or to a subdirectory of itself, which is not allowed. If done manually (i.e. via an SQL client) this will result in infinite loops in the folder sorting code.'; + break 2; + } + $to_update['folder_parent'] = $target_folder; } @@ -349,7 +358,7 @@ $folder = sanitize_page_id($folder); } $folders = array_reverse($folders); - $gal_href = implode('/', $folders) . '/' . sanitize_page_id($row['img_title']); + $gal_href = implode('/', $folders) . ( count($folders) > 0 ? '/' : '' ) . sanitize_page_id($row['img_title']); echo '
';