Jump to:

4952 Posts in 14256 Topics by 1491 members

Installing SilverStripe

SilverStripe Forums » Installing SilverStripe » Installing 2.4 - Array to string conversion

Getting SilverStripe up and running on your computer and on your web server.

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

Page: 1 2
Go to End
Author Topic: 2588 Views
  • thepurpleblob
    Avatar
    Community Member
    28 Posts

    Installing 2.4 - Array to string conversion Link to this post

    I am attempting to install a 2.4 site - the latest from Git topped up with Composer. I am running PHP 5.4.6

    When trying to build the database it fails with the following message...

    [Notice] Array to string conversion
    POST /silver/install.php

    Line 396 in /var/www/silver/sapphire/core/model/Database.php

    I have read a few posts about such issues in 2.4 and PHP 5.4.6 but couldn't find anything related to installing it in the first place. I'm stuck with 2.4 for the moment by the way.

    Any help appreciated.

  • Pigeon
    Avatar
    Community Member
    243 Posts

    Re: Installing 2.4 - Array to string conversion Link to this post

    Are you using a _ss_environment.php file?

    Are you using a global called $database in your config?

    Have you defined $databaseConfig array in your config?

    It sounds like one of the database details that should be a strong is set to an array instead.

  • Willr
    Avatar
    Forum Moderator
    5489 Posts

    Re: Installing 2.4 - Array to string conversion Link to this post

    SilverStripe 2.4 (early versions) do not support PHP5.4 out of the box (before it existed!) so try the post-2.4 branch from git for support. The latest 2.4.* release should also support it.

  • Optic Blaze
    Avatar
    Community Member
    161 Posts

    Re: Installing 2.4 - Array to string conversion Link to this post

    Hi there,

    I just installed a fresh copy of SS 2.4.10 and i also get the 'Array to string conversion' error...see below. The server runs PHP 5.4.4:

    [Notice] Array to string conversion
    GET /sunnyecom/admin/

    Line 386 in ...../sapphire/core/control/Controller.php
    Source

    377    /**
    378     * Returns true if the member is allowed to do the given action.
    379     * @param perm The permission to be checked, such as 'View'.
    380     * @param member The member whose permissions need checking. Defaults to the currently logged
    381     * in user.
    382     * @return boolean
    383     */
    384    function can($perm, $member = null) {
    385       if(!$member) $member = Member::currentUser();
    386       if($this->hasMethod($methodName = 'can' . $perm)) {
    387          return $this->$methodName($member);
    388       } else {
    389          return true;
    390       }
    391    }
    392

  • thepurpleblob
    Avatar
    Community Member
    28 Posts

    Re: Installing 2.4 - Array to string conversion Link to this post

    Sorry for the delay - this site hates me and I couldn't get logged back in.

    I was using the latest version from the Git repository all along so no progress there. In the end, I didn't have a huge amount to do so I just installed it on one of our servers running PHP 5.3. Got the job done in terminal mode and Vim - just like the good old days ;-)

    Thanks anyway for the help !!

  • Tama
    Avatar
    Community Member
    130 Posts

    Re: Installing 2.4 - Array to string conversion Link to this post

    Does anyone have a fix for this?

    I've got an existing 2.4 website I'm trying to work on in my local environment (latest version of XAMMP). I've upgraded it to 2.4.10 but am still getting this error when I try to logon to the admin area:

    [Notice] Array to string conversion
    GET /admin

    Line 386 in C:\xampp\htdocs\heart-of-biking\sapphire\core\control\Controller.php

    384    function can($perm, $member = null) {
    385       if(!$member) $member = Member::currentUser();
    386       if($this->hasMethod($methodName = 'can' . $perm)) {
    387          return $this->$methodName($member);
    388       } else {
    389          return true;
    390       }
    391    }

    I don't want to downgrade the PHP version in my local environment, is there any other way to fix this?

  • Willr
    Avatar
    Forum Moderator
    5489 Posts

    Re: Installing 2.4 - Array to string conversion Link to this post

    Download the post-2.4 branch from github. You can patch that file also if you need http://open.silverstripe.org/ticket/7737

  • Tama
    Avatar
    Community Member
    130 Posts

    Re: Installing 2.4 - Array to string conversion Link to this post

    Thanks Will.

    I added the following to line 386 on Controller.php

    if(is_string($perm) && $this->hasMethod($methodName = 'can' . $perm)) {

    Seems to work.

    2588 Views
Page: 1 2
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.