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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

File Upload on PHP 5.3.2


Go to End


2 Posts   2640 Views

Avatar
mobius

Community Member, 54 Posts

30 November 2011 at 11:10am

Hi all,

I've come across a problem trying to upload files using the Files and Images page. It only seems to happen on this server which runs php 5.3.2.

Looking at the code in the snippet below it does appear to switch based on being above 5.1.3.

Is this a bug? I'm running git 2.4 branch.

[User Error] Uncaught ReflectionException: Class FileNameFilter does not have a constructor, so you cannot pass any constructor arguments
POST /admin/assets/UploadForm

Line 90 in /var/www/sapphire/core/Object.php

Source

81 	 * @param mixed $arguments,... arguments to pass to the constructor
82 	 * @return Object
83 	 */
84 	public static function create() {
85 		$args  = func_get_args();
86 		$class = self::getCustomClass(array_shift($args));
87 		
88 		if(version_compare(PHP_VERSION, '5.1.3', '>=')) {
89 			$reflector = new ReflectionClass($class);
90 			return $reflector->newInstanceArgs($args);
91 		} else {
92 			// we're using a PHP install that doesn't support ReflectionClass->newInstanceArgs()
93 			
94 			$args = $args + array_fill(0, 9, null);
95 			return new $class($args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7], $args[8]);
96 		}
Trace

ReflectionClass->newInstanceArgs(Array) 
Line 90 of Object.php
Object::create(FileNameFilter) 
Line 211 of Folder.php
Folder->addUploadToFolder(Array) 
Line 258 of AssetAdmin.php
AssetAdmin->doUpload(Array,Form,SS_HTTPRequest) 
Line 329 of Form.php
Form->httpSubmission(SS_HTTPRequest) 
Line 143 of RequestHandler.php
RequestHandler->handleRequest(SS_HTTPRequest) 
Line 161 of RequestHandler.php
RequestHandler->handleRequest(SS_HTTPRequest) 
Line 147 of Controller.php
Controller->handleRequest(SS_HTTPRequest) 
Line 282 of Director.php
Director::handleRequest(SS_HTTPRequest,Session) 
Line 125 of Director.php
Director::direct(/admin/assets/UploadForm) 
Line 128 of main.php

Avatar
mikenz

Community Member, 2 Posts

15 March 2012 at 1:07pm

Hopefully you've already solved this but for anyone else that ends up here. It's a PHP bug - fixed in PHP 5.3.4

http://nz.php.net/ChangeLog-5.php#5.3.4
- Fixed bug #52854 (ReflectionClass::newInstanceArgs does not work for classes without constructors). (Johannes)