Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[ProxyManagerBridge] Fixed support of private services #27593

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 15, 2018

Conversation

omnilight
Copy link

Q A
Branch? master
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #...
License MIT
Doc PR

Fixed lazy loading of private services, that was broken since Symfony 4.0 release because of renaming
addObjectResource
https://github.com/symfony/symfony/blame/fa022f05be75aacc8afcdc11b63333685c719e13/src/Symfony/Component/DependencyInjection/CHANGELOG.md#L114

);
}

public function getPrivatePublicDefinitions()
Copy link
Contributor

Choose a reason for hiding this comment

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

make static?

Copy link
Contributor

Choose a reason for hiding this comment

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

what for? it's phpunit dataprovider

Copy link
Contributor

Choose a reason for hiding this comment

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

avoids needing to create instance of test case to invoke

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

https://github.com/sebastianbergmann/phpunit/blob/master/src/Util/Test.php#L840

using $this inside the data provider can be confusing if it's not static too, use of Prophecy for example isn't managed etc... it was just a minor suggestion.

Copy link
Author

@omnilight omnilight Jun 13, 2018

Choose a reason for hiding this comment

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

But nowhere in the Symfony tests data proiders are made static. Why must this one be?


$code = $this->dumper->getProxyFactoryCode($definition, 'foo', '$this->getFoo2Service(false)');

$this->assertStringMatchesFormat(
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be one line to be consistent with the code base.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

/**
* @dataProvider getPrivatePublicDefinitions
*/
public function testCorrectPublicPrivateInstantiation(Definition $definition, string $access)
Copy link
Contributor

Choose a reason for hiding this comment

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

I hate to be picky, but what doesn it mean "correct" in this context?

Copy link
Author

Choose a reason for hiding this comment

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

Changed name

@stof
Copy link
Member

stof commented Jun 13, 2018

The issue is not the method name. It is the !. We want to use privates only on 4.0 where the method is removed

@stof
Copy link
Member

stof commented Jun 13, 2018

And this needs to be fixed in 3.4, to account for ProxyManagerBridge and DependencyInjection being installed at different versions.

@stof
Copy link
Member

stof commented Jun 13, 2018

@nicolas-grekas can you confirm my diagnosis ?

@omnilight
Copy link
Author

Ok, so probably it is better just to remove checking for method existence and look only on service public or not?

@omnilight
Copy link
Author

And maybe check for the version...

@stof
Copy link
Member

stof commented Jun 14, 2018

Well, this method_exists is precisely the way we detect whether we are using DI 3.4 or 4.0. We don't have a version constant in the DI component.

@omnilight
Copy link
Author

Ok, @stof than we probably can check for both methods

@stof
Copy link
Member

stof commented Jun 14, 2018

Why checking for both methods ? We only need to check for a method removed in 4.0.

@nicolas-grekas nicolas-grekas added this to the 3.4 milestone Jun 14, 2018
@nicolas-grekas nicolas-grekas changed the base branch from master to 3.4 June 14, 2018 10:03
@nicolas-grekas nicolas-grekas force-pushed the di_fix_for_proxy_dumper branch from a4ba66f to 90dd156 Compare June 14, 2018 10:03
@nicolas-grekas nicolas-grekas changed the title [DI] Fixed support of private services since Symfony 4.0 [ProxyManagerBridge] Fixed support of private services Jun 14, 2018
@nicolas-grekas nicolas-grekas force-pushed the di_fix_for_proxy_dumper branch from 90dd156 to 198bee0 Compare June 14, 2018 10:06
@nicolas-grekas
Copy link
Member

I rebased your branch on 3.4 and pushed it on your fork.
See adjusted patch.

Status: needs review

@nicolas-grekas
Copy link
Member

Good catch, thanks @omnilight.

@nicolas-grekas nicolas-grekas merged commit 198bee0 into symfony:3.4 Jun 15, 2018
nicolas-grekas added a commit that referenced this pull request Jun 15, 2018
…colas-grekas)

This PR was merged into the 3.4 branch.

Discussion
----------

[ProxyManagerBridge] Fixed support of private services

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #...
| License       | MIT
| Doc PR        |

<!--
Write a short README entry for your feature/bugfix here (replace this comment block.)
This will help people understand your PR and can be used as a start of the Doc PR.
Additionally:
 - Bug fixes must be submitted against the lowest branch where they apply
   (lowest branches are regularly merged to upper ones so they get the fixes too).
 - Features and deprecations must be submitted against the master branch.
-->

Fixed lazy loading of private services, that was broken since Symfony 4.0 release because of renaming
addObjectResource
https://github.com/symfony/symfony/blame/fa022f05be75aacc8afcdc11b63333685c719e13/src/Symfony/Component/DependencyInjection/CHANGELOG.md#L114

Commits
-------

198bee0 [ProxyManagerBridge] Fixed support of private services
This was referenced Jun 25, 2018
@stof
Copy link
Member

stof commented Jun 29, 2018

@nicolas-grekas this patch is broken, because $this->privates is not used to store private services in DI 3.4, only in 4.0+. So we still need a different logic in the ProxyManagerBridge based on the Symfony DI version.

@fabpot
Copy link
Member

fabpot commented Jul 12, 2018

Shall we revert?

@nicolas-grekas
Copy link
Member

I don't have the reference at hand, but it's already fixed.

@stof
Copy link
Member

stof commented Jul 20, 2018

For reference, it is #27776

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.

8 participants