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.
I'm not exactly sure what is producing this error as it occurs on a site with content and several experimental modules installed like (content_moderation and multiversion).
I couldn't reproduce it in a clean install.
Fatal error: Using $this when not in object context in domain/domain_access/src/DomainAccessManager.php on line 101
Comment | File | Size | Author |
---|---|---|---|
#6 | fatal_error_when-2820932-6.patch | 602 bytes | hostdog |
#2 | fatal_error_when-2820932-2.patch | 565 bytes | hostdog |
Comments
Comment #2
hostdog CreditAttribution: hostdog commentedReplace $this with self:: at static function getDefaultValue
Comment #3
hostdog CreditAttribution: hostdog commentedI think we have to alter the getDefaultValue function to public, self::getAccessValues($entity) is producing the following warning.
Strict warning: Non-static method Drupal\domain_access\DomainAccessManager::getAccessValues() should not be called statically in Drupal\domain_access\DomainAccessManager::getAccessValues()
Comment #4
agentrickardI'll see if I can reproduce, but the error is nice and specific.
Comment #5
agentrickardThis is odd, because as far as I can tell -- and the code comment says -- that else statement never fires.
And the getDefaultValues method is already public. Not sure there is anything to do here.
Comment #6
hostdog CreditAttribution: hostdog commentedSteps to reproduce:
I made a new patch to call getAccessValues with "\Drupal::service('domain_access.manager')->getAccessValues($entity);".
I don't know if this is the best approach.
Comment #7
agentrickardCalling a service class from inside the service class seems bad. I think the self:: approach should work.
Comment #8
agentrickardUsing self:: seems to break all the tests.
Have you tried running any tests locally?
Comment #9
agentrickardNever mind. I goofed the code.
Comment #11
agentrickardCommitted. Thanks!
Comment #13
ayalon CreditAttribution: ayalon commentedThis commit introduced a new message:
"Deprecated function: Non-static method Drupal\domain_access\DomainAccessManager::getAccessValues() should not be called statically in Drupal\domain_access\DomainAccessManager::getDefaultValue() (line 105 of modules/contrib/domain/domain_access/src/DomainAccessManager.php)."