typemill / typemill

Typemill is a lightweight, flat-file CMS designed for simple, fast, and flexible website and eBook creation using Markdown.
https://typemill.net
MIT License
427 stars 60 forks source link

[PHP 8.1] PHP Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated #336

Closed Abzie closed 1 year ago

Abzie commented 2 years ago

Hi Sebastian,

Please check for an update to the yaml component, or implement the following patch in system/vendor/symfony/yaml/Inline.php

--- Inline.php.orig     2022-05-10 22:03:16.158105291 +0100
+++ Inline.php  2022-05-10 22:04:28.838725651 +0100
@@ -46,7 +46,7 @@
         self::$objectSupport = $objectSupport;
         self::$objectForMap = $objectForMap;

-        $value = trim($value);
+        $value = trim((string) $value);

         if ('' === $value) {
             return '';

This resolves the error message in nginx logs: PHP message: PHP Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /foo/bar/system/vendor/symfony/yaml/Inline.php on line 49

Apologies for opening an issue, there is no vendor folder to submit a PR to.

The above patch is confirmed working on my Typemill instance: Nginx 1.20.2 PHP 8.1.5 Typemill 1.5.3.1

Regards,

trendschau commented 2 years ago

Thank you, but I think it should be fixed in the symfony-library, otherwise it will break again in Typemill with a composer update.

Can you post the full error history so I can see where it is called in Typemill? Maybe I can fix it in Typemill with a condition or typehint.

Abzie commented 2 years ago

I reverted my patch and have replicated the issue - I'm not sure where it is being called but here is the a clean log file before refreshing the page: typemill_error.log

trendschau commented 1 year ago

thank you, unfortunately I cannot reproduce and the error log does not help as you already mentioned.

I updated the symfony library to a newer version (4) that does not break too much of existing code. Can you check if that version solves the problem? And does the error show up on all pages that you open or only on some pages? With the new version I fixed some plugins that used a wrong yaml syntax, maybe that caused some problems..

trendschau commented 1 year ago

ok, I am just testing the docker version and there I get the same deprecation messages along with some others. Will look into it...

trendschau commented 1 year ago

Tested it this week and unfortunaltely Typemill does not support PHP 8.1 because the slim framework V3 does not support it.

I won't update this version of Typemill, instead I will start Typemill V2 with a completely updated tech-stack (slim4, vue3, parsedown2, tailwindcss and more). There are so many breaking changes, that it does not make sense to upgrade the current typemill version.

trendschau commented 1 year ago

I will close this, added the limitation to php 8.0 into the description and to composer. Typemill 2.0.0 will be compatible with higher php version then...