michael-milette / moodle-filter_filtercodes

FilterCodes filter for Moodle enables content creators to easily customize and personalize course and site content using plain text tags (no HTML). For premium support, contact us at https://www.tngconsulting.ca/contact
https://moodle.org/plugins/filter_filtercodes
GNU General Public License v3.0
30 stars 42 forks source link

Bug: PHP 8 Deprecation #269

Closed susyzan closed 9 months ago

susyzan commented 9 months ago

Prerequisites

What happened?

I am getting a risky test and the following deprecation notices when running unit tests (PHP 8.1.21, PHPUnit 9.5.27, Moodle 4.1.4):

`PHP Deprecated: trim(): Passing null to parameter # 1 ($string) of type string is deprecated in /var/www/html/filter/filtercodes/tests/filter_test.php on line 143

PHP Deprecated: trim(): Passing null to parameter # 1 ($string) of type string is deprecated in /var/www/html/filter/filtercodes/filter.php on line 1094`

What do you think should have happened?

I expected the unit tests to run successfully

Steps to reproduce

  1. Ensure the unit test environment is initialised
  2. From the cli run the unit tests (vendor/bin/phpunit --testsuite filter_filtercodes_testsuite)
  3. See deprecation notices in the console and the risky test result

Screenshots

image

Moodle version

4.1.4

Installed Moodle UI Language packs.

If other language(s), please specify

No response

Workaround

No response

Additional information

No response

System information

PHP 8.1.21 PHPUnit 9.5.27

Code of Conduct

michael-milette commented 9 months ago

Hi @susyzan ,

I am aware of that issue. It was due to a change with PHP 8.1.

The issue should already be fixed if you try the version of FilterCodes available here on GitHub.

Please let me know if it works better for you. I will be releasing a new version on Moodle.org within the next few weeks.

Best regards,

Michael Milette

susyzan commented 9 months ago

Hi @michael-milette,

Thank you for letting me know.

I am probably looking at the wrong branch, but I don't seem to be able to find a fix for this. I created a PR just in case. Please feel free to ignore this if there is a fix already and sorry about the confusion.

Kind regards, Susanna

michael-milette commented 9 months ago

Hi Susanna,

You are absolutely right. I went through all of my plugins fixing those trims but it looks like I missed that one. Thank you for submitting the PR. It has been integrated here on GitHub and will be included in all future releases of FilterCodes.

Let me know if it gives you any more trouble.

Best regards,

Michael

susyzan commented 9 months ago

Hi @michael-milette,

That's great. Thank you so much for maintaining this plugin.

Kind regards, Susanna

michael-milette commented 9 months ago

You are very welcome Susanna.