Silverstripe 2.4.* running on PHP5.4

If your website is still powered by Silverstripe 2.4.* but your hosting server already upgrades PHP from 5.3 to 5.4, you will have this error in a couple of places


[Notice] Array to string conversion

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)) {

Just change line 386 to


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

Also, in the core/SSViewer.php#L162
update it to:

if(is_string($templateList) && substr($templateList,-3) == '.ss') {

Ideally, SS should be upgraded to 3 or above.

This entry was posted in PHP Programming, Silverstripe. Bookmark the permalink.