shadimanna / dhl-logistic-services-for-woocommerce

6 stars 8 forks source link

PHP Fatal error at WordPress Initialization #186

Closed verenaroe closed 1 year ago

verenaroe commented 1 year ago

I copied Code from my Theme to a separate Plugin.

I do this at the very beginning of my Plugin code:

// Load the WordPress library.
require_once __DIR__ . '/../../../wp-load.php';

When it's running I get the following error:

[05-Jun-2023 12:21:46 UTC] PHP Fatal error:  Uncaught Error: Class 'PR\DHL\Utils\API_Utils' not found in /app/wordpress/wp-content/plugins/dhl-for-woocommerce/includes/pr-dhl-api/class-pr-dhl-api-paket.php:22
Stack trace:
#0 /app/wordpress/wp-content/plugins/dhl-for-woocommerce/includes/pr-dhl-api/class-pr-dhl-api-factory.php(52): PR_DHL_API_Paket->__construct('DE')
#1 /app/wordpress/wp-content/plugins/dhl-for-woocommerce/pr-dhl-woocommerce.php(496): PR_DHL_API_Factory::make_dhl('DE')
#2 /app/wordpress/wp-content/plugins/dhl-for-woocommerce/pr-dhl-woocommerce.php(282): PR_DHL_WC->get_dhl_factory()
#3 /app/wordpress/wp-content/plugins/dhl-for-woocommerce/pr-dhl-woocommerce.php(228): PR_DHL_WC->get_pr_dhl_wc_product()
#4 /app/wordpress/wp-includes/class-wp-hook.php(308): PR_DHL_WC->init('')
#5 /app/wordpress/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters(NULL, Array)
#6 /app/wordpress/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#7 /app/wordpress/wp-settings.php(623): do_action('init')
#8 /app/wordpress/wp-config.php(88): require_onc in /app/wordpress/wp-content/plugins/dhl-for-woocommerce/includes/pr-dhl-api/class-pr-dhl-api-paket.php on line 22

As soon as I deactivate the plugin there's no error.

Uninstall and reinstall the newest version of the plugin didn't fixed the error. WordPress Version: 6.2.2

Abdalsalaam commented 1 year ago

Hi @verenaroe , do you have a staging environment ? can you share an access to our email "dhlsupport [at] progressusmarketing.com"

thank you!

verenaroe commented 1 year ago

Thank you very much for your fast reply!

Invitation from the staging environment sent to dhlsupport [at] progressusmarketing.com

Here is the page to see the error message: https://cbgb.eat-this.org/wp-content/plugins/steady-connect/steady_callback.php

Abdalsalaam commented 1 year ago

@verenaroe Thank you! we will check it and let you know.

verenaroe commented 1 year ago

I think our autoload files in the plugin are causing this and are interfering together. I will take a look at it and let you know.

verenaroe commented 1 year ago

Okay so the error is that wp-load is accessing your code before your autoloader is loaded. If I add this line on top of wp-load it works:

include_once( '../dhl-for-woocommerce/includes/class-pr-dhl-autoloader.php' );
require_once __DIR__ . '/../../../wp-load.php';

Now I have to find out how I can write my Plugin, so it doesn't depend on wp-load anymore. I think it's my fault then, maybe just nice to know for you I saw the same error message in the wordpress forum so I thought it's an error in the dhl plugin. https://wordpress.org/support/topic/new-version-3-4-1-created-a-fatal-error-on-our-website/