Sean Reiser

Hi I'm Seán Reiser, this is my Personal Blog

“A person is what they think about all day long”
~Ralph Waldo Emerson

Using ChatGPT to Audit and Migrate Drupal Modules

 

This was fun! I just inherited a new Drupal 9 site.  Whenever I get a new site I do a code review of all the custom modules for security purposes.  Additionally,  since I’ll eventually need to upgrade the site to Drupal 10, I figured I’d assess the code for D10 readiness.  There were 16 custom modules.

As an experiment I fired up ChatGPT and used the following prompt:

Review the following Drupal Module to ensure it followings best practices, is secure, efficient and is compatible with Drupal 9 and 10.

CharGPT found 90% of the issues I would’ve flagged.  The items it didn’t find that I didn’t find were stylistic, not things that I’d consider crucial or security related.  Then I entered this simple prompt:

Please implement these suggestions.

CharGPT updated the code.  I received the code, ran it in stage and will implement it over the weekend in my next release window.

I find using ChatGPT instead of Drupal Rector for removing deprecations interesting because I can ask it questions and do an automated code audit,  This probably saved me 80% of the time and is less prone to error and typos.

Happy Drupal Security Update Day

 

 

Attending the Backdrop Live virtual conference today and tomorrow

Backdrop is a fork of Drupal 7 with a number of the features built-in to D8 and 9, put retaining D7's framework. This gives an option for sites running a Drupal 7 that don't have the budget what time do the large migration to Drupal 9. Generally speaking modules and themes port over quickly and the data model is pretty much the same. Functionality such as configuration management layouts, and mobile first HTML elements are available straight out of the box. Oh no I'm not a huge fan of forks in general, this is a strong option for folks who are concerned about the end-of-life of Drupal seven but aren't in.a  position to move to Drupal 9.

Image
Laptop w/ Stickers

Configuring Drupal 9 to use the SMTP module with iCloud+'s custom domains

When Google announced it was going to shut down its legacy free email for domains, I decided to  use iCloud+ to manage the mail from seanreiser.com since I was paying for it anyway. I set it up but it's been working fine as a mail server. I had been running sendmail off my web server to send mail from my site when I needed to. In order to avoid spam folders,I decided to move to using SMTP, which meant I needed to authenticate to Apple's SMTP Server.

At first, I had a problem authenticating, until I realized that your email addresses at your custom domain is an aliase, so you need to authenticate with your iCloud account and an App-Specific Password. I'm using Drupal 9;s SMTP Authentication Support  Module.  Here are the parameters I used on /admin/config/system/smtp:

SMTP server settings
  • Enable TLS encryption automatically - On
  • Turn on the SMTP keep alive feature - Off
SMTP Authentication
  • App-Specific Password.
E-mail options
  • Allow to send e-mails formatted as HTML - up to your use case

Everything else leave as is. I'd do a test with debugging turned on and then turn it off. I also used the mail system module to redirect all mail to SMTP.

Good luck, Share and  enjoy!

 

 

Image
Laptop w/ Stickers

Somehow over the last couple weeks, ace.js broke on this site, so a number of my coat samples look broken. Lunchtime learning has been replaced today by fixing ace.js. Back to normal tomorrow.  I want to switch to CKeditor's code snippet module, anyway. This is as good a reason as any

Image
Laptop w/ Stickers

 Finally made some progress on the feed system. Got everything installed in dev, added a few feeds and I've got stuff importing.

To support title-less feeds, in the mapping for the feed I just put a constant on the title, and then in hook_entity_presave, I'm testing to see if the feed item title is populated and if not I grab the first 200 characters of the feed item description.  

Next I need to build some a View to support the River of News style interface.

As I remembered, the Aggregator Module does not support feed items without titles, so I suspect that the Feeds Module will be the way to go.  I'll spend some time today thinking about that.

 Although I haven't put keyboard to code editor yet, I spent a lot of time yesterday thinking about the new feed processing system for my personal feed reader. Back when I built the original feed system and Drupal 7,  feed items from the aggregator module weren't entities.  Now that they are entities in Drupal 9, they are fieldable, so I can do far more with the items than I could a few years ago, so maybe I can get away with using the aggregator module instead of the feeds module. However, as memory serves. the aggregator module did not handle title-less items very well. That might not take a big deal to some but some of my fields on my feeds have title-less posts. If you can't picture a title-less post imagine a tweet or better yet this post which has no title it is just a body. I'll have to do some testing to see how well it can be handled.

Also I'm giving a lot of thought to whether I want to add the feed reader to this site or if I wanted to leave it on its own Drupal instance. Having it all in one site will make support and maintenance easier at the cost of some performance because I have a number of modules turned on to support the feeds Bajwa that I don't need today. Another thing to consider, if I ever decided to go back to hosting the site at Pantheon or some other cloud platform, I'll have increased fees to host it.

Lots of little things to consider.

I find mental blocks to be interesting.  I often use lando on top of docker  to do local web development.  Here's the problem, I'm more a Babylon 5 fan than a Star Wars fan (no disrespect to SW or its super fans) so unless I'm really thinking. I'll say "Londo" instead of "Lando".  I feel that in every interview I say at least once "Londo, I mean Lando" and hang a lantern on it by making a B5 vs SW reference.  It's always a little awkward and I wonder what interviewers think.  I think I need an hypnotist to get inside my head and fix it.

Image
Shrug