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

Help with debugging errors in Mustache templates by making it easy to find the template .mustache file which caused the error

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • 4.0.6, 4.1.1
    • Libraries
    • MOODLE_400_STABLE, MOODLE_401_STABLE

      Looking at the stack trace in MDL-77148 (for example) it is hard to know which template the error is coming from. Same issue if you try to follow the code in you PHP debugger.

      It would be nice if there was some way easy way to find out. For example, either a comment at the top of moodledata/localcache/mustache/1675681331/boost/_Mustache_a3d87a9e8dbdfebc2971be0d53490c77.php, or possibly a different class name like __Mustache_a3d87a9e8dbdfebc2971be0d53490c77libtemplates_single_button.

      I think this is doable, in one of two ways, since we already have class mustache_engine extends \Mustache_Engine in our code:

      1. First option. Override the getTemplateClassName method to add the extra bit to the standard class name.
      2. Second option. Override the compile method, so that after calling parent::compile, which returns the PHP code as a string, insert the comment after the opening <?php.

      I prefer the first option, becuase it makes the template filename obvious from the stack trace, without having to go and look in localcache.

            Unassigned Unassigned
            timhunt Tim Hunt
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:

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