umdevelopera / um-account-tabs

Adds custom tabs to user account
GNU General Public License v3.0
9 stars 2 forks source link

exactly what I was looking for but it crashed my site #3

Closed Slimfred closed 1 year ago

Slimfred commented 1 year ago

After installing and activating this the site gave me the "There has been a critical error on this website. Please check your site admin email inbox for instructions." error. I had to go in through the hosting file manager and rename the plugin folder to be able to access the site again. This is what was in the error log:

[23-Aug-2023 20:33:48 UTC] PHP Fatal error: Uncaught Error: Class 'um_ext\um_account_tabs\core\Common' not found in /home4/slimfred/ffri.tracylynhall.com/wp-content/plugins/um-account-tabs-main/includes/core/class-um-account-tabs.php:80 Stack trace:

0 /home4/slimfred/ffri.tracylynhall.com/wp-content/plugins/um-account-tabs-main/includes/core/class-um-account-tabs.php(43): UM_Account_Tabs->common()

1 /home4/slimfred/ffri.tracylynhall.com/wp-content/plugins/um-account-tabs-main/includes/core/class-um-account-tabs.php(33): UM_Account_Tabs->__construct()

2 /home4/slimfred/ffri.tracylynhall.com/wp-content/plugins/ultimate-member/includes/class-init.php(153): UM_Account_Tabs::instance()

3 /home4/slimfred/ffri.tracylynhall.com/wp-content/plugins/um-account-tabs-main/um-account-tabs.php(61): UM->set_class('Account_Tabs', true)

4 /home4/slimfred/ffri.tracylynhall.com/wp-includes/class-wp-hook.php(310): um_account_tabs_init('')

5 /home4/slimfred/ffri.tracylynhall.com/wp-includes/class-wp-hook.php(334): WP_Hook->apply_filters(NULL, Array)

6 /home4/slimfred in /home4/slimfred/ffri.tracylynhall.com/wp-content/plugins/um-account-tabs-main/includes/core/class-um-account-tabs.php on line 80

WordPress: 6.3 Theme: Divi 4.22.1 Plugins: Code Snippets: 3.4.2 Defender Pro: 4.0.1 Duplicate Page: 4.5.2 Enable Media Replace: 4.1.2 Forminator Pro: 1.25.2 Health Check & Troubleshooting: 1.7.0 My Calendar: 3.4.18 Plugin for Google Reviews: 2.8 Smush Pro: 3.14.1 The HostGator Plugin: 1.2.10 Ultimate Member: 2.6.10 UpdraftPlus - Backup/Restore: 1.23.9 WPMU DEV Dashboard: 4.11.19

I'm happy to give you any other info if you want it.

MaximeRoudierDev commented 1 year ago

The plugin's class-um-account-tabs.php file directly includes certain class files without first checking if they have been loaded already, potentially via an autoloader. This can cause redundancy and incompatibility if someone is using autoloading mechanisms like Composer.

Before including a class file, perform a class_exists check to ensure that the class has not already been loaded. This will ensure compatibility with autoloading mechanisms and prevent potential PHP errors.

Here's an example change for class-um-account-tabs.php:

<?php
/**
 * Initializes the extension.
 *
 * @package um_ext\um_account_tabs\core
 */

if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

// Check if the 'um_ext\um_account_tabs\core\Common' class isn't already loaded (as it would be with an autoloader)
if ( ! class_exists('um_ext\um_account_tabs\core\Common') ) {
    include ABSPATH . 'wp-content/plugins/um-account-tabs-main/includes/core/class-common.php';
}

// Check if the 'um_ext\um_account_tabs\admin\Admin' class isn't already loaded
if ( ! class_exists('um_ext\um_account_tabs\admin\Admin') ) {
    include ABSPATH . 'wp-content/plugins/um-account-tabs-main/includes/admin/class-admin.php';
}

/**
 * ... (rest of the file)
 */
Slimfred commented 1 year ago

Thanks so much for this! I will try again.