#451 - Some models are broken on PHP 7+

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']});

Activity

  1. Jack updated this ticket
    9 years ago
    • Component Core
    • Severity Normal Blocker
    • Priority Normal Highest
    • Status New Accepted
    • Assigned 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.

  2. Eric TF Bat commented
    7 years ago

    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.

  3. Jack closed this ticket as Fixed
    7 years ago

Status

Fixed
Jack
Highest

Details

Defect
3.7.2
Core
3.7.2
Blocker

Tracking

alex
9 years ago
7 years and 2 months ago
0
-
-