Closed hannob closed 4 years ago
Forgot: Tested with current release version (2.3.1).
Serendipity is currently not compatible with PHP E_NOTICE turned on.
Usually production versions of s9y should turn off E_NOTICE, and only alpha/testing versions should have it on. I think there are circumstances, where a PHP error_reporting is not touched, if it is specifically set on an instance.
Having said that, it would be much appreciated if Serendipity could take care of all uninitialized variables. However because it stemming from times where dynamic typing was still a valid and easy thing to do, it is much work to initialize each and every variable before use or check for its existance, which will also blow up the amount of code.
These aren't E_NOTICE warnings.
Test:
$ php -r 'error_reporting(E_ALL&~E_NOTICE);$a="";$a["x"];'
PHP Warning: Illegal string offset 'x' in Command line code on line 1
Very true. Thanks for pointing out my mistake. I just pushed a commit that should catch this type misbehaviour . The patch should also apply to older s9y releases, would you be able to confirm this fixes the warnings?
This fixes the warnings, but it introduces more PHP notices due to accessing an undefined index.
This can easily be fixed with an array_key_exists check, I'll do a pull request.
@hannob I saw a major problem; in the code we actually assign $_GET['serendipity']['action'] = 'read'
, but the new code initializes an empty, non-referenced array for that case.
I hope the new commit properly addresses both your concern and allows proper function, could you test that on your site if it still prevents undefined index notices?
(See #653 for reference)
oh yeah, sorry for my insufficient testing.
I can confirm the bug, I applied the patch and will look if new warnings appear in the logs.
I think we're done here.
Accessing certain URLs gives me plenty of "Illegal string offset" warnings in the PHP log.
I reproduced this on a fresh installation, so I'm reasonably confident it's nothing with special extensions or special config options. This happens in all PHP versions from 7.1 to 7.4 (i.e. all currently supported ones), I haven't tested older ones.
The errors get triggered when an URL of this form is accessed:
The warnings in the log look like this: