Migrating SVS scripts from PHP 7 to PHP 8

With Jedox 2022.2, the Supervision Server (SVS) component has been upgraded from PHP 7 to PHP 8. Any SVS scripts may require slight modifications to continue working as expected.

The PHP development team has provided comprehensive documentation on migrating projects to PHP 8. The following links describe PHP changes in version 8 that can influence script execution:

  • In Backward Incompatible Changes, the PHP team describes changes in syntax and functionality that require testing before switching to the new version in production environments.
  • Deprecated Features specifies alternatives to the features that are no longer supported in PHP 8.

In the new version of PHP, some warnings have been converted into error exceptions, notably:

  • Attempting to append an element to an array for which the PHP_INT_MAX key is already used.
  • Attempting to use an invalid type (array or object) as an array key or string offset.
  • Attempting to write to an array index of a scalar value.
  • Attempting to unpack a non-array / Traversable.
  • Attempting to access unqualified constants that are undefined. Previously, unqualified constant access resulted in a warning and were interpreted as strings.

Required changes in DrillThrough events code

Sample scripts included with Jedox software use the latest version of PHP code and need no further changes. If you are using custom code in SVS PHP script file, and so original sample files cannot be used as a direct replacement, the following changes are required.

DrillThroughCube

This change is applicable for sep.inc.drill_through.php and sep.inc.drill_through_cube.php files, function DrillThroughCube.

Replace

Copy
``` php
if (count($values) != 0) {
```

with

Copy
``` php
if (isset($values) && count($values) != 0) {
```

As `$values` can be undefined in some scenarios.

DrillThroughGetArea

This change is applicable for the files

  • sep.inc.drill_through.php
  • sep.inc.drill_through_cube.php
  • sep.inc.drill_through_elt.php

as well as the DrillThroughGetArea function.

As `$coor` can be null in some scenarios, replace

Copy
``` php
if (count($coor) > $maxElements) {
```

with

Copy
``` php
if (!is_null($coor) && count($coor) > $maxElements) {
```

Error during script processing

If there is an exception in custom script processing due to different behavior of PHP 8 compared to PHP 7, then the active event will fail, and OLAP and Supervision Server will log the problem. However, the SVS process will recover, and further unrelated events can still be used.

In such scenarios, the error log may include an entry such as the following, which names the problematic event:

Copy
```
2023-05-02 13:13:48 INFO: (60) Error in SVS PHP script: OnDrillThroughExt (PHP exception thrown)
```

Updated June 7, 2024