Account created on 10 July 2013, almost 11 years ago
  • Principal Software Engineer at Red HatΒ 
#

Merge Requests

Recent comments

πŸ‡ΊπŸ‡ΈUnited States firewaller

FYI I was able to override this the core revert forms to enforce draft on new revisions by:

  1. Copying and renaming the "node.revision_revert_confirm" and "node.revision_revert_translation_confirm" routes from core's node.routing.yml to "MY_MODULE.node.revision_revert_confirm" and "MY_MODULE.node.revision_revert_translation_confirm"
  2. Creating a new file to extend the first class from the routes above here: /web/modules/custom/MY_MODULE/src/Form/NodeRevisionRevertForm.php
  3. Creating a new file to extend the second class from the routes above here: /web/modules/custom/MY_MODULE/src/Form/NodeRevisionRevertTranslationForm.php
  4. Overriding the route with the above new classes here: /web/modules/custom/MY_MODULE/src/Routing/RouteSubscriber.php
  5. Clearing caches

NodeRevisionArchiveForm.php:

<?php

namespace Drupal\MY_MODULE\Form;

use Drupal\Core\Form\FormStateInterface;
use Drupal\node\NodeInterface;
use Drupal\node\Form\NodeRevisionRevertForm as NodeRevisionRevertCoreForm;

/**
 * Provides a form for reverting a node revision.
 *
 * @internal
 */
class NodeRevisionRevertForm extends NodeRevisionRevertCoreForm {

  /**
   * Prepares a revision to be reverted.
   *
   * @param \Drupal\node\NodeInterface $revision
   *   The revision to be reverted.
   * @param \Drupal\Core\Form\FormStateInterface $form_state
   *   The current state of the form.
   *
   * @return \Drupal\node\NodeInterface
   *   The prepared revision ready to be stored.
   */
  protected function prepareRevertedRevision(NodeInterface $revision, FormStateInterface $form_state) {
    $revision = $this->enforceModerationState($revision, $form_state);
    return parent::prepareRevertedRevision($revision, $form_state);
  }

  /**
   * Enforce moderation state for a revision.
   *
   * @param \Drupal\node\NodeInterface $revision
   *   The revision to be reverted.
   * @param \Drupal\Core\Form\FormStateInterface $form_state
   *   The current state of the form.
   * @param string $state
   *   The moderation state to enforce.
   *
   * @return \Drupal\node\NodeInterface
   *   The prepared revision ready to be stored.
   */
  public function enforceModerationState(NodeInterface $revision, FormStateInterface $form_state, string $state = 'draft'): NodeInterface {
    if ($revision->hasField('moderation_state')) {
      $revision->set('moderation_state', $state);
    }
    return $revision;
  }

}

NodeRevisionRevertTranslationForm.php:

<?php

namespace Drupal\MY_MODULE\Form;

use Drupal\Core\Form\FormStateInterface;
use Drupal\node\NodeInterface;
use Drupal\node\Form\NodeRevisionRevertTranslationForm as NodeRevisionRevertTranslationCoreForm;

/**
 * Provides a form for reverting a node revision for a single translation.
 *
 * @internal
 */
class NodeRevisionRevertTranslationForm extends NodeRevisionRevertTranslationCoreForm {

  /**
   * {@inheritdoc}
   */
  protected function prepareRevertedRevision(NodeInterface $revision, FormStateInterface $form_state) {
    $revision = $this->enforceModerationState($revision, $form_state);
    return parent::prepareRevertedRevision($revision, $form_state);
  }

  /**
   * Enforce moderation state for a revision.
   *
   * @param \Drupal\node\NodeInterface $revision
   *   The revision to be reverted.
   * @param \Drupal\Core\Form\FormStateInterface $form_state
   *   The current state of the form.
   * @param string $state
   *   The moderation state to enforce.
   *
   * @return \Drupal\node\NodeInterface
   *   The prepared revision ready to be stored.
   */
  public function enforceModerationState(NodeInterface $revision, FormStateInterface $form_state, string $state = 'draft'): NodeInterface {
    if ($revision->hasField('moderation_state')) {
      $revision->set('moderation_state', $state);
    }
    return $revision;
  }

}

RouteSubscriber.php:

