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

Hooks into the file API (backport of MDL-57476)

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      From MDL-57476's testing instructions:

      Breakout your favorite editor. Add these lines to mod/forum/lib.php:

      function forum_after_file_created($file) {
          debugging('forum_create_file');
          var_dump($file);
      }
       
      function forum_after_file_updated($newfile, $oldfile) {
          debugging('forum_update_file');
          if ($newfile->timemodified == $oldfile->timemodified) {
              throw new coding_exception('fail');
          }
          var_dump($newfile, $oldfile);
      }
       
      function forum_after_file_deleted($file) {
          debugging('forum_delete_file');
          var_dump($file);
      }
      

      Drop the attached file_hooks_test.php into the root of your Moodle. Run file_hooks_test.php on the CLI,
      e.g.

      php file_hooks_test.php

      You should see that the three forum hooks are called.

      Show
      From MDL-57476 's testing instructions: Breakout your favorite editor. Add these lines to mod/forum/lib.php: function forum_after_file_created($file) { debugging('forum_create_file'); var_dump($file); }   function forum_after_file_updated($newfile, $oldfile) { debugging('forum_update_file'); if ($newfile->timemodified == $oldfile->timemodified) { throw new coding_exception('fail'); } var_dump($newfile, $oldfile); }   function forum_after_file_deleted($file) { debugging('forum_delete_file'); var_dump($file); } Drop the attached file_hooks_test.php into the root of your Moodle. Run file_hooks_test.php on the CLI, e.g. php file_hooks_test.php You should see that the three forum hooks are called.
    • Affected Branches:
      MOODLE_32_STABLE, MOODLE_33_STABLE
    • Fixed Branches:
      MOODLE_32_STABLE, MOODLE_33_STABLE

      Description

      Please backport MDL-57476 to 3.2 and 3.3

      The file API callbacks are essential for 1 plugin I have worked on and beneficial for the plugin "image optimiser" (filter_imageopt).

      Without the backport there will be a significant barrier to plugin installation / adoption.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              brudinie guy thomas
              Reporter:
              brudinie guy thomas
              Integrator:
              Jun Pataleta
              Tester:
              John Okely
              Participants:
              Component watchers:
              Matteo Scaramuccia, Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                11/Sep/17