magnusmanske / quickstatements

The official repo for the QuickStatements PHP/HTML/JS interface
https://quickstatements.toolforge.org/
GNU General Public License v3.0
41 stars 16 forks source link

Hard-coded error_reporting breaks API on PHP 8.1 #33

Open kwisatz opened 2 years ago

kwisatz commented 2 years ago

Wondering why error_reporting is hardcoded in api.php?

error_reporting(E_ERROR|E_CORE_ERROR|E_ALL|E_COMPILE_ERROR); // 
ini_set('display_errors', 'On');

I spent quite some time wondering why my settings in php.ini weren't working to finally figure out they were overwritten.

Trouble is, your composer.json does not fix a PHP version, e.g. 7.4 and so we end up with dependencies that require 8.1 in some situations (Think docker multi-stage builds…).

With 8.1 and the level of error_reporting hard-coded in api.php, the result on an API call is:

<br />
<b>Deprecated</b>:  Implicit conversion from float 0.1 to int loses precision in <b>/var/www/html/quickstatements/public_html/quickstatements.php</b> on line <b>1096</b><br />
{"status":"OK","command":{"action":"create","type":"item","data":{"claims":[{"mainsnak":{"snaktype":"value","property":"P1","datavalue":{"type":"wikibase-entityid","value":{"entity-type":"item","id":"Q17"}}},"type":"statement","rank":"normal"},{"mainsnak":{"snaktype":"value","property":"P18","datavalue":{"type":"string","value":"I made a second attempt of a QS"}},"type":"statement","rank":"normal"}]},"meta":{"message":"","status":"RUN","id":0},"summary":"#temporary_batch_1660059860160","status":"done","run":{"action":"wbeditentity","new":"item","data":"{\"claims\":[{\"mainsnak\":{\"snaktype\":\"value\",\"property\":\"P1\",\"datavalue\":{\"type\":\"wikibase-entityid\",\"value\":{\"entity-type\":\"item\",\"id\":\"Q17\"}}},\"type\":\"statement\",\"rank\":\"normal\"},{\"mainsnak\":{\"snaktype\":\"value\",\"property\":\"P18\",\"datavalue\":{\"type\":\"string\",\"value\":\"I made a second attempt of a QS\"}},\"type\":\"statement\",\"rank\":\"normal\"}]}","summary":"#quickstatements; #temporary_batch_1660059860160","bot":1,"token":"************************+\\","format":"json"},"item":"Q1162"},"last_item":"Q1162"}