Reputation: 25
This is a question specific to a custom wrote CMS we have taken over. We moved servers and the PHP version changed from 5.3.8 to 5.4.1. Since then we can't get the CMS to work and are getting this error:
Strict Standards: Non-static method Vox_Model_Setting::getMapper() should not be called statically, assuming $this from incompatible context in /var/www/vhosts/ds8760.dedicated.turbodns.co.uk/eera-bioenergy.com/application/modules/users/models/Role.php on line 71
Line 71 says:
$settings = new Vox_Model_Setting(Vox_Model_Setting::getMapper()->findOne(array('module' => 'users')));
Can anyone advise what may be going wrong?
Thanks :)
edit: adding getMapper()
public function getMapper()
{
if (null === self::$__mapper) {
self::setMapper(new Vox_Model_Setting_Mapper());
}
return self::$__mapper;
}
Upvotes: 1
Views: 12360
Reputation: 8582
PHP 5.4 comes with Strict Standards notices active by default, notices that are off by default in 5.3, and were probably ignored (because most ppl. tend to do this, even though is a bad practice).
To quick fix the problem turn them off them (you can use this):
error_reporting(E_ALL ^ E_STRICT);
Or this in htaccess:
php_value error_reporting 30711
Still, I strongly suggest you fix them one by one. The one you specify there can be fixed by adding static to the getMapper() function, but this may affect other parts of your scripts (where it may be called non statically).
Upvotes: 0
Reputation: 38502
Just change your method type, add the static
keyword and call as you are doing now.
public function getMapper() {
if (null === self::$__mapper)
{
self::setMapper(new Vox_Model_Setting_Mapper());
}
return self::$__mapper;
}
to
public static function getMapper() { # see extra static keyword
if (null === self::$__mapper)
{
self::setMapper(new Vox_Model_Setting_Mapper());
}
return self::$__mapper;
}
Upvotes: 3