44 lines
1.7 KiB
PHP
44 lines
1.7 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @file
|
|
* Contains materio_flag.module.
|
|
*/
|
|
|
|
/**
|
|
* Implements hook_module_implements_alter().
|
|
*
|
|
* flag_lists creates one Flag *config* entity per user list (1700+ on this
|
|
* site). Several flag.module hooks call FlagService::getAllFlags() and loop over
|
|
* every flag for each entity view and each entity form, running an isFlagged()
|
|
* query and an access check per flag. This makes node view and, above all, node
|
|
* edit (flag_form_alter) time out.
|
|
*
|
|
* All these flags are configured with show_in_links / show_as_field /
|
|
* show_on_form / show_contextual_link = FALSE and are only consumed through
|
|
* materio_flag (controllers/routes) and the decoupled Vue app, so flag's native
|
|
* entity integration produces nothing visible here. We therefore remove these
|
|
* expensive implementations instead of patching flag.module.
|
|
*/
|
|
function materio_flag_module_implements_alter(&$implementations, $hook) {
|
|
$hooks_to_remove = [
|
|
// flag_form_alter(): loops all flags on every content entity form
|
|
// (node edit) -> main cause of the 504 gateway timeout.
|
|
'form_alter',
|
|
// flag_entity_view(): builds a flag field render per flag on entity view.
|
|
'entity_view',
|
|
// flag_entity_build_defaults_alter(): sets max-age=0 per contextual flag.
|
|
'entity_build_defaults_alter',
|
|
// flag_entity_view_alter(): adds flag metadata to contextual links.
|
|
'entity_view_alter',
|
|
// flag_entity_extra_field_info(): declares a pseudo-field per flag.
|
|
'entity_extra_field_info',
|
|
// flag_entity_operation(): adds flag operation links per flag.
|
|
'entity_operation',
|
|
];
|
|
|
|
if (in_array($hook, $hooks_to_remove, TRUE) && isset($implementations['flag'])) {
|
|
unset($implementations['flag']);
|
|
}
|
|
}
|