repatched flag again (peformance issues is only with home)
This commit is contained in:
@@ -281,6 +281,9 @@
|
||||
},
|
||||
"drupal/term_reference_tree": {
|
||||
"Term Reference Tree: Re-implement Track List https://www.drupal.org/project/term_reference_tree/issues/3064280": "https://www.drupal.org/files/issues/2024-08-26/term_reference_tree-3064280_bring_back_tracklist-22.patch"
|
||||
},
|
||||
"drupal/flag": {
|
||||
"remove flag hooks to allow site to be accessible again https://www.drupal.org/project/flag/issues/3200806": "./patches/flag-commenthooks.patch"
|
||||
}
|
||||
},
|
||||
"archived-patches": {
|
||||
@@ -316,9 +319,6 @@
|
||||
".editorconfig": "../.editorconfig",
|
||||
".gitattributes": "../.gitattributes"
|
||||
}
|
||||
},
|
||||
"drupal/flag": {
|
||||
"remove flag hooks to allow site to be accessible again https://www.drupal.org/project/flag/issues/3200806": "./patches/flag-commenthooks.patch"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,12 +1,12 @@
|
||||
diff --git a/flag.module b/flag.module
|
||||
index 8dd6181..d67cc8a 100644
|
||||
index d82c105..427ed09 100644
|
||||
--- a/flag.module
|
||||
+++ b/flag.module
|
||||
@@ -342,82 +342,82 @@ function flag_node_links_alter(array &$links, NodeInterface $entity, array &$con
|
||||
@@ -332,85 +332,85 @@ function flag_build_entity_links(array &$links, EntityInterface $entity, array &
|
||||
*
|
||||
* Handles the 'show_in_links' and 'show_as_field' flag options.
|
||||
*/
|
||||
-function flag_entity_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
|
||||
-function flag_entity_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, ?string $view_mode = NULL) {
|
||||
- // Don't show on previews.
|
||||
- if ($entity->isNew()) {
|
||||
- return;
|
||||
@@ -26,10 +26,11 @@ index 8dd6181..d67cc8a 100644
|
||||
- $build['#cache']['tags'] = Cache::mergeTags($build['#cache']['tags'], $flag->getCacheTags());
|
||||
-
|
||||
- // Do not display the flag if disabled.
|
||||
- if (!$flag->status()){
|
||||
- if (!$flag->status()) {
|
||||
- continue;
|
||||
- }
|
||||
-
|
||||
- /** @var \Drupal\flag\Plugin\Flag\EntityFlagType $flag_type_plugin */
|
||||
- $flag_type_plugin = $flag->getFlagTypePlugin();
|
||||
-
|
||||
- // Only add cache key if flag link is displayed.
|
||||
@@ -42,48 +43,53 @@ index 8dd6181..d67cc8a 100644
|
||||
- $entity->getEntityTypeId(),
|
||||
- $entity->id(),
|
||||
- $flag->id(),
|
||||
- ]],
|
||||
- $view_mode,
|
||||
- ],
|
||||
- ],
|
||||
- '#create_placeholder' => TRUE,
|
||||
- ];
|
||||
- }
|
||||
-}
|
||||
+// function flag_entity_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
|
||||
+// function flag_entity_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, ?string $view_mode = NULL) {
|
||||
+// // Don't show on previews.
|
||||
+// if ($entity->isNew()) {
|
||||
+// return;
|
||||
+// }
|
||||
+//
|
||||
+
|
||||
+// $build['#cache']['contexts'][] = 'user.permissions';
|
||||
+//
|
||||
+
|
||||
+// if (empty($build['#cache']['tags'])) {
|
||||
+// $build['#cache']['tags'] = [];
|
||||
+// }
|
||||
+//
|
||||
+
|
||||
+// // Get all possible flags for this entity type.
|
||||
+// $flag_service = \Drupal::service('flag');
|
||||
+// $flags = $flag_service->getAllFlags($entity->getEntityTypeID(), $entity->bundle());
|
||||
+//
|
||||
+
|
||||
+// foreach ($flags as $flag) {
|
||||
+// $build['#cache']['tags'] = Cache::mergeTags($build['#cache']['tags'], $flag->getCacheTags());
|
||||
+//
|
||||
+
|
||||
+// // Do not display the flag if disabled.
|
||||
+// if (!$flag->status()){
|
||||
+// if (!$flag->status()) {
|
||||
+// continue;
|
||||
+// }
|
||||
+//
|
||||
+
|
||||
+// /** @var \Drupal\flag\Plugin\Flag\EntityFlagType $flag_type_plugin */
|
||||
+// $flag_type_plugin = $flag->getFlagTypePlugin();
|
||||
+//
|
||||
+
|
||||
+// // Only add cache key if flag link is displayed.
|
||||
+// if (!$flag_type_plugin->showAsField() || !$display->getComponent('flag_' . $flag->id())) {
|
||||
+// continue;
|
||||
+// }
|
||||
+//
|
||||
+
|
||||
+// $build['flag_' . $flag->id()] = [
|
||||
+// '#lazy_builder' => ['flag.link_builder:build', [
|
||||
+// $entity->getEntityTypeId(),
|
||||
+// $entity->id(),
|
||||
+// $flag->id(),
|
||||
+// ]],
|
||||
+// $view_mode,
|
||||
+// ],
|
||||
+// ],
|
||||
+// '#create_placeholder' => TRUE,
|
||||
+// ];
|
||||
+// }
|
||||
@@ -95,69 +101,62 @@ index 8dd6181..d67cc8a 100644
|
||||
-function flag_entity_build_defaults_alter(array &$build, EntityInterface $entity, $view_mode = 'full', $langcode = NULL) {
|
||||
- /** @var \Drupal\flag\FlagService $flag_service */
|
||||
- $flag_service = \Drupal::service('flag');
|
||||
-
|
||||
+// function flag_entity_build_defaults_alter(array &$build, EntityInterface $entity, $view_mode = 'full', $langcode = NULL) {
|
||||
+// /** @var \Drupal\flag\FlagService $flag_service */
|
||||
+// $flag_service = \Drupal::service('flag');
|
||||
|
||||
- // Get all possible flags for this entity type.
|
||||
- $flags = $flag_service->getAllFlags($entity->getEntityTypeId(), $entity->bundle());
|
||||
-
|
||||
+// // Get all possible flags for this entity type.
|
||||
+// $flags = $flag_service->getAllFlags($entity->getEntityTypeId(), $entity->bundle());
|
||||
|
||||
- $no_cache = FALSE;
|
||||
- foreach ($flags as $flag) {
|
||||
- $flag_type_plugin = $flag->getFlagTypePlugin();
|
||||
-
|
||||
+// $no_cache = FALSE;
|
||||
+// foreach ($flags as $flag) {
|
||||
+// $flag_type_plugin = $flag->getFlagTypePlugin();
|
||||
|
||||
- // Make sure we're dealing with an entity flag type.
|
||||
- if (!$flag_type_plugin instanceof EntityFlagType) {
|
||||
- continue;
|
||||
- }
|
||||
-
|
||||
+// // Make sure we're dealing with an entity flag type.
|
||||
+// if (!$flag_type_plugin instanceof EntityFlagType) {
|
||||
+// continue;
|
||||
+// }
|
||||
|
||||
- // Only add max-age to entity render array if contextual links flag
|
||||
- // display is enabled.
|
||||
- if (!$flag_type_plugin->showContextualLink()) {
|
||||
- continue;
|
||||
- }
|
||||
-
|
||||
- $no_cache = TRUE;
|
||||
- }
|
||||
-
|
||||
- if ($no_cache) {
|
||||
- $build['#cache']['max-age'] = 0;
|
||||
- }
|
||||
-
|
||||
- return $build;
|
||||
-}
|
||||
+// function flag_entity_build_defaults_alter(array &$build, EntityInterface $entity, $view_mode = 'full', $langcode = NULL) {
|
||||
+// /** @var \Drupal\flag\FlagService $flag_service */
|
||||
+// $flag_service = \Drupal::service('flag');
|
||||
+//
|
||||
+// // Get all possible flags for this entity type.
|
||||
+// $flags = $flag_service->getAllFlags($entity->getEntityTypeId(), $entity->bundle());
|
||||
+//
|
||||
+// $no_cache = FALSE;
|
||||
+// foreach ($flags as $flag) {
|
||||
+// $flag_type_plugin = $flag->getFlagTypePlugin();
|
||||
+//
|
||||
+// // Make sure we're dealing with an entity flag type.
|
||||
+// if (!$flag_type_plugin instanceof EntityFlagType) {
|
||||
+// continue;
|
||||
+// }
|
||||
+//
|
||||
+// // Only add max-age to entity render array if contextual links flag
|
||||
+// // display is enabled.
|
||||
+// if (!$flag_type_plugin->showContextualLink()) {
|
||||
+// continue;
|
||||
+// }
|
||||
+//
|
||||
|
||||
- $no_cache = TRUE;
|
||||
- }
|
||||
+// $no_cache = TRUE;
|
||||
+// }
|
||||
+//
|
||||
|
||||
- if ($no_cache) {
|
||||
- $build['#cache']['max-age'] = 0;
|
||||
- }
|
||||
+// if ($no_cache) {
|
||||
+// $build['#cache']['max-age'] = 0;
|
||||
+// }
|
||||
+//
|
||||
|
||||
- return $build;
|
||||
-}
|
||||
+// return $build;
|
||||
+// }
|
||||
|
||||
/**
|
||||
* Implements hook_entity_view_alter().
|
||||
@@ -425,41 +425,41 @@ function flag_entity_build_defaults_alter(array &$build, EntityInterface $entity
|
||||
@@ -418,48 +418,48 @@ function flag_entity_build_defaults_alter(array &$build, EntityInterface $entity
|
||||
* Alters node contextual links placeholder id to contain flag metadata, so that
|
||||
* contextual links cache considers flags granularity.
|
||||
*/
|
||||
@@ -178,7 +177,7 @@ index 8dd6181..d67cc8a 100644
|
||||
- continue;
|
||||
- }
|
||||
-
|
||||
- // Only apply metadata to contextual links if plugin is enabled
|
||||
- // Only apply metadata to contextual links if plugin is enabled.
|
||||
- if (!$flag_type_plugin->showContextualLink()) {
|
||||
- continue;
|
||||
- }
|
||||
@@ -192,44 +191,58 @@ index 8dd6181..d67cc8a 100644
|
||||
- }
|
||||
-
|
||||
- if (!empty($flag_keys)) {
|
||||
- $build['#contextual_links'][$entity_type]['route_parameters']['view_mode'] = $build['#view_mode'];
|
||||
- $build['#contextual_links'][$entity_type]['metadata']['flag_keys'] = implode(',', $flag_keys);
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- // Enable placeholder on entity links to avoid them being cached with the
|
||||
- // entity view mode.
|
||||
- if (isset($build['links']['#lazy_builder'])) {
|
||||
- $build['links']['#create_placeholder'] = TRUE;
|
||||
- }
|
||||
-}
|
||||
+// function flag_entity_view_alter(&$build, EntityInterface $entity, EntityViewDisplayInterface $display) {
|
||||
+// $entity_type = $entity->getEntityTypeId();
|
||||
+// if (isset($build['#contextual_links'][$entity_type])) {
|
||||
+// /** @var \Drupal\flag\FlagService $flag_service */
|
||||
+// $flag_service = \Drupal::service('flag');
|
||||
+//
|
||||
+
|
||||
+// // Get all possible flags for this entity type.
|
||||
+// $flags = $flag_service->getAllFlags($entity_type, $entity->bundle());
|
||||
+//
|
||||
+
|
||||
+// foreach ($flags as $flag) {
|
||||
+// $flag_type_plugin = $flag->getFlagTypePlugin();
|
||||
+//
|
||||
+
|
||||
+// // Make sure we're dealing with an entity flag type.
|
||||
+// if (!$flag_type_plugin instanceof EntityFlagType) {
|
||||
+// continue;
|
||||
+// }
|
||||
+//
|
||||
+// // Only apply metadata to contextual links if plugin is enabled
|
||||
+
|
||||
+// // Only apply metadata to contextual links if plugin is enabled.
|
||||
+// if (!$flag_type_plugin->showContextualLink()) {
|
||||
+// continue;
|
||||
+// }
|
||||
+//
|
||||
+
|
||||
+// $action = 'flag';
|
||||
+// if ($flag->isFlagged($entity)) {
|
||||
+// $action = 'unflag';
|
||||
+// }
|
||||
+//
|
||||
+
|
||||
+// $flag_keys[] = $flag->id() . '-' . $action;
|
||||
+// }
|
||||
+//
|
||||
+
|
||||
+// if (!empty($flag_keys)) {
|
||||
+// $build['#contextual_links'][$entity_type]['route_parameters']['view_mode'] = $build['#view_mode'];
|
||||
+// $build['#contextual_links'][$entity_type]['metadata']['flag_keys'] = implode(',', $flag_keys);
|
||||
+// }
|
||||
+// }
|
||||
+
|
||||
+// // Enable placeholder on entity links to avoid them being cached with the
|
||||
+// // entity view mode.
|
||||
+// if (isset($build['links']['#lazy_builder'])) {
|
||||
+// $build['links']['#create_placeholder'] = TRUE;
|
||||
+// }
|
||||
+// }
|
||||
|
||||
/**
|
||||
|
@@ -104,7 +104,7 @@ class MaterioFlagActionsController extends ActionLinkController {
|
||||
// $node = \Drupal::service('entity.repository')->loadEntityByUuid('node', $uuid);
|
||||
// $nid = $node->id();
|
||||
// call the parent flag function
|
||||
$this->unflag($flag, $id, $flagcollid);
|
||||
$this->unflag($flag, $id, 'default', $flagcollid);
|
||||
// response
|
||||
$data = [
|
||||
'flag' => $flag->toArray(),
|
||||
|
Reference in New Issue
Block a user