I fixed a bug that sporadically made Spotify remove my show, the Getting Simple podcast, from its platform without any logical explanation and, more worrisome, without warnings or notifications.
Some time ago, I noticed the podcast's RSS feed displayed episode release dates localized in Chinese and other languages. Something that, to my eyes, seemed random. Yesterday, I finally identified the issue.
The XML feed is cached for thirty minutes at a time — a duration I set to avoid overloading the server by re-generating the feed on every request.
But this feed re-generation used the requesting party's "locale." This code corresponds to the language and region configured in the system that performs a web request. For instance, the en-US
locale represents a visitor or bot configured to use the English language and the United States region. A localized site — that can adjust its content to different locales — would display a date as Wed, 02 Dec 2020
for en-US
visitors and as Mié., 02 Dic. 2020
for es-ES
visitors.
date('D, d M Y H:i:s O');
// returns "Wed, 02 Dec 2020 05:19:14 -0500"
This date('D, d M Y H:i:s O')
PHP method uses the operating system's language and region to determine what to display, but a localized website can adjust to the visitor's locale or even comply with explicit requirements.
App::setLocale('en-US'); // force locale to en-US
Item::formatDate(Date::now(), 'D, d M Y H:i:s O')
// returns "Wed, 02 Dec 2020 05:22:55 -0500"
App::setLocale('es-ES'); // force locate to es-ES
Item::formatDate(Date::now(), 'D, d M Y H:i:s O')
// returns "Mié., 02 Dic. 2020 05:22:55 -0500"
The issue was that the re-generation of the podcast feed was dependent on the requesting agent's locale when the cache expired, which could be any user or bot. Spotify was pinging the podcast and could load a feed generated by an agent that used a locale other than English in the past thirty minutes.
App::setLocale('en-US');
// Generate episode timestamps here
When Spotify found dates were not in English, it removed the show altogether—something that Apple Podcasts and other networks didn't do—and then added the podcast back hours later, when episode dates were in English again.
Spotify took its time to reload all existing episodes after forcing the localization of episode timestamps to use the en-US
locale and re-generating the feed. Now all episodes and their stats are back. Hopefully, the show won't disappear again, and users won't hit this ugly, erroring embedded player.