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

Cannot upload files in certain cloud hosting environments

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.5.3, 2.6
    • Fix Version/s: 2.6.5, 2.7.2
    • Component/s: Files API
    • Labels:
    • Testing Instructions:
      Hide
      1. If you use $CFG->preventfilelocking in config.php, comment that line.
      2. Log in as admin
      3. Go to site administration -> development -> make test course
      4. Create a XS course
      5. Go to site administration -> development -> make jmeter test plan
      6. Create a XS test plan selecting the course you created 2 steps above
      7. You SHOULD NOT see any error
      8. Follow Download test plan and open it
      9. It SHOULD all be ok
      10. Set $CFG->preventfilelocking to true in config.php
      11. Run php admin/cli/purge_cache.php in the CLI
      12. Go to site administration -> development -> make jmeter test plan
      13. Create a XS test plan selecting the course you created 2 steps above
      14. You SHOULD NOT see any error
      15. Follow Download test plan and open it
      16. It SHOULD all be ok
      Show
      If you use $CFG->preventfilelocking in config.php, comment that line. Log in as admin Go to site administration -> development -> make test course Create a XS course Go to site administration -> development -> make jmeter test plan Create a XS test plan selecting the course you created 2 steps above You SHOULD NOT see any error Follow Download test plan and open it It SHOULD all be ok Set $CFG->preventfilelocking to true in config.php Run php admin/cli/purge_cache.php in the CLI Go to site administration -> development -> make jmeter test plan Create a XS test plan selecting the course you created 2 steps above You SHOULD NOT see any error Follow Download test plan and open it It SHOULD all be ok
    • Affected Branches:
      MOODLE_25_STABLE, MOODLE_26_STABLE
    • Fixed Branches:
      MOODLE_26_STABLE, MOODLE_27_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-43390_master

      Description

      Some cloud hosting environments do not permit exclusive file locking as used by lib/filestorage/file_storage.php line 1757 `$newsize = file_put_contents($hashfile.'.tmp', $content, LOCK_EX);` since https://github.com/moodle/moodle/commit/d91e2c15dbd501231e37efb338418d6b9014bc0c (Moodle 2.5).

      The simple fix is to remove the `LOCK_EX` flag, but if you want to preserve some protection against an (unlikely) race condition you can create a unique temporaray filename (e.g. using mt_rand) instead.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              dmonllao David Monllaó
              Reporter:
              mranchovy Mr Anchovy
              Peer reviewer:
              Damyon Wiese Damyon Wiese
              Integrator:
              Sam Hemelryk Sam Hemelryk
              Tester:
              Andrew Lyons Andrew Lyons
              Participants:
              Component watchers:
              Matteo Scaramuccia, Andrew Lyons, Dongsheng Cai, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              2 Vote for this issue
              Watchers:
              10 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                8/Sep/14