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.
WebTestBase::checkPermissions()
statically caches the available module permissions.
That is completely unnecessary and gets into the way of all tests that need to set up fixtures.
Comment | File | Size | Author |
---|---|---|---|
#3 | drupal8.test-checkpermissions.3.patch | 8.1 KB | sun |
drupal8.test-checkpermissions.0.patch | 8.09 KB | sun | |
Comments
Comment #1
jhodgdonI thought you were trying to make the tests more efficient. How much does removing this slow the tests down?
Comment #3
sunYes, we're working hard to improve the overall test suite performance. However, this is an "optimization" on the completely wrong end — performance optimizations should never cripple the developer experience, and in addition, this custom static variable can get out of sync too easily.
checkPermissions()
is only invoked fromdrupalCreateUser()
/drupalCreateRole()
. Implementations ofhook_permissions()
are either returning simple arrays (fast), or if they call into other services, then those services are caching already. Therefore, there's no need to duplicate any caches here.I mistakenly removed the
array_keys()
from the hook invocation.Comment #4
jhodgdonComment #5
moshe weitzman CreditAttribution: moshe weitzman commentedNice cleanup
Comment #6
webchickAgreed. I'd have no idea I needed to call that were I doing something with permissions in my own test.
Committed and pushed to 8.x. Thanks!