Some models are broken on PHP 7+

451
Defect
alex
Jack
3.7.2
3.7.2
Core
Accepted
Highest
Blocker
1 year ago
1 week ago
0

Description

What did you do to cause this? Fresh installation

What page were you on? /users/1 and /admin/

What PHP and MariaDB versions do you run? PHP 7.1.1 and MariaDB 15.1

Describe the defect: PHP7 changed how variables-variables are processed (explanation here). Among other things, it makes the group view unloadable and breaks functionality such as admin panel.

I know that PHP 7 isn't officially supported in 3.X, but the fix is easy and won't break PHP 5.

File vendor/avalon/database/model.php line #401 changes from:

return $this->$var = $model::find($belongs_to['foreign_key'], $this->$belongs_to['column']);

To:

return $this->$var = $model::find($belongs_to['foreign_key'], $this->{$belongs_to['column']});

Ticket History

1 year and 5 months ago by Jack

  • Set Component to Core
  • Changed Severity from Normal to Blocker
  • Changed Priority from Normal to Highest
  • Changed Status from New to Accepted
  • Assigned ticket to Jack

Thank you for the report, I have not tested on PHP 7 much. Will try to get this done ASAP after work. Thank you again.

1 week and 4 days ago by Eric TF Bat

The suggestion here is almost correct, and was good enough to help me when I tried installing Traq on a modern (ie PHP7) server, but the square brackets are erroneous. I just did this instead:

$xxx = $belongs_to['column'];
return $this->$var = $model::find($belongs_to['foreign_key'], $this->$xxx);

This really needs fixing. Nobody using PHP 7 will be able to use Traq without this, and your website(s) say nothing about the requirement to use ONLY version 5.x.