Following CDN guide – Cachebuster breaks

Hi!

I’m following the guide here – Kirby loves CDN | Kirby CMS

I’ve copied the plugin code from the guide without modifications, only added the following lines:

load([
  'kirby\\cdn\\cachebuster' => __DIR__ . '/src/Cachebuster.php'
]);

use Kirby\Cdn\Cachebuster;

And put the Cachebuster from the linked example getkirby.com/Cachebuster.php at main · getkirby/getkirby.com · GitHub to site/plugins/cdn/src/Cachebuster.php.

However, I am facing an error where it seems like Cachebuster is calling url function that is just being defined in CDN plugin: getkirby.com/Cachebuster.php at main · getkirby/getkirby.com · GitHub

The error looks like this (you can see that #23 in stack trace is the CDN plugin):

Whoops\Exception\ErrorException thrown with message "substr(): Passing null to parameter #1 ($string) of type string is deprecated"

Stacktrace:
#25 Whoops\Exception\ErrorException in /Users/misha/Source/mt.com/kirby/config/components.php:379
#24 substr in /Users/misha/Source/mt.com/kirby/config/components.php:379
#23 Kirby\Cms\Core:{closure} in /Users/misha/Source/mt.com/site/plugins/cdn/index.php:60
#22 Kirby\Filesystem\F:{closure} in /Users/misha/Source/mt.com/kirby/src/Cms/Url.php:64
#21 Kirby\Cms\Url:to in /Users/misha/Source/mt.com/kirby/config/helpers.php:899
#20 url in /Users/misha/Source/mt.com/site/plugins/cdn/src/Cachebuster.php:17
#19 Kirby\Cdn\Cachebuster:path in /Users/misha/Source/mt.com/site/plugins/cdn/index.php:52
#18 Kirby\Filesystem\F:{closure} in /Users/misha/Source/mt.com/kirby/src/Cms/Url.php:64
#17 Kirby\Cms\Url:to in /Users/misha/Source/mt.com/kirby/config/helpers.php:118
#16 css in /Users/misha/Source/mt.com/site/snippets/header.php:29
#15 include in /Users/misha/Source/mt.com/kirby/src/Filesystem/F.php:410
#14 Kirby\Filesystem\F:loadIsolated in /Users/misha/Source/mt.com/kirby/src/Filesystem/F.php:387
#13 Kirby\Filesystem\F:load in /Users/misha/Source/mt.com/kirby/src/Toolkit/Tpl.php:36
#12 Kirby\Toolkit\Tpl:load in /Users/misha/Source/mt.com/kirby/config/components.php:303
#11 Kirby\Cms\Core:{closure} in /Users/misha/Source/mt.com/kirby/src/Cms/App.php:1442
#10 Kirby\Cms\App:snippet in /Users/misha/Source/mt.com/kirby/config/helpers.php:711
#9 snippet in /Users/misha/Source/mt.com/site/templates/slideshow.php:1
#8 include in /Users/misha/Source/mt.com/kirby/src/Filesystem/F.php:410
#7 Kirby\Filesystem\F:loadIsolated in /Users/misha/Source/mt.com/kirby/src/Filesystem/F.php:387
#6 Kirby\Filesystem\F:load in /Users/misha/Source/mt.com/kirby/src/Toolkit/Tpl.php:36
#5 Kirby\Toolkit\Tpl:load in /Users/misha/Source/mt.com/kirby/src/Cms/Template.php:171
#4 Kirby\Cms\Template:render in /Users/misha/Source/mt.com/kirby/src/Cms/Page.php:1061
#3 Kirby\Cms\Page:render in /Users/misha/Source/mt.com/kirby/src/Cms/App.php:713
#2 Kirby\Cms\App:io in /Users/misha/Source/mt.com/kirby/src/Cms/App.php:1086
#1 Kirby\Cms\App:render in /Users/misha/Source/mt.com/index.php:5
#0 require in /Users/misha/Source/mt.com/kirby/router.php:14

Anyone has an idea for what am I doing wrong?

Probably using php 8.1?

Thanks for the quick reply! I should have mentioned the version.

So locally yes, 8.1. But I tried deploying it to Fortrabbit where I have php 8.0 configured and it was still breaking in the same way.

I went with Imgix | Kirby CMS as it also suit my purpose and that worked well.