Dev Board => cpg1.4 Testing/Bugs => cpg1.4 Testing/Bugs: FIXED/CLOSED => Topic started by: SamBuca on January 25, 2009, 10:02:43 am

Title: [Fixed]: Batch upload dupes?
Post by: SamBuca on January 25, 2009, 10:02:43 am
Didn't see this bug anywhere and the bug forum appears to be here it is....

First, all the occurrences of readdir() may cause a problem because they don't do the boolean check.

Second, I had a problem when I upgraded to 1.4.19 where the batch upload function would put 2 of every picture on the page where you select the album, select the pictures, and press "insert selected files" (last step of the batch upload)....but ONLY if it was automatically renaming the files.  It seems that by using readdir(), the actively open file handle is returning the "new" files, and since you put the new file name into $pic_array already, it's putting everything on twice.  Using scandir() would solve that by taking a snapshot of the directory and then processing it, but a huge directory would create a huge array and eat up memory.  Therefore, keeping things the way they are and adding a simple in_array() check is a quick fix.  Here are the fixes I did:

searchnew.php line 225:
Code: [Select]
while ($file = readdir($dir)) {


while (false !== ($file = readdir($dir))) {

searchnew.php line 231:
Code: [Select]
if (is_file($CONFIG['fullpath'] . $folder . $file)) {


if (is_file($CONFIG['fullpath'] . $folder . $file) && !in_array($file, $pic_array)) {

To reproduce it:

1) Upload a directory of files which will be renamed (a space in the file name).
2) chmod -R 777
3) Batch add files
4) Browseable is ON but it doesn't make a difference.
5) Click on the directory and hit OK.
6) The list will double up on all the files that were renamed.

I'm not sure if this is because I'm still running PHP4....they may have changed under-the-hood of readdir() in PHP5.

Debugging output from the program:
PHP version: 4.3.10 - OK
mySQL version: 4.0.24-log
Coppermine version: 1.4.19(stable)
Module: GD
GD Version: bundled (2.0.28 compatible)
FreeType Support:
T1Lib Support:
GIF Read Support: 1
GIF Create Support: 1
JPG Support: 1
PNG Support: 1
WBMP Support: 1
XBM Support: 1
JIS-mapped Japanese Font Support:

Module: mysql
MySQL Supportenabled
Active Persistent Links 0
Active Links 1
Client API version 3.23.49
MYSQL_SOCKET /tmp/mysql.sock
MYSQL_LIBS no value
Module: zlib
ZLib Support enabled
Compiled Version 1.1.4
Linked Version 1.2.3
Server restrictions (safe mode)?
Directive | Local Value | Master Value
safe_mode | Off | Off
safe_mode_exec_dir | no value | no value
safe_mode_gid | Off | Off
safe_mode_include_dir | no value | no value
safe_mode_exec_dir | no value | no value
sql.safe_mode | Off | Off
disable_functions | no value | no value
file_uploads | On | On
include_path | .:/usr/local/lib/php | .:/usr/local/lib/php
open_basedir | no value | no value
Directive | Local Value | Master Value
sendmail_from | no value | no value
sendmail_path | /usr/sbin/sendmail -t -i  | /usr/sbin/sendmail -t -i
SMTP | localhost | localhost
smtp_port | 25 | 25
Size and Time
Directive | Local Value | Master Value
max_execution_time | 30 | 30
max_input_time | 60 | 60
upload_max_filesize | 2M | 2M
post_max_size | 2M | 2M

Since I've been using coppermine for years now....I should say thanks for a great piece of software :)
Title: Re: Batch upload dupes?
Post by: chelnov on April 26, 2009, 01:38:58 pm
I have the same problem with PHP5.
Coppermine UI says that there is 111 pictures in the gallery but when I do like:
ls | grep ^G | nl
index of last image is 101..
Title: Re: Batch upload dupes?
Post by: Joachim Müller on April 27, 2009, 10:00:43 am
There's no support on the bugs board. Post relevant information or don't post at all.
Title: Re: Batch upload dupes?
Post by: Joachim Müller on May 25, 2009, 11:03:02 pm
@SamBuca: thanks for your suggestions - applied them to the SVN both for cpg1.4.x as well as cpg1.5.x. The changes will go into cpg1.4.24
Title: Re: [Fixed]: Batch upload dupes?
Post by: derangedtaco on August 24, 2009, 02:36:38 am
This problem does not appear to be fixed in cpg1.4.24 :-\
Title: Re: [Fixed]: Batch upload dupes?
Post by: Joachim Müller on August 24, 2009, 01:26:31 pm
But the code changes you suggested are in the SVN and the package as far as I can see.