flop25 / adult_content

1 stars 2 forks source link

"An error occurred" enabling plugin in Piwigo 13 #6

Open jsstaedtler opened 2 years ago

jsstaedtler commented 2 years ago

I'm running Piwigo 13.2.0. I can download the adult_content 2.4.6 plugin, but when I try to activate it, instead of a green "Activated" pop-up, a red "an error occurred" message.

When I check my PHP log, this is the error (for reference, it's PHP 8.0.25):

[27-Nov-2022 00:06:03 UTC] PHP Fatal error:  Uncaught TypeError: unserialize(): Argument #1 ($data) must be of type string, array given in /home/[piwigo_dir]/plugins/adult_content/maintain.inc.php:139
Stack trace:
#0 /home/[piwigo_dir]/plugins/adult_content/maintain.inc.php(139): unserialize(Array)
#1 /home/[piwigo_dir]/admin/include/plugins.class.php(26): plugin_activate('adult_content', '2.4.6', Array)
#2 /home/[piwigo_dir]/admin/include/plugins.class.php(181): DummyPlugin_maintain->activate('2.4.6', Array)
#3 /home/[piwigo_dir]/include/ws_functions/pwg.extensions.php(71): plugins->perform_action('activate', 'adult_content')
#4 /home/[piwigo_dir]/include/ws_core.inc.php(600): ws_plugins_performAction(Array, Object(PwgServer))
#5 /home/[piwigo_dir]/include/ws_protocols/rest_handler.php(41): PwgServer->invoke('pwg.plugins.per...', Array)
#6 /home/[piwigo_dir]/include/ws_core.inc.php(281): PwgRestRequestHandler->handleRequest(Object(PwgServer))
#7 /home/[piwigo_dir]/ws.php(22): PwgServer->run()
#8 {main}
  thrown in /home/[piwigo_dir]/plugins/adult_content/maintain.inc.php on line 139
DearFox commented 1 year ago

I have the same problem. This is what is written in the site console:

<br />
<b>Fatal error</b>: Uncaught TypeError: unserialize(): Argument #1 ($data) must be of type string, array given in /config/www/plugins/adult_content/maintain.inc.php:139
Stack trace:
#0 /config/www/plugins/adult_content/maintain.inc.php(139): unserialize()
#1 /app/www/public/admin/include/plugins.class.php(26): plugin_activate()
#2 /app/www/public/admin/include/plugins.class.php(181): DummyPlugin_maintain-&gt;activate()
#3 /app/www/public/include/ws_functions/pwg.extensions.php(71): plugins-&gt;perform_action()
#4 /app/www/public/include/ws_core.inc.php(600): ws_plugins_performAction()
#5 /app/www/public/include/ws_protocols/rest_handler.php(41): PwgServer-&gt;invoke()
#6 /app/www/public/include/ws_core.inc.php(281): PwgRestRequestHandler-&gt;handleRequest()
#7 /app/www/public/ws.php(22): PwgServer-&gt;run()
#8 {main}
thrown in <b>/config/www/plugins/adult_content/maintain.inc.php</b> on line <b>139</b><br />
jsstaedtler commented 1 year ago

The fix I found was to edit file maintain.inc.php. Near the bottom of plugin_activate(), line 139 causes the error (and isn't needed after using pwg_db_fetch_array()):

$cf=unserialize($data_conf);

Replace that line with the following:

$cf=$data_conf;