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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hostdog created an issue. See original summary.

hostdog’s picture

Issue tags: +Quick fix
FileSize
565 bytes

Replace $this with self:: at static function getDefaultValue

hostdog’s picture

I 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()

agentrickard’s picture

I'll see if I can reproduce, but the error is nice and specific.

agentrickard’s picture

This 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.

hostdog’s picture

Steps to reproduce:

  1. Install and enable Domain Access modules
  2. Add an extra field at Basic Page Content Type
  3. Add Basic Page Content
  4. Delete the extra field from Basic Page Content type

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.

agentrickard’s picture

Calling a service class from inside the service class seems bad. I think the self:: approach should work.

agentrickard’s picture

Using self:: seems to break all the tests.

Have you tried running any tests locally?

agentrickard’s picture

Never mind. I goofed the code.

agentrickard’s picture

Status: Active » Fixed

Committed. Thanks!

Status: Fixed » Closed (fixed)

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

ayalon’s picture

This 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)."