Error: Call to a member function getAlias() on null

Created on 28 August 2023, over 1 year ago

Hi,

I am getting the following error

Steps to reproduce,

1. Create new node without URL alias on Remote site
2. Proceed synchronisation on Client site
3. Update URL alias for the same node on Remote site
4. Proceed sync again on client site

entity_share module version is 8.x-3.0
Drupal version: 9.5.8

It throws the below error

Error: Call to a member function getAlias() on null in Drupal\path\Plugin\Field\FieldType\PathItem->postSave() (line 88 of /var/www/html/docroot/core/modules/path/src/Plugin/Field/FieldType/PathItem.php)
#0 /var/www/html/docroot/modules/contrib/pathauto/src/PathautoItem.php(34): Drupal\path\Plugin\Field\FieldType\PathItem->postSave(true)
#1 [internal function]: Drupal\pathauto\PathautoItem->postSave(true)
#2 /var/www/html/docroot/modules/contrib/pathauto/src/PathautoFieldItemList.php(24): call_user_func_array(Array, Array)
#3 /var/www/html/docroot/core/lib/Drupal/Core/Field/FieldItemList.php(198): Drupal\pathauto\PathautoFieldItemList->delegateMethod('postSave', true)
#4 [internal function]: Drupal\Core\Field\FieldItemList->postSave(true)
#5 /var/www/html/docroot/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(941): call_user_func_array(Array, Array)
#6 /var/www/html/docroot/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(973): Drupal\Core\Entity\ContentEntityStorageBase->invokeFieldMethod('postSave', Object(Drupal\node\Entity\Node), true)
#7 /var/www/html/docroot/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(899): Drupal\Core\Entity\ContentEntityStorageBase->invokeFieldPostSave(Object(Drupal\node\Entity\Node), true)
#8 /var/www/html/docroot/core/lib/Drupal/Core/Entity/EntityStorageBase.php(598): Drupal\Core\Entity\ContentEntityStorageBase->invokeHook('update', Object(Drupal\node\Entity\Node))
#9 /var/www/html/docroot/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(784): Drupal\Core\Entity\EntityStorageBase->doPostSave(Object(Drupal\node\Entity\Node), true)
#10 /var/www/html/docroot/core/lib/Drupal/Core/Entity/EntityStorageBase.php(523): Drupal\Core\Entity\ContentEntityStorageBase->doPostSave(Object(Drupal\node\Entity\Node), true)
#11 /var/www/html/docroot/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php(804): Drupal\Core\Entity\EntityStorageBase->save(Object(Drupal\node\Entity\Node))
#12 /var/www/html/docroot/core/lib/Drupal/Core/Entity/EntityBase.php(339): Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object(Drupal\node\Entity\Node))
#13 /var/www/html/docroot/modules/contrib/entity_share/modules/entity_share_client/src/Plugin/EntityShareClient/Processor/EntityReference.php(181): Drupal\Core\Entity\EntityBase->save()
#14 /var/www/html/docroot/modules/contrib/entity_share/modules/entity_share_client/src/Service/ImportService.php(297): Drupal\entity_share_client\Plugin\EntityShareClient\Processor\EntityReference->processEntity(Object(Drupal\entity_share_client\RuntimeImportContext), Object(Drupal\node\Entity\Node), Array)
#15 /var/www/html/docroot/modules/contrib/entity_share/modules/entity_share_client/src/ImportBatchHelper.php(55): Drupal\entity_share_client\Service\ImportService->importEntityListData(Array)
#16 /var/www/html/docroot/core/includes/batch.inc(295): Drupal\entity_share_client\ImportBatchHelper::importUrlBatch(Object(Drupal\entity_share_client\ImportContext), 'https://miaxr-2...', Array)
#17 /var/www/html/docroot/core/includes/batch.inc(137): _batch_process()
#18 /var/www/html/docroot/core/includes/batch.inc(93): _batch_do()
#19 /var/www/html/docroot/core/modules/system/src/Controller/BatchController.php(55): _batch_page(Object(Symfony\Component\HttpFoundation\Request))
#20 [internal function]: Drupal\system\Controller\BatchController->batchPage(Object(Symfony\Component\HttpFoundation\Request))
#21 /var/www/html/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#22 /var/www/html/docroot/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#23 /var/www/html/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#24 /var/www/html/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#25 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(169): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#26 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#27 /var/www/html/docroot/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#28 /var/www/html/docroot/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#29 /var/www/html/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#30 /var/www/html/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#31 /var/www/html/docroot/modules/contrib/shield/src/ShieldMiddleware.php(270): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#32 /var/www/html/docroot/modules/contrib/shield/src/ShieldMiddleware.php(137): Drupal\shield\ShieldMiddleware->bypass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#33 /var/www/html/docroot/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\shield\ShieldMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#34 /var/www/html/docroot/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#35 /var/www/html/docroot/modules/contrib/remove_http_headers/src/StackMiddleware/RemoveHttpHeadersMiddleware.php(49): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#36 /var/www/html/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\remove_http_headers\StackMiddleware\RemoveHttpHeadersMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#37 /var/www/html/docroot/core/lib/Drupal/Core/DrupalKernel.php(718): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#38 /var/www/html/docroot/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#39 {main}
🐛 Bug report
Status

Active

Version

3.0

Component

Entity Share Client

Created by

🇮🇳India anandhi karnan Chennai

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

Merge Requests

Comments & Activities

  • Issue created by @anandhi karnan
  • Assigned to danrod
  • 🇧🇪Belgium kriboogh

    Been looking at this too. We got it using this scenario:

    server: node A with alias.
    client: sync node A, alias is set.
    server: node A remove alias.
    client: sync node A, error getAlias on null.

    The problem as far as I can see is that there processors who are already saving the processed_entity in their processEntity them selves before the importService calls save on the processed_entity. This causes the pathitem postSave hook to be triggered with a PID that is no longer valid.

    Removing the processed_entity->save() calls in the processors seem to be fixing the problem (in our case).
    need some more testing to confirm.

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.0.7 + Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    42 pass
  • 🇧🇪Belgium kriboogh

    Path for the merge request.
    It removes the save call in the processor, since the importService saves the entity anyway.
    Note; if you also use the layoutbuilder patches, check the processors too and remove the save call there too.

  • Status changed to Needs review over 1 year ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.4 + Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    40 pass, 4 fail
  • The last submitted patch, 7: 3383789 -7-82.diff, failed testing. View results
    - codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

  • Pipeline finished with Failed
    8 months ago
    Total: 803s
    #246615
  • Status changed to Needs work 2 months ago
  • 🇬🇧United Kingdom joachim

    I'm seeing this too.

    Tried the MR, but it doesn't fix the problem.

    However, if I enable the Path alias processor on my import configuration, then it works properly.

    I think the problem comes from the path field being sort of an entity reference (it refers to a path alias entity) and sort of not, in that the field holds the path value as well, and isn't considered as being a reference field.

    In the JSONAPI data for the node, we have this:

          "path": {
    
                "alias": "/my-alias-one",
                "pid": 1,
                "langcode": "en"
    
          },
    

    I'm not sure how best to fix this -- I can see several options:

    1. Make the path alias processor compulsory, the same way the Entity reference processor is
    2. Make the Entity reference processor treat path alias fields as a reference (which would have the same effect, I think, but just a different way of doing it)
    3. Have something else skip a path alias field if the path alias processor is not present

    I think this is something the maintainers would need to make a decision on, as I'm not sure which direction this module should take.

Production build 0.71.5 2024