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

Parenthesis miss-placed (detected running PHP 7.3)

    XMLWordPrintable

    Details

      Description

      While doing random checks with PHP 7.3 (MDL-63420) I saw this happening in unit tests (because strXXX() functions now require an string needle.

      1) core_update_code_manager_testcase::test_list_plugin_folder_files
      strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior
       
      /var/www/html/lib/classes/update/code_manager.php:331
      /var/www/html/lib/tests/update_code_manager_test.php:141
      /var/www/html/lib/phpunit/classes/advanced_testcase.php:80
       
      To re-run:
       vendor/bin/phpunit "core_update_code_manager_testcase" lib/tests/update_code_manager_test.php
       
      2) core_update_code_manager_testcase::test_zip_plugin_folder
      strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior
       
      /var/www/html/lib/classes/update/code_manager.php:331
      /var/www/html/lib/classes/update/code_manager.php:224
      /var/www/html/lib/tests/update_code_manager_test.php:153
      /var/www/html/lib/phpunit/classes/advanced_testcase.php:80
       
      To re-run:
       vendor/bin/phpunit "core_update_code_manager_testcase" lib/tests/update_code_manager_test.php
       
      3) core_update_code_manager_testcase::test_archiving_plugin_version
      strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior
       
      /var/www/html/lib/classes/update/code_manager.php:331
      /var/www/html/lib/classes/update/code_manager.php:224
      /var/www/html/lib/classes/update/code_manager.php:265
      /var/www/html/lib/tests/update_code_manager_test.php:180
      /var/www/html/lib/phpunit/classes/advanced_testcase.php:80
       
      To re-run:
       vendor/bin/phpunit "core_update_code_manager_testcase" lib/tests/update_code_manager_test.php
       

      It seems, unless I'm missing something, that there is a parenthesis miss-placed there and it should be, instead:

      diff --git a/lib/classes/update/code_manager.php b/lib/classes/update/code_manager.php
      index 9eac43bf937..3493ad427fb 100644
      --- a/lib/classes/update/code_manager.php
      +++ b/lib/classes/update/code_manager.php
      @@ -328,7 +328,7 @@ class code_manager {
                   if ($fileinfo->getFilename() === '..') {
                       continue;
                   }
      -            if (strpos($fileinfo->getRealPath(), $folderpathinfo->getRealPath() !== 0)) {
      +            if (strpos($fileinfo->getRealPath(), $folderpathinfo->getRealPath()) !== 0) {
                       throw new moodle_exception('unexpected_filepath_mismatch', 'core_plugin');
                   }
                   $key = substr($fileinfo->getRealPath(), $strip);
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              stronk7 Eloy Lafuente (stronk7)
              Reporter:
              stronk7 Eloy Lafuente (stronk7)
              Peer reviewer:
              Daniel Neis Araujo Daniel Neis Araujo
              Integrator:
              Andrew Lyons Andrew Lyons
              Tester:
              CiBoT CiBoT
              Participants:
              Component watchers:
              Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Sujith Haridasan, Matteo Scaramuccia, Andrew Lyons, Dongsheng Cai, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Sara Arjona (@sarjona)
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                12/Nov/18