all admin-structure menus(Content Types, Taxo, Menu, Views, etc) are inaccessible after activating entity_copy_reference module

Created on 14 March 2023, almost 2 years ago
Updated 3 June 2024, 7 months ago

Problem/Motivation

When activating/Installing the "Entity Copy with Reference" extension/module (which is available ) after installing the 'entity_copy_reference 101) module, all main drupal menu at "/admin/structure/" such as Content Types (admin/structure/types) and Comment (admin/structure/comment) , and all the others (block/content/display/...,view) are not accessible . Situation returns to normal when when the 'entity copy reference' is 'removed/uninstalled' from the Extend list.

I am using Drupal 10 PHP 8.1.16 on a standard/shared cpanel hosting account.
I was installing the drupal via ZIP extract install method (not via composer method) on the following directory "/public_html//mysubdomain.com/mysubfolder/"
The drupal web is accessible on the following domain "www.mydomain.com/myfolder/" not from "www.mysubdomain.com"
I have not been performing any 'direct hard coding ' modifications method at all, I've only perform standard drupal install/uninstall composer (via terminal), and install/uninstall via Extend Menu. tehre are other extensions/plugins which I have installed since the fresh install, and most of them are ok, never shows this kind of error.
--
the error message shown in the drupal "admin/reports/dblog/event/312" is as follows:

TypeError: Drupal\entity_copy_reference\EntityCopyReference::isCopyEnabled(): Argument #1 ($node) must be of type Drupal\node\Entity\Node, Drupal\node\Entity\NodeType given, called in /home/commyhos/public_html/mydomain.com/myfolder/modules/contrib/entity_copy_reference/entity_copy_reference.module on line 70 in Drupal\entity_copy_reference\EntityCopyReference->isCopyEnabled() (line 43 of /home/commyhos/public_html/mydomain.com/myfolder/modules/contrib/entity_copy_reference/src/EntityCopyReference.php).

Steps to reproduce

