Hello,
Piwigo version: branch 2.6 r28022
PHP version: 5.3.2
MySQL version: 5.1.61
I would like to use class PluginMaintain for [extension by P@t] AntiAspi but I'm facing some problems. I have added some traces in the code of my class AntiAspi_maintain on every function :
file_put_contents('/tmp/test.log', "==== ".date('c').'['.$conf['exec_key'].'] call function '.__FUNCTION__."\n", FILE_APPEND);
Where $conf['exec_key'] is initialized in local/config/config.inc.php :
$conf['exec_key'] = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 6);
The plugin creates 2 tables.
1) "activate" action
==== 2014-04-30T16:47:43+02:00[r7PAIl] call function __construct
==== 2014-04-30T16:47:43+02:00[r7PAIl] call function __construct
==== 2014-04-30T16:47:43+02:00[r7PAIl] call function install
==== 2014-04-30T16:47:43+02:00[r7PAIl] call function activate
==== 2014-04-30T16:47:43+02:00[r7PAIl] call function install
==== 2014-04-30T16:47:43+02:00[dRz1Nk] call function __construct
==== 2014-04-30T16:47:44+02:00[NnOS6X] call function __construct
Tables created.
mysql> select * from piwigo_plugins where id='AntiAspi';
+----------+--------+---------+
| id | state | version |
+----------+--------+---------+
| AntiAspi | active | 2.6.a |
+----------+--------+---------+
1 row in set (0.00 sec)
2) "deactivate" action
==== 2014-04-30T16:48:58+02:00[9phxv4] call function __construct
==== 2014-04-30T16:48:58+02:00[9phxv4] call function __construct
==== 2014-04-30T16:48:58+02:00[9phxv4] call function deactivate
mysql> select * from piwigo_plugins where id='AntiAspi';
+----------+----------+---------+
| id | state | version |
+----------+----------+---------+
| AntiAspi | inactive | 2.6.a |
+----------+----------+---------+
1 row in set (0.00 sec)
3) "uninstall" action
==== 2014-04-30T16:49:37+02:00[F237cZ] call function __construct
==== 2014-04-30T16:49:37+02:00[F237cZ] call function __construct
==== 2014-04-30T16:49:37+02:00[F237cZ] call function uninstall
mysql> select * from piwigo_plugins where id='AntiAspi';
Empty set (0.00 sec)
Tables not dropped :-/
4) "activate" action (once more)
==== 2014-04-30T16:50:28+02:00[Y6RjWp] call function __construct
==== 2014-04-30T16:50:28+02:00[Y6RjWp] call function __construct
==== 2014-04-30T16:50:28+02:00[Y6RjWp] call function install
==== 2014-04-30T16:50:28+02:00[Y6RjWp] call function activate
==== 2014-04-30T16:50:28+02:00[Y6RjWp] call function install
==== 2014-04-30T16:50:28+02:00[nvSrXf] call function __construct
==== 2014-04-30T16:50:29+02:00[1yKZa3] call function __construct
mysql> select * from piwigo_plugins where id='AntiAspi';
+----------+--------+---------+
| id | state | version |
+----------+--------+---------+
| AntiAspi | active | 2.6.a |
+----------+--------+---------+
1 row in set (0.00 sec)
5) "restore" action (tables have been filled)
==== 2014-04-30T16:52:18+02:00[IuLZGR] call function __construct
==== 2014-04-30T16:52:18+02:00[IuLZGR] call function __construct
==== 2014-04-30T16:52:18+02:00[IuLZGR] call function __construct
==== 2014-04-30T16:52:18+02:00[IuLZGR] call function __construct
==== 2014-04-30T16:52:18+02:00[IuLZGR] call function deactivate
==== 2014-04-30T16:52:18+02:00[IuLZGR] call function uninstall
==== 2014-04-30T16:52:18+02:00[IuLZGR] call function __construct
==== 2014-04-30T16:52:18+02:00[IuLZGR] call function __construct
==== 2014-04-30T16:52:18+02:00[IuLZGR] call function install
==== 2014-04-30T16:52:18+02:00[IuLZGR] call function activate
==== 2014-04-30T16:52:18+02:00[IuLZGR] call function install
==== 2014-04-30T16:52:18+02:00[Dl8iH4] call function __construct
==== 2014-04-30T16:52:19+02:00[4KajnH] call function __construct
Tables reset, so I think they have been dropped (uninstall) then created (install)
Offline
The fact that tables are reset in case 5 (restore) and not dropped in case 3 (uninstall) is very mysterious to me :-/
function uninstall() { global $conf; file_put_contents('/tmp/test.log', "==== ".date('c').'['.$conf['exec_key'].'] call function '.__FUNCTION__."\n", FILE_APPEND); pwg_query('DROP TABLE '.ANTIASPI_TABLE.';'); pwg_query('DROP TABLE '.ANTIASPI_LOG_TABLE.';'); }
(this is the only place where the 2 tables are dropped or truncated.
Offline
plg wrote:
The fact that tables are reset in case 5 (restore) and not dropped in case 3 (uninstall) is very mysterious to me :-/
Code:
function uninstall() { global $conf; file_put_contents('/tmp/test.log', "==== ".date('c').'['.$conf['exec_key'].'] call function '.__FUNCTION__."\n", FILE_APPEND); pwg_query('DROP TABLE '.ANTIASPI_TABLE.';'); pwg_query('DROP TABLE '.ANTIASPI_LOG_TABLE.';'); }(this is the only place where the 2 tables are dropped or truncated.
where do you define ANTIASPI_TABLE ? main is not loaded because inactive.
Offline
didn't take a look but I think rvelices has a point (you don't get ant warning because of the redirect)
maintain.inc.php must always be considered as a standalone script, that's why I generally define $this->table in the constructor of '#####_maintain'
also I don't understand why the constructor is always called twice...
Offline
Much better with:
function uninstall() { global $prefixeTable; pwg_query('DROP TABLE '.$prefixeTable.'antiaspi_ip_ban;'); pwg_query('DROP TABLE '.$prefixeTable.'antiaspi_log;'); }
Thank you!
Offline