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

Review rename_to_unused_name() to produce better short unique names

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.8.5, 3.9.2, 3.10, 4.0
    • Fix Version/s: None
    • Component/s: General
    • Labels:
      None
    • Affected Branches:
      MOODLE_310_STABLE, MOODLE_38_STABLE, MOODLE_39_STABLE, MOODLE_400_STABLE

      Description

      This was discovered @ MDL-69975 by Jun Pataleta 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

              Assignee:
              Unassigned Unassigned
              Reporter:
              stronk7 Eloy Lafuente (stronk7)
              Participants:
              Component watchers:
              Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Sujith Haridasan
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated: