Error with 3.6.1 and PHP 8.1


I’ve updated to Kirby 3.6.1 and changing to PHP 8.1 I’m getting the following error:
is_file(): Passing null to parameter #1 ($filename) of type string is deprecated

Anyone getting this error?

Does the error detail show exactly which file and line is the is_file() function?

Likely due to this change in PHP8.1: Passing null to non-nullable internal function parameters is deprecated.

Would be helpful for the team to know where this error is being thrown. If its in the Kirby core, you should likely file a bug on GitHub for this.

Thanks for the reply. is_file() is never used :thinking:

The error is coming from this line (probably doesn’t say much):

<?php snippet('blocks-style/' . $block->type() . '-style', ['block' => $block, 'numRow' => $numRow, 'numColumn' => $numColumn, 'numBlock' => $numBlock]) ?>

If I remove that line, I get another error:

substr(): Passing null to parameter #1 ($string) of type string is deprecated

This line in my code:

<p class="footer-copyright">&copy; <?= date('Y') ?> <a href="<?= url() ?>"><?= $site->title() ?></a>.<?php if ($site->footerPoweredBy()->bool()): ?> Powered by <a href="#" target="_blank" rel="noopener noreferrer">Themes for Kirby</a>.<?php endif ?></p>

And if I remove that line, everything works :smiley:

This has been fixed now. Was 100% caused by me :slight_smile: for some reason these errors were only captured by PHP 8.1.

I’m getting this exact same error message on local server with:

  • Kirby
  • PHP 8.1.0
  • medienbaecker/autoresize 2.1.2
  • sgkirby/commentions 1.0.5
  • error at line no 379 of kirby/config/components.php

Do you have a stack trace to line 379 of kirby/config/components.php (that’s the url component)?

I hope this is what you need!

// get a language url for the linked page, if the page can be found
        if ($kirby->multilang() === true) {
            $parts = Str::split($path, '#');
            if ($page = page($parts[0] ?? null)) {
                $path = $page->url($language);
                if (isset($parts[1]) === true) {
                    $path .= '#' . $parts[1];
        // keep relative urls
        if (substr($path, 0, 2) === './' || substr($path, 0, 3) === '../') {
            return $path;
        $url = Url::makeAbsolute($path, $kirby->url());

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

#24 Whoops\Exception\ErrorException in /Users/brianliddell/Kirby Sites/brianliddell/kirby/config/components.php:379
#23 substr in /Users/brianliddell/Kirby Sites/brianliddell/kirby/config/components.php:379
#22 Kirby\Cms\Core:{closure} in /Users/brianliddell/Kirby Sites/brianliddell/kirby/src/Cms/Url.php:64
#21 Kirby\Cms\Url:to in /Users/brianliddell/Kirby Sites/brianliddell/kirby/config/helpers.php:899
#20 url in /Users/brianliddell/Kirby Sites/brianliddell/site/plugins/commentions/lib/Formatter.php:259
#19 sgkirby\Commentions\Formatter:purifiy in /Users/brianliddell/Kirby Sites/brianliddell/site/plugins/commentions/lib/Formatter.php:159
#18 sgkirby\Commentions\Formatter:sanitize in /Users/brianliddell/Kirby Sites/brianliddell/site/plugins/commentions/lib/Commentions.php:425
#17 sgkirby\Commentions\Commentions:sgkirby\Commentions{closure} in [internal]:0
#16 array_map in /Users/brianliddell/Kirby Sites/brianliddell/site/plugins/commentions/lib/Commentions.php:415
#15 sgkirby\Commentions\Commentions:get in /Users/brianliddell/Kirby Sites/brianliddell/site/plugins/commentions/index.php:102
#14 Kirby\Cms\Page:{closure} in [internal]:0
#13 Closure:call in /Users/brianliddell/Kirby Sites/brianliddell/kirby/src/Cms/HasMethods.php:43
#12 Kirby\Cms\Page:callMethod in /Users/brianliddell/Kirby Sites/brianliddell/kirby/src/Cms/Page.php:171
#11 Kirby\Cms\Page:__call in /Users/brianliddell/Kirby Sites/brianliddell/site/plugins/commentions/lib/Frontend.php:64
#10 sgkirby\Commentions\Frontend:render in /Users/brianliddell/Kirby Sites/brianliddell/site/plugins/commentions/helpers.php:7
#9 commentions in /Users/brianliddell/Kirby Sites/brianliddell/site/templates/article.php:49
#8 include in /Users/brianliddell/Kirby Sites/brianliddell/kirby/src/Filesystem/F.php:410
#7 Kirby\Filesystem\F:loadIsolated in /Users/brianliddell/Kirby Sites/brianliddell/kirby/src/Filesystem/F.php:387
#6 Kirby\Filesystem\F:load in /Users/brianliddell/Kirby Sites/brianliddell/kirby/src/Toolkit/Tpl.php:36
#5 Kirby\Toolkit\Tpl:load in /Users/brianliddell/Kirby Sites/brianliddell/kirby/src/Cms/Template.php:171
#4 Kirby\Cms\Template:render in /Users/brianliddell/Kirby Sites/brianliddell/kirby/src/Cms/Page.php:1061
#3 Kirby\Cms\Page:render in /Users/brianliddell/Kirby Sites/brianliddell/kirby/src/Cms/App.php:713
#2 Kirby\Cms\App:io in /Users/brianliddell/Kirby Sites/brianliddell/kirby/src/Cms/App.php:1086
#1 Kirby\Cms\App:render in /Users/brianliddell/Kirby Sites/brianliddell/index.php:5
#0 require in /Users/brianliddell/.composer/vendor/laravel/valet/server.php:234

Thanks, that’s what I needed.

The error stems from calling the url() helper in line 259 in the /Users/brianliddell/Kirby Sites/brianliddell/site/plugins/commentions/lib/Formatter.php:259, but that’s something Kirby needs to fix.

For the moment, I’d suggest you downgrade to PHP 8.0.

I created an issue on GitHub: Calling `url()` helper throws deprecation warning with PHP 8.1 · Issue #4047 · getkirby/kirby · GitHub