Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-77953

Fix a PHP 8.1 problem in pagelib when managing NULL $SCRIPT

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 4.1.3
    • 4.1.2, 4.2
    • Unit tests
    • MOODLE_401_STABLE, MOODLE_402_STABLE
    • MOODLE_401_STABLE
    • MDL-77953_401
    • Hide
      1. In all the fixed branches (4.1.x and up).
      2. With PHP 8.1 installed.
      3. Run PHPUnit init.php script (php admin/tool/phpunit/cli/init.php)
      4. Move the vendor directory somewhere else (mv vendor /tmp/).
      5. Create a "vendor" soft link pointing to the real /tmp/vendor directory (ln -s /tmp/vendor vendor)
      6. Run PHPUnit's moodle_page_test (vendor/bin/phpunit -v --filter moodle_page_test).
      7. Verify that the test ends ok, without any PHP notice/warning/deprecation message or any test with the "Risky" outcome.
      Show
      In all the fixed branches (4.1.x and up). With PHP 8.1 installed. Run PHPUnit init.php script ( php admin/tool/phpunit/cli/init.php ) Move the vendor directory somewhere else ( mv vendor /tmp/ ). Create a "vendor" soft link pointing to the real /tmp/vendor directory ( ln -s /tmp/vendor vendor ) Run PHPUnit's moodle_page_test ( vendor/bin/phpunit -v --filter moodle_page_test ). Verify that the test ends ok, without any PHP notice/warning/deprecation message or any test with the "Risky" outcome.

      This was detected while completing the Moodle 4.2 release testing matrix.

      Note that this is not reproducible normally, when the site is running, neither via web or cli.

      It's only reproducible when, on development or testing with PHPUnit, something that is not under Moodle's dirroot is being executed. And it's only a php81 deprecation message.

      You can see the messages @ https://gist.githubusercontent.com/stronk7/519eb2088f0d86028bd4621241760061/raw/fb8d4d98ec48567f1ec15cdb85a1e753829edbc2/mac-php81-phpunit-pgsql-42beta

      1) core\moodle_page_test::test_set_state_normal_path
      This test printed output: 
      Deprecated: ltrim(): Passing null to parameter #1 ($string) of type string is deprecated in /Users/stronk7/git_moodle/integration/lib/pagelib.php on line 1990
       
      /private/tmp/composerbase/integration/402/vendor/phpunit/phpunit/phpunit:98
       
      2) core\moodle_page_test::test_header_printed_becomes_true
      This test printed output: 
      Deprecated: ltrim(): Passing null to parameter #1 ($string) of type string is deprecated in /Users/stronk7/git_moodle/integration/lib/pagelib.php on line 1990
       
      /private/tmp/composerbase/integration/402/vendor/phpunit/phpunit/phpunit:98
      

      To reproduce:

      1. With PHP 8.1
      2. Run PHPUnit init.php script.
      3. Move the vendor directory somewhere else (for example to /tmp/vendor).
      4. Create a "vendor" soft link pointing to the real /tmp/vendor directory.
      5. Run PHPUnit -v --filter test_set_state_normal_path

      Expected:

      • The test passes without any notice/warning/deprecation.

      Current:

      • The test passes with a Deprecation message (ending as risky test).

            stronk7 Eloy Lafuente (stronk7)
            stronk7 Eloy Lafuente (stronk7)
            Paul Holden Paul Holden
            Jun Pataleta Jun Pataleta
            Kim Jared Lucas Kim Jared Lucas
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 hours, 35 minutes
                2h 35m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.