Sweden
Account created on 21 November 2005, about 19 years ago
  • Drupal/Web Developer at FrontkomΒ  …
#

Recent comments

πŸ‡ΈπŸ‡ͺSweden thomjjames Sweden

Hi,

Also experiencing this on the views bulk action only. I checked the bibcite_keyword database table and from what I can tell it seems the "keyword" field doesn't exist which is why the query fails when it's looking for the "keyword" field. From looking at the database query it looks like it should point to "id" instead.

It seems like the field_name is passed from the route definition in modules/bibcite_entity/bibcite_entity.routing.yml:

entity.bibcite_keyword.bibcite_merge_multiple_form:
  path: '/admin/content/bibcite/keyword/merge'
  defaults:
    _form: 'Drupal\bibcite_entity\Form\MergeMultipleForm'
    entity_type_id: 'bibcite_keyword'
    field_name: 'keyword'
  requirements:
    _permission: 'administer bibcite_keyword'

Patch attached against 3.0.x branch or this routeSubscriber seems to fix it too:

<?php

namespace Drupal\MODULE\Routing;

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

class MODULERouteSubscriber extends RouteSubscriberBase {

  public function alterRoutes(RouteCollection $collection) {
    if ($route = $collection->get('entity.bibcite_keyword.bibcite_merge_multiple_form')) {
      // Change the default 'field_name' to 'id'.
      $route->setDefault('field_name', 'id');
    }
  }

}

Cheers
Tom

πŸ‡ΈπŸ‡ͺSweden thomjjames Sweden

Hello again,

Ok turned out a pretty simple fix :)

The patches in the next-drupal docs (https://next-drupal.org/learn/quick-start/apply-patches) stopped applying so I assumed they were fixed and removed both, turns out only the subrequest patch is merged ( https://www.drupal.org/project/subrequests/issues/3049395 πŸ› Page Cache causes different subrequests to return the same responses Fixed ) not the decoupled router patch ( https://www.drupal.org/project/decoupled_router/issues/3111456 πŸ› Unable to resolve path on node in other language than default Needs work ). Updated to the patch in https://www.drupal.org/project/decoupled_router/issues/3111456#comment-1... πŸ› Unable to resolve path on node in other language than default Needs work and everything seems to be working again.

So you need this in your composer.json

"patches": {
  "drupal/decoupled_router": {
     "Unable to resolve path on node in other language than default": "https://www.drupal.org/files/issues/2024-08-05/decouple_router-3111456-resolve-language-issue-63--get-translation-re-rolled-and-good-redirect.patch"
  }
}

Running:
Drupal core 10.3.5
Subrequests 3.0.12 (if that matters)
Next.js 1.6.3
Decoupled Router 2.0.5

Hope that helps
Tom

πŸ‡ΈπŸ‡ͺSweden thomjjames Sweden

Hi,

Also getting this during a Drupal 9 -> 10 upgrade process. I tried the patch but I still get 404s on the frontend and these log errors:

ArgumentCountError: Too few arguments to function Drupal\decoupled_router\EventSubscriber\RouterPathTranslatorSubscriber::__construct(), 6 passed in /var/www/html/web/core/lib/Drupal/Component/DependencyInjection/Container.php on line 261 and exactly 8 expected in Drupal\decoupled_router\EventSubscriber\RouterPathTranslatorSubscriber->__construct() (line 92 of /var/www/html/web/modules/contrib/decoupled_router/src/EventSubscriber/RouterPathTranslatorSubscriber.php).

The original Error: Call to a member function isMultilingual() is gone however :)

I'm using next-drupal as well so will check the issue queue there too, not had much time to look into this yet.

Thanks
Tom

πŸ‡ΈπŸ‡ͺSweden thomjjames Sweden

Hi,

Needed to solve this for a wider deployment so resaving wasn't really an option, this hook_update seems to work & remove the warning. It doesn't respect any previous settings but i'm not so up to speed on the _allowed_image_styles config ie. is it a new setting or an old one:

use Drupal\image\Entity\ImageStyle; // at top of file

function MODULE_update_VERSION() {
  // Step 1: Load all image styles into an array.
  $image_styles = ImageStyle::loadMultiple();
  $image_styles_array = [];
  foreach ($image_styles as $style_name => $style) {
    $image_styles_array[$style_name] = $style->label();
  }
  $image_styles_array['full'] = 'Original';

  // Step 2: Load the Gutenberg settings configuration.
  $config = \Drupal::service('config.factory')->getEditable('gutenberg.settings');

  // Step 3: Load all content types.
  $content_types = \Drupal::entityTypeManager()->getStorage('node_type')->loadMultiple();

  // Step 4: Iterate through each content type and check configuration.
  foreach ($content_types as $content_type_id => $content_type) {
    $config_key = $content_type_id . '_allowed_image_styles';
    $allowed_image_styles = $config->get($config_key);
    
    $config->set($config_key, $image_styles_array);
  }

  // Finally, save the configuration.
  $config->save();
}

Hope it helps others
Tom

πŸ‡ΈπŸ‡ͺSweden thomjjames Sweden

Also ran into this, as outlined in #8 I just had to scan my config replacing instances of node_type for entity_bundle:node which were all related to pathauto as well, reimported the config & problem solved. I guess doing a config export after upgrading would have the same effect.

πŸ‡ΈπŸ‡ͺSweden thomjjames Sweden

Hi,

Needed this on a personal project so custom coded it very roughly/quickly. It's a bit rough coding standards-wise & mashed into a bigger custom module but here's some code snippets that are hopefully useful for someone else (a near clone of the feeds HTTPFetcher fetcher):

/src/Feeds/Fetcher/Form/HttpTokensFetcherFeedForm.php:

<?php

namespace Drupal\MODULE_NAME\Feeds\Fetcher\Form;

use Drupal\Core\Form\FormStateInterface;
use Drupal\feeds\FeedInterface;
use Drupal\feeds\Feeds\Fetcher\Form\HttpFetcherFeedForm;

/**
 * Provides a form on the feed edit page for the HttpFetcher.
 */
class HttpTokensFetcherFeedForm extends HttpFetcherFeedForm {

  /**
   * {@inheritdoc}
   */
  public function buildConfigurationForm(array $form, FormStateInterface $form_state, FeedInterface $feed = NULL) {
    parent::buildConfigurationForm($form, $form_state, $feed);

    $form['source'] = [
      '#title' => $this->t('Feed URL'),
      '#type' => 'url',
      '#default_value' => rawurldecode($feed->getSource()), // maintains token in source without encoding
      '#maxlength' => 2048,
      '#required' => TRUE,
    ];

    // Global tokens
    $form['tokens'] = [
      '#theme' => 'token_tree_link',
      '#token_types' => [
        'global',
      ],
    ];   

    return $form;
  }
}


/src/Feeds/Fetcher/HttpTokensFetcher.php:

<?php

namespace Drupal\MODULE_NAME\Feeds\Fetcher;


use Drupal\feeds\Exception\EmptyFeedException;
use Drupal\feeds\Feeds\Fetcher\HttpFetcher;
use Drupal\feeds\Result\HttpFetcherResult;
use Drupal\feeds\StateInterface;
use Drupal\feeds\Utility\Feed;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\RequestOptions;
use Symfony\Component\HttpFoundation\Response;
use Drupal\feeds\FeedInterface;

/**
 * Defines an HTTP fetcher.
 *
 * @FeedsFetcher(
 *   id = "http_tokens_fetcher",
 *   title = @Translation("Download URL with tokens"),
 *   description = @Translation("Downloads data from a URL using Drupal's HTTP request handler with tokens."),
 *   form = {
 *     "configuration" = "Drupal\feeds\Feeds\Fetcher\Form\HttpFetcherForm",
 *     "feed" = "Drupal\MODULE_NAME\Feeds\Fetcher\Form\HttpTokensFetcherFeedForm"
 *   }
 * )
 */
class HttpTokensFetcher extends HTTPFetcher {

  /**
   * {@inheritdoc}
   */
  public function fetch(FeedInterface $feed, StateInterface $state) {
    $sink = $this->fileSystem->tempnam('temporary://', 'feeds_http_fetcher');
    $sink = $this->fileSystem->realpath($sink);

    $source_url_encoded = rawurldecode($feed->getSource()); // @todo - Drupal way for this?

    // Global tokens
    $token_service = \Drupal::token(); // @todo - inject this
    $source_url = $token_service->replace($source_url_encoded);

    // Get cache key if caching is enabled.
    $cache_key = $this->useCache() ? $this->getCacheKey($feed) : FALSE;

    $response = $this->get($source_url, $sink, $cache_key);
    // @todo Handle redirects.
    // @codingStandardsIgnoreStart
    // $feed->setSource($response->getEffectiveUrl());
    // @codingStandardsIgnoreEnd

    // 304, nothing to see here.
    if ($response->getStatusCode() == Response::HTTP_NOT_MODIFIED) {
      $state->setMessage($this->t('The feed has not been updated.'));
      throw new EmptyFeedException();
    }

    return new HttpFetcherResult($sink, $response->getHeaders());
  }
}

Cheers
Tom

πŸ‡ΈπŸ‡ͺSweden thomjjames Sweden

Hi,

I needed something similar for this, importing sports matches so wanted to set a match "status" field to "result" when the item was no longer available in the live feed.

You have to create a new non-configurable (no options) action for it to show up, take a look at core/lib/Drupal/Core/Action/Plugin/Action/SaveAction.php as an example. In the execute method you'd need to set your boolean field value something like:

  /**
   * {@inheritdoc}
   */
  public function execute($entity = NULL) {
    $entity
      ->set('field_match_status', 'result')
      ->setChangedTime($this->time->getRequestTime())
      ->save();
  }

Hope that helps
Tom

Production build 0.71.5 2024