String with plus character in key doesn't display in AMOS

String with plus character in key doesn't display in AMOS

yazan Nicolas Martignoni -
Yanıt sayısı: 7
Language pack maintainers 'ın resmi

Hi,

I notice the following behavior in AMOS:

Is this a bug in AMOS or is it intended (a feature gülüyor)?

Nicolas Martignoni yanıt olarak

Re: String with plus character in key doesn't display in AMOS

yazan David Mudrák -
Language pack maintainers 'ın resmi

It's a tricky one. Moodle core itself should throw at least a debugging warning because such an identifier does not fit into PARAM_STRINGID format that is defined as a regular expression '|^[a-zA-Z][a-zA-Z0-9\.:/_-]*$|'

I am wondering how many strings like that are there üzgün

David Mudrák yanıt olarak

Re: String with plus character in key doesn't display in AMOS

yazan Nicolas Martignoni -
Language pack maintainers 'ın resmi
Thanks. I forgot about PARAM_STRINGID üzgün Will change in my code.
Nicolas Martignoni yanıt olarak

Re: String with plus character in key doesn't display in AMOS

yazan David Mudrák -
Language pack maintainers 'ın resmi

Actually, how that it worked for you? I just tried and when I use a string with a plus sign in it, I get an exception:

diff --git a/index.php b/index.php
index e95b0bb0d1..b86fac7ad7 100644
--- a/index.php
+++ b/index.php
@@ -328,4 +328,7 @@ foreach (explode(',', $frontpagelayout) as $v) {
 if ($editing && has_capability('moodle/course:create', context_system::instance())) {
     echo $courserenderer->add_new_course_button();
 }
+
+echo get_string('foo+bar');
+
 echo $OUTPUT->footer();
diff --git a/lang/en/moodle.php b/lang/en/moodle.php
index 4032ffb344..4485d63c0d 100644
--- a/lang/en/moodle.php
+++ b/lang/en/moodle.php
@@ -2176,3 +2176,5 @@ $string['sectionusedefaultname'] = 'Use default section name';
 $string['publish'] = 'Publish';
 $string['extendenrol'] = 'Extend enrolment (individual)';
 $string['groupextendenrol'] = 'Extend enrolment (common)';
+
+$string['foo+bar'] = 'Unsupported';

leads to

Coding error detected, it must be fixed by a programmer: Invalid string identifier.
The identifier cannot be empty. Please fix your get_string() call.

Error code: codingerror

Stack trace:
line 7051 of /lib/moodlelib.php: coding_exception thrown
line 332 of /index.php: call to get_string()
David Mudrák yanıt olarak

Re: String with plus character in key doesn't display in AMOS

yazan Nicolas Martignoni -
Language pack maintainers 'ın resmi

Indeed. In fact I forgot then to test my plugin with debug mode on utanmış. With debug off, Moodle doesn't complain at all. This made me think that it was something with AMOS, but it was just me gülüyor

With debug on, I got an error too. Can't remember well, but I thing that it was "Invalid string identifier" too.

PS. Maybe Moodle should throw an error even if the debug mode is off?

Nicolas Martignoni yanıt olarak

Re: String with plus character in key doesn't display in AMOS

yazan David Mudrák -
Language pack maintainers 'ın resmi

Ah I see, thanks. I think we can leave the message to appear under developer debug mode only.

David Mudrák yanıt olarak

Re: String with plus character in key doesn't display in AMOS

yazan Nicolas Martignoni -
Language pack maintainers 'ın resmi

> I think we can leave the message to appear under developer debug mode only.

Yes, agreed, so as not to bother users with strange debug messages.