-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Access to API REST failed with php 8.x #28489
Comments
I use 18.0.4 and I use the API |
Same problem in 19.0.0 |
@1Fopresta I use 19.0.0 now and I have no problem using the API explorer, would expect the regular API calls to work just as fine. I currently run a pod with these images for my development setup.
|
Same issue, it works on php7.4, but on 8 and above it throws the same error. The fix of @1Fopresta works |
My container image from tuxgasy comes with PHP 8.1.20 and the API works.
less -N AutoLoader.php
But the image is based on buster, aka Debian 10, not the version 11 that you use |
Bug
Hi, with php 8.x, it is impossible to acces API
An error occured :
Fatal error: Uncaught TypeError: realpath(): Argument #1 ($path) must be of type string, array given in /var/www/vhosts/.../httpdocs/includes/restler/framework/Luracast/Restler/AutoLoader.php:165
Environment Version
18.0.x and 19.0.0
Environment OS
Debian 11.9
Environment Web server
Nginx 1.24.0.2 and Apache 2.4.56
Environment PHP
8.x
Environment Database
MariaDB 10.5.23
Environment URL(s)
/api/index.php/explorer/
Expected and actual behavior
Fatal error: Uncaught TypeError: realpath(): Argument #1 ($path) must be of type string, array given in /var/www/vhosts/.../httpdocs/includes/restler/framework/Luracast/Restler/AutoLoader.php:165
Stack trace:
#0 /var/www/vhosts/.../httpdocs/includes/restler/framework/Luracast/Restler/AutoLoader.php(165): realpath()
#1 [internal function]: Luracast\Restler\AutoLoader->Luracast\Restler{closure}()
#2 /var/www/vhosts/.../httpdocs/includes/restler/framework/Luracast/Restler/AutoLoader.php(163): array_map()
#3 /var/www/vhosts/.../httpdocs/includes/restler/framework/Luracast/Restler/AutoLoader.php(38): Luracast\Restler\AutoLoader->__construct()
#4 /var/www/vhosts/.../httpdocs/api/index.php(95): Luracast\Restler\AutoLoader::instance()
#5 /var/www/vhosts/.../httpdocs/api/index.php(98): {closure}()
#6 {main}
thrown in /var/www/vhosts/.../httpdocs/includes/restler/framework/Luracast/Restler/AutoLoader.php on line 165
realpath receive an array
With php 8, control error operator @ doesn't silent Fatal Error
In fact, this bug exist with php 7 but is not blocking with @
In Autoloader file (includes/restler/framework/Luracast/Restler/AutoLoader.php), i have replace (lines 153-158)
$paths = array_merge( $paths, array_values(static::loadFile( "$path{$slash}autoload_namespaces.php" )) );
by
foreach( array_values(static::loadFile("$path{$slash}autoload_namespaces.php")) as $aPath) { $paths = array_merge($paths,$aPath); }
And it works :)
Steps to reproduce the behavior
Install a new Dolibarr
Enabled API REST module
Acces to /api/index.php/explorer/
Attached files
No response
The text was updated successfully, but these errors were encountered: