Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility issue with php7.4 #59

Closed
Chluz opened this issue Nov 5, 2021 · 6 comments
Closed

Compatibility issue with php7.4 #59

Chluz opened this issue Nov 5, 2021 · 6 comments

Comments

@Chluz
Copy link
Contributor

Chluz commented Nov 5, 2021

Hi, after upgrading to php7.4, I was having issues with php errors of the type Uncaught ErrorException: Trying to access array offset on value of type null in the file core.php at line 100.

I therefore changed

$prefix = $args[0][0] == "/" ? "/" : "";

to

        if ($args[0] !== null) {
            $prefix = $args[0][0] == "/" ? "/" : "";
        } else {
            $prefix = "";
        }

Its not very clean, but I don't really know php !
Hope it helps others having the same issue. I can create a merge request if this is acceptable.

@wastez
Copy link

wastez commented Nov 7, 2021

Thats really strange, i`m using also php7.4 without issues.

@Chluz
Copy link
Contributor Author

Chluz commented Nov 7, 2021

Indeed, perhaps I have settings in php which do not allow for these types of error, or my specific install triggers $args[0] == null.

@thomas-pike
Copy link
Collaborator

It would be because the path_join function is being called with a null parameter, which it does not expect. It would be interesting to have the full stacktrace to try to figure out why it is being passed a null value in the first place.

@Chluz
Copy link
Contributor Author

Chluz commented Nov 9, 2021

I reverted the change to retrigger the error, and now I'm not getting any error messages. I do not know what is happening.

The original issue was

[Fri Nov 05 23:25:25.974060 2021] [php:error] [pid 16362] [client 192.168.67.13:39040] PHP Fatal error:  Uncaught ErrorException: Trying to access array offset on value of type null in /var/www/ssh-key-authority/core.php:101\nStack trace:\n#0 /var/www/ssh-key-authority/core.php(101): exception_error_handler()\n#1 /var/www/ssh-key-authority/core.php(55): path_join()\n#2 /var/www/ssh-key-authority/core.php(75): autoload_model()\n#3 /var/www/ssh-key-authority/core.php(42): setup_database()\n#4 /var/www/ssh-key-authority/requesthandler.php(19): require('...')\n#5 /var/www/ssh-key-authority/public_html/init.php(18): require('...')\n#6 {main}\n  thrown in /var/www/ssh-key-authority/core.php on line 101

@thomas-pike
Copy link
Collaborator

Making that a bit more readable:

[Fri Nov 05 23:25:25.974060 2021] [php:error] [pid 16362] [client 192.168.67.13:39040] PHP Fatal error:  Uncaught
ErrorException: Trying to access array offset on value of type null in /var/www/ssh-key-authority/core.php:101
Stack trace:
#0 /var/www/ssh-key-authority/core.php(101): exception_error_handler()
#1 /var/www/ssh-key-authority/core.php(55): path_join()
#2 /var/www/ssh-key-authority/core.php(75): autoload_model()
#3 /var/www/ssh-key-authority/core.php(42): setup_database()
#4 /var/www/ssh-key-authority/requesthandler.php(19): require('...')
#5 /var/www/ssh-key-authority/public_html/init.php(18): require('...')
#6 {main}
  thrown in /var/www/ssh-key-authority/core.php on line 101

Given the path this has followed, I can only assume that the error was caused by $base_path somehow being null. Commit be22ecf did fix a bug that would cause $base_path to not be set correctly in CLI scripts. Is it possible that you were running an older version of the code that did not have this fix?

@Chluz
Copy link
Contributor Author

Chluz commented Nov 10, 2021

Hi Thomas, thank you for the answer. Yes it's possible, I would even say it's probable. I had not yet pulled this year's changes when the bug was triggered initially. I then implemented the fix above, and starting cherry picking commits - not noticing that the commit you linked might be fixing the issue.
I think that you found the root cause, and we can close this issue now. Thanks Again !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants