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

Exception in custom reports when first column contains type integer

XMLWordPrintable

      If the first column of a custom report contains an integer (e.g. if using one of the Count aggregation types), then the following exception is thrown:

      {"error":true
      ,"exception":{"message":"Exception - strip_tags(): Argument #1 ($string) must be of type string
      , int given"
      ,"errorcode":"generalexceptionmessage"
      ,"backtrace":"
      * line 341 of \/reportbuilder\/classes\/table\/custom_report_table.php: TypeError thrown
      * line 341 of \/reportbuilder\/classes\/table\/custom_report_table.php: call to strip_tags()
      * line 1119 of \/lib\/tablelib.php: call to core_reportbuilder\\table\\custom_report_table->get_row_cells_html()
      * line 1088 of \/lib\/tablelib.php: call to flexible_table->get_row_html()
      * line 777 of \/lib\/tablelib.php: call to flexible_table->print_row()
      * line 718 of \/lib\/tablelib.php: call to flexible_table->add_data()
      * line 2018 of \/lib\/tablelib.php: call to flexible_table->add_data_keyed()
      * line 372 of \/reportbuilder\/classes\/table\/custom_report_table.php: call to table_sql->build_table()
      * line 253 of \/lib\/table\/classes\/external\/dynamic\/get.php: call to core_reportbuilder\\table\\custom_report_table->out()
      * line ? of unknownfile: call to core_table\\external\\dynamic\\get::execute()
      * line 251 of \/lib\/external\/classes\/external_api.php: call to call_user_func_array()
      * line 83 of \/lib\/ajax\/service.php: call to core_external\\external_api::call_external_function()
      "
      ,"link":"http:\/\/moodle.internal\/master\/reportbuilder\/edit.php?id=218"
      ,"moreinfourl":"https:\/\/docs.moodle.org\/402\/en\/error\/moodle\/generalexceptionmessage"
      ,"debuginfo":"
      Error code: generalexceptionmessage"}}]
      

      I can't find any specific reasoning for this, nor can I repeat the same exception from a minimal test case to state this is particular to any given PHP version:

      <?php
       
      var_dump(strip_tags(1));
       
      Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.27, 8.1.0 - 8.1.15, 8.2.0 - 8.2.2
          string(1) "1"
      

      Seems to be caused by code from MDL-75729. Found by mikelmartíncorrales while testing MDL-77201 (unrelated to this bug, which I can also reproduce back to 4.0)

            mikelmartíncorrales Mikel Martín Corrales
            pholden Paul Holden
            Paul Holden Paul Holden
            David Carrillo David Carrillo
            Kim Jared Lucas Kim Jared Lucas
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour, 40 minutes
                1h 40m

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