Review main Merged

23966[BUGFIX] Correct storage selection (common prefixes)

Ernesto Baschny CR +2 V +2 Easy +16 −3 updated 09/26/13, 14:48

Commit message

If there is a local storage "uploads/test/" and a requested file
is in "uploads/other/file.txt", the storage matching will not
consider this storage for this file anymore, although they share a
common prefix, but will use a correct matching storage (e.g. 0).

Review

  • Code review CR +2
    • Stefan Neufeind +2
    • Wouter Wolters +1
    • Markus Klein +1
  • Verified V +2
    • Stefan Neufeind +2
    • Wouter Wolters +1
    • Markus Klein +1

Issues 1

Files 2

Review log 20

  1. Mr. Jenkins commented on patch set 1 09/23/13, 08:44

  2. Markus Klein commented on patch set 1 CR -1 09/23/13, 17:21

    Wasn't it aggred upon that the commit message shall describe what is changed (positive => commit message) and not was does not work (negative => bug tracker)?

    ResourceFactory.php:183

    Wouldn't be this be much faster? if (substr($localPath, strlen($basePath) !== $basePath) otherwise this needs a preg_quote()
  3. Markus Klein updated the commit message in patch set 1 09/23/13, 17:25

  4. Mr. Jenkins commented on patch set 2 09/23/13, 17:36

  5. Ernesto Baschny commented on patch set 1 09/23/13, 19:26

    Reply

    it was positive before.. "the matching will not consider this *buggy one* the right one .. .anymore".. Maybe the "anymore" is too far away (after the parenthisis and in the next line) to get noticed. ;)

    ResourceFactory.php:183 Reply

    I am so used with preg_match that I use it for everything. Just lazyness. True about the preg_quote part, so your suggestion sounds much better. Thanks!
  6. Ernesto Baschny uploaded patch set 3 09/23/13, 19:35

  7. Wouter Wolters commented on patch set 3 V +1 CR +1 09/23/13, 19:42

    Verified with the unit-test
  8. Markus Klein uploaded patch set 4 09/23/13, 19:44

  9. Markus Klein commented on patch set 4 V +1 CR +1 09/23/13, 19:45

    New patch version to avoid double strlen calculation.
  10. Stefan Neufeind voted on patch set 4 CR +1 09/23/13, 19:47

  11. Wouter Wolters commented on patch set 4 V +1 CR +1 09/23/13, 19:49

    Re-verified with unit-test
  12. Mr. Jenkins commented on patch set 3 09/23/13, 19:55

  13. Stefan Neufeind voted on patch set 4 V +2 CR +2 09/23/13, 19:55

  14. Stefan Neufeind merged patch set 5 09/23/13, 19:55

  15. Stefan Neufeind commented on patch set 5 09/23/13, 19:55

    Cherry Picked This patchset was cherry picked to change: Id14ffd6620554c086b6e77dca285ade8dee39ab2
  16. Stefan Neufeind commented on patch set 5 09/23/13, 19:56

    Cherry Picked This patchset was cherry picked to change: Id14ffd6620554c086b6e77dca285ade8dee39ab2
  17. Mr. Jenkins commented on patch set 4 09/23/13, 20:25

  18. Steffen Ritter commented on patch set 5 09/24/13, 07:10

    PostMerge -1 "continues" are not nice at all and to a reader it is not obvious why things happen like that with this substring and continue magic... Code should be speaking... $basePathLength = strlen($basePath); $matchLength = strlen(PathUtility::getCommonPrefix(array($basePath, $localPath))); if ($basePathLength <= $matchLength && $matchLength > $bestMatchLength) { $bestMatchStorageUid = intval($storageUid); $bestMatchLength = $matchLength; }
  19. Markus Klein commented on patch set 5 09/24/13, 16:57

    In general I do not agree with you that "continues" are not nice... But in this case of course it could have been avoided. On the other hand it is clear to read: "If the length does not match, ignore this storage"
  20. Ernesto Baschny commented on patch set 5 09/26/13, 14:48

    While talking about this patch with Steffen, I noticed another oddity (blame on the author!): before we used the PathUtility::getCommonPrefix method. This method does more "magic" than what is now the current state, because it is OS-independent (cares about Windows "/" vs "\" etc). So I guess we should / could / must rewrite this to make use of this utility method instead of a dump "substr()", and at the same time get rid of the continue to please everyone. :) Take a look at https://review.typo3.org/24071 if you are interested...