Welcome to Geeklog Monday, November 20 2017 @ 04:03 pm EST


Status: offline

gtgillis

Forum User
Full Member
Registered: 05/11/2003
Posts: 121
Location:Spring, TX
I am updating an older plugin so it will install on GL2.0.0+ and have run into a problem with the plugin_autouninstall. See the code below. The groups, features and php_blocks are all removed as expected but the tables remain. I have confirmed that the names in the tables array match the table names in the database. Anyone have an idea why the tables are not getting dropped? It looks like it is something in function PLG_uninstall.



PHP Formatted Code

function plugin_autouninstall_dailyquote ()
{
   $out = array (
        /* give the name of the tables, without $_TABLES[] */
        'tables' => array('dailyquote_category', 'dailyquote_lookup', 'dailyquote_quotes', 'dailyquote_settings'),
        /* give the full name of the group, as in the db */
        'groups' => array('Dailyquote Admin'),
        /* give the full name of the feature, as in the db */
        'features' => array('dailyquote.edit', 'dailyquote.view', 'dailyquote.add'),
        /* give the full name of the block, including 'phpblock_', etc */
        'php_blocks' => array('phpblock_random_quote', 'phpblock_dqmenu'),
        /* give all vars with their name */
        'vars'=> array()
    );
    return $out;
}
 

Status: offline

gtgillis

Forum User
Full Member
Registered: 05/11/2003
Posts: 121
Location:Spring, TX
It looks like the old plugin install does not add the plugins tables to the $_TABLES array so when the uninstall runs the for loop in the function PLG_uninstall it doesn't see the tables I specified for removal. So I guess what I am saying here is, nevermind.

Status: offline

syco

Forum User
Junior
Registered: 24/04/2004
Posts: 15
Location:Liège, Belgium
I'm having the same problem with geeklog 2.1.0. I'm trying to make a plugin that has two tables ... installs fine, works fine but the tables are not removed at uninstall.
I modified lib-plugins.php to see what's going on:


PHP Formatted Code

        // removing tables
        if (isset($remvars['tables'])) {
            $num_tables = count($remvars['tables']);
        } else {
            $num_tables = 0;
        }
        for ($i = 0; $i < $num_tables; $i++) {
            if (isset($_TABLES[$remvars['tables'][$i]])) {
                COM_errorLog("Dropping table {$_TABLES[$remvars['tables'][$i]]}", 1);
                DB_query("DROP TABLE {$_TABLES[$remvars['tables'][$i]]}", 1);
                COM_errorLog('...success', 1);
            // FIXME Mike
            } else {
                COM_errorLog("Not Dropping table: {$_TABLES[$remvars['tables'][$i]]} - \$remvars['tables'][\$i] = {$remvars[tables][$i]}", 1);
            }
        }
 


Error log now returns

PHP Formatted Code

dim. 25 janv. 2015 15:34:17 CET - 127.0.0.1 - Auto-uninstalling plugin blockz:
dim. 25 janv. 2015 15:34:17 CET - 127.0.0.1 - Not Dropping table:  - $remvars['tables'][$i] = blockz_server_status
dim. 25 janv. 2015 15:34:17 CET - 127.0.0.1 - Not Dropping table:  - $remvars['tables'][$i] = blockz_activity
 


$_TABLES['my_tables'] doesn't seem to exist. I'm a php noob and this is really driving me nuts. I've compared with other plugins, the code is exactly the same.

I made another plugin with only one table, with the same code, and there everything works fine !?!??

Status: offline

Laugh

Site Admin
Admin
Registered: 27/09/2005
Posts: 1240
It's hard to say what is going wrong when I don't have the code.

Here is the polls plugin uninstall function. It show you how to tell Geeklog to uninstall things like tables, security groups, security features, and blocks.

PHP Formatted Code
function plugin_autouninstall_polls ()
{
    $out = array (
        /* give the name of the tables, without $_TABLES[] */
        'tables' => array('pollanswers','polltopics','pollvoters','pollquestions'),
        /* give the full name of the group, as in the db */
        'groups' => array('Polls Admin'),
        /* give the full name of the feature, as in the db */
        'features' => array('polls.edit',
                            'config.polls.tab_whatsnew',
                            'config.polls.tab_main',
                            'config.polls.tab_permissions',
                            'config.polls.tab_autotag_permissions',
                            'config.polls.tab_poll_block'),
        /* give the full name of the block, including 'phpblock_', etc */
        'php_blocks' => array('phpblock_polls'),
        /* give all vars with their name */
        'vars'=> array()
    );
    return $out;
}

One of the Geeklog Core Developers.

All times are EST. The time is now 04:03 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content