Skip to main content

Updated to Drupal 9

For Drupal's 20th anniversary I thought I'd make the upgrade from Drupal 8 to Drupal 9. As far as I know nothing drastically changed in Drupal 9. But some APIs got cleaned up and some deprecated APIs were finally removed.

I thought it would be easy but when I ran composer update after having executed this:

composer require drupal/core-recommended:^9.0.0 drupal/core-composer-scaffold:^9.0.0 drupal/core-project-message:^9.0.0 --update-with-dependencies --no-update

it printed several hundred lines of problems... so I knew I was in for some fun.

The problem with composer, in my opinion, has always been that when something goes wrong you have to dig out the actual package the system has a problem with.

Long story short... what I had to do to fix it, because many people have problems with composer and Drupal 8 to 9 updates – it is by no means a painless update – was the following:

  • Remove drupal/console from composer.json. I don't even know why I had it in there because I've never used console.
  • Change image_effects to wanting a version of 3.1 or higher
  • Change admin_toolbar to be 2.4 or higher
  • Remove webflo/drupal-finder
  • Remove drush/drush
  • Add symfony/filesystem version 4.4 or higher

After hours of struggling that turned out what it was it. Then composer update ran fine.

Of course I then added drush again with composer require drush/drush

Next, the database update complained about Drupal's old core requirement that I had in my modules and theme's .info.yml files. Those went from core: 8.x to core_version_requirement: 9.x

drush updb ran without a hitch and now we're on the latest Drupal again.

Happy 20th birthday, Drupal!

Fixing BRIO Switches, Or Why Do Trains Derail On Them?

BRIO track is made from beech wood. A very hard woord that lets them mill very sharp edges that won't chip. This makes their switches look good, as the bits in which the track diverges from the main will look very meticulously cut out from the wood. Nice and sharp.

Unfortunately we're not talking about real trains that have to take the switch, we're talking about children's toys. There is also no actual "switch" happening, there are no switch rails and no switch rods moving them into position. That means the cars just follow the path of least resistance.

The problem with BRIO's switches is that their closure rails start too soon. It looks hella good and it's some fine factory-milled wood... but cars, following the path of least resistance... are very often still going straight and haven't been pulled yet into the direction of the switch. And thus they get stuck behind the other side of the closure rail.

BRIO Train Car Stuck Behind "Closure Rail".

The picture here shows a train that will derail, its two cars' wheels are both on different sides of the closure rail. There is no way the car will be pulled "over" the rail and fall into the right groove of the track.

The solution is to have the closure rail start later. This gives the car that's being pulled to the side a bit more time for its wheels to start going into the direction of the switch before the closure rail starts.

Now I regret not buying that dremel when the shops were still open. I'm writing this during the 2020 coronavirus lockdown and all stores are closed. Luckily I had some sandpaper in the basement, for removal and finishing. I only ended up using the removal one. I took a new pack of Curved Switching Tracks that BRIO had sent me for free, but that's another story, and started filing away.

Curved Switching Track & Sandpaper.

After some time I ended up with a switch on which trains would derail far less often. It was a very noticeable improvement. When I have a dremel I'll cut away some more maybe. Here's the final photo comparing the sanded switch to an untouched one.

Comparing Sanded Switch to an Untouched One.

Granted, it looks less "sharp", but it does work a lot better. BRIO surely knows this too so I don't understand why they haven't made their switches better yet.

In any case, if you want to help out your kids and see less frustration when their trains need to go through switches... sand away the start of the closure rails.

Got a Custom Drupal Module and Theme? Do Not Give Them the Same Name.

Turns out naming things in Computer Science really _is_ hard.

When you are developing a Drupal website, do not name the theme for your website the same as a custom module. Because things will not work and nothing anywhere will report that something is amiss.

Twice in my career as a Drupal developer I have spent hours on figuring out why "things did not work". Last week I spent the whole afternoon and most of the evening pulling my hair on why my custom Drupal 8 theme would not load its CSS. Squinting at my_theme.libraries.yml and peering over my_theme.info.yml, parsing it char by char 20 times... checking the theme functions to see if I mistyped anywhere... But I couldn't find anything.

