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

Behat error handling doesn't know about deprecated error types

XMLWordPrintable

    • MOODLE_311_STABLE, MOODLE_39_STABLE, MOODLE_400_STABLE, MOODLE_401_STABLE, MOODLE_402_STABLE
    • MOODLE_311_STABLE, MOODLE_39_STABLE, MOODLE_400_STABLE, MOODLE_401_STABLE
    • MDL-77417_401
    • Hide

      Notice

      1. This needs to be tested with PHP 8.1 (because the code-changes suggested to do the testing use something that has been deprecated in that PHP version).
      2. The patch is exactly the same for all branches, so it's enough to perform the testing instructions below only with master.

      Before the patch

      1. Ensure that you are using moodle.git (without the patch).
      2. Apply this change to login/index.php:

        diff --git a/login/index.php b/login/index.php
        index 25312086d8a..b6f915e232e 100644
        --- a/login/index.php
        +++ b/login/index.php
        @@ -27,6 +27,8 @@
         require('../config.php');
         require_once('lib.php');
         
        +ini_set('auto_detect_line_endings', true);
        +
         redirect_if_major_upgrade_required();
        

        • Or download 77417.diff to your moodle root folder and apply via git:

          git apply 77417.diff
          

      3. Init behat. e.g. if using MDK:

        mdk behat
        

      4. Run the --name 'Log in as an existing admin user filling the form' scenario.

        php admin/tool/behat/cli/run.php --name="Log in as an existing admin user filling the form"
        

      5. Verify it fails with "Exception - Unknown error type" (and other details).
      6. Edit login/index.php and add the silence operator:

        -ini_set('auto_detect_line_endings', true);
        +@ini_set('auto_detect_line_endings', true);
        

        • Or download and apply 77417_silence.diff. (You might need to run "git reset --hard" first to undo the changes applied earlier.
      7. Run the --name 'Log in as an existing admin user filling the form' scenario.
      8. Verify it fails with "Exception - Unknown error type" (and other details).
      9. Reset the changes by running "git reset --hard"

      After the patch

      1. Ensure that you are using integration.git (with the patch).
      2. Apply this change to login/index.php:

        diff --git a/login/index.php b/login/index.php
        index 25312086d8a..b6f915e232e 100644
        --- a/login/index.php
        +++ b/login/index.php
        @@ -27,6 +27,8 @@
         require('../config.php');
         require_once('lib.php');
         
        +ini_set('auto_detect_line_endings', true);
        +
         redirect_if_major_upgrade_required();
        

      3. Init behat
      4. Run the --name 'Log in as an existing admin user filling the form' scenario.
      5. Verify it fails with "Exception - Unknown error type" (and other details).
      6. Edit login/index.php and add the silence operator:

        -ini_set('auto_detect_line_endings', true);
        +@ini_set('auto_detect_line_endings', true);
        

      7. Run the --name 'Log in as an existing admin user filling the form' scenario.
      8. Verify it passes ok.
      Show
      Notice This needs to be tested with PHP 8.1 (because the code-changes suggested to do the testing use something that has been deprecated in that PHP version). The patch is exactly the same for all branches, so it's enough to perform the testing instructions below only with master . Before the patch Ensure that you are using moodle.git (without the patch). Apply this change to login/index.php : diff --git a/login/index.php b/login/index.php index 25312086d8a..b6f915e232e 100644 --- a/login/index.php +++ b/login/index.php @@ -27,6 +27,8 @@ require('../config.php'); require_once('lib.php'); +ini_set('auto_detect_line_endings', true); + redirect_if_major_upgrade_required(); Or download 77417.diff to your moodle root folder and apply via git: git apply 77417.diff Init behat. e.g. if using MDK: mdk behat Run the --name 'Log in as an existing admin user filling the form' scenario. php admin/tool/behat/cli/run.php --name="Log in as an existing admin user filling the form" Verify it fails with "Exception - Unknown error type" (and other details). Edit login/index.php and add the silence operator: -ini_set('auto_detect_line_endings', true); +@ini_set('auto_detect_line_endings', true); Or download and apply 77417_silence.diff . (You might need to run " git reset --hard " first to undo the changes applied earlier. Run the --name 'Log in as an existing admin user filling the form' scenario. Verify it fails with "Exception - Unknown error type" (and other details). Reset the changes by running " git reset --hard " After the patch Ensure that you are using integration.git (with the patch). Apply this change to login/index.php : diff --git a/login/index.php b/login/index.php index 25312086d8a..b6f915e232e 100644 --- a/login/index.php +++ b/login/index.php @@ -27,6 +27,8 @@ require('../config.php'); require_once('lib.php'); +ini_set('auto_detect_line_endings', true); + redirect_if_major_upgrade_required(); Or download and apply 77417.diff . Init behat Run the --name 'Log in as an existing admin user filling the form' scenario. Verify it fails with "Exception - Unknown error type" (and other details). Edit login/index.php and add the silence operator: -ini_set('auto_detect_line_endings', true); +@ini_set('auto_detect_line_endings', true); Or download and apply 77417_silence.diff . Run the --name 'Log in as an existing admin user filling the form' scenario. Verify it passes ok.

      Right now the behat error handler (behat_error_handler) does not know about deprecated error types (E_DEPRECATED, E_USER_DEPRECATED).

      That implies that:

      • Any of them lead to a failed test.
      • The silence operator (@) that may be used (by libraries mainly, to hide some deprecation messages on purpose) is not observed.

      So this issue is about to ensure that Behat behaves exactly the same with those two "new" error types than with the rest. Because when that handling was created (seee MDL-38041), those error types did not exist. Now they do.

      Ciao

        1. before patch.gif
          before patch.gif
          1.98 MB
        2. after patch.gif
          after patch.gif
          1.81 MB
        3. 77417.diff
          0.4 kB
        4. 77417_silence.diff
          0.4 kB

            stronk7 Eloy Lafuente (stronk7)
            stronk7 Eloy Lafuente (stronk7)
            Simey Lameze Simey Lameze
            Jun Pataleta Jun Pataleta
            Ron Carl Alfon Yu Ron Carl Alfon Yu
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 5 hours, 24 minutes
                5h 24m

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