Skip to content

[Cache][FrameworkBundle] Fix logging for TagAwareAdapter #40740

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
Apr 11, 2021

Conversation

fancyweb
Copy link
Contributor

@fancyweb fancyweb commented Apr 8, 2021

Q A
Branch? 4.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets #40108
License MIT
Doc PR -

@carsonbot carsonbot added this to the 4.4 milestone Apr 8, 2021
@carsonbot carsonbot changed the title [Cache] [FrameworkBundle] Fix logging for TagAwareAdapter [Cache][FrameworkBundle] Fix logging for TagAwareAdapter Apr 8, 2021
@fancyweb fancyweb force-pushed the cache-fwb/tag-aware-log branch from cccd9d1 to 22de60a Compare April 8, 2021 12:20
@fancyweb
Copy link
Contributor Author

fancyweb commented Apr 8, 2021

Do we want to bump the required minimum symfony/cache version in FWB for this or add a runtime check?

@carsonbot
Copy link

Hey!

I think @v-m-i has recently worked with this code. Maybe they can help review this?

Cheers!

Carsonbot

Copy link
Contributor

@v-m-i v-m-i left a comment

Choose a reason for hiding this comment

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

Hi @fancyweb, thank you for this PR.

Kudos for detailed and readable tests.

I have added one typo-fix suggestion. Everything else looks good :)

Besides code, I see that some builds have failed so I would suggest looking into that.

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

(once the typo is fixed)

@fancyweb fancyweb force-pushed the cache-fwb/tag-aware-log branch 9 times, most recently from c08849f to beb338b Compare April 11, 2021 16:46
@fancyweb fancyweb force-pushed the cache-fwb/tag-aware-log branch from beb338b to 6b0beca Compare April 11, 2021 17:06
@@ -81,7 +81,7 @@ public static function setFiles(array $files): array

public static function compute(callable $callback, ItemInterface $item, bool &$save, CacheInterface $pool, \Closure $setMetadata = null, LoggerInterface $logger = null)
{
$key = self::$files ? crc32($item->getKey()) % \count(self::$files) : -1;
$key = self::$files ? abs(crc32($item->getKey())) % \count(self::$files) : -1;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because PHP's integer type is signed many crc32 checksums will result in negative integers on 32bit platforms.

Copy link
Contributor

Choose a reason for hiding this comment

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

I find it better to use sprintf('%u')

@fancyweb
Copy link
Contributor Author

Tests are green 🎉

@nicolas-grekas
Copy link
Member

Thank you @fancyweb.

@nicolas-grekas nicolas-grekas merged commit 4e904ec into symfony:4.4 Apr 11, 2021
@fancyweb fancyweb deleted the cache-fwb/tag-aware-log branch April 16, 2021 13:36
This was referenced May 1, 2021
nicolas-grekas added a commit that referenced this pull request Feb 4, 2022
…yweb)

This PR was merged into the 4.4 branch.

Discussion
----------

[FrameworkBundle] Fix log channel of TagAwareAdapter

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Forgot to add the tag in #40740, therefore the "app" logger is injected instead of the "cache" one.

Commits
-------

494ceaf [FrameworkBundle] Fix log channel of TagAwareAdapter
symfony-splitter pushed a commit to symfony/framework-bundle that referenced this pull request Feb 4, 2022
…yweb)

This PR was merged into the 4.4 branch.

Discussion
----------

[FrameworkBundle] Fix log channel of TagAwareAdapter

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Forgot to add the tag in symfony/symfony#40740, therefore the "app" logger is injected instead of the "cache" one.

Commits
-------

494ceaf6cc [FrameworkBundle] Fix log channel of TagAwareAdapter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants