filerepo: Replace confusing substr() with rtrim()
authorThiemo Kreuz <thiemo.kreuz@wikimedia.de>
Wed, 2 Jan 2019 15:29:04 +0000 (16:29 +0100)
committerThiemo Kreuz <thiemo.kreuz@wikimedia.de>
Wed, 2 Jan 2019 15:29:04 +0000 (16:29 +0100)
commit4dba60597840b21c0ce0af25df4f3c835b9cd321
treeae0c396849ffc2624a33a305a7e026e73c0b7bdf
parent0aedb4d5e0597ec915026ec586ad141434324987
filerepo: Replace confusing substr() with rtrim()

I just looked at this code for ten minutes to understand what
sub-string is extracted here. Not only are the numbers hard to
understand: With 0 and -1 the last character is removed – that's
really all this does. Even more problematic is the fact there is
no check, hint, not even a comment explaining *which* character is
removed. If – for whatever reason – the code above returns a string
that does *not* end with a slash, the unconditional substr() call
must destroy this string.

rtrim() shows the character.

I checked and these strings are all guaranteed to use forward
slashes, never backwards (Windows) slashes.

Change-Id: I2e17fd583982920bb8a0ca73035094099e5e5d31
includes/filerepo/file/File.php