Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

File upload issue - 500 Server Error - Gallery modules on SS3.1.2


Go to End


4 Posts   3318 Views

Avatar
Liquid Edge Creative

Community Member, 56 Posts

19 December 2013 at 11:13am

Hi team,

I'm having a hard time trying to get various gallery modules to work properly on a fresh install of SS 3.1.2 on my local server.

Doing thorough testing with the tractorcow silverstripe-imagegallery (my preferred option), I think I've narrowed the problem down to a file size issue, as follows:

I can add new images to the gallery just fine as long as they are only a few hundred K in size. However, as soon as I try to upload a larger image (say 3MB), it throws a 500 Internal Server Error (according to Fire Bug).

From then on, I am unable to access the Uploads folder in the CMS Files section - the same error appears. Likewise, when I try to choose a file from the site for the album 'Cover Image' instead of upload a new one, the pop-up is blank and the same error is thrown.

The only other modules I have installed are gridfieldextensions and sortablegridfield.

According to phpInfo, my post_max_size and upload_max_filesize are both set to 32M.

Unfortunately I've been unable to get any more details on the errors. Someone may be able to suggest a way to do this?

I think I've set the environment to Dev mode via the config.yml file but I'm more used to the old way of doing it through the mysite/_config.php file and I'm not sure it's working as I'm not receiving any errors by email. The content of my config.yml looks like this:

---
Name: mysite
After: 'framework/*','cms/*'
---
# YAML configuration for SilverStripe
# See http://doc.silverstripe.org/framework/en/topics/configuration
# Caution: Indentation through two spaces, not tabs
SSViewer:
  theme: 'simple'
Director:
  environment_type: 'dev'
Debug:
  send_errors_to: 'studio@liquidedge.co.nz'

Hope someone can help!

Cheers,

Dave

Avatar
Nivanka

Community Member, 400 Posts

31 December 2013 at 5:02am

Good to check the permissions of the assets folder too.

also check the apache error logs. if you post a bit of those will be able to give more information

Avatar
Liquid Edge Creative

Community Member, 56 Posts

15 January 2014 at 4:54pm

Thanks Nivanka, have made a little more headway on this issue.

First up, I finally found the full error message that's thrown when I upload images to the silverstripe-imagegallery using BulkUpload. Here's the start of the it (and the full message is attached):

ERROR [Notice]: Undefined index: ImageID
IN POST /ss3.1/wildside/admin/pages/edit/EditForm/field/Albums/item/4/ItemEditForm/field/GalleryItems/bulkimageupload/upload
Line 131 in /Volumes/Macintosh HD 2/Documents/Design/WebServer/ss3.1/wildside/gridfield-bulk-editing-tools/code/GridFieldBulkImageUpload_Request.php

Source
======
  122: 	 */
  123: 	private function getFileRelationClassName()
  124: 	{
  125: 		$recordClass        = $this->gridField->list->dataClass;
  126: 		$recordHasOneFields = Config::inst()->get($recordClass, 'has_one', Config::INHERITED);
  127: 
  128: 		$fieldName = $this->getFileRelationName();
  129: 		if($fieldName != null)
  130: 		{
* 131: 			return $recordHasOneFields[$fieldName];
  132: 		}
  133: 		else{
  134: 			return 'File';
  135: 		}		
  136: 	}
  137: 	

Just to clarify, the images themselves are uploaded to the folder fine but I'm not given the opportunity to add the caption they should have. Here are some screen shots of the CMS following an attempted upload, and you can see that the two new images are not connecting themselves to the gallery album correctly:


I assume the red indicates a problem with the upload even though it says (correctly) that the images were uploaded.


At the bottom of the table you can see two empty rows where the new images should be.

Secondly, I found the following error in the PHP error logs when I was trying to access the Uploads folder:

PHP Fatal error:  Allowed memory size of 67108864 bytes exhausted (tried to allocate 15552 bytes) in /Volumes/Macintosh HD 2/Documents/Design/WebServer/ss3.1/wildside/framework/filesystem/GD.php on line 51

Increasing the memory_limit from 32M to 128M and the max_execution_time from 30 to 60 in php.ini has fixed this, but I suspect the root cause is still tied up in the BulkUpload problem.

Attached Files
Avatar
Liquid Edge Creative

Community Member, 56 Posts

31 January 2014 at 11:27am

PROBLEM SOLVED!

Thanks to Mr TractorCow himself, I discovered the version of ImageGallery I was using (composer require tractorcow/silverstripe-imagegallery dev-master from late December 2013) didn't include this vital patch:
https://github.com/tractorcow/ImageGallery/commit/e50c77a12d197f07b48946a5d0f980b90dbaf7d0
With that change made, we are all hunky-dory.

On another related note, album pagination is not working in TractorCow's otherwise excellent port of the original Uncle Cheese module to SS3. I fixed this by adding the following to ImageGalleryPage.php:

 public function PaginatedGallery() {
		$length = $this->MediaPerPage;
	  	$paginatedList = new PaginatedList($this->AllGalleryItems(), $this->request);
	  	$paginatedList->setPageLength($length);
	  	return $paginatedList;
	}

Then replacing the original pagination code in AlbumImages.ss with this:

<% if $PaginatedGallery.MoreThanOnePage %>
	<ul id="pagination-imagegallery">
    <% if $PaginatedGallery.NotFirstPage %>
        <li class="previous"><a class="prev" href="$PaginatedGallery.PrevLink">Prev</a></li>
    <% end_if %>
    <% loop $PaginatedGallery.Pages %>
        <% if $CurrentBool %>
            <li class="active">$PageNum</li>
        <% else %>
            <% if $Link %>
                <li><a href="$Link">$PageNum</a></li>
            <% else %>
                <li>...</li>
            <% end_if %>
        <% end_if %>
        <% end_loop %>
    <% if $PaginatedGallery.NotLastPage %>
        <li class="next"><a class="next" href="$PaginatedGallery.NextLink">Next</a></li>
    <% end_if %>
    </ul>
<% end_if %>

Hopefully something similar will make it's way into the ImageGallery module soon.