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

print_object() does not look nice when used in CLI scripts

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.1.4, 2.2, 2.3
    • Fix Version/s: 2.1.5, 2.2.2
    • Component/s: Libraries
    • Labels:
    • Environment:
      GNU/Linux is the supported platform for CLI scripts, Mac OS should work too.
    • Testing Instructions:
      Hide

      1. Write two simple scripts that call print_object() - one for web and one for CLI
      2. TEST: Make sure the output for the web works as it used to (no regression test)
      3. TEST: Make sire the output for the command line does not print HTML rubbish

      Show
      1. Write two simple scripts that call print_object() - one for web and one for CLI 2. TEST: Make sure the output for the web works as it used to (no regression test) 3. TEST: Make sire the output for the command line does not print HTML rubbish
    • Affected Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE, MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-30966-print-object

      Description

      During the development, using a code like

      print_object($something); die(); // DONOTCOMMIT

      is a useful debugging trick to stop execution of the script and dump the information about some object. However, the current implementation of the print_object() expects it prints to a web page. When used in a CLI script, the output does not look nice.

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            mudrd8mz David Mudrák added a comment -

            Please review my suggested solution. Thanks in advance.

            Show
            mudrd8mz David Mudrák added a comment - Please review my suggested solution. Thanks in advance.
            Hide
            quen Sam Marshall added a comment -

            +1 except shouldn't you use html_writer for the pre tag?

            Show
            quen Sam Marshall added a comment - +1 except shouldn't you use html_writer for the pre tag?
            Hide
            mudrd8mz David Mudrák added a comment -

            Done. Thanks Sam (it actually forced me to test the patch myself and to realize it did not work previously :-p)

            Show
            mudrd8mz David Mudrák added a comment - Done. Thanks Sam (it actually forced me to test the patch myself and to realize it did not work previously :-p)
            Hide
            mudrd8mz David Mudrák added a comment -

            Submitting for integration

            Show
            mudrd8mz David Mudrák added a comment - Submitting for integration
            Hide
            stronk7 Eloy Lafuente (stronk7) added a comment -

            The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week.

            TIA and ciao

            Show
            stronk7 Eloy Lafuente (stronk7) added a comment - The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week. TIA and ciao
            Hide
            stronk7 Eloy Lafuente (stronk7) added a comment -

            Uhm.. hope nobody is relying in standard output hacks produced by custom print_object() calls, because the switch to STDERR will cause them some annoyance. Perhaps it would be nice to comment it in release notes?

            Anyway, I like it, so integrating...

            Show
            stronk7 Eloy Lafuente (stronk7) added a comment - Uhm.. hope nobody is relying in standard output hacks produced by custom print_object() calls, because the switch to STDERR will cause them some annoyance. Perhaps it would be nice to comment it in release notes? Anyway, I like it, so integrating...
            Hide
            stronk7 Eloy Lafuente (stronk7) added a comment -

            Integrated, thanks!

            Show
            stronk7 Eloy Lafuente (stronk7) added a comment - Integrated, thanks!
            Hide
            samhemelryk Sam Hemelryk added a comment -

            Thanks David, passing this now after testing before and after and verifying things got better.

            Show
            samhemelryk Sam Hemelryk added a comment - Thanks David, passing this now after testing before and after and verifying things got better.
            Hide
            stronk7 Eloy Lafuente (stronk7) added a comment -

            This virus has been spread upstream, everybody will be infected soon. Congrats, you did it!

            Closing, ciao

            Show
            stronk7 Eloy Lafuente (stronk7) added a comment - This virus has been spread upstream, everybody will be infected soon. Congrats, you did it! Closing, ciao

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  12/Mar/12