<?php

namespace Drupal\MY_MODULE\Routing;

use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection;

/**
 * Route subscriber to subscribe to route event.
 */
class RouteSubscriber extends RouteSubscriberBase {

  /**
   * {@inheritDoc}
   */
  protected function alterRoutes(RouteCollection $collection) {
    // Altering the node revert form.
    if ($route = $collection->get('node.revision_revert_confirm')) {
      $route->setDefault('_form', '\Drupal\MY_MODULE\Form\NodeRevisionRevertForm');
    }

    // Altering the node translation revert form.
    if ($route = $collection->get('node.revision_revert_translation_confirm')) {
      $route->setDefault('_form', '\Drupal\MY_MODULE\Form\NodeRevisionRevertTranslationForm');
    }
  }

}
πŸ‡ΊπŸ‡ΈUnited States firewaller

The patch on #3037259 fixed an issue with infinite redirects because of a trailing question mark (?).

πŸ‡ΊπŸ‡ΈUnited States firewaller

The patch on #3037259 fixed an issue with infinite redirects because of a trailing question mark (?).

πŸ‡ΊπŸ‡ΈUnited States firewaller

#35 fixed an issue with infinite redirects because of a trailing question mark (?).

πŸ‡ΊπŸ‡ΈUnited States firewaller

Patch #13 (tmgmt-reset-finished-job-button-3094355-9.patch) works for us

πŸ‡ΊπŸ‡ΈUnited States firewaller

Patch #2 (3359495-error-when-importing-01.patch) works for us

πŸ‡ΊπŸ‡ΈUnited States firewaller

Patch #18 (tab_issues-3208439-15.patch) works for us

πŸ‡ΊπŸ‡ΈUnited States firewaller

#6 works for me

πŸ‡ΊπŸ‡ΈUnited States firewaller

#12 works for me

πŸ‡ΊπŸ‡ΈUnited States firewaller

#8 works for me

πŸ‡ΊπŸ‡ΈUnited States firewaller

Yeah, #4 doesn't work for me on a fresh migration.

FYI that message is getting logged here: https://git.drupalcode.org/project/webform/-/blob/6.2.x/src/WebformSubmi...

Based on that logic above, the only way to silence these messages in CLI was to disable the "results_disabled" setting in each form temporarily. However, now I'm seeing the error from here: https://git.drupalcode.org/project/webform/-/blob/6.2.x/src/Plugin/Webfo...

That's caused by this logic: https://git.drupalcode.org/project/webform/-/blob/6.2.x/src/Plugin/Webfo...

So I don't think that's a viable approach either.

πŸ‡ΊπŸ‡ΈUnited States firewaller

I think what's happening is if any of the conditions fail then the tag won't show up (i.e. you can't use both a positive node and a term condition). This logic likely needs to be revisited: https://git.drupalcode.org/project/google_tag/-/blob/2.0.x/src/TagContai...

πŸ‡ΊπŸ‡ΈUnited States firewaller

@william.thomas.cox can you post your patch that fixed this?

πŸ‡ΊπŸ‡ΈUnited States firewaller

This was driving me crazy when exporting config! The patch from #2 fixes this issue for me.

πŸ’¬ | Paragraphs | Error 500
πŸ‡ΊπŸ‡ΈUnited States firewaller

+1

πŸ‡ΊπŸ‡ΈUnited States firewaller

Thanks, having that "webform" process mapping helped!

πŸ‡ΊπŸ‡ΈUnited States firewaller

Patch attached for 9.1.0-beta8. This excludes the hook_update to prevent conflicts with future hook updates. Please run drush cset patternkit.settings patternkit_json_editor_token_clear false -y when using this specific patch.

πŸ‡ΊπŸ‡ΈUnited States firewaller

Does it make sense to relocate this change to `\Drupal\Core\Asset\CssCollectionOptimizerLazy::optimizeGroup` similar to the JS approach? https://git.drupalcode.org/project/drupal/-/blob/11.x/core/lib/Drupal/Co...

πŸ‡ΊπŸ‡ΈUnited States firewaller

Thanks for confirming. I have validated that it was an incompatibility with the module_filter module as mentioned previously:

It appears that the module_filter patch mentioned above has been merged into the stable version and simply needed a config change via:
drush config:set module_filter.settings enabled_filters.permissions false -y
I appreciate the support!

πŸ‡ΊπŸ‡ΈUnited States firewaller

After upgrading to Drupal core 10.1, this patch seems to be unnecessary.

As to whether this entire module is obsolete due to the core changes, for the most part yes, however this module does introduce certain permissions that don't seem to be covered by core (i.e. revert block_content BLOCK_TYPE revisions, view block_content BLOCK_TYPE history, and view block_content BLOCK_TYPE revisions).

πŸ‡ΊπŸ‡ΈUnited States firewaller

I refactored the above for D10:

/**
 * Implements hook_entity_presave().
 */
function MY_MODULE_entity_presave(EntityInterface $entity): void {
  // Skip if not file.
  if (!$entity instanceof FileInterface) {
    return;
  }

  // Migrate epsa crop to focal point.
  $fid = $entity->id();
  $migrate_database = Database::getConnection('default', 'migrate');
  $query = $migrate_database->select('epsacrop_files', 'e');
  $query->innerJoin('file_metadata', 'fmw', "fmw.fid = e.fid AND fmw.name = 'width'");
  $query->innerJoin('file_metadata', 'fmh', "fmh.fid = e.fid AND fmh.name = 'height'");
  $query->addField('e', 'coords');
  $query->addField('fmw', 'value', 'width');
  $query->addField('fmh', 'value', 'height');
  $query->condition('e.fid', $fid);
  $query->range(0, 1);
  $results = $query->execute();
  if ($results) {
    /** @var \Drupal\focal_point\FocalPointManagerInterface $focal_point_manager */
    $focal_point_manager = \Drupal::service('focal_point.manager');
    $crop_type = \Drupal::config('focal_point.settings')->get('crop_type');
    $crop = $focal_point_manager->getCropEntity($entity, $crop_type);
    while ($record = $results->fetchAssoc()) {
      $coords = unserialize($record['coords']);
      $coords = Json::decode($coords);
      if (isset($coords[$fid])) {
        // Get first image style.
        $coords = reset($coords[$fid]);
        $focal_point_x = $coords['x'] + round($coords['w'] / 2);
        $focal_point_y = $coords['y'] + round($coords['h'] / 2);
        $width = unserialize($record['width']);
        $height = unserialize($record['height']);
        // Skip if invalid.
        if (
          $focal_point_x > $width ||
          $focal_point_y > $height
        ) {
          continue;
        }
        $relative = $focal_point_manager->absoluteToRelative($focal_point_x, $focal_point_y, $width, $height);
        $x = $relative['x'];
        $y = $relative['y'];
        $focal_point = implode(',', $relative);
        if (
          $focal_point_manager->validateFocalPoint($focal_point) &&
          $width &&
          $height
        ) {
          $focal_point_manager->saveCropEntity($x, $y, $width, $height, $crop);
        }
      }
    }
  }
}
πŸ‡ΊπŸ‡ΈUnited States firewaller

All good, thanks!

πŸ‡ΊπŸ‡ΈUnited States firewaller

Once we upgraded from Drupal 9 to Drupal 10.1 we experienced the same issue with core aggregation (we had to disable the AdvAgg module regarless) and a custom file_public_base_url. Patch #2 fixes the issue for us!

πŸ‡ΊπŸ‡ΈUnited States firewaller

Updated patch for latest 6.0.x (<=6.0.2)

πŸ‡ΊπŸ‡ΈUnited States firewaller

Here's a version of the patch for D10 support against `2.0.0-beta1`

πŸ‡ΊπŸ‡ΈUnited States firewaller

FYI the `.form--inline` class is removed in the D10 Claro theme. I'll submit an updated MR via GitLab.

πŸ‡ΊπŸ‡ΈUnited States firewaller

Patch #2 works well for me

πŸ‡ΊπŸ‡ΈUnited States firewaller

When installing the module I'm seeing this notice for each language:

[notice] Translation file not found: https://ftp.drupal.org/files/translations/all/jsonapi_resources/jsonapi_resources-8.x-1.0-beta5.es.po.
[notice] Checked es translation for jsonapi_resources.
Production build 0.69.0 2024