cccraig/MugShot

Activation fails under Piwigo 13.8.0

Opened this issue · 4 comments

Fresh installation of piwigo 13.8.0 fails to activate MugShot.
When I add a new plugin / search MugShot, piwigo offers to add version 2.0.3 from site https://de.piwigo.org/ext/extension_view.php?eid=910

Once added (message - successfully installed), it displays version 2.0.2 and appears on the list of available updates 2.0.2 -> 2.0.3. I updated (successfully), but it remains on version 2.0.2 an re-appears on the list.

I've found advice to fix the version number manually in piwigo/plugins/MugShot/main.inc.php (was still 2.0.2 there).
OK so far, the updates available loop disapperared.

But I can't activate the MugShot plugin even with the correct version number.
While trying, an error message appears with no further details.

Piwigo 13.8.0
Ubuntu 22.04
PHP: 8.1.21

jresse commented

Even i have the same error

piwigo: 13.7.0
Ubuntu: 22.04.2 LTS
PHP 8.1.2-1ubuntu2.11

Adding below error from the apache error.log file:
modified error log to hide local system info

PHP Fatal error: Uncaught mysqli_sql_exception: Duplicate entry 'MugShot' for key 'PRIMARY' in <piwigo-install-path>/include/dblayer/functions_mysqli.inc.php:139 Stack trace: #0 <piwigo-install-path>/include/dblayer/functions_mysqli.inc.php(139): mysqli->query() #1 <piwigo-install-path>/plugins/MugShot/include/helpers.php(84): pwg_query() #2 <piwigo-install-path>/plugins/MugShot/maintain.inc.php(40): create_facetag_table() #3 <piwigo-install-path>/plugins/MugShot/maintain.inc.php(65): MugShot_maintain->install() #4 <piwigo-install-path>/admin/include/plugins.class.php(202): MugShot_maintain->activate() #5 <piwigo-install-path>/include/ws_functions/pwg.extensions.php(76): plugins->perform_action() #6 <piwigo-install-path>/include/ws_core.inc.php(600): ws_plugins_performAction() #7 <piwigo-install-path>/include/ws_protocols/rest_handler.php(41): PwgServer->invoke() #8 <piwigo-install-path>/include/ws_core.inc.php(281): PwgRestRequestHandler->handleRequest() #9 <piwigo-install-path>/ws.php(22): PwgServer->run() #10 {main} thrown in <piwigo-install-path>/include/dblayer/functions_mysqli.inc.php on line 139, referer: http://<ipaddress>/photos/admin.php?page=plugins&plugin=MugShot&pwg_token=1ecf01c9207585c1d9616d971224868f&action=activate&filter=deactivated

jresse commented

Update:

  1. When the MugShot extension is tried to be activated, it does an insert operation on the CONFIG_TABLE
  2. But the installation of the piwigo already has an entry of MugShot in the CONFIG_TABLE and the sql insert operation fails resulting in the failure to activate the extension

I was able to get the extension activated by below:
WA: manually delete the MugShot entry from the piwigo_config table of the piwigo_db

achuet commented

Thanks @jresse ..

Use this to delete the entry manually.
DELETE FROM piwigo_config Where param = 'MugShot';

laerm commented

Check line 82 of the file plugins/MugShot/include/helpers.php

If it reads

$configQuery = 'INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) VALUES ("MugShot","","MugShot configuration values");';

Change to

$configQuery = 'REPLACE INTO ' . CONFIG_TABLE . ' (param,value,comment) VALUES ("MugShot","","MugShot configuration values");';