#2581 - Compatibility with PHP 7.0
In PHP 7.0 there is a change:
From [php.net - Calls from incompatible context removed](http://php.net/manual/en/migration70.incompatible.php)
> Previously deprecated in PHP 5.6, static calls made to a non-static method with an incompatible context will now result in the called method having an undefined $this variable and a deprecation warning being issued.
When running under PHP 7.0+ the code in SecurityGroup.php breaks when making references to $this.
Example:
~~~
function assign_default_groups(&$focus,$isUpdate)
{
global $sugar_config;
global $current_user;
if(!$isUpdate) {
$defaultGroups = SecurityGroup::retrieveDefaultGroups(); // <-- Class function called statically
.......
~~~
In the function retrieveDefaultGroups:
~~~
function retrieveDefaultGroups() {
$default_groups = array();
$query = "select securitygroups_default.id, securitygroups.name, securitygroups_default.module, securitygroups_default.securitygroup_id "
."from securitygroups_default "
."inner join securitygroups on securitygroups_default.securitygroup_id = securitygroups.id "
."where securitygroups_default.deleted = 0 and securitygroups.deleted = 0";
$GLOBALS['log']->debug("SecuritySuite: Retrieve Default Groups: $query");
$result = $this->db->query($query); // <----- This produces a PHP Fatal error
~~~
**Could all the references to $this->db be changed to $GLOBALS['db'] ??**
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago