Follow up to #2049085: Inject database dependency into AggregatorFeedBlock derivative class

Problem/Motivation

Drupal\aggregator\Plugin\Derivative\AggregatorFeedBlock is querying the aggregator_feed table.

Proposed resolution

We have a FeedStorageController. Let's use it.

Remaining tasks

Move the queries from AggregatorFeedBlock to FeedStorageController.

User interface changes

API changes

CommentFileSizeAuthor
#2 2085197-feedblock-storage-2.patch5.21 KBkim.pepper
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ParisLiakos’s picture

also as part of #2068325: [META] Convert entity SQL queries to the Entity Query API (we already have a major open for this)

kim.pepper’s picture

Status: Active » Needs review
FileSize
5.21 KB

This simply moves the db queries into FeedStorageController. Not sure how to do the entity query stuff in #1.

Status: Needs review » Needs work

The last submitted patch, 2085197-feedblock-storage-2.patch, failed testing.

ParisLiakos’s picture

  1. +++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Derivative/AggregatorFeedBlock.php
    @@ -81,7 +82,7 @@ public function getDerivativeDefinition($derivative_id, array $base_plugin_defin
    -    $result = $this->connection->query('SELECT fid, title, block FROM {aggregator_feed} WHERE block <> 0 AND fid = :fid', array(':fid' => $derivative_id))->fetchObject();
    

    so the more i look at this query the more i think we can replace this with just an aggregator_feed_load($derivative_id) and then just check $feed->block->value and bail out

  2. +++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Derivative/AggregatorFeedBlock.php
    @@ -93,7 +94,7 @@ public function getDerivativeDefinition($derivative_id, array $base_plugin_defin
    -    $result = $this->connection->query('SELECT fid, title FROM {aggregator_feed} WHERE block <> 0 ORDER BY fid');
    +    $result = $this->feedStorage->loadAllFeedBlocks();
    

    This i would call it loadBlockEnabled()

  3. Not sure how to do the entity query stuff

    Those methods from the feed storage should return a full loaded entity, so we can also standarize on calls like id() or label()..fetchObject only gives an stdClass.
    You can check \Drupal\aggregator\Form\OpmlFeedAdd to see how ti works

Finally though:

I noticed that #1888702: Use configuration selection instead of derivatives for some blocks kills both those queries and i think it will eventually get in, so we should probably postpone this issue

ParisLiakos’s picture

Status: Needs work » Closed (fixed)

yeap, those classes where removed