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

tgz (mbz) packer requires zlib (for backup). Make it unavailable if not installed.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 2.6
    • 2.6
    • Backup, Unit tests
    • None
    • MOODLE_26_STABLE
    • MOODLE_26_STABLE
    • MDL-42714-master
    • Hide

      NOTE: In order to do this test you will need to 'disable zlib' or 'disable zlib for admin settings'. There are two ways to do this:

      a. Actually disable the zlib extension in your PHP settings.
      b. Fake it by hacking code.

      As the zlib extension is often compiled into code and can't be disabled, you may find the second approach easier. Here is how to fake it:

      Fake 'disable zlib': edit lib/filestorage/tgz_packer.php, find the line that says 'extension_loaded('zlib')' and change the word 'zlib' to 'zlibfrog'.

      Fake 'disable zlib for admin settings': edit admin/settings/development.php, change 'zlib' to 'zlibfrog' only in one instance in the last parameter of the call to admin_settings_php_extension_enabled constructor, currently on line 32.

      1. With zlib enabled, run the two unit tests affected by this change:

      vendor/bin/phpunit lib/filestorage/tests/tgz_packer_test.php
      vendor/bin/phpunit lib/filestorage/tests/mbz_packer_test.php
      

      EXPECTED: These unit tests pass in both cases with no skipped tests.

      2. Disable zlib and rerun the two unit tests as above.

      EXPECTED: The unit tests pass but all but one test in the first, and all test(s) in the second, are marked as skipped.

      3. Enable zlib.

      4. Look at admin settings Development / Experimental / Experimental settings.

      EXPECTED: The 'enabletgzbackups' option is present (as before). There is no 'zlib enabled' option.

      5. Disable zlib for admin settings, and reload the page.

      EXPECTED: Below the enabletgzbackups option is a new 'zlib enabled' informational display with text telling you that the new backup format will be disabled if you don't install zlib.

      6. Enable zlib for admin settings. Reload the page, then turn on the enabletgzbackups option and save changes.

      7. Go to any small course page. Choose the backup option and proceed through the process using default settings. The backup file should be created.

      8. Disable zlib.

      9. Repeat the backup process.

      EXPECTED: There should be no error and the backup file should be created. However you will probably notice that the file is a slightly different size, because it's now using the default zip compression as zlib is not available.

      10. With zlib still disabled, restore the second backup file (the zip format one) to a new course using all default settings.

      EXPECTED: This should complete successfully.

      11. Return to the original course and this time, try to restore the first backup file (the gz format one).

      EXPECTED: You don't even get to the first screen of backup but get an error 'The selected file is in the new backup format and cannot be restored because the zlib PHP extension is not available on this system.'

      12. Enable zlib.

      13. Repeat the attempt to restore the gz format backup (to a new course using default settings).

      EXPECTED: This should complete successfully.

      Show
      NOTE: In order to do this test you will need to 'disable zlib' or 'disable zlib for admin settings'. There are two ways to do this: a. Actually disable the zlib extension in your PHP settings. b. Fake it by hacking code. As the zlib extension is often compiled into code and can't be disabled, you may find the second approach easier. Here is how to fake it: Fake 'disable zlib': edit lib/filestorage/tgz_packer.php, find the line that says 'extension_loaded('zlib')' and change the word 'zlib' to 'zlibfrog'. Fake 'disable zlib for admin settings': edit admin/settings/development.php, change 'zlib' to 'zlibfrog' only in one instance in the last parameter of the call to admin_settings_php_extension_enabled constructor, currently on line 32. 1. With zlib enabled, run the two unit tests affected by this change: vendor/bin/phpunit lib/filestorage/tests/tgz_packer_test.php vendor/bin/phpunit lib/filestorage/tests/mbz_packer_test.php EXPECTED: These unit tests pass in both cases with no skipped tests. 2. Disable zlib and rerun the two unit tests as above. EXPECTED: The unit tests pass but all but one test in the first, and all test(s) in the second, are marked as skipped. 3. Enable zlib. 4. Look at admin settings Development / Experimental / Experimental settings. EXPECTED: The 'enabletgzbackups' option is present (as before). There is no 'zlib enabled' option. 5. Disable zlib for admin settings, and reload the page. EXPECTED: Below the enabletgzbackups option is a new 'zlib enabled' informational display with text telling you that the new backup format will be disabled if you don't install zlib. 6. Enable zlib for admin settings. Reload the page, then turn on the enabletgzbackups option and save changes. 7. Go to any small course page. Choose the backup option and proceed through the process using default settings. The backup file should be created. 8. Disable zlib. 9. Repeat the backup process. EXPECTED: There should be no error and the backup file should be created. However you will probably notice that the file is a slightly different size, because it's now using the default zip compression as zlib is not available. 10. With zlib still disabled, restore the second backup file (the zip format one) to a new course using all default settings. EXPECTED: This should complete successfully. 11. Return to the original course and this time, try to restore the first backup file (the gz format one). EXPECTED: You don't even get to the first screen of backup but get an error 'The selected file is in the new backup format and cannot be restored because the zlib PHP extension is not available on this system.' 12. Enable zlib. 13. Repeat the attempt to restore the gz format backup (to a new course using default settings). EXPECTED: This should complete successfully.

      In MDL-42593 it was discussed to raise zlib from recommendation to requirement. But that has been delayed to 2.7.

      That discussion leaded to the detection of places using it unconditionally (for 2.6) and the new tgz packer is one of them.

      Note that, right now (2.6beta), the tgz packer is only used by the mbz_packer in backup/restore operations. And related tests.

      So this is about:

      1) Add some explanation about "zlib" being required into the $CFG->enabletgzbackups setting.

      2) Modify the mbz_packer so it also looks for "zlib" availability when deciding which packer to use, aka: get_packer_for_archive_operation().

      3) Look if we should be skipping some tests if "zlib" is not available.

      That should be enough to allow everything to work perfectly under 2.6 with zlib being only recommended.

            quen Sam Marshall
            stronk7 Eloy Lafuente (stronk7)
            Damyon Wiese Damyon Wiese
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

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