CalderaWP / Caldera-Forms

Drag and drop, responsive WordPress form builder.
https://CalderaForms.com
GNU General Public License v2.0
187 stars 163 forks source link

Admin Back-end gives critical error when logged in #3436

Open MarthinusBotha opened 4 years ago

MarthinusBotha commented 4 years ago

The following file causes the following Fatal Error with latest WordPress website. Caldera-Forms/includes/cf-pro-client/classes/hooks.php

The fatal error it causes:

Cannot use calderawp\calderaforms\pro\api\local\settings as settings because the name is already in use in /wp-content/plugins/caldera-forms/includes/cf-pro-client/classes/hooks.php on line 10

I had to comment out Line 10 for the website to run the admin back-end section. The front-end is fine but the admin back-end breaks once this line is active. I think is picking the following file in the same namespace that could cause the error Caldera-Forms/includes/cf-pro-client/classes/settings.php

mlang38 commented 4 years ago

:+1:

New0 commented 4 years ago

Hello @MarthinusBotha , thank you for reporting this issue. I think you are facing the same issue reported at #3426
Do you confirm the server is using PHP 5.6 ?

At the moment we know all the users that faced this issue were using PHP 5.6 but that wasn't the only parameter that lead to the issue. Could you share the information at Caldera Forms -> Support under the debug information tab and any errors reported at Tools -> Site Health?

MarthinusBotha commented 4 years ago

Yes, it is still using 5.6 and we use the free version of Caldera Forms. The only errors I found was the mentioned message in the first comment.

mlang38 commented 4 years ago

I think the issue is due to the fact that there is already a settings class in the same calderawp\calderaforms\pro namespace as the hooks class. So it cannot use calderawp\calderaforms\pro\api\local\settings as settings because it is already seen from the same namespace at line 4 namespace calderawp\calderaforms\pro.

I think this is related to this PHP bug, closed and released with PHP 7.0.13

Unfortunately I'm stuck with PHP 5.6 for now because of a stale plug-in which I don't find alternatives. (WPFilebase)

mlang38 commented 4 years ago

Perhaps you could just use the settings class with another name ? Prevents from having to drop PHP 5.6 compatibility

@@ -7,7 +7,7 @@
 use calderawp\calderaforms\pro\admin\scripts;
 use calderawp\calderaforms\pro\api\client;
 use calderawp\calderaforms\pro\api\local\files;
-use calderawp\calderaforms\pro\api\local\settings;
+use calderawp\calderaforms\pro\api\local\settings as api_local_settings;
 use calderawp\calderaforms\pro\api\message;
 use calderawp\calderaforms\pro\log\mail;
 use calderawp\calderaforms\pro\settings\active;
@@ -343,7 +343,7 @@
     */
    public function init_api($api)
    {
-       $api->add_route(new settings());
+       $api->add_route(new api_local_settings());
    }

    /**