XPressME Integration Kit

Trac

Changeset 188


Ignore:
Timestamp:
Apr 21, 2009, 12:51:44 PM (15 years ago)
Author:
toemon
Message:

#111 XPressMEモジュールをアンインストールしても、プラグインが作成したデータベーステーブルが残ってしまうバグ修正
xoops_version.php から $modversiontables?の記述を外し
onuninstall でdb_prefixからテーブルを見つけてDROPするようにした。
またxoops_version.php から $modversiontables?の記述を外したことにより、wordpressのテーブル構成が変わっても気にしないですむようになった。
但しXOOPSのモジュールインフォメーションにはSQLテーブルの情報がでない

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/onuninstall.php

    r1 r188  
    2424        $db =& Database::getInstance() ; 
    2525        $mid = $module->getVar('mid') ; 
    26 /* 
    27         // TABLES (loading mysql.sql) 
    28         $sql_file_path = dirname(__FILE__).'/sql/mysql.sql' ; 
    29         $prefix_mod = $db->prefix() . '_' . $mydirname ; 
    30         if( file_exists( $sql_file_path ) ) { 
    31                 $ret[] = "SQL file found at <b>".htmlspecialchars($sql_file_path)."</b>.<br  /> Deleting tables...<br />"; 
    32                 $sql_lines = file( $sql_file_path ) ; 
    33                 foreach( $sql_lines as $sql_line ) { 
    34                         if( preg_match( '/^CREATE TABLE \`?([a-zA-Z0-9_-]+)\`? /i' , $sql_line , $regs ) ) { 
    35                                 $sql = 'DROP TABLE '.$prefix_mod.'_'.$regs[1] ; 
    36                                 if (!$db->query($sql)) { 
    37                                         $ret[] = '<span style="color:#ff0000;">ERROR: Could not drop table <b>'.htmlspecialchars($prefix_mod.'_'.$regs[1]).'<b>.</span><br />'; 
    38                                 } else { 
    39                                         $ret[] = 'Table <b>'.htmlspecialchars($prefix_mod.'_'.$regs[1]).'</b> dropped.<br />'; 
    40                                 } 
     26         
     27        $xp_prefix = $mydirname; 
     28        if ($xp_prefix == 'wordpress'){ 
     29                $xp_prefix = 'wp'; 
     30        } 
     31         
     32        $xoops_prefix = $db->prefix(); 
     33 
     34        if (empty($xoops_prefix) || empty($xp_prefix)) { 
     35                $ret[] = '<span style="color:#ff0000;">ERROR: Empty Prefix.</span><br />'; 
     36                return false; 
     37        } 
     38         
     39        $prefix_mod = $xoops_prefix  . '_' . $xp_prefix; 
     40        $sql = "SHOW TABLES LIKE '$prefix_mod%'"; 
     41        if ($result = $db->query($sql)) { 
     42                while ($table = $db->fetchRow($result)){ 
     43                        $drop_sql = 'DROP TABLE '. $table[0] ; 
     44                        if (!$db->queryF($drop_sql)) { 
     45                                $ret[] = '<span style="color:#ff0000;">ERROR: Could not drop table <b>'.htmlspecialchars($table[0]).'<b>.</span><br />'; 
     46                        } else { 
     47                                $ret[] = 'Table <b>'.htmlspecialchars($table[0]).'</b> dropped.<br />'; 
    4148                        } 
    4249                } 
     50        } else { 
     51                $ret[] = '<span style="color:#ff0000;">ERROR: Table not found of prefix <b>'.htmlspecialchars($prefix_mod).'<b> .</span><br />'; 
     52                return false; 
    4353        } 
    44 */ 
     54 
     55 
    4556        // TEMPLATES (Not necessary because modulesadmin removes all templates) 
    4657        /* $tplfile_handler =& xoops_gethandler( 'tplfile' ) ; 
  • trunk/xoops_version.php

    r186 r188  
    4040 
    4141// status 
    42 $modversion['codename'] = "Bata3(r186)"; 
     42$modversion['codename'] = "Bata3(r188)"; 
    4343 
    4444// onInstall, onUpdate, onUninstall 
     
    5555} 
    5656 
    57 $modversion['tables'] = array( 
    58         $db_prefix . "_comments", 
    59         $db_prefix . "_links", 
    60         $db_prefix . "_options", 
    61         $db_prefix . "_postmeta", 
    62         $db_prefix . "_posts", 
    63         $db_prefix . "_users", 
    64         $db_prefix . "_usermeta", 
    65         $db_prefix . "_terms", 
    66         $db_prefix . "_term_relationships", 
    67         $db_prefix . "_term_taxonomy", 
    68         $db_prefix . "_views",   
    69         $db_prefix . "_d3forum_link", 
    70         $db_prefix . "_group_role" 
    71 ); 
     57/* 
     58 * Table information is not described.  
     59 *  
     60 * The create of the table is do with oninstall.php.  
     61 * The drop of the table is do with onuninstall.php.  
     62 * 
     63 * $modversion['tables'] = array( ,,,); 
     64 */ 
    7265 
    7366 
Note: See TracChangeset for help on using the changeset viewer.