Until I realised that the theme had the same folder name as my custom module. And I can't imagine this does not happen to more people? So often when you create a small website, the website has a name, right? And automatically I name the module that will hold the custom logic after the website. Just as I do the theme, because the theme is... the theme for _that_ website. Well, that does not work.

Again, a module and a theme, within the same Drupal website, can not have the same folder name.

TrackBuilder 0.9.5

This release must be the near-final one before the 1.0 Minimal Viable Product is there. The only thing that seems to be missing is loading and saving tracks. That won't be too hard to add. Could be really simple saving just the text-strings in a file... but that's nog flexible enough. It will be JSON, opening up the possibility of a web-service, who knows. I'm having fun.

New in this release are "nudgeable" Double Curved Tracks, but the biggest thing is that the curved switches can now be nudged as well, when rotated. This way you can add a curved switch... rotate it so that the switch track is at the front, and it can be nudged so that the curved switch track connects to the railroad instead of the straight track of the curved switch.

Download TrackBuilder 0.9.5

TrackBuilder 0.9

And again another release with some improvements. Version 0.9 meaning it's pretty much "feature" complete for the MVP that I envisioned at first.

I've tidied up the code and it should be a bit less fickle now. You should be able to paste in whole strings of tracks and they should render.

The tracks that got added in this release are:

  • Cross Track
  • Criss Cross Track
  • Turntable
  • Stop&Go Crossing
  • Double Straight Track

I also made some macOS specific code not run if the app launches on Windows.

Known issues:

  • Double Curved Tracks won't "nudge" yet
  • Switching Tracks don't rotate or nudge
  • The app does not "follow" the entered track out of view so some scrolling is needed

Here's the download link.

TrackBuilder 0.8, Switching It Up

Another update to the TrackBuilder. This time there is support for switches and more vintage types of tracks and the "control panel" should stay a fixed width when resizing the window.

The tracks that got added are:

  • Brio's elusive Middle Straight, a piece of track that is 72mm long
  • Outer Curve of a Short Double Curved Track
  • Outer Curve of Double Curved Track
  • Curved Switch
  • Parallel Switch
  • Short Curved Switch
  • Cross Track

I've added the the schematics of a track I built recently, you can see where some "vario" is needed. But it's minimal and nothing to worry about. I used TrackBuilder to tidy up the track I had laid down as much as possible.

Brio track layout schematics

Next up will be "actual" double track curves I think. Now you need to add the inner and outer track separately, that's not good :)

And finally, the download link. As before, run it (on macOS) with: java -jar TrackBuilder.jar

[Update: Released 0.8.1 fixing the long curve radius and 0.8.2 fixing short curved switches getting badly calculated when rotating them. The download now links to 0.8.2]

TrackBuilder 0.7

[Edit: It has come to my attention that the app only works if you have the latest Java installed, and probably only on a Mac as well. ]

I couldn't just leave it with a sloppy UI like that so read up on Java Swing Layouts a bit and made some minimal adustments.

Fixed in this version:

  • Better resizing behaviour
  • Better layout of control panel
  • Better scrollbar behaviour

 

Known issues:

  • TrackBuilder does not follow the end-point of the track to keep it "in view". This means you'll need to scroll manually.

 

Download: TrackBuilder 0.7

Trackuilder 0.6

Had some more time today so I thought I'd make TrackBuilde a little more user-friendly.

New in this release:

  • Input track in TrackBuilder window, not on the command line anymore.
  • Track gets drawn on the fly.
  • Program does not exit on invalid input.
  • Input gets filtered. Only A, B, C, D, E, F, E' and F' are allowed.

 

Fixed:

  • Track draws immediately, no need to scroll or resize the window first.

 

Download: TrackBuilder 0.6

TrackBuilder 0.5

This version of TrackBuilder adds scrollbars and does not "end" after having entered the first layout. It shows the prompt again and waits for input for a new layout.

Fixed in this version:

  • The window in which the track is laid out does not scroll so if your layout is big it will fall outside of the window.
  • It seems that if you start your track with a straight it does not get drawn. I do not know why.

Known issues:

  • The track only gets drawn after clicking in the window.  

Download: TrackBuilder 0.5