From b7a1d9ffeba0bd196652a2a0cc1bf6ba60e482c2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Mudr=C3=A1k?= <david@moodle.com>
Date: Wed, 5 Feb 2020 11:37:20 +0100
Subject: [PATCH] MDL-62468 output: Improve the debug message on js_call_amd
 params length

Add the actual length of the arguments that triggered the message.
---
 lib/outputrequirementslib.php | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/outputrequirementslib.php b/lib/outputrequirementslib.php
index 3eb24e2b68..850b4ffdf2 100644
--- a/lib/outputrequirementslib.php
+++ b/lib/outputrequirementslib.php
@@ -1051,11 +1051,12 @@ class page_requirements_manager {
             $strparams = implode(', ', $jsonparams);
             if ($CFG->debugdeveloper) {
                 $toomanyparamslimit = 1024;
-                if (strlen($strparams) > $toomanyparamslimit) {
+                $actualparamslength = strlen($strparams);
+                if ($actualparamslength > $toomanyparamslimit) {
                     debugging('Too much data passed as arguments to js_call_amd("' . $fullmodule . '", "' . $func .
                         '"). Generally there are better ways to pass lots of data from PHP to JavaScript, for example via Ajax, ' .
                         'data attributes, ... . This warning is triggered if the argument string becomes longer than ' .
-                        $toomanyparamslimit . ' characters.', DEBUG_DEVELOPER);
+                        $toomanyparamslimit . ' characters (' . $actualparamslength . ' in this case).', DEBUG_DEVELOPER);
                 }
             }
 
-- 
2.24.1

