PHP Deprecation Error

PHP Deprecation Error

por Michael Lim -
Número de respuestas: 2

I tried to run the given testsubmit.py file in our server which runs PHP 7.4.4, and I got the following error:

A PHP Error was encountered

Severity: 8192

Message:  array_key_exists(): Using array_key_exists() on objects is deprecated. Use isset() or property_exists() instead

Filename: controllers/Restapi.php

Line Number: 175


I fixed this by changing the corresponding conditional to:

if (!property_exists($this->languages, $language))

I just posted here instead of GitHub because it seems that the CodeRunner admins are more active here. However, if you prefer, I can initiate a pull request in the repo. Thanks!

En respuesta a Michael Lim

Re: PHP Deprecation Error

por Richard Lobb -

HI Michael. Thanks for the heads up on that. I'm running PHP 7.2 and wasn't seeing it.

I've pushed a new version of Jobe to github with several minor changes including a fix for that bug. My fix is different from yours because it turns out that the real problem was that the $languages variable was sometimes an associative array (as intended) but when json-encoded, cached then decoded by json-decode it turned into an object rather than an array. I've changed the json-decode to force an associative array again, as intended. 

En respuesta a Richard Lobb

Re: PHP Deprecation Error

por Michael Lim -

Hi Richard.

Thanks for the quick fix! Seems like everything is working fine for now. Will let you know if we find other issues.

Best,

Michael