News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Attachments not working (for some) after upgrade.

Started by casp3r, March 15, 2010, 11:42:36 AM

Previous topic - Next topic

casp3r

I've just upgraded from RC2 to RC3. Uninstalled all mods and used the 'Large Upgrade'. Upgrade went fine, no errors reported, or so I thought. A few members have reported that when they try to add image attachments to a post they get the following error message:

QuoteFatal error: Allowed memory size of 16777216 bytes exhausted (tried to allocate 4400 bytes) in /home/sites/public_html/Sources/Subs-Graphics.php  on line 415

The attachments always worked before the upgrade. I've tried adding an attachment as the admin and it works fine. Is there anything I should be looking at to fix this problem?

Many thanks in advance.
Aviation forum & gallery
www.niaviation.co.uk

Kays

Hi, what size image are they trying to upload?

Go into the Attachment settings and verify them.
Any errors in the forum error log?

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

casp3r

The image was
Image size 1100x741 407kb.

and nothing is showing in the error logs. I have no limits set for attachments (other than 4 per post).
Aviation forum & gallery
www.niaviation.co.uk

Kays

There shouldn't be a problem with a file that size. Judging by the error, it's running out f memory when resizing.

In Subs-Graphics.php on about line 267, is this value set at 90?


// Ask for more memory: we need it for this, and it'll only happen once!
@ini_set('memory_limit', '90M');

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

casp3r

It's at line 222 but yes it is set to 90M. I see another member has since posted some attachments but there are still two how can't and always could before the upgrade.
Aviation forum & gallery
www.niaviation.co.uk

mint

I'm getting a 500 internal server error when trying to post any attachment after the upgrade. I removed all mods prior to upgrade and there are non installed atm. I've tried changing the attachments directory to 777 but i'm not sure what else to try.

mint

I've just tried uploading another image and it sits there looking like it might be uploading and then I get a blank white page  :-\

casp3r

I've been able to replicate the error and it seems to related to the resizing of the attachments. I tried to attach 3 photos that were 1200*800 and got the error message mentioned earlier - it mentions line 389 of the Subs-Graphics.php - it's the line in bold

      // Don't bother resizing if it's already smaller...
      if (!empty($dst_width) && !empty($dst_height) && ($dst_width < $src_width || $dst_height < $src_height || $force_resize))
      {
         // (make a true color image, because it just looks better for resizing.)
         if ($gd2)
         {
            $dst_img = imagecreatetruecolor($dst_width, $dst_height);

            if (!empty($modSettings['avatar_download_png']))
            {
               imagealphablending($dst_img, false);
               if (function_exists('imagesavealpha'))
                  imagesavealpha($dst_img, true);
            }
         }

I resized the three images to 800*533 and they attached to the post with no problems. Is this a problem server side or coding?
Aviation forum & gallery
www.niaviation.co.uk

Kays

it sounds like your server isn't respecting the temporary memory limit change.

For the smaller images, do the thumbnails get made? What size do you have posted images set at?

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

casp3r

Sorted - was able to increase the memory_limit from 16M to 32M using a custom php.ini in the sites root folder.

memory_limit=32M

Just can't understand how this only occurred after the upgrade.
Aviation forum & gallery
www.niaviation.co.uk

Kays

Good, I'm glad that you were able to up the limit.

I don't know why it would bork with RC3 since the code in that area hasn't changed as far as I know.

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

casp3r

I definitely think it may have something to do with the code. I have another forum (SMF 2.0 RC1-1) on the same server. The images that cause the problems on the RC3 forum upload with no problems on the RC1-1 forum.
Aviation forum & gallery
www.niaviation.co.uk

mint

 :-[ I don't know anything about php.ini files. Is this really the way to fix it?

Kill Em All



My Site: KEAGaming.com

Manual Installation of Mods
Prevent Spam and Forum Attacks
Please do not PM or email me for support unless offered, help should be publicly displayed to others.

Kays

Quote from: casp3r on March 20, 2010, 04:56:11 PM
I definitely think it may have something to do with the code. I have another forum (SMF 2.0 RC1-1) on the same server. The images that cause the problems on the RC3 forum upload with no problems on the RC1-1 forum.

I did a comparison of that file to the older version and there have been some changes made. But the memory limit increase is still a part of how it works. So I don't understand.

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Kays

It looks like it might be a bug. Someone else was having the same problem and I was able to reproduce it.
I have added it to the bug tracker.

A temporary fix, since you could still have problems with larger files. On line about 309 in Subs-Graphics.php look for:


require_once($sourcedir . '/Subs-Package.php');


And add after it:


@ini_set('memory_limit', '90M');



If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

amorosso

Quote from: Kays on March 21, 2010, 10:47:47 AM
It looks like it might be a bug. Someone else was having the same problem and I was able to reproduce it.
I have added it to the bug tracker.

A temporary fix, since you could still have problems with larger files. On line about 309 in Subs-Graphics.php look for:


require_once($sourcedir . '/Subs-Package.php');


This did the trick for me.. Thank you very much.

And add after it:


@ini_set('memory_limit', '90M');


louco

Quote from: Kays on March 21, 2010, 10:47:47 AM
It looks like it might be a bug. Someone else was having the same problem and I was able to reproduce it.
I have added it to the bug tracker.

A temporary fix, since you could still have problems with larger files. On line about 309 in Subs-Graphics.php look for:


require_once($sourcedir . '/Subs-Package.php');


And add after it:


@ini_set('memory_limit', '90M');




Thx a lot !
That solved my problem of the white page showing up when trying to upload atachments!

Kays

Hmm, upgrading to RC4 should resolve that as well as some other issues with attachment handling.

Please do so, as there have been some security issues addressed also.

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Advertisement: