Dolibarr / dolibarr

Dolibarr ERP CRM is a modern software package to manage your company or foundation's activity (contacts, suppliers, invoices, orders, stocks, agenda, accounting, ...). it's an open source Web application (written in PHP) designed for businesses of any sizes, foundations and freelancers.
https://www.dolibarr.org
GNU General Public License v3.0
5.37k stars 2.77k forks source link

(http 500) Can't explore API with version 18 (cannot use object as class name) #25657

Open ro78 opened 1 year ago

ro78 commented 1 year ago

Bug

Hello,

Since the upgrade of Dolibarr to version 18, I can't use the API. I tried to access the explorer (api/index.php/explorer/), and it displays this error: 500 : https://mydomain.com/api/index.php/explorer/swagger.json

In Apache error logs: [Tue Aug 22 17:14:07.846715 2023] [php7:error] [pid 821150] [client [IP]] PHP Fatal error: Cannot use 'Object' as class name as it is reserved in /home/dolibarr/includes/restler/framework/Luracast/Restler/Data/Object.php on line 16, referer: https://mydomain.com/api/index.php/explorer/

Environment Version

18.0.0

Environment OS

Debian 11

Environment Web server

Apache 2..56

Environment PHP

PHP 7.4.33

Environment Database

MariaDB 10.5.19

Environment URL(s)

No response

Expected and actual behavior

No response

Steps to reproduce the behavior

See above

Attached files

No response

ro78 commented 1 year ago

@eldy any idea?

ro78 commented 1 year ago

Found an old file includes/restler/framework/Luracast/Restler/Data/Object.php Seems replaced by includes/restler/framework/Luracast/Restler/Data/Obj.php

But upgrades didn't handle it. I'll try by deleting this file myself as it's no longer in the archive today.

ro78 commented 1 year ago

Fix confirmed. I'll keep this issue open in case you want to fix it in the upgrade script.

ksar-ksar commented 1 year ago

Hello,

The upgrade script do not check that, unfortunately. So better to start the upgrade by deleting/moving old files.

ro78 commented 1 year ago

@ksar-ksar what do you suggest for upgrades? Delete all files & folders of current installation except documents & conf, then upload the content of the new version to the folder & access the UI to run the upgrade?

ksar-ksar commented 1 year ago

Hello,

Yes it's a good way I think.

May be an upgrade of the https://github.com/Dolibarr/dolibarr/blob/develop/htdocs/install/upgrade2.php#L4095 function

riskyfly commented 11 months ago

Hello, thank you @ro78 for your help. I had the same issue "error 500 with swagger.json" when trying to use the REST API.

I started using Dolibarr from 14 and now I am in 18.0.1, but never used the REST API . And I moved from php 7 to now php 8.1.24 recently.

To fix the issue deleted the "includes\restler" folder and replace it by the one downloaded from the dolibarr-18.0.2

May be this should be implemented in upgrade script for old non-developper user who use upgrade script from cpanel, as I did.