Step 1. Terminal : composer require 'drupal/entity_copy_reference:^1.0'
Step 2. Drupal Menu : INSTALL the extension 'Entity Copy Reference (this part seem to cause error/problem in the main drupal menus (content type/comments /others)
Step 3. try to enter the 'Content Type' or 'Comment' menu (or al menu within the STRUCTURE http://yourdomain.com/admin/structure/ ) ,and it will show a blank white screen page WSOD (White Screen of Death) with 'one line sentence' error message =

"The website encountered an unexpected error. Please try again later."

I've retried the steps a few tiems and the problme still exists

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @infohome
  • πŸ‡ΊπŸ‡ΈUnited States jerrac

    I have a similar issue, not quite the same error message, and only the people admin view is blocked, but I think it's the same.

    [Tue Aug 29 20:27:36.898101 2023] [php:notice] [pid 20] [client 10.212.134.11:0] TypeError: Drupal\\entity_copy_reference\\EntityCopyReference::isCopyEnabled(): Argument #1 ($node) must be of type Drupal\\node\\Entity\\Node, Drupal\\user\\Entity\\User given, called in /var/www/html/web/modules/contrib/entity_copy_reference/entity_copy_reference.module on line 71 in /var/www/html/web/modules/contrib/entity_copy_reference/src/EntityCopyReference.php on line 43 #0 /var/www/html/web/modules/contrib/entity_copy_reference/entity_copy_reference.module(71): Drupal\\entity_copy_reference\\EntityCopyReference->isCopyEnabled()\n#1 /var/www/html/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(562): entity_copy_reference_entity_operation_alter()\n#2 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityListBuilder.php(114): Drupal\\Core\\Extension\\ModuleHandler->alter()\n#3 /var/www/html/web/core/modules/user/src/UserListBuilder.php(159): Drupal\\Core\\Entity\\EntityListBuilder->getOperations()\n#4 /var/www/html/web/core/modules/views/src/Plugin/views/field/EntityOperations.php(137): Drupal\\user\\UserListBuilder->getOperations()\n#5 /var/www/html/web/core/modules/views/src/Plugin/views/field/FieldPluginBase.php(1158): Drupal\\views\\Plugin\\views\\field\\EntityOperations->render()\n#6 /var/www/html/web/core/modules/views/views.theme.inc(238): Drupal\\views\\Plugin\\views\\field\\FieldPluginBase->advancedRender()\n#7 [internal function]: template_preprocess_views_view_field()\n#8 /var/www/html/web/core/lib/Drupal/Core/Theme/ThemeManager.php(287): call_user_func_array()\n#9 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(433): Drupal\\Core\\Theme\\ThemeManager->render()\n#10 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(204): Drupal\\Core\\Render\\Renderer->doRender()\n#11 /var/www/html/web/core/modules/views/src/Plugin/views/field/FieldPluginBase.php(1746): Drupal\\Core\\Render\\Renderer->render()\n#12 /var/www/html/web/core/modules/views/src/Plugin/views/style/StylePluginBase.php(777): Drupal\\views\\Plugin\\views\\field\\FieldPluginBase->theme()\n#13 [internal function]: Drupal\\views\\Plugin\\views\\style\\StylePluginBase->elementPreRenderRow()\n#14 /var/www/html/web/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php(101): call_user_func_array()\n#15 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(788): Drupal\\Core\\Render\\Renderer->doTrustedCallback()\n#16 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(374): Drupal\\Core\\Render\\Renderer->doCallback()\n#17 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(204): Drupal\\Core\\Render\\Renderer->doRender()\n#18 /var/www/html/web/core/modules/views/src/Plugin/views/style/StylePluginBase.php(716): Drupal\\Core\\Render\\Renderer->render()\n#19 /var/www/html/web/core/modules/views/src/Plugin/views/style/StylePluginBase.php(582): Drupal\\views\\Plugin\\views\\style\\StylePluginBase->renderFields()\n#20 /var/www/html/web/core/modules/views/src/Plugin/views/style/StylePluginBase.php(470): Drupal\\views\\Plugin\\views\\style\\StylePluginBase->renderGrouping()\n#21 /var/www/html/web/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php(2169): Drupal\\views\\Plugin\\views\\style\\StylePluginBase->render()\n#22 /var/www/html/web/core/modules/views/src/ViewExecutable.php(1538): Drupal\\views\\Plugin\\views\\display\\DisplayPluginBase->render()\n#23 /var/www/html/web/core/modules/views/src/Plugin/views/display/Page.php(199): Drupal\\views\\ViewExecutable->render()\n#24 /var/www/html/web/core/modules/views/src/ViewExecutable.php(1635): Drupal\\views\\Plugin\\views\\display\\Page->execute()\n#25 /var/www/html/web/core/modules/views/src/Element/View.php(81): Drupal\\views\\ViewExecutable->executeDisplay()\n#26 [internal function]: Drupal\\views\\Element\\View::preRenderViewElement()\n#27 /var/www/html/web/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php(101): call_user_func_array()\n#28 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(788): Drupal\\Core\\Render\\Renderer->doTrustedCallback()\n#29 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(374): Drupal\\Core\\Render\\Renderer->doCallback()\n#30 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(204): Drupal\\Core\\Render\\Renderer->doRender()\n#31 /var/www/html/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(242): Drupal\\Core\\Render\\Renderer->render()\n#32 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\\Core\\Render\\MainContent\\HtmlRenderer->Drupal\\Core\\Render\\MainContent\\{closure}()\n#33 /var/www/html/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(235): Drupal\\Core\\Render\\Renderer->executeInRenderContext()\n#34 /var/www/html/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(132): Drupal\\Core\\Render\\MainContent\\HtmlRenderer->prepare()\n#35 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/MainContentViewSubscriber.php(90): Drupal\\Core\\Render\\MainContent\\HtmlRenderer->renderResponse()\n#36 [internal function]: Drupal\\Core\\EventSubscriber\\MainContentViewSubscriber->onViewRenderArray()\n#37 /var/www/html/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(142): call_user_func()\n#38 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(174): Drupal\\Component\\EventDispatcher\\ContainerAwareEventDispatcher->dispatch()\n#39 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\\Component\\HttpKernel\\HttpKernel->handleRaw()\n#40 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\\Component\\HttpKernel\\HttpKernel->handle()\n#41 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\\Core\\StackMiddleware\\Session->handle()\n#42 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\\Core\\StackMiddleware\\KernelPreHandle->handle()\n#43 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\\page_cache\\StackMiddleware\\PageCache->pass()\n#44 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\\page_cache\\StackMiddleware\\PageCache->handle()\n#45 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\\Core\\StackMiddleware\\ReverseProxyMiddleware->handle()\n#46 /var/www/html/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\\Core\\StackMiddleware\\NegotiationMiddleware->handle()\n#47 /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php(718): Stack\\StackedHttpKernel->handle()\n#48 /var/www/html/web/index.php(19): Drupal\\Core\\DrupalKernel->handle()\n#49 {main}, referer: https://testsite/admin
    

    Ended up combining my patch for this with an older one for an error I ran into when viewing entities that were copy enabled. So I'm just going to paste it as a code block instead of upload it.

    Index: entity_copy_reference.module
    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    ===================================================================
    diff --git a/entity_copy_reference.module b/entity_copy_reference.module
    --- a/entity_copy_reference.module
    +++ b/entity_copy_reference.module	(date 1693345065482)
    @@ -49,6 +49,7 @@
             'title' => t('Copy'),
             'url' => Url::fromRoute('entity_copy_reference.copy', [
               'node' => $node->id(),
    +          'localized_options' => [],
             ]),
           ],
           '#weight' => 2,
    @@ -62,15 +63,17 @@
      * Implements hook_entity_operation_alter().
      */
     function entity_copy_reference_entity_operation_alter(&$operations, $entity) {
    -  $entityCopyReference = new EntityCopyReference();
    +  if ($entity instanceof \Drupal\node\Entity\Node) {
    +    $entityCopyReference = new EntityCopyReference();
    
    -  if ($entityCopyReference->isCopyEnabled($entity) && $entity->access('update')) {
    -    $weight = (array_key_exists('edit', $operations)) ? $operations['edit']['weight'] + 1 : count($operations) + 1;
    +    if ($entityCopyReference->isCopyEnabled($entity) && $entity->access('update')) {
    +      $weight = (array_key_exists('edit', $operations)) ? $operations['edit']['weight'] + 1 : count($operations) + 1;
    
    -    $operations['entity_copy_reference.copy'] = [
    -      'title' => t('Copy'),
    -      'url' => Url::fromRoute('entity_copy_reference.copy', ['node' => $entity->id()]),
    -      'weight' => $weight,
    -    ];
    +      $operations['entity_copy_reference.copy'] = [
    +        'title' => t('Copy'),
    +        'url' => Url::fromRoute('entity_copy_reference.copy', ['node' => $entity->id()]),
    +        'weight' => $weight,
    +      ];
    +    }
       }
     }
    
    

    You can drop that as a file in Drupal's root directory/patches, then add something like this to composer's extra section:

            "patches": {
                "drupal/entity_copy_reference": {
                    "node type error fix": "patches/3347826-enitity_copy_reference_node_type_error_fix.patch"
                }
            }
    
  • πŸ‡ΊπŸ‡ΈUnited States texas-bronius

    Thank you @jerrac. I am having some kind of issue with local patches, so I will try a file fetch. At the same time, I simplified your patch down to just this issue's original intent (as I understand, your c/p patch here addresses something else you were doing for your environment).

    How I tested it:
    * Visit /admin/structure/menu

    With the patch: See menu edit.

    Without the patch: WSOD and the following in

  • Status changed to Needs review 11 months ago
  • πŸ‡ΊπŸ‡ΈUnited States texas-bronius

    Please consider the patch in #3 based on @jerrace #2 above. It applies locally and fixes the problem exhibited for me.

    Note: I could not could not could not initially get either of these patches to load until I deleted `patches.lock.json` and tried again. Phew!

            "patches": {
                ...
                "drupal/entity_copy_reference": {
                    "Edit Menu WSOD": "https://www.drupal.org/files/issues/2024-02-09/3347826-3-entity_copy_reference-fix-entity_alter.patch"
                }
            }
    
  • Status changed to Fixed 7 months ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024