πŸ‡ΊπŸ‡ΈUnited States @lisagodare@gmail.com

Account created on 25 March 2012, over 12 years ago
  • Senior Software Engineer at NerderyΒ  …
#

Recent comments

πŸ‡ΊπŸ‡ΈUnited States lisagodare@gmail.com

I'm just going to try that again, this time with the missing new files.

πŸ‡ΊπŸ‡ΈUnited States lisagodare@gmail.com

Re-rolled the patch from #86 for 10.3.x - this is just a crutch for now, ultimately the merge request is the better option.

πŸ‡ΊπŸ‡ΈUnited States lisagodare@gmail.com

I believe the intent is to use `hook_autologout_prevent` for that. Specifically, the module does implement that hook, and if the user timeout is set to 0, it is deleting the relevant session variable.

  // If user has no timeout set.
  if (\Drupal::service('autologout.manager')->getUserTimeout() === 0) {
    autologout_check_session_variable();
    return TRUE;
  }
/**
 * Helper function to unset the autologout session variable if present.
 */
function autologout_check_session_variable() {
  $currentRequest = \Drupal::service('request_stack')->getCurrentRequest();
  $session = $currentRequest->getSession()->get('autologout_last');
  if (isset($session)) {
    $currentRequest->getSession()->remove('autologout_last');
  }
}

So in the code you're looking at: `$session` should be null (and PHP will likely convert it to 0 when doing math), `$now` will be some horrifically large number (e.g., 1718311268), and `$diff` will be equal to $now.

A quick fix might be to implement the hook yourself, and if the user timeout is 0, set the session variable to some unreasonably high number, like "$now + $padding + 1". You'll likely want to make sure your hook implementation runs last as well.

/**
 * Implements hook_autologout_prevent().
 */
function mymodule_autologout_prevent() {
  $manager = \Drupal::service('autologout.manager');
  // If user has no timeout set.
  if ($manager->getUserTimeout() === 0) {
    $now = \Drupal::time()->getCurrentTime();
    $padding = \Drupal::config('autologout.settings')->get('padding');
    $currentRequest = \Drupal::service('request_stack')->getCurrentRequest();
    $currentRequest->getSession()->('autologout_last', $now+$padding+1);
    return TRUE;
  }
}
πŸ‡ΊπŸ‡ΈUnited States lisagodare@gmail.com

Thanks to the clue about Lightning Media, I was able to hunt down my issue and fix it.

Specifically, using Media: Image Browser, if the Image field in question allowed more than one reference, I would not be able to select images in the entity browser. @shelane's workaround did work though.

Patch over there fixes it for me:
https://www.drupal.org/project/lightning_media/issues/3392244#comment-15... πŸ› Entity browser enhancements should only be executed once Needs review

πŸ‡ΊπŸ‡ΈUnited States lisagodare@gmail.com

Similar to @jmcintyre, I've noticed this issue on when entity browser is used on an Image field that accepts more than 1 value. When the entity browser is initially loaded, I cannot select an image. Clicking over to "Upload" tab and back to the "Library" tab allows me to select images again. The only difference I could see is that BigPipe is loaded with the initial entity browser load, but not when clicking through the tabs.

Using filters causes it to break again, using a pager does not. This is due to the call to "once", the element returned via Ajax isn't being updated due to having already been applied once before.

I'm testing an updated patch locally, where I've added a call to .ajaxStop() to add the functionality there as well. So far it is working.

πŸ‡ΊπŸ‡ΈUnited States lisagodare@gmail.com

Well that's embarrassing. Thanks for calling it out!

πŸ‡ΊπŸ‡ΈUnited States lisagodare@gmail.com

That setting doesn't help us, as the directly related entities aren't the same type/bundle, and this common scenario for us:

  • Have a Node related to multiple Storage entities.
  • Have those Storage entities related to multiple Nodes, of the same or different bundle, as they are reusable components.
  • Have a need to trigger Gatsby builds when Storage entities are saved, as content editors will also edit Storage entities directly (not just through Node edit forms).
  • Use Inline Entity Forms on the node bundle, so that content editors can add/edit Storage entities directly on the Node edit form.

This means when a Storage is edited on the Node form, and the node is saved:

  1. The Node save triggers Gatsby, which recurses through all the relationships of the Node.
  2. Inline Entity Forms triggers a save on the edited Storage entity, which triggers Gatsby, recursing through all the relationships of that Storage entity.
  3. With the option Do not store data for entity types that are self referenced checked:
    • #1 does not recurse through Nodes of the same bundle. It does recurse through other relationships of the related Storage entities, which may include Nodes of a different bundle - and all of their relationships.
    • #2 is a Storage entity that trigged Gatsby, so it gathers all of the relationships of that Storage entity - which will include the original Node, and not exclude any other Nodes of that bundle, so there may be many. And each of those nodes may be related to 0 or more additional Storage entities, of a variety of bundles. Which may also be related to other Nodes, of the same bundle as the original.

