Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
drupal_container() is deprecated, and all calls in the simpletest module need to be replaced with Drupal::service(), except for where the module_handler service is requested, which needs to be replaced with Drupal::moduleHandler() (see #1957154: Replace calls to drupal_container()->get('module_handler') service with Drupal::moduleHandler())
This task a part of #2001206: Replace drupal_container() with Drupal::service()
Comment | File | Size | Author |
---|---|---|---|
#40 | simpletest-2014015-40.patch | 4.3 KB | Berdir |
#38 | simpletest-2014015-38.patch | 3.51 KB | kgoel |
#36 | simpletest-2014015-36.patch | 3.51 KB | kgoel |
#33 | simpletest-2014015-33.patch | 4.79 KB | kgoel |
#33 | interdiff.txt | 569 bytes | kgoel |
Comments
Comment #1
dmitrii CreditAttribution: dmitrii commentedComment #2
dmitrii CreditAttribution: dmitrii commentedComment #3
andypostYou should always use internal container
$this->container
in testsComment #4
andyposttagged for rocketship
Comment #5
BerdirThis is the thing that we're creating the internal container with, so that correctly uses Drupal, $this->container = $this->container isn't going to work very well ;), with the exception of the last one maybe about keyvalue.
I'd just say "Rebuild the container". You can't rebuild a method or function :)
Comment #6
dmitrii CreditAttribution: dmitrii commentedComment #8
kgoel CreditAttribution: kgoel commentedComment #10
kgoel CreditAttribution: kgoel commentedComment #12
kgoel CreditAttribution: kgoel commentedComment #14
kgoel CreditAttribution: kgoel commentedAh, that was very stupid of me.
Comment #15
kgoel CreditAttribution: kgoel commentedComment #17
kgoel CreditAttribution: kgoel commentedand again....
Comment #19
dmitrii CreditAttribution: dmitrii commented#6: drupal_container-2014015-6.patch queued for re-testing.
Comment #20
kgoel CreditAttribution: kgoel commentedI have looked into it a bit more and found that Drupal::getContainer is deprecated. My guess would be to use Drupal::$container but I want someone else to confirm before I post another silly patch.
Comment #21
BerdirDrupal::getContainer() is correct, that's just a documentation bug :)
Comment #22
kgoel CreditAttribution: kgoel commented@Berdir - any idea why I am getting this fatal error - Undefined class constant 'getContainer' ?
Comment #23
BerdirBecause it's a method, not a constant: \Drupal::getContainer();
Comment #24
kgoel CreditAttribution: kgoel commentedComment #26
kgoel CreditAttribution: kgoel commentedSo the patch failed and error seems to be here -
error message in review log is - 'The service definition "state" does not exist. Does this mean it needs a create method to inject keyvalue properly?
Comment #27
BerdirHave a look at #1786490: Add caching to the state system, I had to fix that too there, the problem is that it's called too late. While you move it around, please change the container id it is checking from keyvalue to state, as that's what it is using.
Also, if you check in $this->container, you also want to call $this->container->get('state')->get().
Comment #28
BerdirDouble post.
Comment #29
kgoel CreditAttribution: kgoel commentedComment #31
kgoel CreditAttribution: kgoel commentedComment #33
kgoel CreditAttribution: kgoel commentedHopefully this is it.
Comment #35
kgoel CreditAttribution: kgoel commented@Berdir - I have followed what you recommended under comment but it seems like same error I was getting before.
Comment #36
kgoel CreditAttribution: kgoel commentedComment #38
kgoel CreditAttribution: kgoel commentedComment #40
BerdirThat's what I meant, let's try this. And yes, this is not a Novice issue :)
Comment #41
Crell CreditAttribution: Crell commented#40: simpletest-2014015-40.patch queued for re-testing.
Comment #42
Crell CreditAttribution: Crell commented#40 seems OK to me visually if the bot still approves. Mr. Roboto can CNW it if it wants.
Comment #43
webchickCommitted and pushed to 8.x. Thanks!
Comment #43.0
webchickadd link to related task