Skip to content

Commit

Permalink
MDL-59467 core: Use hasHelper instead of catching exception
Browse files Browse the repository at this point in the history
When xdebug is set to break on exceptions it stops on all exceptions,
including _caught_ exceptions.

As a result we regularly hit this uniqid helper issue if debugging with
xdebug.

The solution is to check if the helper exists using the hasHelper method
instead of catching an exception when it does not exist.
  • Loading branch information
andrewnicols committed Dec 19, 2023
1 parent bc6e290 commit 40966ee
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/outputrenderers.php
Expand Up @@ -181,10 +181,10 @@ public function __construct(moodle_page $page, $target) {
public function render_from_template($templatename, $context) {
$mustache = $this->get_mustache();

try {
if ($mustache->hasHelper('uniqid')) {
// Grab a copy of the existing helper to be restored later.
$uniqidhelper = $mustache->getHelper('uniqid');
} catch (Mustache_Exception_UnknownHelperException $e) {
} else {
// Helper doesn't exist.
$uniqidhelper = null;
}
Expand Down

0 comments on commit 40966ee

Please sign in to comment.