Soft-Dependency for #2497243: Replace Symfony container with a Drupal one, stored in cache:

Problem/Motivation

Core uses once 'persistIds' and once 'form_test.form.serviceForm' as the only uppercase services (and here relies on a side-effect), but Symfony internally lower cases everything, so anything dumped will be 'persistids' and 'form_test.form.serviceform'.

(Symfony does that because it camelCase's at run time, which is bad for performance.)

Proposed resolution

Deprecate using camelCase, use "_" everywhere with lowercase in container service IDs or parameter names.

Throw an Exception in ContainerBuilder to support developers in fixing their applications.

Remaining tasks

- Patch
- Fix it

User interface changes

- None

API changes

- camelCase service IDs or parameters are no longer supported.

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Task because this is a performance enhancement.
Issue priority Major because it is a non-Critical performance issue whose time savings have not been demonstrated.
Prioritized changes The main goal of this issue is performance.
Disruption It will be a minor disruption for contrib modules who may use uppercased names. The exception this patch throws is clear and obvious. If we do not commit this now, we will not have another chance during the 8.x cycle.
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Fabianx’s picture

The last submitted patch, 1: only_allow_lowercase-2498293-1--test-only.patch, failed testing.

cilefen’s picture

I think this is where we need a test.

The last submitted patch, 1: only_allow_lowercase-2498293-1.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 3: only_allow_lowercase-2498293-2.patch, failed testing.

cilefen’s picture

Status: Needs work » Needs review
FileSize
1.42 KB
1.16 KB
5.04 KB

There was another: DefaultConfigTest.schema_storage

dawehner’s picture

That is odd, isn't the point that you can in HEAD access the services by upper and lowercase name.
So why not just tell people: You can't access services, with a lowercase name, in case you have supported uppercase at some point.

Having said that, I think its still a fair limitation to have just lowercase names.

The last submitted patch, 3: only_allow_lowercase-2498293-2-test.patch, failed testing.

The last submitted patch, 6: only_allow_lowercase-2498293-6-tests.patch, failed testing.

Fabianx’s picture

We might need some more test coverage for the other methods?

lauriii’s picture

cilefen’s picture

@Fabianx Oh, ::register()...

cilefen’s picture

Fabianx’s picture

And ::set

cilefen’s picture

@Fabianx ::set() is there.

Fabianx’s picture

+++ b/core/tests/Drupal/Tests/Core/DependencyInjection/ContainerBuilderTest.php
@@ -30,12 +30,37 @@ public function testGet() {
    * @covers ::set
+   * @expectedException \InvalidArgumentException
+   * @expectedExceptionMessage Service ID names must be lowercase: Bar
    */
...
+    $class = new BarClass();
+    $container->set('Bar', $class);
+    $this->assertNotEquals('bar', $class->_serviceId);
+  }

Should be in its own function to isolate the test case ...

cilefen’s picture

The last submitted patch, 13: only_allow_lowercase-2498293-13-tests.patch, failed testing.

The last submitted patch, 17: only_allow_lowercase-2498293-17-tests.patch, failed testing.

Fabianx’s picture

Assigned: Fabianx » Unassigned

Great work, still need a beta eval and change record. I don't have time right now, but will hopefully come back to this later again sometime this week.

Edit:

Would be RTBC - if not missing that.

cilefen’s picture

cilefen’s picture

Fabianx’s picture

Assigned: Unassigned » catch
Status: Needs review » Reviewed & tested by the community

Lets get core committer feedback.

  • catch committed c219ec8 on 8.0.x
    Issue #2498293 by cilefen, Fabianx: Only allow lowercase service and...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Yes this constraint makes sense and while I don't think we can remove the complexity added upstream to support case insensitivity here at least we can ensure we're not relying on that behaviour ourselves - lets us optimize without breaking backwards compatibility later.

Committed/pushed to 8.0.x, thanks!

cilefen’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.