diff --git a/administrator/components/com_admin/sql/updates/postgresql/3.6.3-2016-10-04.sql b/administrator/components/com_admin/sql/updates/postgresql/3.6.3-2016-10-04.sql new file mode 100644 index 0000000000000..5a4262f94e7a1 --- /dev/null +++ b/administrator/components/com_admin/sql/updates/postgresql/3.6.3-2016-10-04.sql @@ -0,0 +1,3 @@ +ALTER TABLE "#__finder_links" ALTER COLUMN "title" TYPE character varying(400); +ALTER TABLE "#__finder_links" ALTER COLUMN "description" TYPE text; +ALTER TABLE "#__finder_links" ALTER COLUMN "description" SET NOT NULL; diff --git a/administrator/components/com_finder/helpers/indexer/driver/postgresql.php b/administrator/components/com_finder/helpers/indexer/driver/postgresql.php index 5cff3a7b8ce27..debec3c713756 100644 --- a/administrator/components/com_finder/helpers/indexer/driver/postgresql.php +++ b/administrator/components/com_finder/helpers/indexer/driver/postgresql.php @@ -298,7 +298,7 @@ public function index($item, $format = 'html') ' ) AS t1' . ' JOIN ' . $db->quoteName('#__finder_tokens') . ' AS t2 ON t2.term = t1.term' . ' LEFT JOIN ' . $db->quoteName('#__finder_terms') . ' AS t ON t.term = t1.term' . - ' WHERE t2.context = %d' . + ' WHERE t2.context = %d AND t.term_id IS NOT NULL' . ' GROUP BY t1.term, t.term_id, t1.term, t1.stem, t1.common, t1.phrase, t1.weight, t1.context, t1.language' . ' ORDER BY t1.term DESC'; @@ -354,7 +354,7 @@ public function index($item, $format = 'html') $query = $db->getQuery(true) ->update($db->quoteName('#__finder_tokens_aggregate') . ' AS ta') ->join('INNER', $db->quoteName('#__finder_terms') . ' AS t ON t.term = ta.term') - ->set('ta.term_id = t.term_id') + ->set('term_id = t.term_id') ->where('ta.term_id = 0'); $db->setQuery($query); $db->execute(); @@ -370,7 +370,7 @@ public function index($item, $format = 'html') $query->clear() ->update($db->quoteName('#__finder_terms') . ' AS t') ->join('INNER', $db->quoteName('#__finder_tokens_aggregate') . ' AS ta ON ta.term_id = t.term_id') - ->set('t.' . $db->quoteName('links') . ' = t.links + 1'); + ->set($db->quoteName('links') . ' = t.links + 1'); $db->setQuery($query); $db->execute(); @@ -416,7 +416,7 @@ public function index($item, $format = 'html') ' ROUND(SUM(' . $db->quoteName('context_weight') . '), 8)' . ' FROM ' . $db->quoteName('#__finder_tokens_aggregate') . ' WHERE ' . $db->quoteName('map_suffix') . ' = ' . $db->quote($suffix) . - ' GROUP BY ' . $db->quoteName('term') . + ' GROUP BY ' . $db->quoteName('term') . ', ' . $db->quoteName('term_id') . ' ORDER BY ' . $db->quoteName('term') . ' DESC' ); $db->execute(); @@ -470,9 +470,10 @@ public function remove($linkId) for ($i = 0; $i <= 15; $i++) { // Update the link counts for the terms. + $query->clear(); $query->update($db->quoteName('#__finder_terms') . ' AS t') ->join('INNER', $db->quoteName('#__finder_links_terms' . dechex($i)) . ' AS m ON m.term_id = t.term_id') - ->set('t.links = t.links - 1') + ->set('links = t.links - 1') ->where('m.link_id = ' . $db->quote((int) $linkId)); $db->setQuery($query); $db->execute(); @@ -544,8 +545,16 @@ public function optimize() $db->execute(); } - // Optimize the terms mapping table. - $db->setQuery('REINDEX TABLE ' . $db->quoteName('#__finder_links_terms')); + // Optimize the filters table. + $db->setQuery('REINDEX TABLE ' . $db->quoteName('#__finder_filters')); + $db->execute(); + + // Optimize the terms common table. + $db->setQuery('REINDEX TABLE ' . $db->quoteName('#__finder_terms_common')); + $db->execute(); + + // Optimize the types table. + $db->setQuery('REINDEX TABLE ' . $db->quoteName('#__finder_types')); $db->execute(); // Remove the orphaned taxonomy nodes. @@ -555,6 +564,10 @@ public function optimize() $db->setQuery('REINDEX TABLE ' . $db->quoteName('#__finder_taxonomy_map')); $db->execute(); + // Optimize the taxonomy table. + $db->setQuery('REINDEX TABLE ' . $db->quoteName('#__finder_taxonomy')); + $db->execute(); + return true; } diff --git a/administrator/components/com_finder/helpers/indexer/taxonomy.php b/administrator/components/com_finder/helpers/indexer/taxonomy.php index 9a9c9a831a87e..1234c5c847c46 100644 --- a/administrator/components/com_finder/helpers/indexer/taxonomy.php +++ b/administrator/components/com_finder/helpers/indexer/taxonomy.php @@ -329,11 +329,22 @@ public static function removeOrphanNodes() { // Delete all orphaned nodes. $db = JFactory::getDbo(); - $query = 'DELETE t' . - ' FROM ' . $db->quoteName('#__finder_taxonomy') . ' AS t' . - ' LEFT JOIN ' . $db->quoteName('#__finder_taxonomy_map') . ' AS m ON m.node_id = t.id' . - ' WHERE t.parent_id > 1' . - ' AND m.link_id IS NULL'; + $query = $db->getQuery(true); + $subquery = $db->getQuery(true); + $subquery1 = $db->getQuery(true); + + $subquery1->select($db->quoteName('t.id')) + ->from($db->quoteName('#__finder_taxonomy', 't')) + ->join('LEFT', $db->quoteName('#__finder_taxonomy_map', 'm') . ' ON ' . $db->quoteName('m.node_id') . '=' . $db->quoteName('t.id')) + ->where($db->quoteName('t.parent_id') . ' > 1 ') + ->where($db->quoteName('m.link_id') . ' IS NULL'); + + $subquery->select($db->quoteName('id')) + ->from('(' . $subquery1 . ') temp'); + + $query->delete($db->quoteName('#__finder_taxonomy')) + ->where($db->quoteName('id') . ' IN (' . $subquery . ')'); + $db->setQuery($query); $db->execute(); diff --git a/installation/sql/postgresql/joomla.sql b/installation/sql/postgresql/joomla.sql index f946df699fd41..37d47f6501f03 100644 --- a/installation/sql/postgresql/joomla.sql +++ b/installation/sql/postgresql/joomla.sql @@ -665,8 +665,8 @@ CREATE TABLE "#__finder_links" ( "link_id" serial NOT NULL, "url" varchar(255) NOT NULL, "route" varchar(255) NOT NULL, - "title" varchar(255) DEFAULT NULL, - "description" varchar(255) DEFAULT NULL, + "title" varchar(400) DEFAULT NULL, + "description" text DEFAULT '' NOT NULL, "indexdate" timestamp without time zone DEFAULT '1970-01-01 00:00:00' NOT NULL, "md5sum" varchar(32) DEFAULT NULL, "published" smallint DEFAULT 1 NOT NULL,