Developer Notes: Down the Rabbit Hole

Please tell me that other developers have days like this?

  • One of my co-workers at ASU Engineering asked me to install the Enable Media Replacement plugin for a web site. Easy.
  • Expected time to execute: 10 minutes.
  • Looked at the website and noticed that it hadn’t been updated in a while. It’s not in any particular upstream and gets updated the old-fashioned way. Dropped the site into SFTP mode, clicked all the buttons. Also added the plugin.
  • Pushed the code, looked at the result in TEST. Site was live, everything looked great.
  • Pushed the code to LIVE, got ready to tell my co-worker that the plugin was available. I started plotting out my next task for the day.
  • Then, I thought to myself, “I should activate the plugin just to be extra nice. I’m not sure if there are configuration things I need to do once it’s activated for the first time.”
  • Logged in. Activated the plugin, looked at the media library… and saw a mostly blank screen.
  • Deactivated the plugin and saw…. the same blank screen.

So, I went into error tracking mode:

  • Copied the DB down to DEV, added some debugging plugins and looked for the error.
  • Caught the error in the console – a JS error was preventing the page from loading.
  • The WordPress standard procedure is to turn off all plugins and figure out which one of them is causing the problem.
  • Turned them all back on one at a time with a reload of /wp-admin/upload.php in between each one.
  • Verified that Yoast SEO was causing the issue.
  • Yes, that’s the plugin at the bottom of the list. Yes, I think it would have been Anti-Spam Bee if I had instead started in inverse order.
  • Dug into the error queue for Yoast SEO on Github and didn’t see anything obvious. However, the latest version was released a mere 10 hours ago. So maybe there was more to come?
  • I decided to be sure that the error was isolated to the plugin, so I temporarily switched themes to the TwentyTwenty theme.

Unexpectedly, the error completely disappeared when a new theme was activated. I winced for a split second when I realized that I was not likely to bump into other smart people on the internet who also have had the joy of tracking this particular bug down.

I forced myself to slow down for a second. I took a brief walk around the office. And, lo and behold, in between sips of Diet Coke, my brain made a fairly big leap in a new direction. It still amazes me how much of a silly little rush that is when of those super helpful connections from the past is suddenly brought forward at the exact right moment.

The connection:

  • On Friday, late in the afternoon, a different co-worker and I were working through a content shaping problem with a completely different site, running a different theme.
  • The site happened to be the recipient of a very recent batch of updates. But, oh yeah… I noticed the exact same problem in a completely different environment. Media library, blank screen. Solved by deactivating Yoast SEO.
  • My brain popped its clutch and spun up into fifth gear. Is it Yoast that’s the problem or something else? Not Yoast. Two different versions in production, both producing the error and the error is still completely fixed by a theme switch.
  • So, I was looking for an error caused by (the first custom theme + Yoast SEO) and (the second custom theme + Yoast SEO).
  • What’s the commonality between the two custom themes? Answer… both use a third-party library to do fancy custom stuff in the admin area. The library is called Carbon Fields. (It’s awesome!)
  • Checking into Carbon Fields. Took note of a really generic update message with a new version from 5 days earlier about a fix that addressed a potential “conflict with third party plugins.”
  • Ran a composer update to grab the new library within the ASU Labs theme local environment. Tested the updated code.

Hallelujah. But, wait…. did that actually fix the original problem?

  • In full sprint mode now, both cans of nitrous wide open.
  • Spun up a local development environment for the original site
  • Pulled down the most current version of the theme.
  • Grabbed the list of active plugins from DEV.
  • Verify that the bug still exists in the local development environment. Yep, still there.
  • Composer update.
  • Crossed fingers.

Checkered flag and another hallelujah.

As my brain took its victory lap, I happened to look up at the time and immediately laughed to myself. Yep, I totally figured out the problem, and it felt pretty excellent.

But… well, it was like being told that at the end of your 100 lap race on the oval, it was now time to run the REAL race. And that was a Formula-1 track with all kinds of twists and turns.

There’s still more work to do. (And this blog post isn’t helping me get it done!) My ten-minute activity turned into a four-hour, all-out bug hunt. And now that I know the problem, I still get to deploy the solution across all the thirty or so different websites that are affected.

Oh yeah. Here’s the bug, in case anyone else happens down this way.