Skip to content

Division by zero issue #635

@rapotek

Description

@rapotek

There is a code fragment in /okapi/services/caches/map/TileTree.php:

try {
list($z21x, $z21y) = self::latlon_to_z21xy($lat, $lon);
} catch (Exception $e) {
/* E.g. division by zero, if the cache is placed at the north pole. */
return false;
}

When the "division by zero" problem occurs:

  • in PHP 5.6 only a warning is generated, no exception is thrown, evaluation of the code continues as in any non-exceptionable case (probably with $z21y value set to INF)
  • in PHP 7+ a DivisionByZeroError is generated, but it is not caught by above try...catch block, because this error extends Error not Exception. In result a service call throws genericError and does not end correctly

The easiest solution should be to use Throwable instead of Exception but Throwable was added in PHP 7.0 which does not comply with okapi requirement of PHP >= 5.6.
However, is there any okapi server still running on PHP 5.6? Shouldn't the required version be changed to f.ex. 7.0+ ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions