View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
1905 | RackTables | default | public | 2019-04-30 10:30 | 2019-05-04 23:12 |
Reporter | altpeter | Assigned To | infrastation | ||
Priority | low | Severity | block | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Product Version | 0.21.2 | ||||
Target Version | 0.21.3 | Fixed in Version | 0.21.3 | ||
Summary | 1905: functions.php using new array initializatio | ||||
Description | Hi, I tried to update my RackTables installation from 0.20.14 to 0.21.2. That failed with the following error when trying to run the upgrade procedure: PHP Parse error: syntax error, unexpected '[' in /srv/www/htdocs/RackTables-0.21.2/wwwroot/inc/functions.php on line 4825 That line says: $removed = []; As far as I was able to research, this seems to be a new way to initialize arrays with [] instead of array(), but is basically the same. Problem is, this new style doesn't work with PHP 5.3, but I have to stick with this version since there are too many caveats trying to upgrad this particular machine. While I can live with that, I assume there are some other installations out there running old PHP, and since [] can easily be replaced by array(), I would suggest using the classic syntax here. Patch attached. | ||||
Steps To Reproduce | - Install RackTables-0.21.2 on a server running PHP 5.3 and execute wwwroot/index.php (or open in browser) | ||||
Tags | No tags attached. | ||||
patch.txt (1,175 bytes)
*** functions.php.orig Tue Apr 30 10:25:09 2019 --- functions.php Tue Apr 30 10:27:35 2019 *************** *** 4822,4828 **** { if (! array_key_exists($pn, $before)) { ! $removed = []; $added = $new['allowed']; } else --- 4822,4828 ---- { if (! array_key_exists($pn, $before)) { ! $removed = array(); $added = $new['allowed']; } else *************** *** 4841,4850 **** } } foreach ($removed as $vid) ! if (!permitted (NULL, NULL, $op, [['tag' => "\$fromvlan_{$vid}"], ['tag' => "\$vlan_{$vid}"]])) continue 2; // next port foreach ($added as $vid) ! if (!permitted (NULL, NULL, $op, [['tag' => "\$tovlan_{$vid}"], ['tag' => "\$vlan_{$vid}"]])) continue 2; // next port $ret[$pn] = $new; } --- 4841,4850 ---- } } foreach ($removed as $vid) ! if (!permitted (NULL, NULL, $op, array( 'tag' => "\$fromvlan_{$vid}", 'tag' => "\$vlan_{$vid}" ) )) continue 2; // next port foreach ($added as $vid) ! if (!permitted (NULL, NULL, $op, array( 'tag' => "\$tovlan_{$vid}", 'tag' => "\$vlan_{$vid}" ) )) continue 2; // next port $ret[$pn] = $new; } |
|
Frank, the proposed change would break the function (mind the way arrays are nested in each other), I have committed a corrected version. Beware that RackTables 0.21.x will expose other issues on a server with PHP 5.3 because it does not support PHP older than 5.5. This was announced on the mailing list a long time ago. Moreover, dropping support for PHP 5.x completely will happen in not so distant future because the upstream no longer supports it. If it is difficult to upgrade the server, maybe it would be better to setup a separate server with a recent stable PHP version and migrate RackTables there. |
|
Date Modified | Username | Field | Change |
---|---|---|---|
2019-04-30 10:30 | altpeter | New Issue | |
2019-04-30 10:30 | altpeter | File Added: patch.txt | |
2019-05-04 23:08 | infrastation | Source_changeset_attached | => RackTables master 1cdada15 |
2019-05-04 23:12 | infrastation | Assigned To | => infrastation |
2019-05-04 23:12 | infrastation | Status | new => closed |
2019-05-04 23:12 | infrastation | Resolution | open => fixed |
2019-05-04 23:12 | infrastation | Fixed in Version | => 0.21.3 |
2019-05-04 23:12 | infrastation | Target Version | => 0.21.3 |
2019-05-04 23:12 | infrastation | Description Updated | |
2019-05-04 23:12 | infrastation | Steps to Reproduce Updated | |
2019-05-04 23:12 | infrastation | Note Added: 0003925 |