repatched flag again (peformance issues is only with home)
This commit is contained in:
@@ -281,6 +281,9 @@
|
|||||||
},
|
},
|
||||||
"drupal/term_reference_tree": {
|
"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"
|
"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": {
|
"archived-patches": {
|
||||||
@@ -316,9 +319,6 @@
|
|||||||
".editorconfig": "../.editorconfig",
|
".editorconfig": "../.editorconfig",
|
||||||
".gitattributes": "../.gitattributes"
|
".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
|
diff --git a/flag.module b/flag.module
|
||||||
index 8dd6181..d67cc8a 100644
|
index d82c105..427ed09 100644
|
||||||
--- a/flag.module
|
--- a/flag.module
|
||||||
+++ b/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.
|
* 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.
|
- // Don't show on previews.
|
||||||
- if ($entity->isNew()) {
|
- if ($entity->isNew()) {
|
||||||
- return;
|
- return;
|
||||||
@@ -30,6 +30,7 @@ index 8dd6181..d67cc8a 100644
|
|||||||
- continue;
|
- continue;
|
||||||
- }
|
- }
|
||||||
-
|
-
|
||||||
|
- /** @var \Drupal\flag\Plugin\Flag\EntityFlagType $flag_type_plugin */
|
||||||
- $flag_type_plugin = $flag->getFlagTypePlugin();
|
- $flag_type_plugin = $flag->getFlagTypePlugin();
|
||||||
-
|
-
|
||||||
- // Only add cache key if flag link is displayed.
|
- // Only add cache key if flag link is displayed.
|
||||||
@@ -42,48 +43,53 @@ index 8dd6181..d67cc8a 100644
|
|||||||
- $entity->getEntityTypeId(),
|
- $entity->getEntityTypeId(),
|
||||||
- $entity->id(),
|
- $entity->id(),
|
||||||
- $flag->id(),
|
- $flag->id(),
|
||||||
- ]],
|
- $view_mode,
|
||||||
|
- ],
|
||||||
|
- ],
|
||||||
- '#create_placeholder' => TRUE,
|
- '#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.
|
+// // Don't show on previews.
|
||||||
+// if ($entity->isNew()) {
|
+// if ($entity->isNew()) {
|
||||||
+// return;
|
+// return;
|
||||||
+// }
|
+// }
|
||||||
+//
|
+
|
||||||
+// $build['#cache']['contexts'][] = 'user.permissions';
|
+// $build['#cache']['contexts'][] = 'user.permissions';
|
||||||
+//
|
+
|
||||||
+// if (empty($build['#cache']['tags'])) {
|
+// if (empty($build['#cache']['tags'])) {
|
||||||
+// $build['#cache']['tags'] = [];
|
+// $build['#cache']['tags'] = [];
|
||||||
+// }
|
+// }
|
||||||
+//
|
+
|
||||||
+// // Get all possible flags for this entity type.
|
+// // Get all possible flags for this entity type.
|
||||||
+// $flag_service = \Drupal::service('flag');
|
+// $flag_service = \Drupal::service('flag');
|
||||||
+// $flags = $flag_service->getAllFlags($entity->getEntityTypeID(), $entity->bundle());
|
+// $flags = $flag_service->getAllFlags($entity->getEntityTypeID(), $entity->bundle());
|
||||||
+//
|
+
|
||||||
+// foreach ($flags as $flag) {
|
+// foreach ($flags as $flag) {
|
||||||
+// $build['#cache']['tags'] = Cache::mergeTags($build['#cache']['tags'], $flag->getCacheTags());
|
+// $build['#cache']['tags'] = Cache::mergeTags($build['#cache']['tags'], $flag->getCacheTags());
|
||||||
+//
|
+
|
||||||
+// // Do not display the flag if disabled.
|
+// // Do not display the flag if disabled.
|
||||||
+// if (!$flag->status()) {
|
+// if (!$flag->status()) {
|
||||||
+// continue;
|
+// continue;
|
||||||
+// }
|
+// }
|
||||||
+//
|
+
|
||||||
|
+// /** @var \Drupal\flag\Plugin\Flag\EntityFlagType $flag_type_plugin */
|
||||||
+// $flag_type_plugin = $flag->getFlagTypePlugin();
|
+// $flag_type_plugin = $flag->getFlagTypePlugin();
|
||||||
+//
|
+
|
||||||
+// // Only add cache key if flag link is displayed.
|
+// // Only add cache key if flag link is displayed.
|
||||||
+// if (!$flag_type_plugin->showAsField() || !$display->getComponent('flag_' . $flag->id())) {
|
+// if (!$flag_type_plugin->showAsField() || !$display->getComponent('flag_' . $flag->id())) {
|
||||||
+// continue;
|
+// continue;
|
||||||
+// }
|
+// }
|
||||||
+//
|
+
|
||||||
+// $build['flag_' . $flag->id()] = [
|
+// $build['flag_' . $flag->id()] = [
|
||||||
+// '#lazy_builder' => ['flag.link_builder:build', [
|
+// '#lazy_builder' => ['flag.link_builder:build', [
|
||||||
+// $entity->getEntityTypeId(),
|
+// $entity->getEntityTypeId(),
|
||||||
+// $entity->id(),
|
+// $entity->id(),
|
||||||
+// $flag->id(),
|
+// $flag->id(),
|
||||||
+// ]],
|
+// $view_mode,
|
||||||
|
+// ],
|
||||||
|
+// ],
|
||||||
+// '#create_placeholder' => TRUE,
|
+// '#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) {
|
-function flag_entity_build_defaults_alter(array &$build, EntityInterface $entity, $view_mode = 'full', $langcode = NULL) {
|
||||||
- /** @var \Drupal\flag\FlagService $flag_service */
|
- /** @var \Drupal\flag\FlagService $flag_service */
|
||||||
- $flag_service = \Drupal::service('flag');
|
- $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.
|
- // Get all possible flags for this entity type.
|
||||||
- $flags = $flag_service->getAllFlags($entity->getEntityTypeId(), $entity->bundle());
|
- $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;
|
- $no_cache = FALSE;
|
||||||
- foreach ($flags as $flag) {
|
- foreach ($flags as $flag) {
|
||||||
- $flag_type_plugin = $flag->getFlagTypePlugin();
|
- $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.
|
- // Make sure we're dealing with an entity flag type.
|
||||||
- if (!$flag_type_plugin instanceof EntityFlagType) {
|
- if (!$flag_type_plugin instanceof EntityFlagType) {
|
||||||
- continue;
|
- 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
|
- // Only add max-age to entity render array if contextual links flag
|
||||||
- // display is enabled.
|
- // display is enabled.
|
||||||
- if (!$flag_type_plugin->showContextualLink()) {
|
- if (!$flag_type_plugin->showContextualLink()) {
|
||||||
- continue;
|
- 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
|
+// // Only add max-age to entity render array if contextual links flag
|
||||||
+// // display is enabled.
|
+// // display is enabled.
|
||||||
+// if (!$flag_type_plugin->showContextualLink()) {
|
+// if (!$flag_type_plugin->showContextualLink()) {
|
||||||
+// continue;
|
+// continue;
|
||||||
+// }
|
+// }
|
||||||
+//
|
|
||||||
|
- $no_cache = TRUE;
|
||||||
|
- }
|
||||||
+// $no_cache = TRUE;
|
+// $no_cache = TRUE;
|
||||||
+// }
|
+// }
|
||||||
+//
|
|
||||||
|
- if ($no_cache) {
|
||||||
|
- $build['#cache']['max-age'] = 0;
|
||||||
|
- }
|
||||||
+// if ($no_cache) {
|
+// if ($no_cache) {
|
||||||
+// $build['#cache']['max-age'] = 0;
|
+// $build['#cache']['max-age'] = 0;
|
||||||
+// }
|
+// }
|
||||||
+//
|
|
||||||
|
- return $build;
|
||||||
|
-}
|
||||||
+// return $build;
|
+// return $build;
|
||||||
+// }
|
+// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements hook_entity_view_alter().
|
* 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
|
* Alters node contextual links placeholder id to contain flag metadata, so that
|
||||||
* contextual links cache considers flags granularity.
|
* contextual links cache considers flags granularity.
|
||||||
*/
|
*/
|
||||||
@@ -178,7 +177,7 @@ index 8dd6181..d67cc8a 100644
|
|||||||
- continue;
|
- 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()) {
|
- if (!$flag_type_plugin->showContextualLink()) {
|
||||||
- continue;
|
- continue;
|
||||||
- }
|
- }
|
||||||
@@ -192,44 +191,58 @@ index 8dd6181..d67cc8a 100644
|
|||||||
- }
|
- }
|
||||||
-
|
-
|
||||||
- if (!empty($flag_keys)) {
|
- 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);
|
- $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) {
|
+// function flag_entity_view_alter(&$build, EntityInterface $entity, EntityViewDisplayInterface $display) {
|
||||||
+// $entity_type = $entity->getEntityTypeId();
|
+// $entity_type = $entity->getEntityTypeId();
|
||||||
+// if (isset($build['#contextual_links'][$entity_type])) {
|
+// if (isset($build['#contextual_links'][$entity_type])) {
|
||||||
+// /** @var \Drupal\flag\FlagService $flag_service */
|
+// /** @var \Drupal\flag\FlagService $flag_service */
|
||||||
+// $flag_service = \Drupal::service('flag');
|
+// $flag_service = \Drupal::service('flag');
|
||||||
+//
|
+
|
||||||
+// // Get all possible flags for this entity type.
|
+// // Get all possible flags for this entity type.
|
||||||
+// $flags = $flag_service->getAllFlags($entity_type, $entity->bundle());
|
+// $flags = $flag_service->getAllFlags($entity_type, $entity->bundle());
|
||||||
+//
|
+
|
||||||
+// foreach ($flags as $flag) {
|
+// foreach ($flags as $flag) {
|
||||||
+// $flag_type_plugin = $flag->getFlagTypePlugin();
|
+// $flag_type_plugin = $flag->getFlagTypePlugin();
|
||||||
+//
|
+
|
||||||
+// // Make sure we're dealing with an entity flag type.
|
+// // Make sure we're dealing with an entity flag type.
|
||||||
+// if (!$flag_type_plugin instanceof EntityFlagType) {
|
+// if (!$flag_type_plugin instanceof EntityFlagType) {
|
||||||
+// continue;
|
+// 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()) {
|
+// if (!$flag_type_plugin->showContextualLink()) {
|
||||||
+// continue;
|
+// continue;
|
||||||
+// }
|
+// }
|
||||||
+//
|
+
|
||||||
+// $action = 'flag';
|
+// $action = 'flag';
|
||||||
+// if ($flag->isFlagged($entity)) {
|
+// if ($flag->isFlagged($entity)) {
|
||||||
+// $action = 'unflag';
|
+// $action = 'unflag';
|
||||||
+// }
|
+// }
|
||||||
+//
|
+
|
||||||
+// $flag_keys[] = $flag->id() . '-' . $action;
|
+// $flag_keys[] = $flag->id() . '-' . $action;
|
||||||
+// }
|
+// }
|
||||||
+//
|
+
|
||||||
+// if (!empty($flag_keys)) {
|
+// 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);
|
+// $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);
|
// $node = \Drupal::service('entity.repository')->loadEntityByUuid('node', $uuid);
|
||||||
// $nid = $node->id();
|
// $nid = $node->id();
|
||||||
// call the parent flag function
|
// call the parent flag function
|
||||||
$this->unflag($flag, $id, $flagcollid);
|
$this->unflag($flag, $id, 'default', $flagcollid);
|
||||||
// response
|
// response
|
||||||
$data = [
|
$data = [
|
||||||
'flag' => $flag->toArray(),
|
'flag' => $flag->toArray(),
|
||||||
|
|||||||
Reference in New Issue
Block a user