We do not need the recursive relationships in this scenario. If we do not recurse through them, the Node that was edited will have one level of relationship, which will include the Storage that was edited. The Storage that was edited and saved at the same time will have one level of relationship, which will include all other Nodes that reference this Storage. That's all we need updated in the fastbuild, and does not cause memory errors.

πŸ‡ΊπŸ‡ΈUnited States lisagodare@gmail.com

This patch appears to work great for our needs.

We don't want to use Entity Reference Revisions fields, because we don't want to associate a specific revision of a related entity on the relating entity. This is because multiple different entities may relate to it, and we don't want them each showing a different revision. They should all show the same revision - either the default revision, if published, on the 'live' build; or the latest revision, published or not, on the 'preview' build.

πŸ‡ΊπŸ‡ΈUnited States lisagodare@gmail.com

Re-roll to work with patch in https://www.drupal.org/project/gatsby/issues/3356434 πŸ› Large number of log entries leads to memory/timeout issues Fixed

πŸ‡ΊπŸ‡ΈUnited States lisagodare@gmail.com

First pass at a patch to add the config option

πŸ‡ΊπŸ‡ΈUnited States lisagodare@gmail.com

I've added these patches to my project, and after doing so, the "preview" is no longer triggered for incremental builds on inserting content, if the content is created as a draft/unpublished. I can see in `gatsby_entity_insert` that was removed in this refactor.

I've got a small patch here that adds it back in. Preview does correctly get triggered on updates, and receives draft content on updates, so it should also be triggered on insert of draft content.

πŸ‡ΊπŸ‡ΈUnited States lisagodare@gmail.com

Sure thing!
It's sort of complex, but in the end I'm using tokens + metatag + pivot (multivalue in metatag), and needed to not use the default comma as separator, because that breaks on text that has commas in it.
Using the patch in this issue for a custom delimiter in Metatag, which I have set to `||`:
https://www.drupal.org/node/3067803 β†’
And using patch in #28, my field token looks something like:
[node:multivalued_entity_reference_field:array:entity:field_text:join:||]

However, this resulted in always using a comma for the separator, until the changes I made in #30.

πŸ‡ΊπŸ‡ΈUnited States lisagodare@gmail.com

I also needed the ability to customize the join separator, but #28 didn't work for me. I modified it just a little bit.

πŸ‡ΊπŸ‡ΈUnited States lisagodare@gmail.com

Patch attached; the patch also includes some code style fixes.

πŸ‡ΊπŸ‡ΈUnited States lisagodare@gmail.com

With the patch in the parent issue, I've done the following. It's not necessary to use the autocreate bundle feature, but is necessary to use the views_with_autocreate reference method.

/**
 * Implements function hook_field_widget_complete_form_alter().
 */
function MY_MODULE_field_widget_complete_form_alter(&$field_widget_complete_form, FormStateInterface $form_state, $context) {
  if (isset($field_widget_complete_form['widget']['#ief_root'])) {
    $ief_id = $field_widget_complete_form['widget']['#ief_id'];
    $storage = $form_state->getStorage();

    if (isset($storage['inline_entity_form'][$ief_id]['instance'])) {
      $field_instance = $storage['inline_entity_form'][$ief_id]['instance'];
      $settings = $field_instance->getSettings();

      if (isset($settings['handler']) && in_array($settings['handler'], [
        'views',
        'views_with_autocreate',
      ])) {
        $storage = \Drupal::entityTypeManager()
          ->getStorage('view')
          ->load($settings['handler_settings']['view']['view_name']);

        /** @var \Drupal\views\ViewExecutable $view */
        $view = $storage->getExecutable();
        $view->setDisplay($settings['handler_settings']['view']['display_name']);
        $filters = $view->display_handler->getOption('filters');
        $type_filter = ['value' => [], 'entity_type' => 'node'];
        if (isset($filters['type'])) {
          $type_filter = array_merge($type_filter, $filters['type']);
        }
        $bundles = $type_filter['value'];
        $bundle_info = \Drupal::service('entity_type.bundle.info')
          ->getBundleInfo($type_filter['entity_type']);
        foreach ($bundles as &$bundle) {
          if (isset($bundle_info[$bundle])) {
            $bundle = $bundle_info[$bundle]['label'];
          }
        }

        $field_widget_complete_form['widget']['actions']['bundle']['#options'] = $bundles;
      }
    }
  }
}
Production build 0.71.5 2024