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

new lang_string('a', 'b', 0) != get_string('a', 'b', 0)

XMLWordPrintable

    • MOODLE_310_STABLE, MOODLE_38_STABLE
    • MOODLE_310_STABLE, MOODLE_39_STABLE
    • Hide

      Manual test

      1. Download 71048.php to your dirroot
      2. Execute it, confirm output is as follows:

        $ php 71048.php 
        0 days
        0 days
        0 days
        0 days
        

      Run unit tests

      $ vendor/bin/phpunit --filter test_get_string
      

      Show
      Manual test Download 71048.php to your dirroot Execute it, confirm output is as follows: $ php 71048.php 0 days 0 days 0 days 0 days Run unit tests $ vendor/bin/phpunit --filter test_get_string

        1. Context

      I discovered this misbehaviour working on a settings.php, where I need to use an admin_setting_description to show some parameterized string. I suppose it will work the same way in other parts of the Moodle.

        1. Scenario

      Supose the string 'a' of the component 'b' is of the form "{$a}<br/>Some kind description".

        1. What works properly

      get_string('a', 'b', 0) returns a string like "0<br/>Some kind description", replacing the given value inside the string.

        1. What doesn't work

      new lang_string('a', 'b', 0) return a string like '{$a}<br/>Some kind description", without replacing the given value inside the string.

      I do not know if any other cases with similar behaviour may produce similar side effects (like working with booleans or empty strings or so).

       

            pholden Paul Holden
            jpahullo Jordi Pujol-Ahulló
            Jordi Pujol-Ahulló Jordi Pujol-Ahulló
            Adrian Greeve Adrian Greeve
            Janelle Barcega Janelle Barcega
            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, 35 minutes
                1h 35m

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