Skip to content

Commit

Permalink
🐛 Source should be unique for each feedProvider
Browse files Browse the repository at this point in the history
The tagged locator uses the source as an index to retrieve the
corresponding feedprovider. If there is a source that points to multiple
services the locator fetches the first one it encounters. This results
in the second feed not being fetched.

AFAIK Symfony does not provide a locator that can fetch multiple
services by index.

There are multiple solutions to this problem:

- We could have the php.watch feed provider fetch both feeds.
- We could keep both the providers and give them a unique source.

In this commit we decided on the latter. We introduce two new sources,
php.watch-changes and php.watch-news.
  • Loading branch information
LVoogd committed Dec 31, 2023
1 parent 31c4ad8 commit b983daf
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
37 changes: 37 additions & 0 deletions migrations/Version20231231123959.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20231231123959 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}

public function up(Schema $schema): void
{
// Delete 'php.watch' source
$this->addSql("DELETE FROM sources WHERE id='9930338f-d07c-4030-ade6-5ac19821e554'");

$this->addSql("INSERT INTO sources (id, name) VALUES ('a9ba164c-5a86-43d2-b024-f38e6a227a41', 'php.watch-news')");
$this->addSql("INSERT INTO sources (id, name) VALUES ('18929b96-79a4-44bf-8d97-f442851b7b44', 'php.watch-changes')");

}

public function down(Schema $schema): void
{
$this->addSql("INSERT INTO sources (id, name) VALUES ('9930338f-d07c-4030-ade6-5ac19821e554','php.watch')");

$this->addSql("DELETE FROM sources WHERE id='a9ba164c-5a86-43d2-b024-f38e6a227a41'");
$this->addSql("DELETE FROM sources WHERE id='18929b96-79a4-44bf-8d97-f442851b7b44'");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct(

public static function getSource(): string
{
return 'php.watch';
return 'php.watch-changes';
}

public function fetchFeedItems(): array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct(

public static function getSource(): string
{
return 'php.watch';
return 'php.watch-news';
}

public function fetchFeedItems(): array
Expand Down

0 comments on commit b983daf

Please sign in to comment.