Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fixed DoctrineMigrationsPass not working with latest Symfony 3.4+ #1590

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 26, 2018
Merged

Fixed DoctrineMigrationsPass not working with latest Symfony 3.4+ #1590

merged 1 commit into from
Jun 26, 2018

Conversation

Toflar
Copy link
Member

@Toflar Toflar commented Jun 26, 2018

The changes in symfony/symfony#27272 broke our support for doctrine migrations support.

@Toflar Toflar changed the base branch from master to 4.4 June 26, 2018 08:01
@leofeyer leofeyer added the bug label Jun 26, 2018
@leofeyer leofeyer added this to the 4.4.21 milestone Jun 26, 2018
$reflection = new \ReflectionClass($pass);
$beforeRemovingClasses[] = $reflection->getName();
}

$this->assertContains(AddPackagesPass::class, $classes);
$this->assertContains(AddSessionBagsPass::class, $classes);
$this->assertContains(AddResourcesPathsPass::class, $classes);
$this->assertContains(AddImagineClassPass::class, $classes);
$this->assertContains(DoctrineMigrationsPass::class, $classes);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we delete this line?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be in both arrays 😄

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably should change getPasses() to getBeforeOptimizationPasses() to be more explicit then.

@leofeyer leofeyer merged commit dedd30c into contao:4.4 Jun 26, 2018
@leofeyer
Copy link
Member

Thank you @Toflar.

@Toflar Toflar deleted the fix-doctrine-command-pass-type branch June 26, 2018 09:14
@leofeyer leofeyer modified the milestones: 4.4.21, 4.4 May 14, 2019
leofeyer pushed a commit that referenced this pull request Apr 8, 2020
Description
-----------

| Q                | A
| -----------------| ---
| Fixed issues     | -
| Docs PR or issue | Related to contao/docs#322

While working on an example for contao/docs#322 I noticed a possible problem within the current `RobotsTxtListener` of Contao. No matter what I tried, the resulting `robots.txt` was always

```
user-agent:*
disallow:/foo/
disallow:/contao/

user-agent:*
disallow:/contao/
```

instead of

```
user-agent:*
disallow:/foo/
disallow:/contao/
```

when using the following `App\EventListener\RobotsTxtListener`:

```php
// src/EventListener/RobotsTxtListener.php
namespace App\EventListener;

use Contao\CoreBundle\Event\ContaoCoreEvents;
use Contao\CoreBundle\Event\RobotsTxtEvent;
use Terminal42\ServiceAnnotationBundle\Annotation\ServiceTag;
use Terminal42\ServiceAnnotationBundle\ServiceAnnotationInterface;
use webignition\RobotsTxt\Directive\Directive;
use webignition\RobotsTxt\Record\Record;

/**
 * @ServiceTag("kernel.event_listener", event=ContaoCoreEvents::ROBOTS_TXT)
 */
class RobotsTxtListener implements ServiceAnnotationInterface
{
    public function __invoke(RobotsTxtEvent $event): void
    {
        $file = $event->getFile();

        // If no directive for user-agent: * exists, we add the record
        if (0 === count($file->getRecords())) {
            $record = new Record();
            $this->addDirectivesToRecord($record);
            $file->addRecord($record);
        }

        foreach ($file->getRecords() as $record) {
            $this->addDirectivesToRecord($record);
        }
    }

    private function addDirectivesToRecord(Record $record): void
    {
        $directiveList = $record->getDirectiveList();
        $directiveList->add(new Directive('Disallow', '/foo/'));
    }
}
```

The `App\EventListener\RobotsTxtListener` is actually executed before the `Contao\CoreBundle\EventListener\RobotsTxtListener` (when using no priority setting). So, even though `App\EventListener\RobotsTxtListener` already added a record, the following check still holds true:

https://github.com/contao/contao/blob/7de5fddec93c9a575166296da06e40a5f3e1c9b9/core-bundle/src/EventListener/RobotsTxtListener.php#L42-L52

This PR simply counts the returned records directly - but may be I am overlooking something here.

Commits
-------

c0b4b126 fix robots.txt listener
0649ea9c add user-agent directive
9c18d11a remove superfluous function
cc9c51a8 undo comment change
5d7302b9 adjust test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.