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

Properly deprecate print_textarea()

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Fixed
    • Icon: Minor Minor
    • 3.6
    • 2.9, 3.6
    • General
    • MOODLE_29_STABLE, MOODLE_36_STABLE
    • MOODLE_36_STABLE
    • MDL-50225_master
    • Hide
      Test 1
      1. Do a grep for 'print_textarea' (grep -Ri print_textarea *)
        1. Confirm that the only results are in:
          1. lib/deprecatedlib.php (the deprecated function)
          2. lib/upgrade.txt (the notes about the deprecated function)
          3. lib/outputrenderers.php (Not really a match, just looks like one)
            Note: Uses of $OUTPUT->print_textarea are fine.
      Test 2
      1. Put the following code into a file test_form.php in your wwwroot.

        <?php
         
        require_once('config.php');
        require_once($CFG->libdir.'/formslib.php');
         
        $PAGE->set_context(context_system::instance());
        $PAGE->set_url($CFG->wwwroot . '/test_form.php');
         
        class test_form extends moodleform {
         
            public function definition() {
                $mform =& $this->_form;
                $mform->addElement('header', 'general', get_string('general', 'form'));
                $mform->addElement('htmleditor', 'htmleditor');
                $mform->addElement('editor', 'editor');
            }
        }
         
        $form = new test_form();
        echo $OUTPUT->header();
        echo $form->display();
        echo $OUTPUT->footer();
        

      2. Visit <yoursite>/test_form.php and ensure there are two textareas displayed (second one larger than the first).
      Test 3
      1. Create a course.
      2. Enrol a student.
      3. Log in as the student.
      4. Click on the 'Notification' icon in the top-right then on the cog.
      5. Turn on all the 'Feedback' notifications (all 4 checkboxes should be green)
      6. Log in as the admin.
      7. Visit the course with the enrolled student.
      8. Add a feedback activity with 'Record user names' set to "User's name will be logged and shown with answers".
      9. Click on the feedback activity.
      10. Click on the 'Show non-respondents' tab.
      11. Select the checkbox next to the user.
      12. Write a subject and message.
      13. Click 'Send'.
      14. Log in as the student and confirm there is a notification with the subject listed in the pop-up.
      15. Click on 'View full notification'.
        1. Confirm the message is shown on the next page
      Test 4
      1. Add the following code to test_deprecation.php in your wwwroot.

        <?php
         
        require_once('config.php');
         
        $deprecatedstrings =[
            'formattexttype' => 'core',
            'currentlyselectedusers' => 'core',
            'emailuserhasnone' => 'core',
            'emaildisplayhidden' => 'core',
            'sitemessage' => 'core',
            'coursemessage' => 'core',
            'addedrecip' => 'core',
            'addedrecips' => 'core',
            'messagingdisabled' => 'core_message',
            'messagedselectedcountusersfailed' => 'core',
            'backtoparticipants' => 'core',
            'keepsearching' => 'core',
            'allfieldsrequired' => 'core',
            'previewhtml' => 'core',
            'messagedselecteduserfailed' => 'core',
        ];
         
        foreach ($deprecatedstrings as $string => $component) {
            print_string($string, $component);
        }
        

      2. Visit the page.
        1. Confirm there are 15 debugging notices warning about deprecated strings.
      Test 5
      1. Create a course.
      2. Add a wiki activity.
      3. Click on the wiki.
      4. Select the 'NWiki' format for the first page and save.
      5. Click on the 'Comments' tab.
      6. Click 'Add comment'.
      7. Ensure there is no debugging message.
        1. Confirm you can add a comment
      Show
      Test 1 Do a grep for 'print_textarea' ( grep -Ri print_textarea * ) Confirm that the only results are in: lib/deprecatedlib.php (the deprecated function) lib/upgrade.txt (the notes about the deprecated function) lib/outputrenderers.php (Not really a match, just looks like one) Note: Uses of $OUTPUT->print_textarea are fine. Test 2 Put the following code into a file test_form.php in your wwwroot. <?php   require_once ( 'config.php' ); require_once ( $CFG ->libdir. '/formslib.php' );   $PAGE ->set_context(context_system::instance()); $PAGE ->set_url( $CFG ->wwwroot . '/test_form.php' );   class test_form extends moodleform {   public function definition() { $mform =& $this ->_form; $mform ->addElement( 'header' , 'general' , get_string( 'general' , 'form' )); $mform ->addElement( 'htmleditor' , 'htmleditor' ); $mform ->addElement( 'editor' , 'editor' ); } }   $form = new test_form(); echo $OUTPUT ->header(); echo $form ->display(); echo $OUTPUT ->footer(); Visit <yoursite>/test_form.php and ensure there are two textareas displayed (second one larger than the first). Test 3 Create a course. Enrol a student. Log in as the student. Click on the 'Notification' icon in the top-right then on the cog. Turn on all the 'Feedback' notifications (all 4 checkboxes should be green) Log in as the admin. Visit the course with the enrolled student. Add a feedback activity with 'Record user names' set to "User's name will be logged and shown with answers". Click on the feedback activity. Click on the 'Show non-respondents' tab. Select the checkbox next to the user. Write a subject and message. Click 'Send'. Log in as the student and confirm there is a notification with the subject listed in the pop-up. Click on 'View full notification'. Confirm the message is shown on the next page Test 4 Add the following code to test_deprecation.php in your wwwroot. <?php   require_once ( 'config.php' );   $deprecatedstrings =[ 'formattexttype' => 'core' , 'currentlyselectedusers' => 'core' , 'emailuserhasnone' => 'core' , 'emaildisplayhidden' => 'core' , 'sitemessage' => 'core' , 'coursemessage' => 'core' , 'addedrecip' => 'core' , 'addedrecips' => 'core' , 'messagingdisabled' => 'core_message' , 'messagedselectedcountusersfailed' => 'core' , 'backtoparticipants' => 'core' , 'keepsearching' => 'core' , 'allfieldsrequired' => 'core' , 'previewhtml' => 'core' , 'messagedselecteduserfailed' => 'core' , ];   foreach ( $deprecatedstrings as $string => $component ) { print_string( $string , $component ); } Visit the page. Confirm there are 15 debugging notices warning about deprecated strings. Test 5 Create a course. Add a wiki activity. Click on the wiki. Select the 'NWiki' format for the first page and save. Click on the 'Comments' tab. Click 'Add comment'. Ensure there is no debugging message. Confirm you can add a comment

      This issue remains here so we can eventually deprecate this function when all usages are removed. Until then keep moving it to the next deprecation epic

      Deprecated function print_textarea() does not display debugging message. Also there are still usages in core:

      $ git grep print_textarea
      lib/adminlib.php:        $return = '<div class="form-htmlarea">'.print_textarea(true, 15, 60, 0, 0, $this->get_full_name(), $data, 0, true, 'summar
      lib/form/htmleditor.php:                    print_textarea(true,
      mod/feedback/show_nonrespondents.php:        print_textarea(true, 15, 25, 30, 10, "message", $message);
      mod/wiki/editors/html.php:    echo $OUTPUT->container(print_textarea(true, 20, 100, 0, 0, "newcontent", $content, 0, true, '', 'form-textarea-advan
      mod/wiki/editors/wiki_editor.php:    echo $OUTPUT->container(print_textarea(false, 20, 60, 0, 0, "newcontent", $content, 0, true), false, 'wiki_edi
      user/message.html:    <?php print_textarea(true, 15, 65, 1, 1, "messagebody", $messagebody); ?>
      

      Also see MDL-50222

        1. 1.PNG
          1.PNG
          142 kB
        2. 2.PNG
          2.PNG
          422 kB
        3. 3.PNG
          3.PNG
          36 kB

            markn Mark Nelson
            marina Marina Glancy
            Carlos Escobedo Carlos Escobedo
            Andrew Lyons Andrew Lyons
            Janelle Barcega Janelle Barcega
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour
                1h

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