Problem/Motivation
Drupal\serialization\Normalizer\NormalizerBase class declares the use of Drupal\rest\EventSubscriber\ResourceResponseSubscriber. This was added by a committed patch from the closed issue #2910211: Allow computed exposed properties in ComplexData to support cacheability.. That makes the serialization module depend on the rest module. I got this error working with serialization:
Class 'Drupal\rest\EventSubscriber\ResourceResponseSubscriber' not found in Drupal\serialization\Normalizer\NormalizerBase->addCacheableDependency() (line 95 of /var/www/html/core/modules/serialization/src/Normalizer/NormalizerBase.php)
#0 /var/www/html/core/modules/serialization/src/Normalizer/TypedDataNormalizer.php(21): Drupal\serialization\Normalizer\NormalizerBase->addCacheableDependency(Array, Object(Drupal\text\TextProcessed))
...
As the rest module already depends on serialization, there is a circular dependency between the two modules. There is a similar situation with the hal module, see #2928869: Class ResourceResponseSubscriber not found in LinkManagerBase causes fatal error.
Proposed resolution
The most obvious solution would be to add a dependency declaration on the rest module in the serialization module info, but this would confirm the mutual dependency. Therefore, the serialization module should be reviewed to break such dependency on the rest module.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 2938642-2.patch | 1.09 KB | dawehner |
Comments
Comment #2
dawehnerThis is indeed something which shouldn't happen. I think this should be critical given sites without rest module installed, but serialization, will break, when they update to 8.5.0.
I think a totally fine fix is to use literal strings, instead of using the constant.
Comment #3
timmillwoodThis is the same as #2931765: Regression: \Drupal\hal\LinkManager\LinkManagerBase implicitly depends on REST module
Comment #4
tstoecklerDo those issues point to to the fact that the constant should be in serialization module instead, maybe? (Genuinely asking, not sure.)
Comment #5
timmillwoodYes, I think the constant does need to be in serialization module, which is what #2931765: Regression: \Drupal\hal\LinkManager\LinkManagerBase implicitly depends on REST module does.
Comment #6
tstoecklerAhh, sorry, didn't check that out. That does seem to make sense. So that would make this issue a duplicate?
Comment #7
timmillwoodI guess
Comment #8
manuel.adanDespite the hal and serialization are different modules, I can confirm that the last patch from #2931765-11: Regression: \Drupal\hal\LinkManager\LinkManagerBase implicitly depends on REST module solves this issue as well.
Comment #9
manuel.adanComment #10
wim leers#2931765: Regression: \Drupal\hal\LinkManager\LinkManagerBase implicitly depends on REST module has just been committed.