I'm blogging about Emacs, Drupal, php and exciting subjects

· Lars Nielsen

A Presave Hook's isNew() Check Is the Exact Reason a Scheduled Publish Isn't Blocked

This site's automated publishing pipeline runs under a scoped account, api_publisher, that has no permission to touch a node's status field. That's deliberate: a hook_node_presave() in this site's custom module forces any new node owned by that role unpublished, no matter what the content type's default says or what the API client asked for:

Read article A Presave Hook's isNew() Check Is the Exact Reason a Scheduled Publish Isn't Blocked
· Lars Nielsen

I Installed drupal/redirect for Four URLs. It Redirected Every Node Path on the Site.

I had exactly four URLs I wanted redirected. Two articles had accidentally been published twice in July under different titles — a mixup during the early days of the JSON:API publishing pipeline — and once I'd settled on which copy of each to keep, the other needed to 301 somewhere instead of just disappearing. Four source paths, four targets, done.

Read article I Installed drupal/redirect for Four URLs. It Redirected Every Node Path on the Site.
· Lars Nielsen

The JSON:API Route That 403s With No Reason String

There's a specific kind of unhelpful a 403 can be. Try to set a field you don't have permission for through Drupal's JSON:API and you get a real, actionable message back — something like "The current user is not allowed to POST the selected field (status). The 'administer nodes' permission is required." That's a 403 that tells you exactly what to go fix.

Read article The JSON:API Route That 403s With No Reason String
· Lars Nielsen

The Allow-Plugins Security Prompt Is Composer's Best Feature and Its Most Annoying One

Somewhere in the middle of upgrading this site from Drupal 10 to 11, composer require drupal/core-recommended:^11 stopped and refused to install anything at all, not because of a version conflict this time, but because one of the packages it needed to pull in, symfony/runtime, ships a Composer plugin, and Composer plugins don't get to run just because they're in the de

Read article The Allow-Plugins Security Prompt Is Composer's Best Feature and Its Most Annoying One
· Lars Nielsen

A Config Entity's UUID Is Its Real Identity, Not Its Machine Name

Every Drupal config entity has a machine name and a UUID, and it's easy to go a long time treating the machine name as the entity's actual identity, because it's the one you type — id: api_publisher, right there at the top of the YAML file, human-readable and stable. The UUID sits a couple of lines above it, a string nobody reads, that looks like it shouldn't matter.

Read article A Config Entity's UUID Is Its Real Identity, Not Its Machine Name
Subscribe to Linkhub