MyBB Community Forums

Full Version: Error Installing Plugin
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I uploaded Shade's Letter Avatar's plugin but every time I try to install it, I get this error message:

Quote:Fatal error: Uncaught Error: Non-static method LetterAvatars::addAvatarToUser() cannot be called statically in /home/alpharomeo15/public_html/inc/plugins/letteravatars.php:107 Stack trace: #0 /home/alpharomeo15/public_html/admin/modules/config/plugins.php(432): letteravatars_install() #1 /home/alpharomeo15/public_html/admin/index.php(830): require('/home/alpharome...') #2 {main} thrown in /home/alpharomeo15/public_html/inc/plugins/letteravatars.php on line 107

Also, the plugin stays in the inactive plugin list but the settings are actually accessible under plugin settings but the plugin is not functioning.  I can delete the plugin but how do I delete the settings in the ACP?

[attachment=46141]

[attachment=46140]
you have 3 ways to fix this.
1. change method to static method like this
static function addAvatarToUser
2. call method non-static like this
change
LetterAvatars::addAvatarToUser($user);
to this
(new LetterAvatars())->addAvatarToUser($user)

3.  send message to programmer to fix plugin code.
(2023-07-07, 04:29 PM)Mostafa.Shiraali Wrote: [ -> ]you have 3 ways to fix this.
1. change method to static method like this
static function addAvatarToUser
2. call method non-static like this
change
LetterAvatars::addAvatarToUser($user);
to this
(new LetterAvatars())->addAvatarToUser($user)

3.  send message to programmer to fix plugin code.

THANK YOU for the reply!!

The dev has left MyBB so it looks like method 1 or 2 for me!  Is one method better than the other?

ETA:
Method 2 listed this error in the ACP>Plugins screen...

Quote:Parse error: syntax error, unexpected variable "$info" in /home/alpharomeo15/public_html/inc/plugins/letteravatars.php on line 111

I'm not sure what to do with method 1 to test??

So, I reverted my site back to PHP 7.4 and I was able to install the plugin fully.  I bumped it back to PHP8.1 and now I get this error in my ACP>Plugins:

Quote:Fatal error: Uncaught TypeError: call_user_func_array(): Argument #1 ($callback) must be a valid callback, non-static method LetterAvatars::admin() cannot be called statically in /home/alpharomeo15/public_html/inc/class_plugins.php:136 Stack trace: #0 /home/alpharomeo15/public_html/admin/modules/config/plugins.php(19): pluginSystem->run_hooks(Array) #1 /home/alpharomeo15/public_html/admin/index.php(830): require('/home/alpharome...') #2 {main} thrown in /home/alpharomeo15/public_html/inc/class_plugins.php on line 136