CAPTCHA
Image CAPTCHA
Enter the characters shown in the image.
This question is for testing whether or not you are human.
  • Create new account
  • Reset your password

User account menu

Home
The Hyperlogos
Read Everything

Main navigation

  • Home
  • My Resumé
  • blog
  • Howtos
  • Pages
  • Contact
  • Search

Hyperlogos.org moves to D9

Breadcrumb

  • Home
  • User Blogs
  • User Blog
  • Hyperlogos.org moves to D9
By drink | Thu November 10, 2022

...as soon as I can get hosting... because my host is still stuck on PHP 7.4. This means that I'm still stuck with D7. But this blog is about converting my site from D7 to D9. I was able to preserve everything, it seems, down to text formats — but all of them were refusing to display because they had references to missing filters, so it made it look like none of my content was present.

Speaking of missing filters, many Drupal functions now refuse to run in an eval(), so I'm having to finally figure out how to produce modules to do some things that I've been doing with PHP snippets. The current (and I think only major) issue is image support, as there is no longer an img_assist module. I put multiple PHP versions with FastCGI on my system, so I currently have both the old and new sites running here, and I have hopes of brewing a solution.

Because I used to use the amazon module, I had some bad references to clean up. I had some odd errors like these:

[error]  A non-existent config entity name returned by FieldStorageConfigInterface::getBundles(): entity type: comment, bundle: comment_node_amazon, field name: comment_body  
[error]  A non-existent config entity name returned by FieldStorageConfigInterface::getBundles(): entity type: comment, bundle: comment_node_amazon_node, field name: comment_body  
[error]  A non-existent config entity name returned by FieldStorageConfigInterface::getBundles(): entity type: node, bundle: amazon, field name: body 

Long story short, I found a solution to the entity problem on the Drupal site.

Here's what I used to use to display img_assist links with, using customfilter module and the PHP option:

Match: /\[img_assist\|(.+?)]/
$elements = explode('|', $matches[1]);

$result = '(filter error or malformed img_assist tag)';

foreach ($elements as $element) {
  $parts = explode('=', $element);
  if ( $parts[1] != '' ) {
    $values[$parts[0]] = $parts[1];
  }
}

if ( $values[nid] ) {
  $mynode = node_load($values[nid]);
  if (!$mynode) {
    $result = "(cannot load image node)";
  } else {
    if ($mynode->node_image[$mynode->language][0]['uri']) {
      $path = $mynode->node_image[$mynode->language][0]['uri'];
    } else {
      $path = $mynode->node_image['und'][0]['uri'];
    }

    if ( $values[height] && $values[width] ) {
      $result = theme('image_style', array('style_name' => 'large', 'path' => $path, 'getsize' => FALSE, 'alt' => $mynode->title, 'attributes' => array('class' => 'img_assist', 'width' => $values[width], 'height' => $values[height])));
    } else {
      $result = theme('image_style', array('style_name' => 'large', 'path' => $path, 'getsize' => TRUE, 'alt' => $mynode->title, 'attributes' => array('class' => 'img_assist')));
    }
  }
  if ( $values[link] == 'node' ) {
    $result = l($result, 'node/'.$values[nid],array('html' => TRUE));
  }
}

return $result;

I also have the nigh-identical following for D7 image filter links, I'm not sure why I felt a need to replace the actual D7 module, but I clearly did. It doesn't have a D8/D9 version anyway.

Match: /\+) (.+?)]/
$nid = $matches[1];
$elements = explode(' ', $matches[2]);

$result = '(filter error or malformed image tag)';

foreach ($elements as $element) {
  $parts = explode('=', $element);
  if ( $parts[1] != '' ) {
    $values[$parts[0]] = $parts[1];
  }
}

if ( $nid ) {
  $mynode = node_load($nid);
  if (!$mynode) {
    $result = "(cannot load image node)";
  } else {
    if ($mynode->node_image[$mynode->language][0]['uri']) {
      $path = $mynode->node_image[$mynode->language][0]['uri'];
    } else {
      $path = $mynode->node_image['und'][0]['uri'];
    }

    if ( $values[height] && $values[width] ) {
      $result = theme('image_style', array('style_name' => 'large', 'path' => $path, 'getsize' => FALSE, 'alt' => $mynode->title, 'attributes' => array('class' => 'img_assist', 'width' => $values[width], 'height' => $values[height])));
    } else {
      $result = theme('image_style', array('style_name' => 'large', 'path' => $path, 'getsize' => TRUE, 'alt' => $mynode->title, 'attributes' => array('class' => 'img_assist'))); 
    }
  }
}

return $result;

Since PHP in customfilter is no longer a thing, I need to come up with a module that produces a real filter that does the same job. It still does some neat stuff, but not this any longer. I might try running the image filter D7 module through the module converter, though, just to see what happens. My image nodes made the trip, at least the ones I've checked on. Ideally, the module then goes on to convert both types of tag to something more modern.

Some content is leaving the site. If you miss it, know that it's still in the Internet Archive.

hyperlogos
Drupal

drink

2 years 10 months ago

Permalink

After spending some time…

After spending some time trying to figure out how to make my own drush command module that would convert the image fields, I found image_field_to_media. I was about 90% there, oh well. This module could use more configuration (like letting you transfer into  a field you created manually, instead of always creating a new media reference field) but it does do the job. Now I just need to turn my image and img_assist tags into media embed tags, I will try scanner module. But first, I shall dump the db again...

  • Log in or register to post comments

drink

2 years 10 months ago

Permalink

Scanner module is broken and…

Scanner module is broken and not receiving a lot of attention. There are a couple of modules which are candidates for light modification: mostly convert_media_tags_to_markup but there is also convert_entity_media_embed to look at. A quick tweak might make one of these modules into a viable tool.

  • Log in or register to post comments

drink

2 years 10 months ago

Permalink

Attached is a media_field…

Attached is a media_field_formatters formatter to display media entities as their UUID. Name it MediaUUID.php and put it into media_field_formatters/src/Plugin/Field/FieldFormatter.

  • Log in or register to post comments
  • Log in or register to post comments

Footer menu

  • Contact
Powered by Drupal

Copyright © 2025 Martin Espinoza - All rights reserved