Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

[Messenger] Testing LoggingMiddleware and minor improvements#26912

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
sroze merged 1 commit intosymfony:masterfromyceruto:messenger/logging_middleware
Apr 15, 2018

Conversation

yceruto
Copy link
Member

@ycerutoyceruto commentedApr 13, 2018
edited
Loading

QA
Branch?master
Bug fix?no
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets-
LicenseMIT
Doc PR-

@ycerutoycerutoforce-pushed themessenger/logging_middleware branch 6 times, most recently froma35bbe2 to0f87c02CompareApril 13, 2018 04:45
@@ -49,10 +49,6 @@ public function process(ContainerBuilder $container)
return;
}

if (!$container->getParameter('kernel.debug') || !$container->has('logger')) {
$container->removeDefinition('messenger.middleware.debug.logging');
}
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I needed move this part toFrameworkExtension to make tests pass (see old failures)

"symfony/serializer": "~3.4|~4.0",
"symfony/dependency-injection": "~3.4.6|~4.0",
"symfony/http-kernel": "~3.4|~4.0",
"symfony/property-access": "~3.4|~4.0",
"symfony/var-dumper": "~3.4|~4.0",
"symfony/property-access": "~3.4|~4.0",
Copy link
MemberAuthor

@ycerutoycerutoApr 13, 2018
edited
Loading

Choose a reason for hiding this comment

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

Removing as duplicated entry (unrelated change)

@@ -1446,6 +1446,10 @@ private function registerMessengerConfiguration(array $config, ContainerBuilder

$loader->load('messenger.xml');

if (!$container->getParameter('kernel.debug') || !$container->hasAlias('logger')) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, the!$container->hasAlias('logger') part could be removed, as the Fwb always registers a default logger implementation since#24300

But anyway that'll be handled differently with#26864 as it'll have to be opt-in explicitly.

Copy link
Contributor

Choose a reason for hiding this comment

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

AFAIK doing so will always remove the middleware. I don't see any value in changing what was just changed in#26896 :)

Copy link
Contributor

Choose a reason for hiding this comment

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

The!$container->hasAlias('logger') check in the fwb extension will indeed lead to the middleware removal, even if there is in fact alogger alias declared by the monolog bundle or the kernelLoggerPass, so it's wrong. But as stated above, this check is not necessary anyway, as there will always be alogger alias.

Regarding#26896 , I agree with@yceruto: It doesn't really make sense to me having a LoggingMiddleware without a hard logger dependency. It solves an issue we usually solve at compilation time by removing proper services.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I'll try this again soon.

@@ -1446,6 +1446,10 @@ private function registerMessengerConfiguration(array $config, ContainerBuilder

$loader->load('messenger.xml');

if (!$container->getParameter('kernel.debug') || !$container->hasAlias('logger')) {
Copy link
Contributor

Choose a reason for hiding this comment

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

AFAIK doing so will always remove the middleware. I don't see any value in changing what was just changed in#26896 :)

$next = $this->createPartialMock(\stdClass::class, array('__invoke'));
$next->expects($this->once())->method('__invoke')->with($message);

(new LoggingMiddleware($logger))->handle($message, $next);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you test that it returns the value returned by the previous middleware as well?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Done.

@ycerutoycerutoforce-pushed themessenger/logging_middleware branch 2 times, most recently from462ca65 todafd241CompareApril 13, 2018 14:22
@yceruto
Copy link
MemberAuthor

yceruto commentedApr 13, 2018
edited
Loading

@ogizanagi thetests fail again, I guessLoggerPass is processed afterMessengerPass? or not?

$container->addCompilerPass(newLoggerPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -32);

Any suggestions?

@ogizanagi
Copy link
Contributor

@yceruto : IIUC, the FrameworkExtensionTest does not build the FrameworkBundle, so compiler passes like theLoggerPass registered in the fwb are never processed.

Anyway, you moved it back to the MessengerPass, so this check is kind of required here as you can theoretically use the pass shipped within the component out of the Fwb usage, just with DI. So, let's keep this check.

@ycerutoycerutoforce-pushed themessenger/logging_middleware branch 7 times, most recently from45ca387 toecdb38cCompareApril 13, 2018 17:09
@@ -52,7 +52,7 @@

<!-- Logging & Debug -->
<service id="messenger.middleware.debug.logging" class="Symfony\Component\Messenger\Debug\LoggingMiddleware">
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Another workaround could be creating from scratch this service definition inMessengerPass, only if debug and logger are enabled/exists, wdyt?

Copy link
Contributor

@ogizanagiogizanagiApr 14, 2018
edited
Loading

Choose a reason for hiding this comment

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

We usually try as much as possible to declare all services in xml files so everything is in one place, favoring discovery/inspections and allowing to jump from classes to definitions with the PhpStorm Symfony plugin.

yceruto and nicolas-grekas reacted with thumbs up emoji
@nicolas-grekasnicolas-grekas added this to the4.1 milestoneApr 14, 2018
nicolas-grekas
nicolas-grekas approved these changesApr 14, 2018
edited
Loading
Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

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

composer.json should be alpha ordered
could also validator+process work with 3.4? if yes, let's do the change here.

@yceruto
Copy link
MemberAuthor

Done! (failures are unrelated)

Status: Needs Review

@sroze
Copy link
Contributor

Thank you@yceruto.

@srozesroze merged commiteedad4c intosymfony:masterApr 15, 2018
sroze added a commit that referenced this pull requestApr 15, 2018
…ents (yceruto)This PR was merged into the 4.1-dev branch.Discussion----------[Messenger] Testing LoggingMiddleware and minor improvements| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | -| License       | MIT| Doc PR        | -- This add tests for `LoggingMiddleware` class- Similar to [`translator.logging`](https://github.com/symfony/symfony/blob/6bbb5bcc5294fdd540bec35541f77b87e212fc5f/src/Symfony/Component/Translation/LoggingTranslator.php#L33) a logging service doesn't make sense without a [hard `logger` dependency](https://github.com/symfony/symfony/blob/6bbb5bcc5294fdd540bec35541f77b87e212fc5f/src/Symfony/Bundle/FrameworkBundle/Resources/config/translation.xml#L25-L29) and according to:https://github.com/symfony/symfony/blob/6bbb5bcc5294fdd540bec35541f77b87e212fc5f/src/Symfony/Component/Messenger/DependencyInjection/MessengerPass.php#L52-L54   it must be removed if `logger` alias doesn't exists.Commits-------eedad4c Make logger arg a hard dependency, remove dead code and add tests
@ycerutoyceruto deleted the messenger/logging_middleware branchApril 16, 2018 11:14
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@ogizanagiogizanagiogizanagi approved these changes

@srozesrozesroze approved these changes

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

Assignees
No one assigned
Projects
None yet
Milestone
4.1
Development

Successfully merging this pull request may close these issues.

5 participants
@yceruto@ogizanagi@sroze@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp