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

Decide what to do with print_error() + lang strings on moodle_exception

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Priority: Minor
    • Resolution: Done
    • Affects Version/s: 3.10
    • Fix Version/s: None
    • Component/s: Policy
    • Labels:
      None

      Description

      Policy: print_error() deprecation and lang strings use in moodle_exception cleanup

      Since 5th Mar 2021, these points have been agreed:

      • print_error() is deprecated. Will be removed in the future (standard deprecation process unless re-analysing it makes it to stay longer).
      • lang strings in moodle_exception will be only translated when they are meant to be shown to final users.

      This issue is about to decide if we want to do something with the print_error() function.

      Rationale:

      • It's a simple wrapper over moodle_exception, with zero added value.
      • There are right now, 913 places where we are already throwing the exception without using it, specially new code (vs 1563 using print_error()).
      • People keeps asking.

      Alternatives:

      A) Do nothing. print_error() is awesome.

      B) In the coding style, recommend to throw new moodle_exception and do the same within code-checker. Keeping the function as is.

      C) Same than B) plus deprecate the print_error(), without debugging. Will stay deprecated forever.

      D) Same than C) plus deprecate it with debugging. Will stay forever. This implies all core cases must be changed (not the hardest replacement in the world).

      E) Same than D) plus removing it at some point. This will break non-updated plugins.

      Bonus (lang strings on moodle_exception).

      In any case, and apart from the alternatives above, we should also clarify when to use (or no) translated strings when throwing moodle exceptions. Note this is exclusively about moodle exceptions and never about any type of coding / database... exceptions.

      The trend seems to be something like: "If the moodle_exception is going to be shown to a final user, translated. Else, hardcoded English literal string"

      Let's discuss a little bit about the 2 points and prepare a voting once them are clear enough.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              stronk7 Eloy Lafuente (stronk7)
              Reporter:
              stronk7 Eloy Lafuente (stronk7)
              Participants:
              Component watchers:
              Adrian Greeve, Andrew Nicols, Eloy Lafuente (stronk7), Juan Leyva, Jun Pataleta, Sander Bangma
              Votes:
              0 Vote for this issue
              Watchers:
              13 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: