You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Internal test instance of Skosmos, running with PHP 8.0.8 and Skosmos release version 2.16
What steps will reproduce the problem?
Have Skosmos 2.16 running with PHP 8.x
Have a vocabulary with a concept that has a skos:notation with an integer value, e.g. 35
View the concept
What is the expected output? What do you see instead?
Seeing the detail view of the concept, instead there is a blank view. In the apache log files I get this error:
PHP Fatal error: Uncaught TypeError: method_exists(): Argument #1 ($object_or_class) must be of type object|string, int given in /var/www/html/model/Concept.php:663
What browser did you use? (eg. Firefox, Chrome, Safari, Internet explorer)
osma
changed the title
Raising a TypeError on method_exists() in PHP 8.x
Integer notation code raises a TypeError on method_exists() in PHP 8.x
Jan 28, 2025
At which URL did you encounter the problem?
Internal test instance of Skosmos, running with PHP 8.0.8 and Skosmos release version 2.16
What steps will reproduce the problem?
What is the expected output? What do you see instead?
Seeing the detail view of the concept, instead there is a blank view. In the apache log files I get this error:
What browser did you use? (eg. Firefox, Chrome, Safari, Internet explorer)
Firefox but this is not relevant here.
How to solve the issue?
Since PHP 8.x the behaviour of method_exists() changed, now it raises a TypeError if it is not an object/string, which is not the case in PHP 7.x (see e.g. https://stackoverflow.com/questions/70584290/php-8-0-method-exists-on-non-object-causes-fatal-typeerror) - I've also compared the behaviour with our production instance running an older version of Skosmos and a PHP 7.x, where this error does not occur.
In https://github.com/NatLibFi/Skosmos/blob/v2.16-maintenance/model/Concept.php#L663
method_exists
is called without checking if it is an object. In case of an integer the TypeError is raised, as it is the case with askos:notation 35
. Adding such a check withis_object()
in the line 663 solves the issue in my understanding:Hope, that this is the correct solution - if you prefer, I can also create a pull request.
The text was updated successfully, but these errors were encountered: