In CheckExceptionOnInvalidReferenceBehaviorPass.php line 31:
                                                                                                                                   
  The service "viewsreference.normalizer.views_reference_item.hal" has a dependency on a non-existent service "hal.link_manager". 

Not really sure what would cause this. Forcing composer to go back to 8.2.0-alpha4 fixes the issue and the site becomes usable again.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

RedEight created an issue. See original summary.

yovince’s picture

same issue.

demonde’s picture

I confirm this error. It breaks the whole system. I cannot even run drush commands.

Rajab Natshah’s picture

Having the same issue, Even newly built sites

reevo’s picture

Quick note on this: alpha5 includes #2900315: Normalizer for viewsreferencefield, which introduces a dependency on services from the hal and serialization modules but doesn't add them as actual dependencies. If you don't have these modules installed prior to installing or updating to alpha5 you'll see the above error.

I can confirm that rolling back to alpha4 as the OP states makes the site usable again. It's then possible to enable hal - which in turn enables serialization. After that, alpha5 can be installed.

composer require 'drupal/viewsreference:2.0-alpha4'
...
drush en hal -y
...
composer require 'drupal/viewsreference:^2.0'
vmiron’s picture

@reevo, works, thank you!

hudri’s picture

Same here, @revoo's workaround from #5 worked for me too

reevo’s picture

Patch attached which a) adds hal and serialization as dependencies in .info.yml, and b) enables these modules in an update hook for sites which already have the module installed.

Rajab Natshah’s picture

FileSize
1.05 KB

Made the same patch, only the older of enabling, and a hook update order

Rajab Natshah’s picture

Status: Active » Needs review

Oh it is Paul's troubleshooting and fixes, only the order of enabling

reevo’s picture

For some reason, I couldn't get the patch to apply with composer when the dependencies were at the end of the info file, hence why I moved it in-between package and type

package: Views
+
+dependencies:
+  - drupal:hal
+  - drupal:serialization
+
 type: module

Also, the update hook threw an exception when I enabled serialization before hal.

Obviously both could be specific to my local environment :)

Rajab Natshah’s picture

Reevo you are right, the patch in #8 is working.

effortDee’s picture

I messed up my website a handful of times before finding out it was views reference.

I installed HAL and Serialization and views reference updates fine.

I do have anotehr issue though that when I update a module, any module, any page with a views reference on it gives me a "page not found" but its still there in admin > content.

I have to edit it and then resave for it to reappear.

RedEight’s picture

Is there any specific reason that HAL and Serialization must be enabled in order to use Views Reference? I can see needing it if I was using views reference to generate a serialized version of the view... but it seems like a largely unnecessary requirement for a module that won't necessarily be used in that manner. My understanding is that this service, 'viewsreference.normalizer.views_reference_item.hal', is only used when generating a JSON or otherwise serialized view output. Am I mistaken for thinking this?

Is there a way to set up the service to give a warning if the service is being configured (selected view is serialized) and HAL + Serialization is NOT available? Or some other soft dependency on HAL + Serialization. Fortunately it's a fairly innocuous dependency since both are core modules, but I would still rather not be required to enable modules whose functionality I definitely won't use.

saschaeggi’s picture

Status: Needs review » Reviewed & tested by the community

Both the patch and #5 worked for me.

reevo’s picture

Status: Reviewed & tested by the community » Needs review
Related issues: +#2900315: Normalizer for viewsreferencefield

Good point, @RedEight. I think it's possible to declare services as optional dependencies, which would - I assume - remove the need to add HAL and Serialization as dependent modules.

Setting this back to needs review as, although it does fix the issue, there's likely a better way.

reevo’s picture

FileSize
555 bytes

New patch attached which declares the services as optional dependencies.

Rajab Natshah’s picture

Agrees with Reevo
An optional service could be better, we thought of that it could had been don by a sub-module.
as we had a big question yesterday to the development leads.

Is it OK to enable
- drupal:serialization
- drupal:hal
In all our sites?

I like the optional service fix.

Anybody’s picture

Agree with #17 - just ran into the same problem. I guess we should create a new release asap, before many more people run into the problem?

#17 works fine and is a great solution!

effortDee’s picture

I have already installed HAL and Serialization then updated viewsreference.

When the next update comes can I uninstall those two modules?

Anybody’s picture

I have already installed HAL and Serialization then updated viewsreference.

When the next update comes can I uninstall those two modules?

IF #17 will be committed, yes!

saschaeggi’s picture

+1 on what Anybody said. Applied patch from #17 and works for me – without installing HAL and Serialization.

Rajab Natshah’s picture

Status: Needs review » Reviewed & tested by the community

Patch in #17 is working with Drupal 8.7.x and Drupal 8.8.x

reevo’s picture

Status: Reviewed & tested by the community » Needs work

I'm marking this as 'Needs work' - the patch in #17 worked fine for the site I was working on during the week, but another site I'm working on today is kaput after patching.

One difference between the two sites is that site A (working with patch #17) doesn't use HAL or Serialization, site B (not working) uses Serialization, but not HAL.

RedEight’s picture

Regarding #24, it sounds like the site that is failing is trying to use the service. Since the patch in #17 makes both services optional arguments (meaning a null is passed if they aren't present) the subscriber to the service then fails when it tries to use the Serialization service. Is there a way to modify the service class, Drupal\viewsreference\Normalizer\ViewsReferenceItemNormalizer, to recognize the null being passed to one or both of its arguments and send a message to enable the HAL and Serialization modules if the service is needed? Instead of just hard failing.

jedgar1mx’s picture

Still getting error after applying #17

PHP Fatal error:  Uncaught Error: Class 'Drupal\hal\Normalizer\EntityReferenceItemNormalizer' not found 
jedgar1mx’s picture

It seems enabling hal fixed the issue. I find it odd that i need to enable a module to get a site up.🤔

codechefmarc’s picture

Confirmed #17 worked for me too. Thanks!

RedEight’s picture

I can confirm that patching with #17 has been fixing my issues all day. I will note however that I do not use HAL or Serialization for anything currently on any of my sites so I can only attest to this fixing it for people not using those two modules.

It seems there is still an issue with sites that have only one or the other installed (strange because HAL requires Serialization, not sure if the reverse is also the case)

jedgar1mx’s picture

I had to remove this patch in order to upgrade to 8.8. Anyone else having this issue?

Ruslan Piskarov’s picture

Title: Updating from alpha4 to alpha5 via composer results in error. » Updating from alpha4 to alpha5 via composer results in error
Ruslan Piskarov’s picture

I noticed, the patch does not resolve the issue for 404's pages. For example /test404page-blablabla...

Rajab Natshah’s picture

Seems 8.x-2.0-alpha4 is more stable option at this time.

kualee’s picture

Title: Updating from alpha4 to alpha5 via composer results in error » Updating from alpha4 to alpha5 via composer results in error.

I can confirm that the workaround in #5 works for me. And the patch in #17 works too!

kualee’s picture

Title: Updating from alpha4 to alpha5 via composer results in error. » Updating from alpha4 to alpha5 via composer results in error

Not sure why the title was changed when I commented

flocondetoile’s picture

Another approach could be to register the service conditionnally as CommerceLog does with a ServiceProvider

For example

 /**
   * {@inheritdoc}
   */
  public function register(ContainerBuilder $container) {
    // We cannot use the module handler as the container is not yet compiled.
    // @see \Drupal\Core\DrupalKernel::compileContainer()
    $modules = $container->getParameter('container.modules');

    if (isset($modules['commerce_cart'])) {
      $container->register('commerce_log.cart_subscriber', 'Drupal\commerce_log\EventSubscriber\CartEventSubscriber')
        ->addTag('event_subscriber')
        ->addArgument(new Reference('entity_type.manager'));
    }
    if (isset($modules['commerce_order'])) {
      $container->register('commerce_log.order_subscriber', 'Drupal\commerce_log\EventSubscriber\OrderEventSubscriber')
        ->addTag('event_subscriber')
        ->addArgument(new Reference('entity_type.manager'));
    }
  }
reevo’s picture

@flocondetoile, that looks like the right approach to take.

Just to recap, the Normalizer introduced in #2900315: Normalizer for viewsreferencefield depends on HAL and Serialization. Making the dependencies optional as in #17 only works if Serialization is not enabled.

I wonder, then, if we should:

  1. only register the service if Serialization and HAL are enabled
  2. implement hook_requirements() to check if Serialization is enabled, then notify the site admin that HAL is also required for the Nomalizer to function
reevo’s picture

Status: Needs work » Needs review
FileSize
2.59 KB

Attached patch which:

  1. Removes the Normalizer from viewsreference.services.yml
  2. Introduces a ServiceProvider which only registers the Normalizer if both Serialization and HAL are enabled
  3. Implements hook_requirements() to alert site admin - if Serialization is enabled - that HAL is also required for the Normalizer

Thanks @flocondetoile for the pointer! :)

I don't have a use case for the Normalizer so cannot verify whether it's still working as expected. Hoping that someone with working knowledge of #2900315: Normalizer for viewsreferencefield can contribute to this issue.

Any input on appropriate code comments/hook_requirements() messaging would be welcome.

RedEight’s picture

Just tested #38 on a site that didn't use HAL or Serialization and can confirm that it fixes the error. Unfortunately, I also do not have any use case for the normalizer so I can't confirm if this fixes those issues as well.

seanB’s picture

FileSize
2.02 KB

I think we should go for a service provider indeed! Patch is attached. Could someone test this and confirm this fixes the issue without breaking denormalization for views reference fields?

c_archer’s picture

I can confirm the patch in #40 works.

DesignWork’s picture

I also can confirm that patch #40 works for me.

  • seanB committed 5d34796 on 8.x-2.x
    Issue #3096956 by reevo, RajabNatshah, seanB, RedEight, jedgar1mx,...
seanB’s picture

Status: Needs review » Fixed

Thanks for testing it out! Since it is such an important fix I've committed the latest patch. Tagged and released an alpha6 version. Also had some tests for using the viewsreference normalizer in a client project which still passed with the patch applied.

Sorry this slipped through and hopefully everything now works as expected.

If anyone wants to (or has time to) help add test coverage for the module that would really help prevent stuff like this in the future (and also improves the chances of tagging a stable release sooner).

Status: Fixed » Closed (fixed)

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