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

Regression of MDL-82787 due to incompatibility with older versions of PHP

XMLWordPrintable

    • MOODLE_401_STABLE, MOODLE_403_STABLE
    • MOODLE_401_STABLE, MOODLE_403_STABLE
    • MDL-84498-401
    • MDL-84498-403
    • Hide

      Avoid PHP 8.0

      Show
      Avoid PHP 8.0
    • Hide

      Prerequisites

      This needs to be tested on 4.1 and 4.3 running PHP 8.0

      Testing

      1. Edit lib/tests/behat_lib_test.php and add the following test to the class:

            public function test_stop_without_driver() {
                $driver = new WebDriver();
                $driver->stop();
                // Any dummy assertion will do. The test is that it makes it here without crashing.
                $this->assertEquals(1,1);
            }
        

      2. Init PHPUnit:

        php admin/tool/phpunit/cli/init.php

      3. Run the test_stop_without_driver unit test:

         vendor/bin/phpunit --filter="test_stop_without_driver" 

      4. Verify that it doesn't thrown a ReflectionException:

        1) behat_lib_test::test_stop_without_driver
        ReflectionException: Cannot access non-public property OAndreyev\Mink\Driver\WebDriver::$webDriver
        

      Please note: During the test run you'll see a "Could not connect to a Selenium 2 / WebDriver server", that's unrelated and can be ignored.

      Show
      Prerequisites This needs to be tested on 4.1 and 4.3 running PHP 8.0 Testing Edit lib/tests/behat_lib_test.php and add the following test to the class: public function test_stop_without_driver() { $driver = new WebDriver(); $driver->stop(); // Any dummy assertion will do. The test is that it makes it here without crashing. $this->assertEquals(1,1); } Init PHPUnit : php admin/tool/phpunit/cli/init.php Run the test_stop_without_driver unit test: vendor/bin/phpunit --filter="test_stop_without_driver" Verify that it doesn't thrown a ReflectionException : 1) behat_lib_test::test_stop_without_driver ReflectionException: Cannot access non-public property OAndreyev\Mink\Driver\WebDriver::$webDriver Please note : During the test run you'll see a "Could not connect to a Selenium 2 / WebDriver server" , that's unrelated and can be ignored.
    • Hide

      Code verified against automated checks.

      Checked MDL-84498 using repository: https://github.com/jaypha/moodle

      More information about this report

      Built on: Wed Feb 12 10:27:13 PM UTC 2025

      Show
      Code verified against automated checks. Checked MDL-84498 using repository: https://github.com/jaypha/moodle MOODLE_401_STABLE (0 errors / 0 warnings) [branch: 84498-41-regression-fix | CI Job ] MOODLE_403_STABLE (0 errors / 0 warnings) [branch: 84498-43-regression-fix | CI Job ] More information about this report Built on: Wed Feb 12 10:27:13 PM UTC 2025

      MDL-82787 added statements to access private members of a parent class, but failed to take into account that PHP 8.0 and earlier requires an additional statement to allow access.

      See https://www.php.net/manual/en/reflectionproperty.setvalue.php

      This bug can be reproduced when doing behat testing using PHP 8.0. You can do the same kind of testing done for MDL-82787. You should get a ReflectionException.

            jasondendulk Jason den Dulk
            jasondendulk Jason den Dulk
            Scott Verbeek Scott Verbeek
            Simey Lameze Simey Lameze
            Simey Lameze Simey Lameze
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 28 minutes
                28m

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