Welcome to Geeklog, Anonymous Friday, March 29 2024 @ 01:50 am EDT

Geeklog Forums

plugin_autouninstall


Status: Banned

gtgillis

Forum User
Full Member
Registered: 11/05/03
Posts: 121
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.



Text 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;
}
 
 Quote

Status: Banned

gtgillis

Forum User
Full Member
Registered: 11/05/03
Posts: 121
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.
 Quote

Status: offline

syco

Forum User
Junior
Registered: 04/24/04
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:


Text 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

Text 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 !?!??
 Quote

Status: offline

Laugh

Site Admin
Admin
Registered: 09/27/05
Posts: 1468
Location:Canada
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.

Text 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.
 Quote

All times are EDT. The time is now 01:50 am.

  • 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