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

Progress bars with messages which contain a % throw an exception

XMLWordPrintable

      If you send an update which contains a % it breaks an sprintf call, 1 liner to escape it.

      Attached is an example script showing the failure. Normal tty mode works fine:

      root@14acf95cfe6f:/var/www/master# php MDL-81901-escape-progress.php 
      [███████████████████████████████████████████████████████] 100.0%                       
      a good test                                                                     
      [███████████████████████████████████████████████████████] 100.0%                       
      a bad %3d  test      

                                                                 

      But when you pipe it through cat or similar it converts to non tty mode and you get this bug:

       

       

      root@14acf95cfe6f:/var/www/master# php MDL-81901-escape-progress.php  | cat
      [#######################################################] 100.0%
      a good test
      [#####################################################!!! Exception - 3 arguments are required, 2 given !!!
      !! 
      Error code: generalexceptionmessage !!
      !! Stack trace: * line 5496 of /lib/outputrenderers.php: ArgumentCountError thrown
      * line 5496 of /lib/outputrenderers.php: call to sprintf()
      * line 5299 of /lib/outputcomponents.php: call to core_renderer_cli->render_progress_bar_update()
      * line 5336 of /lib/outputcomponents.php: call to progress_bar->_update()
      * line 28 of /MDL-81901-escape-progress.php: call to progress_bar->update_full()
       !!
      

       

            brendanheywood Brendan Heywood
            brendanheywood Brendan Heywood
            Vithusha Kethiri Vithusha Kethiri
            Sara Arjona (@sarjona) Sara Arjona (@sarjona)
            Ron Carl Alfon Yu Ron Carl Alfon Yu
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

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

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