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

[HttpKernel] fix ErrorException in CacheWarmerAggregate#43501

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

Conversation

@Ahummeling
Copy link
Contributor

QA
Branch?4.4
Bug fix?yes
New feature?no
Deprecations?no
Tickets
LicenseMIT
Doc PR

I ran into anErrorException reloading after some changes. I suppose this triggered a cache warmup call. This didn't go as expected, because$previousLogs = unserialize(file_get_contents($this->deprecationLogsFilepath)); set$previousLogs tofalse instead of the expected array. I think it makes sense to only callarray_merge if$previousLogs was successfully instantiated as an array.

My IDE also pointed out that$collectedLogs was possible undefined, so moving its declaration outside of the if block resolved that.

Stacktrace:

ErrorException:Warning: array_merge(): Expected parameter 1 to be an array, bool given  at /srv/vendor/symfony/http-kernel/CacheWarmer/CacheWarmerAggregate.php:106  at Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate->warmUp('/srv/var/cache/local')     (/srv/vendor/symfony/http-kernel/Kernel.php:584)  at Symfony\Component\HttpKernel\Kernel->initializeContainer()     (/srv/vendor/symfony/http-kernel/Kernel.php:786)  at Symfony\Component\HttpKernel\Kernel->preBoot()     (/srv/vendor/symfony/http-kernel/Kernel.php:187)  at Symfony\Component\HttpKernel\Kernel->handle(object(Request))     (/srv/public/index.php:44)

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has acontribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (seehttps://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (seehttps://symfony.com/releases)
  • Features and deprecations must be submitted against the 5.4 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@AhummelingAhummelingforce-pushed thefix-http-kernel-cache-warmer-aggregate branch from06edb66 toe623192CompareOctober 14, 2021 12:00
@nicolas-grekasnicolas-grekas changed the titlefix ErrorExcception in CacheWarmerAggregate[HttpKernel ]fix ErrorException in CacheWarmerAggregateOct 28, 2021
@nicolas-grekasnicolas-grekas changed the title[HttpKernel ]fix ErrorException in CacheWarmerAggregate[HttpKernel] fix ErrorException in CacheWarmerAggregateOct 28, 2021
{
$collectedLogs = [];
if ($collectDeprecations =$this->debug && !\defined('PHPUNIT_COMPOSER_INSTALL')) {
$collectedLogs = [];

Choose a reason for hiding this comment

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

this should be reverted, the IDE is just missing a brain :)

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

fair enough, will take care of that.
Reverting that is:p

@carsonbotcarsonbot changed the title[HttpKernel] fix ErrorException in CacheWarmerAggregatefix ErrorException in CacheWarmerAggregateOct 28, 2021
@carsonbotcarsonbot changed the titlefix ErrorException in CacheWarmerAggregate[HttpKernel] fix ErrorException in CacheWarmerAggregateOct 28, 2021
Copy link
Member

@derrabusderrabus left a comment

Choose a reason for hiding this comment

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

Looks good to me. Is it possible to write a test for that change?

@Ahummeling
Copy link
ContributorAuthor

Looks good to me. Is it possible to write a test for that change?

Oh I hadn't looked into that actually.
I'll see if there are related tests and see if it's possible to test it. And if so, write a test:)

@Ahummeling
Copy link
ContributorAuthor

So@derrabus I am running into an issue here attempting to test this. The relevant codeblock is only executed when the constantPHPUNIT_COMPOSER_INSTALL is not defined. I found that I can "undefine" a constant usinguopz_undefine, however, I'd have to install the extension in the ci flow and I am not really sure it's worth the hassle.
Maybe I am overthinking this, I am open to suggestions, but as it stands right now, I'm unable to test it.

@nicolas-grekas
Copy link
Member

I'm not sure this can be tested, because I suspect this might happen only in some race conditions.

derrabus reacted with thumbs up emoji

@AhummelingAhummelingforce-pushed thefix-http-kernel-cache-warmer-aggregate branch frome623192 to2eaa19fCompareOctober 29, 2021 09:47
@Ahummeling
Copy link
ContributorAuthor

Ahummeling commentedOct 29, 2021
edited
Loading

I'm not sure this can be tested, because I suspect this might happen only in some race conditions.

I am quite sure you can replicate it without race conditions by truncating the file to size 0 before warming cache
asunserialize(file_get_contents('empty_file')) returnsfalse. Which causes a type error as it's not an array

@nicolas-grekas
Copy link
Member

Oh, can you figure out a test case then?

@Ahummeling
Copy link
ContributorAuthor

Yeah give me a few minutes and I'll push my testcase

@Ahummeling
Copy link
ContributorAuthor

So without the\is_array check in there, running with php8.0, I get the expected error:

There was 1 error:1) Symfony\Component\HttpKernel\Tests\CacheWarmer\CacheWarmerAggregateTest::testWarmupEmptyFileTypeError: array_merge(): Argument #1 must be of type array, bool given

With the\is_array check, it runs fine. I am a little stuck looking for a cleaner solution for getting the$collectDeprecations to be true.
Maybe the\defined('PHPUNIT_COMPOSER_INSTALL') could be taken out? I am really not sure about this part

publicfunctionwarmUp($cacheDir)
{
if ($collectDeprecations =$this->debug && !\defined('PHPUNIT_COMPOSER_INSTALL')) {
if ($collectDeprecations =$this->debug &&(!\defined('PHPUNIT_COMPOSER_INSTALL') ||file_exists(CacheWarmerAggregateTest::$emptyFile))) {

Choose a reason for hiding this comment

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

please revert this.
I'm fine if we don't test, compared to adding it :)

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Yes!
I commited it to show why I thought I couldn't test it, and hoped that maybe I overlooked something.
I will revert the last commit and it should be good to go

@AhummelingAhummelingforce-pushed thefix-http-kernel-cache-warmer-aggregate branch fromfadafdc to2eaa19fCompareOctober 29, 2021 19:06
@fabpot
Copy link
Member

Thank you@Ahummeling.

@fabpotfabpot merged commit415592a intosymfony:4.4Oct 30, 2021
This was referencedNov 22, 2021
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@fabpotfabpotfabpot approved these changes

@derrabusderrabusderrabus approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

4.4

Development

Successfully merging this pull request may close these issues.

5 participants

@Ahummeling@carsonbot@nicolas-grekas@fabpot@derrabus

[8]ページ先頭

©2009-2025 Movatter.jp