MidCOM svn: r27080 - in branches/ragnaroek/midcom: fi.aalto.linkfeedmanager net.nehmer.blog net.nemein.calendar

rambo midcom-commits at lists.midgard-project.org
Wed Nov 30 21:04:27 CET 2011


Author: rambo
Date: Wed Nov 30 21:04:25 2011
New Revision: 27080
URL: http://trac.midgard-project.org/changeset/27080

Log:
refactor the additional constraints handling again since the previous implementation broke article links

Modified:
   branches/ragnaroek/midcom/fi.aalto.linkfeedmanager/feed.php
   branches/ragnaroek/midcom/net.nehmer.blog/viewer.php
   branches/ragnaroek/midcom/net.nemein.calendar/viewer.php

Modified: branches/ragnaroek/midcom/fi.aalto.linkfeedmanager/feed.php
==============================================================================
--- branches/ragnaroek/midcom/fi.aalto.linkfeedmanager/feed.php	(original)
+++ branches/ragnaroek/midcom/fi.aalto.linkfeedmanager/feed.php	Wed Nov 30 21:04:25 2011
@@ -144,26 +144,19 @@
         $config = new midcom_helper_configuration($interface->_data['config']->get_all());
         $config->store_from_object($topic, 'fi.aalto.linkfeedmanager');
 
-        $qb->begin_group('OR');
-            $class = fi_aalto_linkfeedmanager_feed_dba::add_topic_constraint_by_component($qb, $topic);
-            foreach($target_topics as $id)
+        foreach($target_topics as $id)
+        {
+            $target = new midcom_db_topic($id);
+            if (!fi_aalto_linkfeedmanager_feed_dba::has_additional_constraints($config, $class))
             {
-                $target = new midcom_db_topic($id);
-                /**
-                 * TODO: this needs to be made two-phase so first we check if there are constraints and then add them
-                 * though not sure if it's worth the trouble, aalto will always have constraints anyway...
-                if (!fi_aalto_linkfeedmanager_feed_dba::has_additional_constraints($config, $class))
-                {
-                    continue;
-                }
-                 */
-                $qb->begin_group('AND');
-                    fi_aalto_linkfeedmanager_feed_dba::add_topic_constraint_by_component($qb, $target);
-                    fi_aalto_linkfeedmanager_feed_dba::apply_additional_constraints($qb, $config, $class);
-                $qb->end_group();
+                continue;
             }
-            unset($target, $target_topics, $id);
-        $qb->end_group();
+            $qb->begin_group('AND');
+                fi_aalto_linkfeedmanager_feed_dba::add_topic_constraint_by_component($qb, $target);
+                fi_aalto_linkfeedmanager_feed_dba::apply_additional_constraints($qb, $config, $class);
+            $qb->end_group();
+        }
+        unset($target, $target_topics, $id);
         return true;
     }
 

Modified: branches/ragnaroek/midcom/net.nehmer.blog/viewer.php
==============================================================================
--- branches/ragnaroek/midcom/net.nehmer.blog/viewer.php	(original)
+++ branches/ragnaroek/midcom/net.nehmer.blog/viewer.php	Wed Nov 30 21:04:25 2011
@@ -907,10 +907,10 @@
             }
             unset($mc, $keys, $guid, $dummy);
         }
-        if ($_MIDCOM->componentloader->is_installed('fi.aalto.linkfeedmanager'))
+        if (   $_MIDCOM->componentloader->is_installed('fi.aalto.linkfeedmanager')
+            && $config->get('enable_article_links'))
         {
             $topic_ids = array_merge($topic_ids, fi_aalto_linkfeedmanager_feed_dba::get_skipmoderated_target_ids($data['content_topic']->id));
-            fi_aalto_linkfeedmanager_feed_dba::apply_additional_constraints_boilerplate($qb, $data['content_topic']);
         }
 
         // Include the article links to the indexes if enabled
@@ -952,28 +952,25 @@
             $mc->execute();
 
             $links = $mc->list_keys();
+            $article_ids = array();
+            foreach ($links as $guid => $link)
+            {
+                $article_ids[] = $mc->get_subkey($guid, 'article');
+            }
+            unset($mc, $links, $guid, $link);
             $qb->begin_group('OR');
-                // PONDER: Shouldn't this be formulated to single IN constraint for a less complex query (from query parser POV)
-                foreach ($links as $guid => $link)
-                {
-                    $article_id = $mc->get_subkey($guid, 'article');
-                    $qb->add_constraint('id', '=', $article_id);
-                }
-                unset($mc, $links, $guid, $link);
-                /**
-                 * Ref #1776, expands GUIDs before adding them as constraints, should save query time
-                $qb->add_constraint('topic.guid', 'IN', $guids_array);
-                 */
+                $qb->add_constraint('id', 'IN', $article_ids);
                 $qb->add_constraint('topic', 'IN', $topic_ids);
+                fi_aalto_linkfeedmanager_feed_dba::apply_additional_constraints_boilerplate($qb, $data['content_topic']);
             $qb->end_group();
         }
         else
         {
+            $qb->add_constraint('topic', 'IN', $topic_ids);
             /**
-             * Ref #1776, expands GUIDs before adding them as constraints, should save query time
-            $qb->add_constraint('topic.guid', 'IN', $guids_array);
+             * If article links are not enabled do not bother with linkfeedmanager constraints, they're not there...
+            fi_aalto_linkfeedmanager_feed_dba::apply_additional_constraints_boilerplate($qb, $data['content_topic']);
              */
-            $qb->add_constraint('topic', 'IN', $topic_ids);
         }
 
         if (   count($topic_ids) > 1

Modified: branches/ragnaroek/midcom/net.nemein.calendar/viewer.php
==============================================================================
--- branches/ragnaroek/midcom/net.nemein.calendar/viewer.php	(original)
+++ branches/ragnaroek/midcom/net.nemein.calendar/viewer.php	Wed Nov 30 21:04:25 2011
@@ -664,10 +664,10 @@
                 $topic_ids = array($data['content_topic']->id);
             }
         }
-        if ($_MIDCOM->componentloader->is_installed('fi.aalto.linkfeedmanager'))
+        if (   $_MIDCOM->componentloader->is_installed('fi.aalto.linkfeedmanager')
+            && $config->get('enable_event_links'))
         {
             $topic_ids = array_merge($topic_ids, fi_aalto_linkfeedmanager_feed_dba::get_skipmoderated_target_ids($data['content_topic']->id));
-            fi_aalto_linkfeedmanager_feed_dba::apply_additional_constraints_boilerplate($qb, $data['content_topic']);
         }
 
         // Include the event links to the indexes if enabled (copied from n.n.blog) see http://trac.midgard-project.org/ticket/1939
@@ -697,19 +697,19 @@
                 {
                     $qb->add_constraint('id', 'IN', $event_ids);
                 }
+                fi_aalto_linkfeedmanager_feed_dba::apply_additional_constraints_boilerplate($qb, $data['content_topic']);
                 $qb->add_constraint('node', 'IN', $topic_ids);
             $qb->end_group();
         }
         else
         {
+            $qb->add_constraint('node', 'IN', $topic_ids);
             /**
-             * Ref #1776, expands GUIDs before adding them as constraints, should save query time
-            $qb->add_constraint('topic.guid', 'IN', $guids_array);
+             * If event links are not enabled do not bother with linkfeedmanager constraints, they're not there...
+            fi_aalto_linkfeedmanager_feed_dba::apply_additional_constraints_boilerplate($qb, $data['content_topic']);
              */
-            $qb->add_constraint('node', 'IN', $topic_ids);
         }
 
-
         // Add filtering constraint
         if (isset($filters['type_filter']))
         {


More information about the midcom-commits mailing list