When I install "Domain Content" module through administration UI, before I confirm to install "Domain, Domain Access", the warning occurs:
Warning: Use of undefined constant DOMAIN_ACCESS_FIELD - assumed 'DOMAIN_ACCESS_FIELD' (this will throw an Error in a future version of PHP) in domain_content_requirements() (line 22 of modules/contrib/domain/domain_content/domain_content.install).
domain_content_requirements('install')
call_user_func_array('domain_content_requirements', Array) (Line: 392)
Drupal\Core\Extension\ModuleHandler->invoke('domain_content', 'requirements', Array) (Line: 1035)
drupal_check_module('domain_content') (Line: 419)
Drupal\system\Form\ModulesListForm->buildModuleList(Object) (Line: 437)
Drupal\system\Form\ModulesListForm->submitForm(Array, Object)
call_user_func_array(Array, Array) (Line: 111)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 51)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 589)
Drupal\Core\Form\FormBuilder->processForm('system_modules', Array, Object) (Line: 318)
Drupal\Core\Form\FormBuilder->buildForm('system_modules', Object) (Line: 93)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 693)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Domain content cannot be enabled until Domain access has installed its required fields.
Notice: Undefined index: domain_content in Drupal\system\Form\ModulesListConfirmForm->buildMessageList() (line 148 of core/modules/system/src/Form/ModulesListConfirmForm.php).
Drupal\system\Form\ModulesListConfirmForm->buildMessageList() (Line: 124)
Drupal\system\Form\ModulesListConfirmForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 518)
Drupal\Core\Form\FormBuilder->retrieveForm('system_modules_confirm_form', Object) (Line: 275)
Drupal\Core\Form\FormBuilder->buildForm('system_modules_confirm_form', Object) (Line: 93)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 693)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
And after them install complete, another notice occur:
Notice: Undefined index: domain_content in Drupal\system\Form\ModulesListConfirmForm->buildMessageList() (line 148 of core/modules/system/src/Form/ModulesListConfirmForm.php).
Drupal\system\Form\ModulesListConfirmForm->buildMessageList() (Line: 124)
Drupal\system\Form\ModulesListConfirmForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 518)
Drupal\Core\Form\FormBuilder->retrieveForm('system_modules_confirm_form', Object) (Line: 275)
Drupal\Core\Form\FormBuilder->buildForm('system_modules_confirm_form', Object) (Line: 93)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 693)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
The content access permissions need to be rebuilt. Rebuild permissions.
And then, I found "Domain, Domain Access" had install success, but "Domain Content" Fail.
So, I reinstall "Domain Content", it works!!! install success.
but, it must be something went wrong here.
Evns:
Database type and version : MySQL 5.7
PHP version : 7.2.8
I install this base on a pure "droopler" distribution instance which version is v8.1.4
Drupal Version
8.6.17
Last Cron Run
Last run 1 day 5 hours ago
(more information)
Run cron
Web Server
Apache/2.4.33 (Unix)
PHP
Version
7.2.8 (more information)
Memory limit
512M
Database
Version
5.7.24
System
MySQL
| Comment | File | Size | Author |
|---|---|---|---|
| #24 | 3078503-domain-constants_23.patch | 110.4 KB | agentrickard |
Comments
Comment #2
司南 commentedComment #3
司南 commentedComment #4
司南 commentedComment #5
司南 commentedComment #6
司南 commentedI found why "Warning: Use of undefined constant DOMAIN_ACCESS_FIELD" occurs.
These two const should not be defined in "domain_access.module", cause "domain_content_requirements()" can not find it when "domain_access" module has not been install.
Comment #7
agentrickardExcept that Domain Access is declared as a dependency for the installation of Domain Content, which makes this a core installation error.
Any ideas as for where to put those constants instead?
We could also force-load the Domain Access module file...
Comment #8
agentrickardWe could move these constants to the DomainAccessManagerInterface.
Comment #9
davps commented@agentrickard, it seems that need to check requirements when the dependency is already installed, otherwise there is no sense in checking requirements that will never be met when the dependent module is disabled.
Comment #11
andypost@agentrickard I bet it because no .module file loaded in install stage
But you point about this constant is interesting! There's some mess with this constant in other domain contrib.
I used to introduce other variable in domain_entity module for 2 reasons:
- get rid of "field_" prefix because this names supposed to be used for fields added with Field UI
- to prevent dependency on domain_access (node) module when I need to "domainize" other entities but not nodes
Probably better to move this discussion to separate issue because domain module supposed to be applicable to nodes only
Comment #12
agentrickardBumping. We should move these to an interface so they can be loaded with a use statement.
Comment #13
andypostInteresting idea with interface, module installer probably adds installable's namespace to classloader before calling
hook_install()Comment #14
agentrickardI would think so. That's why most core constants have moved to interfaces.
Comment #15
agentrickardFor reference, see https://api.drupal.org/api/drupal/core%21modules%21node%21src%21NodeInte...
Comment #16
andypostIt looks great except removal of constants (I bet you made it intentionally to make sure nothing will fail)
The example https://git.drupalcode.org/project/drupal/-/blob/8.9.x/core/modules/comm...
Here we are keeping old constant value instead of assigning interface constant to prevent autoloader useless run when loading module file
I bet this constants should stay but marked as deprecated
Comment #17
agentrickardI had forgotten about @deprecated. Thanks.
Comment #18
agentrickardNew patch, which fixes a Domain Source error found during testing.
Comment #20
agentrickardAnd a new patch.
Comment #21
agentrickardComment #22
agentrickardAnd a patch which makes two changes:
- Restores the old constants and marks them as @deprecated.
- Moves the DOMAIN_MATCH_* constants to DomainNegotiatorInterface.
Comment #24
agentrickardFor compatibility, the DomainNegotiatorInterface constants must be renamed.
Comment #25
agentrickard@andypost -- I think this is ready for final review.
Comment #26
andypostThis looks mostly ready, just not sure the field name could be a part of domain interface as it used only for access controller
That's what I find it strage - this field is added via config in main (domain) module, but also defined in dependent module - "domain_access" which is hard to override or replace
Comment #27
agentrickardThese are different fields, DOMAIN_ADMIN_FIELD and DOMAIN_ACCESS_FIELD.
The ADMIN field, defined by Domain module, is for users and the ACCESS field, defined by Domain Access, is for nodes.
There are non-node access reasons when the ADMIN field on the user is in the main module. This is largely present for people who want to divide up admin tasks or logins.
Drupal\domain_config_ui\Form\SwitchForm::getDomainOptions() looks at the Domain admin field and uses Drupal\domain\DomainAccessControlHandler::checkAccess() to determine which domains can be used by the current user.
Something similar happens in domain_alias.routing.yml, which refers to the same method
This was a deliberate change from earlier versions, since we had people who wanted to extend or separate admin actions based on domain.
Comment #29
agentrickardComment #30
andypostThank you! It works great for me.
@agentrickard please add PHP 8 test run on commit
Comment #31
agentrickardEDIT: Looks like you can do that, just not for issues.
Comment #33
musa.thomasStill got this issue with the last dev version (Drupal 9.3)
Comment #34
breezeweb commentedI'm just confirming that this is still occurring on a D9 fresh install (Drupal 9.3) as @Musa.thomas said.
Comment #35
brad.bulger commentedin 1.0-beta6 I get
Error: Class 'Drupal\\domain_access\\DomainAccessManagerInterface' not found in /home/www/domainsite/web/modules/contrib/domain/domain_content/domain_content.install on line 24 #0 [internal function]: domain_content_requirements()
is that this same issue?
UPDATE: sorry I missed that this was closed, opened #3272765: domain_content install fatal error using DomainAccessManagerInterface
Comment #36
flyke commentedI just updated to the latste dev (from dev-1.x 818fd0f to dev-1.x 8818fae) and now I have this error too on my project.
For example when editing a node.
The error was not there before updating the Domain module to the latest dev.
I do not use the domain_content module.
My exact message:
Warning: Use of undefined constant DOMAIN_ACCESS_FIELD - assumed 'DOMAIN_ACCESS_FIELD' (this will throw an Error in a future version of PHP) in /app/web/modules/contrib/domain/domain_access/domain_access.module on line 760Nevermind my comment, in my case this came from applying patch from here:
https://www.drupal.org/project/domain/issues/2909853
I updated that patch in #33 there and now this error went away.