Bug in backup if you have cust. tables with FULLTEXT index

Hans <[email protected]> 1 Aug 2003 10:07:15 -0000
Newsgroups gmane.comp.web.oscommerce.devel
Message-ID <182ae1b79b6d751f28b7078465b905a1@osCommerce-Forums>
This message was sent from: Development
http://forums.oscommerce.com/viewtopic.php?p=205548#205548
----------------------------------------------------------------

There is ab bug in admin/backup.php, if you have customer tables with FULLTEXT indexes.

I'm developing a module for glossary system (local, beta state), that needs a table with a fulltext index (FULLTEXT KEY) over 2 columns.
The backup.php does not take care of this at all and interpret it as normal index (KEY).

To fix the problem modify the section that handeles key analysis as follows, start line 68 :
(ver. 2.2MS2, tested on MySql 3.23.33 on Win98)

[code]
// add the keys
          $index = array();
          $keys_query = tep_db_query("show keys from " . $table);
          while ($keys = tep_db_fetch_array($keys_query)) {
            $kname = $keys['Key_name'];

            if (!isset($index[$kname])) {
              $index[$kname] = array('unique' => !$keys['Non_unique'],
                                     'columns' => array());
            }

            $index[$kname]['columns'][] = $keys['Column_name'];

// ------------------------------------------------------------------------------
// begin fix insert for FULLTEXT indexes handling
// ------------------------------------------------------------------------------
            $index[$kname]['fulltext'] =
//                       only once necessary, protect overwriting
              ($index[$kname]['fulltext'] || $keys['Comment'] == "FULLTEXT");
// ------------------------------------------------------------------------------
// end fix insert
// ------------------------------------------------------------------------------

          }

          while (list($kname, $info) = each($index)) {
            $schema .= ',' . "\n";

            $columns = implode($info['columns'], ', ');

            if ($kname == 'PRIMARY') {
              $schema .= '  PRIMARY KEY (' . $columns . ')';
            } elseif ($info['unique']) {
              $schema .= '  UNIQUE ' . $kname . ' (' . $columns . ')';

// ------------------------------------------------------------------------------
// begin fix insert for FULLTEXT indexes handling
// ------------------------------------------------------------------------------
            } elseif ($info['fulltext']) {
              $schema .= '  FULLTEXT KEY ' . $kname . ' (' . $columns . ')';
// --------------------------------------------------------------------
// end fix insert
// --------------------------------------------------------------------

            } else {
              $schema .= '  KEY ' . $kname . ' (' . $columns . ')';
            }
          }

          $schema .= "\n" . ');' . "\n\n";
          fputs($fp, $schema);

[/code]

Regards,

Hans