magnusmanske / magnusmanske/quickstatements
Hard-coded error_reporting breaks API on PHP 8.1
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 58
- Forks
- 21
- PR merge metrics
- No merged PRs in 30d
Description
Wondering why `error_reporting` is hardcoded in `api.php`?
```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:
```
Deprecated: Implicit conversion from float 0.1 to int loses precision in /var/www/html/quickstatements/public_html/quickstatements.php on line 1096
{"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"}
```
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with api.php and composer.json, then reproduce an API call under PHP 8.1 while checking the error reported from public_html/quickstatements.php line 1096. Confirm the resulting API response is valid JSON and that the configured PHP error-reporting behavior is not unexpectedly overwritten.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100