8000 [HttpKernel] ConfigDataCollector to return known data without the need of a Kernel by topikito · Pull Request #40535 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[HttpKernel] ConfigDataCollector to return known data without the need of a Kernel #40535

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
Mar 25, 2021

Conversation

topikito
Copy link
Contributor
@topikito topikito commented Mar 21, 2021
Q A
Branch? 4.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets Fix #40534
License MIT
Doc PR

Sets $this->data with information that can be known without the need of a Kernel.

@carsonbot
Copy link

Hey!

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

Symfony has a contribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (see https://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (see https://symfony.com/releases)
  • Features and deprecations must be submitted against the 5.x 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

@derrabus
Copy link
Member

How is it possible that we get null here in the first place? Shouldn't we always be able to determine that piece of information?

@ciaranmcnulty
Copy link
Contributor

@derrabus Not when this condition is false

if (isset($this->kernel)) {
foreach ($this->kernel->getBundles() as $name => $bundle) {
$this->data['bundles'][$name] = new ClassStub(\get_class($bundle));
}
$this->data['symfony_state'] = $this->determineSymfonyState();
$this->data['symfony_minor_version'] = sprintf('%s.%s', Kernel::MAJOR_VERSION, Kernel::MINOR_VERSION);
$this->data['symfony_lts'] = 4 === Kernel::MINOR_VERSION;
$eom = \DateTime::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_MAINTENANCE);
$eol = \DateTime::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_LIFE);
$this->data['symfony_eom'] = $eom->format('F Y');
$this->data['symfony_eol'] = $eol->format('F Y');
}

@ro0NL
Copy link
Contributor
ro0NL commented Mar 22, 2021

we should only rely on the $this->kernel instance for bundle aggregration IMHO.

then always get remaining metadata from static Kernel symbol (which is a hard dep)

@topikito
Copy link
Contributor Author

I have suggested a different solution as to the suggestion of @fabpot to return false: bring out of the if block all assignments that rely on Kernel and not on $kernel.

#40535 (comment)

@topikito
Copy link
Contributor Author

I have extracted the corresponding bits outside of the if block.

For the tests, I decided to add extra checks for all the content I extracted. I required a way to generate the same output for determineSymfonyState() so I decided to copy the behaviour. The reason behind this is that I assume it's not desired to rewrite the tests for each version, so it should rather expect to have the same logic in the tests. If the logic in the class would change, the test should catch it. If this is not acceptable, please let me know how to proceed to test that particular getter.

@nicolas-grekas
Copy link
Member

The descrition+title of the PR need an update now ;)

@topikito topikito requested a review from stof March 23, 2021 12:33
8000
@topikito topikito changed the title [HttpKernel] Add nullable return type on isSymfonyLts() [HttpKernel] ConfigDataCollector to return known data without the need of a Kernel Mar 23, 2021
@Nyholm
Copy link
Member
Nyholm commented Mar 25, 2021

Awesome. Congratulations to your first contribution!

@Nyholm Nyholm merged commit a863e2f into symfony:4.4 Mar 25, 2021
@topikito topikito deleted the kernel-lts-4.4 branch March 25, 2021 22:08
This was referenced Mar 29, 2021
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.

9 participants
0