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

langimport can accidentally uninstall all languages

    XMLWordPrintable

Details

    • MOODLE_311_STABLE, MOODLE_39_STABLE, MOODLE_400_STABLE, MOODLE_401_STABLE, MOODLE_402_STABLE
    • MOODLE_400_STABLE, MOODLE_401_STABLE, MOODLE_402_STABLE
    • MDL-78346-401
    • MDL-78346-402
    • MDL-78346-master
    • Hide
      1. Navigate to Site admin -> Language -> Language packs
      2. Install a language pack in the UI
      3. Refresh the page
        1. Confirm that you were not warned by the browser about resubmitting a submitted form
      4. Select two (or more) languages from the list of langs to install
      5. Install them
      6. Refresh the page
        1. Confirm that you were not warned by the browser about resubmitting a submitted form
      7. Run Cron to install the languages
      8. Select one of the languages from the list of installed languages
      9. Uninstall it
      10. Refresh the page
        1. Confirm that you were not warned by the browser about resubmitting a submitted form
      11. Edit admin/tool/langimport/index.php in your preferred editor
      12. Find the redirect line around line 113 (Deleting languages section)
      13. Remove the line
      14. In the UI, uninstall another language
      15. Refresh the page
        1. Confirm that you were not warned by the browser about resubmitting a submitted form
        2. Confirm that we did not uninstall all languages
      Show
      Navigate to Site admin -> Language -> Language packs Install a language pack in the UI Refresh the page Confirm that you were not warned by the browser about resubmitting a submitted form Select two (or more) languages from the list of langs to install Install them Refresh the page Confirm that you were not warned by the browser about resubmitting a submitted form Run Cron to install the languages Select one of the languages from the list of installed languages Uninstall it Refresh the page Confirm that you were not warned by the browser about resubmitting a submitted form Edit admin/tool/langimport/index.php in your preferred editor Find the redirect line around line 113 (Deleting languages section) Remove the line In the UI, uninstall another language Refresh the page Confirm that you were not warned by the browser about resubmitting a submitted form Confirm that we did not uninstall all languages

    Description

      When you queue a removal/installation of a langpack, the page is immediately printed without a redirect after the POST. This means that if the user refreshes the page:

      1. they get a warning
      2. we somehow remove the entire lang directory

      The removal of all language happens because we accept an array of languages to remove from the POST.
      We filter that array using PARAM_LANG
      The clean_param() action for PARAM_LANG replaces any invalid lang with an empty string
      We were not filtering this out, and through a catastrophe of errors, the code to uninstall a lang wast just appending our empty string to the parent dir, checking if the dir existed, and then removing it.

      This patch does not address the stupidity of returning an empty string in this manner - that's probably beyond the scope of this changes as it would equate to a major change in behaviour.

      This patch does:

      1. filter out empty langs
      2. filter out the default lang
      3. check in the API call for any similar errors
      4. add a unit test for the API call for a number of related values

      Attachments

        Issue Links

          Activity

            People

              dobedobedoh Andrew Lyons
              dobedobedoh Andrew Lyons
              Jordi Pujol-Ahulló Jordi Pujol-Ahulló
              Jun Pataleta Jun Pataleta
              Ron Carl Alfon Yu Ron Carl Alfon Yu
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 3 hours, 9 minutes
                  3h 9m

                  Clockify

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