Open 1Fopresta opened 8 months ago
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.
localhost/podman-pause 5.0.0-dev-8a643c243-1710720000 288b8061dc18 13 days ago 1.14 MB
docker.io/tuxgasy/dolibarr 19.0.0-php8.2 bfcc0eea82d4 13 days ago 798 MB
docker.io/library/phpmyadmin latest 79fbc663d551 2 weeks ago 575 MB
docker.io/library/mariadb latest bc6434c28e9a 6 weeks ago 411 MB
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.
root@dolipod:/var/www/html# php -v
PHP 8.1.20 (cli) (built: Jun 13 2023 12:02:18) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.20, Copyright (c) Zend Technologies
less -N AutoLoader.php
153 $paths = array_merge(
154 $paths,
155 array_values(static::loadFile(
156 "$path{$slash}autoload_namespaces.php"
157 ))
158 )
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