Support

Admin Tools for WordPress

#41209 Plugin could not be activated because it triggered a fatal error.

Posted in ‘Admin Tools for WordPress’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Environment Information

WordPress version
6.6.2
PHP version
8.2.24
Admin Tools version
1.6.7-pro

Latest post by BarefootDC on Friday, 22 November 2024 12:33 CST

BarefootDC

I noticed my Admin Tools was deactivated so tried reenabling it, but I got the "Plugin could not be activated because it triggered a fatal error." error message. I deleted it and tried to install the latest version and got the same message. Not sure what else to try. Thanks for your help!

nicholas
Akeeba Staff
Manager

If you try to activate twice in a row do you get the same result?

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

BarefootDC

Yes. I've tried multiple times and still get the error.

nicholas
Akeeba Staff
Manager

We will need to convince WordPress to show us the actual error. This requires a lot of fiddling, since WordPress has stupidly decided to hide this information very thoroughly –even from the PHP error log files!– since WordPress 5.

First, create the file wp-content/mu-plugins/debug.php with the following code in it:

<?php

add_filter(
	'wp_php_error_message', function ($message, $error) {
	if (!defined('MY_CUSTOM_ERROR_HANDLER') || !MY_CUSTOM_ERROR_HANDLER)
	{
		return $message;
	}

	$theMessage = $error['message'] ?? '(no message)';
	$file       = $error['file'] ?? '(no file)';
	$line       = $error['line'] ?? '(no line)';
	$context    = <<< HTML

<div style="border: thick solid red; border-radius: 1em; padding: 1em; margin: 1em 0;">
	<h4 style="margin: 0 0 0.75em">$theMessage</h4>
	<p style="margin: 0">$file:$line</p>
</div>

HTML;

	return $context . $message;
}, 10, 2
);

Then, edit your wp-config.php file. Find the code block below the comment reading “For developers: WordPress debugging mode.“ and change it to the following:

define('WP_DEBUG', true);
define('WP_DEBUG_DISPLAY', true);
define('WP_DEBUG_LOG', true);
define('MY_CUSTOM_ERROR_HANDLER', true);

Now, reproduce your problem. It will come up with a far more detailed error report. Copy it, and paste it to your next reply.

Then, edit your wp-config.php file again and change the aforementioned lines to:

define('WP_DEBUG', false);
define('WP_DEBUG_DISPLAY', false);
define('WP_DEBUG_LOG', false);
define('MY_CUSTOM_ERROR_HANDLER', false);

This disables the extra logging we added previously as it's not a good idea to have it in production beyond the small amount of time we need to troubleshoot a plugin installation, update, or activation.

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

BarefootDC

This seems to be working now after installing the latest update. Thank you!