Skip to content
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

Accessing entity storage in service constructors causes a container error. #140

Closed
Jaesin opened this issue Feb 27, 2019 · 5 comments
Closed
Labels
apigee_edge_teams bug Something isn't working

Comments

@Jaesin
Copy link
Contributor

Jaesin commented Feb 27, 2019

Q A
Bug? yes
Module Version 8.x-1.x
PHP Client version N/A
Requires PHP client fix no

Actual Behavior

Rebuilding the container cache will fail if a service used in an entity hook accesses a the entity storage.

Expected Behavior

All services should be Inject-able.

Steps to Reproduce the behavior

Call a service during an entity hook that injects the apigee_edge_teams.team_permissions service.

Proposed Solution

Only the entity type manager in services and don't use then in the constructor.

@Jaesin
Copy link
Contributor Author

Jaesin commented Feb 27, 2019

A quick fix patch without tests.
140-1.diff.txt

@Jaesin
Copy link
Contributor Author

Jaesin commented Feb 27, 2019

Adds a demonstration test.

140-2-test-and-fix.diff.txt
140-2-test-only.diff.txt

mxr576 added a commit to mxr576/apigee-edge-drupal that referenced this issue Feb 28, 2019
@mxr576
Copy link
Contributor

mxr576 commented Feb 28, 2019

@Jaesin Thanks for the detailed description and especially for the tests files, please test my fix from the #141.

 $ ./test.sh web/modules/contrib/apigee_edge/modules/apigee_edge_teams/tests/src/Kernel/DependencyInjectionTest.php 
PHPUnit 6.5.14 by Sebastian Bergmann and contributors.

Runtime:       PHP 7.1.17 with Xdebug 2.6.0
Configuration: /var/www/html/web/core/phpunit.xml.dist

Testing Drupal\Tests\apigee_edge_teams\Kernel\DependencyInjectionTest
Test 'Drupal\Tests\apigee_edge_teams\Kernel\DependencyInjectionTest::testDependencyInjection' started
Test 'Drupal\Tests\apigee_edge_teams\Kernel\DependencyInjectionTest::testDependencyInjection' ended


Time: 1.54 seconds, Memory: 6.00MB

OK (1 test, 1 assertion)

@mxr576
Copy link
Contributor

mxr576 commented Mar 1, 2019

140-2-better-test-only.diff.txt

POC for #141

@arunz6161
Copy link
Collaborator

Was been fixed by #144

@Jaesin Jaesin removed their assignment May 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apigee_edge_teams bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants