Skip to main content

Drupal

Getting Started with Drupal QueueWorker and Cron

Submitted by daniel on

In Drupal there are the QueueWorker  and QueueWorkerManager classes that are helpful in managing a queue. One benefit of managing tasks is a queue is they offer a way of managing tasks or jobs in an orderly way. Think First in First Out. 

The way the QueueWorker in Drupal works is tied in with cron.

Lets have a look at the run function in web/core/lib/Drupal/Core/Cron.php

Migrate Process Text to Paragraphs

Submitted by daniel on

Migrate Process Text to Paragraphs provides a Migrate process plugin to allow processing of string with new lines into string with paragraphs (similar to nl2br()).

Example

process:
  'body/value':
    -
      plugin: get
      source: text
    -
      plugin: migrate_process_text_to_paragraphs
      delimiter: \n // default \n\n

https://www.drupal.org/project/migrate_process_text_to_paragraphs

Date Created

CSS Reset

Submitted by daniel on

This is a simple module that adds a CSS Reset at a module level. One benefit of this appoach is that the 'reset' can be loaded before other modules that include some css etc. This means that the 'reset' should only normalise the user agent's styles and not styles that have been defined in other core and contributed modules that may be loaded by Drupal before the theme layer.

https://www.drupal.org/sandbox/2dareis2do/2275019

Date Created

File Managed Alter

Submitted by daniel on

This is simple utility module that enables you to increase the length of the 'uri' field used by the 'file_managed' table which is in turn used by Drupal's 'file' entity. This module increases the maximum length from varchar(255) to varchar(2048).

Background

By default, in Drupal there is a restriction of 255 chars on the varchar size or length of the uri field in the file_managed table. In some circumstances this is not sufficient and may result in an exception.

e.g.

Date Created

Search API Views Ajax

Submitted by daniel on

Search API Views Ajax is a simple Drupal module that faciliates updating a search view asynchronously when using an AJAX enabled view with the Search API module.

In particular it:

Date Created

Migrate Process Extract Regex

Submitted by daniel on

This module provides a Migrate process plugin to enable you to parse and extract a $needle (string) from a $haystack (string). This will either return $match[1] or the original $haystack if no match is found.

Use Case

This migrate_process_extract_regex module is useful where developers are handling remote images with the remote_steam_wrapper module. Sometimes remote media assets (pictures etc.) do not contain a valid query string and will fail to import.

e.g.

This is handled fine:

Date Created

Migrate Process Remote Image Check

Submitted by daniel on

This module provides a Migrate process plugin to enable you to check whether a migrated remote image url/string is in fact a valid address for a media asset such as an image. It does this by requesting each image and see if it returns a valid response.

If this fails, it will attempt to remove any query string to that has been appended to an image to see if removing this helps to generate a successful response.

If the response is not ok, it will fallback to using an empty string so as to avoid any exceptions when trying to migrate the remote image asset.

Date Created