Advertisement
theitd

#__finder_tokens full workaround

Aug 3rd, 2020 (edited)
2,252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 20.04 KB | None | 0 0
  1. <?php
  2. /**
  3.  * @package     Joomla.Administrator
  4.  * @subpackage  com_finder
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE.txt
  8.  */
  9.  
  10. /** Deeply frustating - but a core hack is necessary to ensure all memory tables are written to disk.
  11.  * this avoids the 'full' error message when attempting to index large documents / articles.
  12.  * this will need to be done on each upgrade, until the chunk-ing feature works.
  13.  * REMEMBER - set the tables to MyISAM manually, before indexing
  14.  */
  15. defined('_JEXEC') or die;
  16.  
  17. jimport('joomla.filesystem.file');
  18.  
  19. /**
  20.  * Indexer class supporting MySQL(i) for the Finder indexer package.
  21.  *
  22.  * The indexer class provides the core functionality of the Finder
  23.  * search engine. It is responsible for adding and updating the
  24.  * content links table; extracting and scoring tokens; and maintaining
  25.  * all referential information for the content.
  26.  *
  27.  * Note: All exceptions thrown from within this class should be caught
  28.  * by the controller.
  29.  *
  30.  * @since  3.0
  31.  */
  32. class FinderIndexerDriverMysql extends FinderIndexer
  33. {
  34.     /**
  35.      * Method to index a content item.
  36.      *
  37.      * @param   FinderIndexerResult  $item    The content item to index.
  38.      * @param   string               $format  The format of the content. [optional]
  39.      *
  40.      * @return  integer  The ID of the record in the links table.
  41.      *
  42.      * @since   3.0
  43.      * @throws  Exception on database error.
  44.      */
  45.     public function index($item, $format = 'html')
  46.     {
  47.         // Mark beforeIndexing in the profiler.
  48.         static::$profiler ? static::$profiler->mark('beforeIndexing') : null;
  49.         $db = $this->db;
  50.         $nd = $db->getNullDate();
  51.  
  52.         // Check if the item is in the database.
  53.         $query = $db->getQuery(true)
  54.             ->select($db->quoteName('link_id') . ', ' . $db->quoteName('md5sum'))
  55.             ->from($db->quoteName('#__finder_links'))
  56.             ->where($db->quoteName('url') . ' = ' . $db->quote($item->url));
  57.  
  58.         // Load the item  from the database.
  59.         $db->setQuery($query);
  60.         $link = $db->loadObject();
  61.  
  62.         // Get the indexer state.
  63.         $state = static::getState();
  64.  
  65.         // Get the signatures of the item.
  66.         $curSig = static::getSignature($item);
  67.         $oldSig = isset($link->md5sum) ? $link->md5sum : null;
  68.  
  69.         // Get the other item information.
  70.         $linkId = empty($link->link_id) ? null : $link->link_id;
  71.         $isNew = empty($link->link_id) ? true : false;
  72.  
  73.         // Check the signatures. If they match, the item is up to date.
  74.         if (!$isNew && $curSig == $oldSig)
  75.         {
  76.             return $linkId;
  77.         }
  78.  
  79.         /*
  80.          * If the link already exists, flush all the term maps for the item.
  81.          * Maps are stored in 16 tables so we need to iterate through and flush
  82.          * each table one at a time.
  83.          */
  84.         if (!$isNew)
  85.         {
  86.             for ($i = 0; $i <= 15; $i++)
  87.             {
  88.                 // Flush the maps for the link.
  89.                 $query->clear()
  90.                     ->delete($db->quoteName('#__finder_links_terms' . dechex($i)))
  91.                     ->where($db->quoteName('link_id') . ' = ' . (int) $linkId);
  92.                 $db->setQuery($query);
  93.                 $db->execute();
  94.             }
  95.  
  96.             // Remove the taxonomy maps.
  97.             FinderIndexerTaxonomy::removeMaps($linkId);
  98.         }
  99.  
  100.         // Mark afterUnmapping in the profiler.
  101.         static::$profiler ? static::$profiler->mark('afterUnmapping') : null;
  102.  
  103.         // Perform cleanup on the item data.
  104.         $item->publish_start_date = (int) $item->publish_start_date != 0 ? $item->publish_start_date : $nd;
  105.         $item->publish_end_date = (int) $item->publish_end_date != 0 ? $item->publish_end_date : $nd;
  106.         $item->start_date = (int) $item->start_date != 0 ? $item->start_date : $nd;
  107.         $item->end_date = (int) $item->end_date != 0 ? $item->end_date : $nd;
  108.  
  109.         // Prepare the item description.
  110.         $item->description = FinderIndexerHelper::parse($item->summary);
  111.  
  112.         /*
  113.          * Now, we need to enter the item into the links table. If the item
  114.          * already exists in the database, we need to use an UPDATE query.
  115.          * Otherwise, we need to use an INSERT to get the link id back.
  116.          */
  117.  
  118.         if ($isNew)
  119.         {
  120.             $columnsArray = array(
  121.                 $db->quoteName('url'), $db->quoteName('route'), $db->quoteName('title'), $db->quoteName('description'),
  122.                 $db->quoteName('indexdate'), $db->quoteName('published'), $db->quoteName('state'), $db->quoteName('access'),
  123.                 $db->quoteName('language'), $db->quoteName('type_id'), $db->quoteName('object'), $db->quoteName('publish_start_date'),
  124.                 $db->quoteName('publish_end_date'), $db->quoteName('start_date'), $db->quoteName('end_date'), $db->quoteName('list_price'),
  125.                 $db->quoteName('sale_price')
  126.             );
  127.  
  128.             // Insert the link.
  129.             $query->clear()
  130.                 ->insert($db->quoteName('#__finder_links'))
  131.                 ->columns($columnsArray)
  132.                 ->values(
  133.                     $db->quote($item->url) . ', '
  134.                     . $db->quote($item->route) . ', '
  135.                     . $db->quote($item->title) . ', '
  136.                     . $db->quote($item->description) . ', '
  137.                     . $query->currentTimestamp() . ', '
  138.                     . '1, '
  139.                     . (int) $item->state . ', '
  140.                     . (int) $item->access . ', '
  141.                     . $db->quote($item->language) . ', '
  142.                     . (int) $item->type_id . ', '
  143.                     . $db->quote(serialize($item)) . ', '
  144.                     . $db->quote($item->publish_start_date) . ', '
  145.                     . $db->quote($item->publish_end_date) . ', '
  146.                     . $db->quote($item->start_date) . ', '
  147.                     . $db->quote($item->end_date) . ', '
  148.                     . (double) ($item->list_price ?: 0) . ', '
  149.                     . (double) ($item->sale_price ?: 0)
  150.                 );
  151.             $db->setQuery($query);
  152.             $db->execute();
  153.  
  154.             // Get the link id.
  155.             $linkId = (int) $db->insertid();
  156.         }
  157.         else
  158.         {
  159.             // Update the link.
  160.             $query->clear()
  161.                 ->update($db->quoteName('#__finder_links'))
  162.                 ->set($db->quoteName('route') . ' = ' . $db->quote($item->route))
  163.                 ->set($db->quoteName('title') . ' = ' . $db->quote($item->title))
  164.                 ->set($db->quoteName('description') . ' = ' . $db->quote($item->description))
  165.                 ->set($db->quoteName('indexdate') . ' = ' . $query->currentTimestamp())
  166.                 ->set($db->quoteName('state') . ' = ' . (int) $item->state)
  167.                 ->set($db->quoteName('access') . ' = ' . (int) $item->access)
  168.                 ->set($db->quoteName('language') . ' = ' . $db->quote($item->language))
  169.                 ->set($db->quoteName('type_id') . ' = ' . (int) $item->type_id)
  170.                 ->set($db->quoteName('object') . ' = ' . $db->quote(serialize($item)))
  171.                 ->set($db->quoteName('publish_start_date') . ' = ' . $db->quote($item->publish_start_date))
  172.                 ->set($db->quoteName('publish_end_date') . ' = ' . $db->quote($item->publish_end_date))
  173.                 ->set($db->quoteName('start_date') . ' = ' . $db->quote($item->start_date))
  174.                 ->set($db->quoteName('end_date') . ' = ' . $db->quote($item->end_date))
  175.                 ->set($db->quoteName('list_price') . ' = ' . (double) ($item->list_price ?: 0))
  176.                 ->set($db->quoteName('sale_price') . ' = ' . (double) ($item->sale_price ?: 0))
  177.                 ->where('link_id = ' . (int) $linkId);
  178.             $db->setQuery($query);
  179.             $db->execute();
  180.         }
  181.  
  182.         // Set up the variables we will need during processing.
  183.         $count = 0;
  184.  
  185.         // Mark afterLinking in the profiler.
  186.         static::$profiler ? static::$profiler->mark('afterLinking') : null;
  187.  
  188.         // Truncate the tokens tables.
  189.         $db->truncateTable('#__finder_tokens');
  190.  
  191.         // Truncate the tokens aggregate table.
  192.         $db->truncateTable('#__finder_tokens_aggregate');
  193.  
  194.         /*
  195.          * Process the item's content. The items can customize their
  196.          * processing instructions to define extra properties to process
  197.          * or rearrange how properties are weighted.
  198.          */
  199.         foreach ($item->getInstructions() as $group => $properties)
  200.         {
  201.             // Iterate through the properties of the group.
  202.             foreach ($properties as $property)
  203.             {
  204.                 // Check if the property exists in the item.
  205.                 if (empty($item->$property))
  206.                 {
  207.                     continue;
  208.                 }
  209.  
  210.                 // Tokenize the property.
  211.                 if (is_array($item->$property))
  212.                 {
  213.                     // Tokenize an array of content and add it to the database.
  214.                     foreach ($item->$property as $ip)
  215.                     {
  216.                         /*
  217.                          * If the group is path, we need to a few extra processing
  218.                          * steps to strip the extension and convert slashes and dashes
  219.                          * to spaces.
  220.                          */
  221.                         if ($group === static::PATH_CONTEXT)
  222.                         {
  223.                             $ip = JFile::stripExt($ip);
  224.                             $ip = str_replace(array('/', '-'), ' ', $ip);
  225.                         }
  226.  
  227.                         // Tokenize a string of content and add it to the database.
  228.                         $count += $this->tokenizeToDb($ip, $group, $item->language, $format);
  229.  
  230.                         // Check if we're approaching the memory limit of the token table.
  231.                         if ($count > static::$state->options->get('memory_table_limit', 30000))
  232.                         {
  233.                             $this->toggleTables(false);
  234.                         }
  235.                     }
  236.                 }
  237.                 else
  238.                 {
  239.                     /*
  240.                      * If the group is path, we need to a few extra processing
  241.                      * steps to strip the extension and convert slashes and dashes
  242.                      * to spaces.
  243.                      */
  244.                     if ($group === static::PATH_CONTEXT)
  245.                     {
  246.                         $item->$property = JFile::stripExt($item->$property);
  247.                         $item->$property = str_replace('/', ' ', $item->$property);
  248.                         $item->$property = str_replace('-', ' ', $item->$property);
  249.                     }
  250.  
  251.                     // Tokenize a string of content and add it to the database.
  252.                     $count += $this->tokenizeToDb($item->$property, $group, $item->language, $format);
  253.  
  254.                     // Check if we're approaching the memory limit of the token table.
  255.                     if ($count > static::$state->options->get('memory_table_limit', 30000))
  256.                     {
  257.                         $this->toggleTables(false);
  258.                     }
  259.                 }
  260.             }
  261.         }
  262.  
  263.         /*
  264.          * Process the item's taxonomy. The items can customize their
  265.          * taxonomy mappings to define extra properties to map.
  266.          */
  267.         foreach ($item->getTaxonomy() as $branch => $nodes)
  268.         {
  269.             // Iterate through the nodes and map them to the branch.
  270.             foreach ($nodes as $node)
  271.             {
  272.                 // Add the node to the tree.
  273.                 $nodeId = FinderIndexerTaxonomy::addNode($branch, $node->title, $node->state, $node->access);
  274.  
  275.                 // Add the link => node map.
  276.                 FinderIndexerTaxonomy::addMap($linkId, $nodeId);
  277.             }
  278.         }
  279.  
  280.         // Mark afterProcessing in the profiler.
  281.         static::$profiler ? static::$profiler->mark('afterProcessing') : null;
  282.  
  283.         /*
  284.          * At this point, all of the item's content has been parsed, tokenized
  285.          * and inserted into the #__finder_tokens table. Now, we need to
  286.          * aggregate all the data into that table into a more usable form. The
  287.          * aggregated data will be inserted into #__finder_tokens_aggregate
  288.          * table.
  289.          */
  290.         $query = 'INSERT INTO ' . $db->quoteName('#__finder_tokens_aggregate') .
  291.             ' (' . $db->quoteName('term_id') .
  292.             ', ' . $db->quoteName('map_suffix') .
  293.                 ', ' . $db->quoteName('term') .
  294.             ', ' . $db->quoteName('stem') .
  295.             ', ' . $db->quoteName('common') .
  296.             ', ' . $db->quoteName('phrase') .
  297.             ', ' . $db->quoteName('term_weight') .
  298.             ', ' . $db->quoteName('context') .
  299.             ', ' . $db->quoteName('context_weight') .
  300.             ', ' . $db->quoteName('total_weight') .
  301.                 ', ' . $db->quoteName('language') . ')' .
  302.             ' SELECT' .
  303.             ' COALESCE(t.term_id, 0), \'\', t1.term, t1.stem, t1.common, t1.phrase, t1.weight, t1.context,' .
  304.             ' ROUND( t1.weight * COUNT( t2.term ) * %F, 8 ) AS context_weight, 0, t1.language' .
  305.             ' FROM (' .
  306.             '   SELECT DISTINCT t1.term, t1.stem, t1.common, t1.phrase, t1.weight, t1.context, t1.language' .
  307.             '   FROM ' . $db->quoteName('#__finder_tokens') . ' AS t1' .
  308.             '   WHERE t1.context = %d' .
  309.             ' ) AS t1' .
  310.             ' JOIN ' . $db->quoteName('#__finder_tokens') . ' AS t2 ON t2.term = t1.term' .
  311.             ' LEFT JOIN ' . $db->quoteName('#__finder_terms') . ' AS t ON t.term = t1.term' .
  312.             ' WHERE t2.context = %d' .
  313.             ' GROUP BY t1.term, t.term_id, t1.term, t1.stem, t1.common, t1.phrase, t1.weight, t1.context, t1.language' .
  314.             ' ORDER BY t1.term DESC';
  315.  
  316.         // Iterate through the contexts and aggregate the tokens per context.
  317.         foreach ($state->weights as $context => $multiplier)
  318.         {
  319.             // Run the query to aggregate the tokens for this context..
  320.             $db->setQuery(sprintf($query, $multiplier, $context, $context));
  321.             $db->execute();
  322.         }
  323.  
  324.         // Mark afterAggregating in the profiler.
  325.         static::$profiler ? static::$profiler->mark('afterAggregating') : null;
  326.  
  327.         /*
  328.          * When we pulled down all of the aggregate data, we did a LEFT JOIN
  329.          * over the terms table to try to find all the term ids that
  330.          * already exist for our tokens. If any of the rows in the aggregate
  331.          * table have a term of 0, then no term record exists for that
  332.          * term so we need to add it to the terms table.
  333.          */
  334.         $db->setQuery(
  335.             'INSERT IGNORE INTO ' . $db->quoteName('#__finder_terms') .
  336.             ' (' . $db->quoteName('term') .
  337.             ', ' . $db->quoteName('stem') .
  338.             ', ' . $db->quoteName('common') .
  339.             ', ' . $db->quoteName('phrase') .
  340.             ', ' . $db->quoteName('weight') .
  341.             ', ' . $db->quoteName('soundex') .
  342.             ', ' . $db->quoteName('language') . ')' .
  343.             ' SELECT ta.term, ta.stem, ta.common, ta.phrase, ta.term_weight, SOUNDEX(ta.term), ta.language' .
  344.             ' FROM ' . $db->quoteName('#__finder_tokens_aggregate') . ' AS ta' .
  345.             ' WHERE ta.term_id = 0' .
  346.             ' GROUP BY ta.term, ta.stem, ta.common, ta.phrase, ta.term_weight, SOUNDEX(ta.term), ta.language'
  347.         );
  348.         $db->execute();
  349.  
  350.         /*
  351.          * Now, we just inserted a bunch of new records into the terms table
  352.          * so we need to go back and update the aggregate table with all the
  353.          * new term ids.
  354.          */
  355.         $query = $db->getQuery(true)
  356.             ->update($db->quoteName('#__finder_tokens_aggregate') . ' AS ta')
  357.             ->join('INNER', $db->quoteName('#__finder_terms') . ' AS t ON t.term = ta.term')
  358.             ->set('ta.term_id = t.term_id')
  359.             ->where('ta.term_id = 0');
  360.         $db->setQuery($query);
  361.         $db->execute();
  362.  
  363.         // Mark afterTerms in the profiler.
  364.         static::$profiler ? static::$profiler->mark('afterTerms') : null;
  365.  
  366.         /*
  367.          * After we've made sure that all of the terms are in the terms table
  368.          * and the aggregate table has the correct term ids, we need to update
  369.          * the links counter for each term by one.
  370.          */
  371.         $query->clear()
  372.             ->update($db->quoteName('#__finder_terms') . ' AS t')
  373.             ->join('INNER', $db->quoteName('#__finder_tokens_aggregate') . ' AS ta ON ta.term_id = t.term_id')
  374.             ->set('t.' . $db->quoteName('links') . ' = t.links + 1');
  375.         $db->setQuery($query);
  376.         $db->execute();
  377.  
  378.         // Mark afterTerms in the profiler.
  379.         static::$profiler ? static::$profiler->mark('afterTerms') : null;
  380.  
  381.         /*
  382.          * Before we can insert all of the mapping rows, we have to figure out
  383.          * which mapping table the rows need to be inserted into. The mapping
  384.          * table for each term is based on the first character of the md5 of
  385.          * the first character of the term. In php, it would be expressed as
  386.          * substr(md5(substr($token, 0, 1)), 0, 1)
  387.          */
  388.         $query->clear()
  389.             ->update($db->quoteName('#__finder_tokens_aggregate'))
  390.             ->set($db->quoteName('map_suffix') . ' = SUBSTR(MD5(SUBSTR(' . $db->quoteName('term') . ', 1, 1)), 1, 1)');
  391.         $db->setQuery($query);
  392.         $db->execute();
  393.  
  394.         /*
  395.          * At this point, the aggregate table contains a record for each
  396.          * term in each context. So, we're going to pull down all of that
  397.          * data while grouping the records by term and add all of the
  398.          * sub-totals together to arrive at the final total for each token for
  399.          * this link. Then, we insert all of that data into the appropriate
  400.          * mapping table.
  401.          */
  402.         for ($i = 0; $i <= 15; $i++)
  403.         {
  404.             // Get the mapping table suffix.
  405.             $suffix = dechex($i);
  406.  
  407.             /*
  408.              * We have to run this query 16 times, one for each link => term
  409.              * mapping table.
  410.              */
  411.             $db->setQuery(
  412.                 'INSERT INTO ' . $db->quoteName('#__finder_links_terms' . $suffix) .
  413.                 ' (' . $db->quoteName('link_id') .
  414.                 ', ' . $db->quoteName('term_id') .
  415.                 ', ' . $db->quoteName('weight') . ')' .
  416.                 ' SELECT ' . (int) $linkId . ', ' . $db->quoteName('term_id') . ',' .
  417.                 ' ROUND(SUM(' . $db->quoteName('context_weight') . '), 8)' .
  418.                 ' FROM ' . $db->quoteName('#__finder_tokens_aggregate') .
  419.                 ' WHERE ' . $db->quoteName('map_suffix') . ' = ' . $db->quote($suffix) .
  420.                 ' GROUP BY ' . $db->quoteName('term') . ', ' . $db->quoteName('term_id') .
  421.                 ' ORDER BY ' . $db->quoteName('term') . ' DESC'
  422.             );
  423.             $db->execute();
  424.         }
  425.  
  426.         // Mark afterMapping in the profiler.
  427.         static::$profiler ? static::$profiler->mark('afterMapping') : null;
  428.  
  429.         // Update the signature.
  430.         $query->clear()
  431.             ->update($db->quoteName('#__finder_links'))
  432.             ->set($db->quoteName('md5sum') . ' = ' . $db->quote($curSig))
  433.             ->where($db->quoteName('link_id') . ' = ' . $db->quote($linkId));
  434.         $db->setQuery($query);
  435.         $db->execute();
  436.  
  437.         // Mark afterSigning in the profiler.
  438.         static::$profiler ? static::$profiler->mark('afterSigning') : null;
  439.  
  440.         // Truncate the tokens tables.
  441.         $db->truncateTable('#__finder_tokens');
  442.  
  443.         // Truncate the tokens aggregate table.
  444.         $db->truncateTable('#__finder_tokens_aggregate');
  445.  
  446.         // Toggle the token tables back to memory tables.
  447.         $this->toggleTables(true);
  448.  
  449.         // Mark afterTruncating in the profiler.
  450.         static::$profiler ? static::$profiler->mark('afterTruncating') : null;
  451.  
  452.         return $linkId;
  453.     }
  454.  
  455.     /**
  456.      * Method to optimize the index. We use this method to remove unused terms
  457.      * and any other optimizations that might be necessary.
  458.      *
  459.      * @return  boolean  True on success.
  460.      *
  461.      * @since   3.0
  462.      * @throws  Exception on database error.
  463.      */
  464.     public function optimize()
  465.     {
  466.         // Get the database object.
  467.         $db = $this->db;
  468.         $query = $db->getQuery(true);
  469.  
  470.         // Delete all orphaned terms.
  471.         $query->delete($db->quoteName('#__finder_terms'))
  472.             ->where($db->quoteName('links') . ' <= 0');
  473.         $db->setQuery($query);
  474.         $db->execute();
  475.  
  476.         // Optimize the links table.
  477.         $db->setQuery('OPTIMIZE TABLE ' . $db->quoteName('#__finder_links'));
  478.         $db->execute();
  479.  
  480.         for ($i = 0; $i <= 15; $i++)
  481.         {
  482.             // Optimize the terms mapping table.
  483.             $db->setQuery('OPTIMIZE TABLE ' . $db->quoteName('#__finder_links_terms' . dechex($i)));
  484.             $db->execute();
  485.         }
  486.  
  487.         // Optimize the filters table.
  488.         $db->setQuery('OPTIMIZE TABLE ' . $db->quoteName('#__finder_filters'));
  489.         $db->execute();
  490.  
  491.         // Optimize the terms common table.
  492.         $db->setQuery('OPTIMIZE TABLE ' . $db->quoteName('#__finder_terms_common'));
  493.         $db->execute();
  494.  
  495.         // Optimize the types table.
  496.         $db->setQuery('OPTIMIZE TABLE ' . $db->quoteName('#__finder_types'));
  497.         $db->execute();
  498.  
  499.         // Remove the orphaned taxonomy nodes.
  500.         FinderIndexerTaxonomy::removeOrphanNodes();
  501.  
  502.         // Optimize the taxonomy mapping table.
  503.         $db->setQuery('OPTIMIZE TABLE ' . $db->quoteName('#__finder_taxonomy_map'));
  504.         $db->execute();
  505.  
  506.         // Optimize the taxonomy table.
  507.         $db->setQuery('OPTIMIZE TABLE ' . $db->quoteName('#__finder_taxonomy'));
  508.         $db->execute();
  509.  
  510.         return true;
  511.     }
  512.  
  513.  
  514.     /**
  515.      * Method to switch the token tables from Memory tables to MyISAM tables
  516.      * when they are close to running out of memory.
  517.      *
  518.      * @param   boolean  $memory  Flag to control how they should be toggled.
  519.      *
  520.      * @return  boolean  True on success.
  521.      *
  522.      * @since   3.0
  523.      * @throws  Exception on database error.
  524.      */
  525.     protected function toggleTables($memory)
  526.     {
  527.         static $state;
  528.  
  529.         // Get the database adapter.
  530.         $db = $this->db;
  531.  
  532.         // Check if we are setting the tables to the Memory engine.
  533.         if ($memory === true && $state !== true)
  534.         {
  535.             // Set the tokens table to Memory.
  536.             // theITD edit
  537.             // $db->setQuery('ALTER TABLE ' . $db->quoteName('#__finder_tokens') . ' ENGINE = MEMORY');
  538.             $db->setQuery('ALTER TABLE ' . $db->quoteName('#__finder_tokens') . ' ENGINE = MYISAM');
  539.             $db->execute();
  540.  
  541.             // Set the tokens aggregate table to Memory.
  542.             //$db->setQuery('ALTER TABLE ' . $db->quoteName('#__finder_tokens_aggregate') . ' ENGINE = MEMORY');
  543.             $db->setQuery('ALTER TABLE ' . $db->quoteName('#__finder_tokens_aggregate') . ' ENGINE = MYISAM');
  544.             $db->execute();
  545.  
  546.             // Set the internal state.
  547.             $state = $memory;
  548.         }
  549.         // We must be setting the tables to the MyISAM engine.
  550.         elseif ($memory === false && $state !== false)
  551.         {
  552.             // Set the tokens table to MyISAM.
  553.             $db->setQuery('ALTER TABLE ' . $db->quoteName('#__finder_tokens') . ' ENGINE = MYISAM');
  554.             $db->execute();
  555.  
  556.             // Set the tokens aggregate table to MyISAM.
  557.             $db->setQuery('ALTER TABLE ' . $db->quoteName('#__finder_tokens_aggregate') . ' ENGINE = MYISAM');
  558.             $db->execute();
  559.  
  560.             // Set the internal state.
  561.             $state = $memory;
  562.         }
  563.  
  564.         return true;
  565.     }
  566. }
  567.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement