πŸ‡΅πŸ‡±Poland @krystianbuczak

Account created on 5 December 2008, about 16 years ago
  • Software Engineer at VMLY&RΒ 
#

Recent comments

πŸ‡΅πŸ‡±Poland krystianbuczak

Those CSS rules have been added in the commit https://git.drupalcode.org/project/mercury_editor/-/commit/448d0b632a2ff... as a kind of override of Claro claro/media_library.theme library related somehow with gin_toolbar module. In my opinion Mercury Editor should avoid such dependency assumptions. I would recommend simply remove the override, if this is something crucial, maybe try to style it conditionally in the context of enabled gin_toolbar module or require dependency to gin_toolbar module in mercury_editor.info file.

Temporary workaround is to stop loading the CSS file by adding below override to *.info file in own, custom admin theme:

libraries-override:
  mercury_editor/claro.media_library.theme:
    css:
      theme:
        build/css/overrides/claro/media-library.css: false
πŸ‡΅πŸ‡±Poland krystianbuczak

Hi @siva01,

even with passed $window argument the code seemed to not work properly. I tried to limit 10 requests within 1 minute window and Redis didn't expire my event properly. I have just added my proposal of the issue:

In register() method

BEFORE:

$this->client->zAdd($key, $_SERVER['REQUEST_TIME'] + $window, microtime(TRUE));
$this->client->expire($key, $_SERVER['REQUEST_TIME'] + $window);

AFTER

$this->client->zAdd($key, microtime(TRUE), microtime(TRUE));
$this->client->expire($key, $window);

In isAllowed() method

BEFORE

$number = $this->client->zCount($key, $_SERVER['REQUEST_TIME'], 'inf');
return ($number < $threshold);

AFTER

$number = $this->client->zCount($key, microtime(TRUE) - $window, 'inf');
return $number < $threshold;

+ redundant comments removal.

microtime() is used for consistency.

πŸ‡΅πŸ‡±Poland krystianbuczak

krystianbuczak β†’ made their first commit to this issue’s fork.

πŸ‡΅πŸ‡±Poland krystianbuczak

Version 2 of the module provided the setRevisionable(TRUE) flag in a hook_entity_base_field_info(). In documentation block of this hook we can read:

Field (storage) definitions returned by this hook must run through the regular field storage life-cycle operations: they need to be properly installed, updated, and uninstalled. This would typically be done through the Entity Update API provided by the entity definition update manager.

Looks like no proper database updates are executed and field storage must be updated another way.

An example post update action for Menu link content can be found here: https://api.drupal.org/api/drupal/core%21modules%21menu_link_content%21m...

Similar to the linked function appropriate update script can be placed in hook_update_n() and minimal version that should work could be like:

function translatable_menu_link_uri_update_9001(&$sandbox) {
  try {
    $definition_update_manager = \Drupal::entityDefinitionUpdateManager();
    $last_installed_schema_repository = \Drupal::service('entity.last_installed_schema.repository');
    $entity_type = $definition_update_manager
      ->getEntityType('menu_link_content');
    $field_storage_definitions = $last_installed_schema_repository
      ->getLastInstalledFieldStorageDefinitions('menu_link_content');
    $field_storage_definitions['link_override']->setRevisionable(TRUE);
    $definition_update_manager
      ->updateFieldableEntityType($entity_type, $field_storage_definitions, $sandbox);
  }
  catch (Throwable $e) {
    watchdog_exception('translatable_menu_link_uri', $e);
  }
}

This way API should also take care of proper table columns what can be verified by the command describe menu_link_content_field_revision;:
+-------------------------------+------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------------------------+------------------+------+-----+---------+-------+
...
| link_override__uri | varchar(2048) | YES | MUL | NULL | |
| link_override__title | varchar(255) | YES | | NULL | |
| link_override__options | longblob | YES | | NULL | |
+-------------------------------+------------------+------+-----+---------+-------+

Production build 0.71.5 2024