Jump to:

23478 Posts in 18941 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » File Upload on PHP 5.3.2

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

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

Page: 1
Go to End
Author Topic: 1261 Views
  • mobius
    Avatar
    Community Member
    54 Posts

    File Upload on PHP 5.3.2 Link to this post

    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

  • mikenz
    Avatar
    Community Member
    2 Posts

    Re: File Upload on PHP 5.3.2 Link to this post

    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)

    1261 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.