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

Review and fix incorrect strpos() @admin/tool/behat/cli/run.php

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      1. Init Behat parallel run, e.g.:

        $ php admin/tool/behat/cli/init.php  --parallel=2
        

      2. Try to use invalid profile:

        $ php admin/tool/behat/cli/run.php --profile=doesntexist
        

      3. Pass empty 'replace' param:

        $ php admin/tool/behat/cli/run.php --profile=doesntexist --replace
        

      4. Pass non-matching 'replace' param:

        $ php admin/tool/behat/cli/run.php --profile=doesntexist --replace=foo
        

      5. Confirm that for each of steps 2-4 you see the message "Invalid profile passed: doesntexist" and do not see a PHP warning about strpos non-string needles
      6. Pass matching 'replace' param:

        $ php admin/tool/behat/cli/run.php --profile=doesntexist --replace=exist
        

      7. Confirm Behat starts run (it will fail later because 'doesnt1' and 'doesnt2' profiles don't exist either):

        Running 2 parallel behat sites:
        [behatrun1] vendor/bin/behat --config /var/www/behatdata/behatrun1/behat/behat.yml --profile="doesnt1"
        [behatrun2] vendor/bin/behat --config /var/www/behatdata/behatrun2/behat/behat.yml --profile="doesnt2"
        

       

      Show
      Init Behat parallel run, e.g.: $ php admin/tool/behat/cli/init.php --parallel=2 Try to use invalid profile: $ php admin/tool/behat/cli/run.php --profile=doesntexist Pass empty 'replace' param: $ php admin/tool/behat/cli/run.php --profile=doesntexist --replace Pass non-matching 'replace' param: $ php admin/tool/behat/cli/run.php --profile=doesntexist --replace=foo Confirm that for each of steps 2-4 you see the message " Invalid profile passed: doesntexist " and do not see a PHP warning about strpos non-string needles Pass matching 'replace' param: $ php admin/tool/behat/cli/run.php --profile=doesntexist --replace=exist Confirm Behat starts run (it will fail later because 'doesnt1' and 'doesnt2' profiles don't exist either): Running 2 parallel behat sites: [behatrun1] vendor/bin/behat --config /var/www/behatdata/behatrun1/behat/behat.yml --profile="doesnt1" [behatrun2] vendor/bin/behat --config /var/www/behatdata/behatrun2/behat/behat.yml --profile="doesnt2"  
    • Affected Branches:
      MOODLE_310_STABLE
    • Fixed Branches:
      MOODLE_310_STABLE, MOODLE_39_STABLE
    • Pull 3.9 Branch:
    • Pull 3.10 Branch:
      MDL-70917-310
    • Pull 3.11 Branch:
      MDL-70917-311
    • Pull Master Branch:

      Description

      Line 149 of admin/tool/behat/cli/run.php throws a warning with php74

      149 : strpos($options['profile'], $options['replace']) >= 0

      PHP Deprecated: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in admin/tool/behat/cli/run.php on line 149

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              pholden Paul Holden
              Reporter:
              rdebleu Renaat Debleu
              Peer reviewer:
              Tim Hunt Tim Hunt
              Integrator:
              Sara Arjona (@sarjona) Sara Arjona (@sarjona)
              Tester:
              Anna Carissa Sadia Anna Carissa Sadia
              Participants:
              Component watchers:
              Andrew Lyons, Dongsheng Cai, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                10/May/21

                  Time Tracking

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