HugoFara / lwt

Learn languages by reading! A language learning app stemmed from Learning with Texts (LWT).
https://hugofara.github.io/lwt/
The Unlicense
164 stars 19 forks source link

str_replace null case deprecated #199

Open ohnekopf opened 2 months ago

ohnekopf commented 2 months ago

Hi. i was trying to backup a database and i got a lot of deprecation warnings messing up the output: str_replace(): Passing null to parameter #3 ($subject) apparently some null were being passed to the function prepare_textdata? the database i was using was quite small so idk what could be causing that, and im having trouble reproducing the error now! the database was mostly empty (just one text and one term) so idk. after backing up with this patch, and then reverting the patch and restoring the database backup, the bug was gone and i could download the backup succesfully again, no mention of str_replace. maybe there's an easier way to avoid this by just telling php NOT to clutter the output with deprecation notices, maybe it's because i am running lwt with the "php -S" server locally isntead of with docker or a proper production server. anyway. PHP 8.3.7 last lwt commit 8196ced74c61b14a1d8e666aba96e58f02bd9df4 (Sun Apr 21 18:08:59 2024 +0200) cheers

HugoFara commented 2 months ago

Hi, thanks for reaching out. I can't reproduce your issue, could you provide more details?

I have tried a backup/restore, with/without Docker, with empty/demo database, but no trouble so far, so it may come from your specific database. I may try to pinpoint the issue if you send me the old database file, or the complete stack trace.

On a general note, it is only a warning, you can safely disable them in you PHP configuration. In your PR a function supposed to receive a string receives nothing so I would not hide this bad behavior.

Cheers