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

Review rename_to_unused_name() to produce better short unique names

    XMLWordPrintable

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 3.8.5, 3.9.2, 3.10, 4.0
    • None
    • General
    • None
    • MOODLE_310_STABLE, MOODLE_38_STABLE, MOODLE_39_STABLE, MOODLE_400_STABLE

    Description

      This was discovered @ MDL-69975 by jpataleta when some reduction to make_unique_writable_directory() were being applied to reduce the length of those temporal / request local directories.

      The function rename_to_unused_name() also uses a "sub-optimal" algorithm to rename files / dirs to unique new names.

      It always uses a prefix (default to "temp") plus a 32 chars md5.

      This is about to check uses and consider if we could change that md5() to be, similarly to the linked issue, a uniqid(), that is only 13 chars. Of course, the change has to be done ensuring that the uniqueness is checked properly.

      That will save 19 chars that, sometimes, can be critical, specially under Windows environments where there is a max 260 chars limit by default in many systems (and only recent PHP versions are able to work over that limit in Windows).

      Surely, at the same time, we could review if there are similar functions using long names and try to reduce them together, haven't looked if there are more candidates. And, ideally, ensure that all those "random, short and unique" names are calculated the same way everywhere.

      Ciao

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              stronk7 Eloy Lafuente (stronk7)
              Adrian Greeve, David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: