PDA

View Full Version : Problem with admincp/attachment.php


Mystics
Sat 21st Jun '03, 2:16pm
I think there is a bug in admincp/attachment.php (domoveattachment function): if ($startat < 0)
{
$start = $DB_site->query_first("SELECT MIN(attachmentid) AS min FROM " . TABLE_PREFIX . "attachment");
$startat = $start['min'];
}You never have the chance to enter a value for $startat...so this condition will never be true, and therefore $startat will be always 0.

So if your first attachmentid is eg. 2000 and $perpage is set to 100, this function will be executed around 20 times without doing anything...until $startat=2000 :)

(And a few lines below is a little unimportant typo: if ($devdeug))

And last but not least IMO the text of the phrase error_writing_x is not appropriate:Error Writing {1}. You Can See More Information AboveBut there is no more information :)
I think this information is only shown when $devdebug=1;

Mystics
Sun 22nd Jun '03, 9:47am
I found another bug in this file, take a look at this piece of code: // delete attachments
$ids = $DB_site->query("SELECT attachmentid, userid FROM " . TABLE_PREFIX . "attachment");
while ($id = $DB_site->fetch_array($ids))
{
$userids[] = $id['userid'];
@unlink("$vboptions[attachpath]/$id[userid]/$id[attachmentid].attach");
}
$DB_site->free_result($ids);

// delete attachment directories
foreach($userids AS $userid)
{
@exec("rm -rf $vboptions[attachpath]/$id[userid]");
}$id[userid] has to be replaced with $userid. Otherwise you will end up with this command:rm -rf $vboptions[attachpath]/And this will remove the entire attachment directory (I'm talking from experience :p)

Please add also a check that $userid actually is not = "".

And why is the command within the foreach loop not included in the while loop? Like this: $ids = $DB_site->query("SELECT attachmentid, userid FROM " . TABLE_PREFIX . "attachment");
while ($id = $DB_site->fetch_array($ids))
{
// delete attachments
@unlink("$vboptions[attachpath]/$id[userid]/$id[attachmentid].attach");

// delete attachment directories
@exec("rm -rf $vboptions[attachpath]/$id[userid]");
}
$DB_site->free_result($ids);(yes, if an user has more than one attachment, the "delete attachment directories" function will be executed several times...but IMO that also happens with the foreach loop)

----------------------------------------------------------------------

Another thing, maybe I have misunderstood the "Move Attachments to a Different Directory" function, but I thought I can actually move the attachments to a different directory....but in fact only the path for future attachments will be updated. And all old attachments don't work any longer when changing the path.

----------------------------------------------------------------------

While moving the attachments from DB -> FS I noticed this error message:Written filesize does not match database filesize:

File: banner.jpg
Database: 33468
Filesystem: 33346
Error Writing banner.jpg. You Can See More Information AboveThat was the only image with such a problem (and yes, it seems to be damaged as I can't view it), but I couldn't continue with the other attachments until deleting this attachment or removing the print_stop_message. Maybe it would be possible to continue nevertheless with a "Ignore this error and continue the process", "Delete this attachment" button or something like that :)

Mystics
Sun 22nd Jun '03, 10:37am
And another attachment bug, but this time in includes/functions.php.

Line 79-83:function verify_attachment_path($userid)
{
global $vboptions;

if ($userid)This condition won't be true if a guest/unregistered member has posted the attachment. Maybe this should be changed inif (isset($userid))or something like that (this change worked for me) ;)

Freddie Bingham
Sun 22nd Jun '03, 12:22pm
You have to move the attachments yourself to the new location. I checked and the phrase that is displayed when using "move to a different directory" tells you this.

Mystics
Sun 22nd Jun '03, 12:32pm
and the phrase that is displayed when using "move to a different directory" tells you this.Ah ok, thanks for the info.

But actually it doesn't tell this in Beta 3 :)Could not find phrase 'your_vb_settings_have_been_updated_to_store_attac hments_in_x'.But I have checked the cvs now and have seen it in the new language file.

Freddie Bingham
Sun 22nd Jun '03, 1:44pm
My beta 3 board has that phrase as it appears in the CVS currently. Odd.

Mystics
Sun 22nd Jun '03, 3:36pm
My beta 3 board has that phrase as it appears in the CVS currently. Odd.Hm, yes you are right, it really does exist but it is not shown.

I also have tried it now at http://beta.jelsoft.com and there is the same error message. I think that's because this phrase is in the wrong "Phrase Type Category" (Attachment / Image instead of Control Panel Stop Message).

Freddie Bingham
Sun 22nd Jun '03, 4:51pm
Yes that's it.