- Issue created by @longwave
- Merge request !7155If the aliased service exists, reuse its visibility. β (Open) created by longwave
- Status changed to Needs review
3 months ago 12:06pm 22 March 2024 - π¬π§United Kingdom longwave UK
MR reuses the visibility of the aliased service, unsure if this is the correct approach but seems to work.
> \Drupal::service('Drupal\Core\Form\FormCacheInterface'); Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException You have requested a non-existent service "Drupal\Core\Form\FormCacheInterface". > unserialize(Drupal::service("kernel")->getCachedContainerDefinition()['services']['form_builder']); = [ "class" => "Drupal\Core\Form\FormBuilder", "arguments" => {#7337 +"type": "collection", +"value": [ {#7341 +"type": "service", +"id": "form_validator", +"invalidBehavior": 1, }, {#7339 +"type": "service", +"id": "form_submitter", +"invalidBehavior": 1, }, {#7338 +"type": "private_service", +"id": "private__G8Uu4hTcUgjMeXKACab9jV6Lz0_L84M9F590Ayb57E0", +"value": [ "class" => "Drupal\Core\Form\FormCache", "public" => false, "arguments" => {#7336 ...
- Status changed to Needs work
3 months ago 12:22pm 22 March 2024 - Status changed to Needs review
3 months ago 7:28pm 28 March 2024 - π¬π§United Kingdom longwave UK
Fixed some tests.
backend_overridable
backend services must follow the visibility of the service being overridden. JSON:API had a public alias to a private service in a test, which I think was relying on this bug; worked around this by adding another compiler pass to the test to make the service public again. - π¬π§United Kingdom longwave UK
Alternatively maybe we should just explicitly copy the visibility of the original alias in autowired service aliases? AutowireTest could be extended to check for this.
- π¬π§United Kingdom catch
One very small nit on the MR, but overall the approach seems good to me, as you say a good first step to private-by-default services.
- πΊπΈUnited States smustgrave
@longwave don't mind marking if you can take a look at the one thread.
- Status changed to RTBC
14 days ago 7:34pm 11 June 2024 - πΊπΈUnited States smustgrave
Had some time so went ahead and applied the change mentioned in the MR.
- Status changed to Needs work
14 days ago 10:24am 12 June 2024 - π¬π§United Kingdom alexpott πͺπΊπ
It feels like we're missing test coverage of the heart of this change - the bit where we copy the visibility from the service definition to the alias.
- Status changed to Needs review
13 days ago 11:32am 12 June 2024 - π¬π§United Kingdom longwave UK
Done, let's see what the tests say. Also reapplied @catch's nit which I inadvertently removed when rebasing earlier.
- Status changed to Needs work
13 days ago 6:11pm 12 June 2024 - π¬π§United Kingdom longwave UK
Well, that breaks the tests that use backend overridden services..