Created
October 19, 2012 12:02
-
-
Save damiankloip/3917904 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/Views/aggregator/Plugin/views/argument/CategoryCid.php b/lib/Views/aggregator/Plugin/views/argument/CategoryCid.php | |
index 2be3fdd..06c16f5 100644 | |
--- a/lib/Views/aggregator/Plugin/views/argument/CategoryCid.php | |
+++ b/lib/Views/aggregator/Plugin/views/argument/CategoryCid.php | |
@@ -28,10 +28,7 @@ class CategoryCid extends Numeric { | |
function title_query() { | |
$titles = array(); | |
- $query = db_select('aggregator_category', 'c'); | |
- $query->addField('c', 'title'); | |
- $query->condition('c.cid', $this->value); | |
- $result = $query->execute(); | |
+ $result = db_query('SELECT title from {aggregator_category} WHERE cid = :cid', array(':cid' => $this->value)); | |
foreach ($result as $term) { | |
$titles[] = check_plain($term->title); | |
} | |
diff --git a/lib/Views/aggregator/Plugin/views/argument/Fid.php b/lib/Views/aggregator/Plugin/views/argument/Fid.php | |
index 2561098..a68bccf 100644 | |
--- a/lib/Views/aggregator/Plugin/views/argument/Fid.php | |
+++ b/lib/Views/aggregator/Plugin/views/argument/Fid.php | |
@@ -29,10 +29,6 @@ class Fid extends Numeric { | |
$titles = array(); | |
$result = db_query("SELECT f.title FROM {aggregator_feed} f WHERE f.fid IN (:fids)", array(':fids' => $this->value)); | |
- $query = db_select('aggregator_feed', 'f'); | |
- $query->addField('f', 'title'); | |
- $query->condition('f.fid', $this->value); | |
- $result = $query->execute(); | |
foreach ($result as $term) { | |
$titles[] = check_plain($term->title); | |
} | |
diff --git a/lib/Views/block/Plugin/views/display/Block.php b/lib/Views/block/Plugin/views/display/Block.php | |
index a1d205a..b498979 100644 | |
--- a/lib/Views/block/Plugin/views/display/Block.php | |
+++ b/lib/Views/block/Plugin/views/display/Block.php | |
@@ -219,7 +219,7 @@ class Block extends DisplayPluginBase { | |
* Update the block delta when you change the machine readable name of the display. | |
*/ | |
protected function updateBlockBid($name, $old_delta, $delta) { | |
- $old_hashes = $hashes = variable_get('views_block_hashes', array()); | |
+ $old_hashes = $hashes = state()->get('views_block_hashes', array()); | |
$old_delta = $name . '-' . $old_delta; | |
$delta = $name . '-' . $delta; | |
@@ -234,7 +234,7 @@ class Block extends DisplayPluginBase { | |
} | |
// Maybe people don't have block module installed, so let's skip this. | |
- if (db_table_exists('block')) { | |
+ if (module_exists('block')) { | |
db_update('block') | |
->fields(array('delta' => $delta)) | |
->condition('delta', $old_delta) | |
@@ -243,27 +243,7 @@ class Block extends DisplayPluginBase { | |
// Update the hashes if needed. | |
if ($hashes != $old_hashes) { | |
- variable_set('views_block_hashes', $hashes); | |
- } | |
- } | |
- | |
- /** | |
- * Save the block cache setting in the blocks table if this block allready | |
- * exists in the blocks table. Dirty fix untill http://drupal.org/node/235673 gets in. | |
- */ | |
- protected function saveBlockCache($delta, $cache_setting) { | |
- if (strlen($delta) >= 32) { | |
- $delta = md5($delta); | |
- } | |
- if (db_table_exists('block') && $bid = db_query("SELECT bid FROM {block} WHERE module = 'views' AND delta = :delta", array( | |
- ':delta' => $delta))->fetchField()) { | |
- db_update('block') | |
- ->fields(array( | |
- 'cache' => $cache_setting, | |
- )) | |
- ->condition('module', 'views') | |
- ->condition('delta', $delta) | |
- ->execute(); | |
+ state()->set('views_block_hashes', $hashes); | |
} | |
} | |
diff --git a/lib/Views/comment/Plugin/views/field/NodeLink.php b/lib/Views/comment/Plugin/views/field/NodeLink.php | |
index c599403..934f5ff 100644 | |
--- a/lib/Views/comment/Plugin/views/field/NodeLink.php | |
+++ b/lib/Views/comment/Plugin/views/field/NodeLink.php | |
@@ -43,12 +43,7 @@ class NodeLink extends FieldPluginBase { | |
function render($values) { | |
$node = $this->get_entity($values); | |
- | |
- // Call comment.module's hook_link: comment_link($type, $node = NULL, $teaser = FALSE) | |
- // Call node by reference so that something is changed here | |
comment_node_view($node, $this->options['teaser'] ? 'teaser' : 'full'); | |
- // question: should we run these through: drupal_alter('link', $links, $node); | |
- // might this have unexpected consequences if these hooks expect items in $node that we don't have? | |
// Only render the links, if they are defined. | |
return !empty($node->content['links']['comment']) ? drupal_render($node->content['links']['comment']) : ''; | |
diff --git a/lib/Views/comment/Plugin/views/field/NodeNewComments.php b/lib/Views/comment/Plugin/views/field/NodeNewComments.php | |
index fbc4979..96ec82d 100644 | |
--- a/lib/Views/comment/Plugin/views/field/NodeNewComments.php | |
+++ b/lib/Views/comment/Plugin/views/field/NodeNewComments.php | |
@@ -78,15 +78,8 @@ class NodeNewComments extends Numeric { | |
} | |
if ($nids) { | |
- $query = db_select('node', 'n'); | |
- $query->addField('n', 'nid'); | |
- $query->innerJoin('comment', 'c', 'n.nid = c.nid'); | |
- $query->addExpression('COUNT(c.cid)', 'num_comments'); | |
- $query->leftJoin('history', 'h', 'h.nid = n.nid'); | |
- $query->condition('n.nid', $nids); | |
- $query->where('c.changed > GREATEST(COALESCE(h.timestamp, :timestamp), :timestamp)', array(':timestamp' => NODE_NEW_LIMIT)); | |
- $query->condition('c.status', COMMENT_PUBLISHED); | |
- $query->groupBy('n.nid'); | |
+ $query = 'SELECT n.nid, COUNT(c.cid) as num_comments from {node} n INNER JOIN {comment} c ON n.nid = c.nid LEFT JOIN {history} h ON h.nid = n.nid WHERE n.nid IN :nids AND (c.changed > GREATEST(COALESCE(h.timestamp, :timestamp) AND c.status = :status GROUP BY n.nid'; | |
+ $result = db_query($query, array(':nids' => $nids, ':timestamp' => NODE_NEW_LIMIT, ':status' => COMMENT_PUBLISHED)); | |
$result = $query->execute(); | |
foreach ($result as $node) { | |
foreach ($ids[$node->nid] as $id) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment