php - 控制器结果声称提供了相关的缓存元数据,但检测到泄漏的元数据。Drupal 8
问题描述
我收到错误消息“控制器结果声称提供了相关的缓存元数据,但检测到了泄漏的元数据。” 在 Drupal 8.9.6 上。
这是有问题的功能/控制器:
public function getByType(Term $taxonomy_term) {
$response = new CacheableJsonResponse();
$response->addCacheableDependency($taxonomy_term);
$metadata = new CacheableMetadata();
$listCacheTags = $this->entityTypeManager()->getDefinition('product_option')->getListCacheTags();
$metadata->addCacheTags($listCacheTags);
$response->addCacheableDependency($metadata);
$productOptionStorage = $this->entityTypeManager()->getStorage('product_option');
$query = $productOptionStorage->getQuery()
->condition('field_product_variant.entity.field_product_type_', $taxonomy_term->id());
$ids = $query->execute();
$results = $productOptionStorage->loadMultiple($ids);
$data = [];
$skip = [
'field_layer_colors',
'field_product_variant',
'field_supporting_colors',
];
/** @var ProductOptionEntity $result */
foreach ($results as $result) {
$response->addCacheableDependency($result);
$option = ProductSerializer::serializeEntityReferenceField($result, $skip);
$option['field_product_variant'] = $result->get('field_product_variant')->target_id;
$data[] = $option;
}
$response->setData($data);
return $response;
有任何想法吗?
谢谢!
解决方案
推荐阅读
- firebase - 如何在firebase托管的一台服务器上部署nodejs服务器(发送电子邮件)和vuejs应用程序
- stenciljs - 需要帮助为 Stencil 设置类名
- javascript - 如何在 laravel 中使用日期选择器?
- jquery - 尝试使用 jquery 将值传递给 mvc 控制器
- elasticsearch-7 - 非嵌套对象的ES范围查询和嵌套对象的查询词
- ios - 如何在 SwiftUI 中创建 2 个计时器?
- java - Gradle build error: CreateProcess error=206, The filename or extension is too long
- java - Apache POI XSSFWorkbook 为文件抛出 NullPointerException
- angular - 设置角度服务方法以便客户端组件可以正确响应调用中发生的 HTTP 错误的好方法是什么?
- angular - 无法读取未定义错误的属性“长度”,但仍呈现正确的数据