Closed (duplicate)
Project:
Drupal core
Version:
8.0.x-dev
Component:
base system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
20 Dec 2013 at 17:06 UTC
Updated:
30 Jan 2015 at 19:20 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
chx commentedComment #3
chx commentedI think flipping the logic around makes this easier to understand.
Comment #4
chx commentedCopied the better error message from #2084521: Improve error handling of \Drupal class
Comment #5
chx commentedComment #7
chx commentedComment #8
dawehnerSomeone should find the other issues which do the same.
I really like the patch.
Comment #9
xjm7: 2160655_7.patch queued for re-testing.
Comment #11
dawehnerRerolled.
Comment #13
jibranFixed the test.
Comment #15
jibran13: drupal-2160655-13.patch queued for re-testing.
Comment #17
dawehner13: drupal-2160655-13.patch queued for re-testing.
Comment #19
jibranFixed the tests.
Comment #22
jibranrmdir(sites/simpletest/353397): Directory not empty: drupal_rmdir('sites/simpletest/353397') file_unmanaged_delete_recursive('sites/simpletest/353397', Array) Drupal\simpletest\TestBase->restoreEnvironment() Drupal\simpletest\TestBase->run() simpletest_script_run_one_test('269', 'Drupal\field\Tests\reEnableModuleFieldTest')now what :SComment #23
jibran19: drupal-2160655-19.patch queued for re-testing.
Comment #24
ianthomas_ukThat's certainly a much more useful error message. The pattern seems a bit weird, but only because php should provide a better way (it doesn't AFAIK).
I don't understand these changes. Surely we need to put the services into the object, and if we can't do that because we haven't got a container yet, then we need to find a way of having a container? Won't just ignoring it cause us problems later?
These might not be set depending on where getContainer is called from. But we're already killing the page, so do we care about a couple of notices?
It's probably beyond the scope of this issue, but I don't think getContainer() should be deprecated. protected-unless-youre-a-test would be more accurate.
Comment #25
ianthomas_ukI have raised #2195725: Un-deprecate \Drupal()::getContainer() to look at whether getContainer() should be deprecated.
Comment #26
dawehnerAfaik the problem is that we have no proper semantics to tell people that they really should not do it that way unless there is no alternative solution.
Comment #27
jibranPossible duplicate of #2363341: Throw exception in Drupal::service() and friends, if container not initialized yet.
Comment #28
jibran