Skip to content

Conversation

@PVince81
Copy link
Contributor

Before this fix, the root "/files" with path "/files_trashbin" would
return "_trashbin" as relative path...

Please review @icewind1991 @schiesbn

I'm still having doubts whether this quickfix is safe or will break other parts of OC...

I raised #16478 to look into a more extensive fix.

Fixes #16475
Fixes #18509

@PVince81
Copy link
Contributor Author

The alternative would be to just detect these cases and log a warning and carry on... at least for 8.1.
My worry is about code that assumes that the return value has a leading slash. It doesn't always have it...

@PVince81
Copy link
Contributor Author

I wonder what could go wrong if someone ever had a real "_trashbin" folder in their home storage...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mind adding array('/files', '/files/', '/'), aswell?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried adding more cases initially, but they failed. This is because response we are getting will sometimes have a trailing slash and sometimes not. It's a real mess and I didn't want to "enforce" the expected behavior here until we fix it and decide what the API contract is for that method, as part of #16478

I'm not sure about adding test cases that asserts that the behavior is still as buggy as it was before, basically giving a "wrong" answer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well the case I mentioned is hardcoded before your patch:

        if (rtrim($path,'/') === rtrim($this->fakeRoot, '/')) {
            return '/';
        }

so that should always work (until someone breaks it)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, then it makes sense. I'll add it. (I'm a bit blinded by my 😡 regarding this method)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also empty fakeRoot should be easily testable

@nickvergessen
Copy link
Contributor

Test coverage for the patch is good and the patch looks fine aswell.

The alternative would be to just detect these cases and log a warning and carry on... at least for 8.1.

To not break anything I'd not backport it, but only fix in master. So I agree with that.

@PVince81
Copy link
Contributor Author

I agree, this PR should only go to 8.1

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather not take this risk. When I tried it it changed the behavior from "having a slash in the response" to "not having a slash in the response" in some cases. Keep in mind that some code that uses this API rely insanely on such slash to exist (or not exist). There is risk of breakage.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, option 2 would be strlen(rtrim($this->fakeRoot, '/')) but I guess this is all 💩 until we freeze the method to one behaviour.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah... I'd say just leave it. I tried to keep this PR to the minimum to just avoid the bad match, nothing more.

@PVince81
Copy link
Contributor Author

Note: this PR isn't needed any more for #16475

If we want to be on the safe side, we could just defer to 8.2

@PVince81 PVince81 added this to the 8.2-next milestone May 26, 2015
@MorrisJobke
Copy link
Contributor

@PVince81 State of this?

@PVince81
Copy link
Contributor Author

At this point, need to continue with the proper fix on top of this PR. (too late for quickfix anyway)

@PVince81
Copy link
Contributor Author

Rebased.

@scrutinizer-notifier
Copy link

A new inspection was created.

@PVince81
Copy link
Contributor Author

I'd still have to have this quickfix in as it would potentially solve #18509 and #18524

The proper fix is much more risky.

@MorrisJobke
Copy link
Contributor

I did some sometests and all went good 👍

@nickvergessen
Copy link
Contributor

Mind also fixing getPath() ?

@PVince81
Copy link
Contributor Author

@nickvergessen separately then. Since @icewind1991 is off then I'll have a look myself.

@PVince81
Copy link
Contributor Author

@nickvergessen what's left to fix in getPath ? getPath uses getRelativePath and I thought this would fix it already ?

@PVince81
Copy link
Contributor Author

I hereby 👍 the commit from @nickvergessen for the unit tests.

Needs a second thumbs up for the original fix.

@PVince81
Copy link
Contributor Author

@nickvergessen anything left to be done here ? Does it fix #18509 ?

@icewind1991
Copy link
Contributor

👍

@nickvergessen
Copy link
Contributor

@PVince81 works for the activity app atm

Vincent Petry and others added 2 commits September 22, 2015 11:34
Before this fix, the root "/files" with path "/files_trashbin" would
return "_trashbin" as relative path...
@PVince81 PVince81 force-pushed the core-fixgetrelativepathwrongmatches branch from f7e6f22 to d26c49b Compare September 22, 2015 09:34
@PVince81
Copy link
Contributor Author

Rebased to wake up CI.

@MorrisJobke
Copy link
Contributor

@PVince81 OCI fails :(

@nickvergessen
Copy link
Contributor

Testergebnis (6 fehlgeschlagene Tests / +6)

Test\BackgroundJob\JobList::testAddRemove.testAddRemove with data set #0
Test\BackgroundJob\JobList::testAddRemove.testAddRemove with data set #1
Test\BackgroundJob\JobList::testAddRemove.testAddRemove with data set #2
Test\BackgroundJob\JobList::testAddRemove.testAddRemove with data set #3
Test\BackgroundJob\JobList::testAddRemove.testAddRemove with data set #4
Test\BackgroundJob\JobList::testRemoveDifferentArgument.testRemoveDifferentArgument with data set #0

Failing OCI is unlikely to be related:

Failed asserting that OCA\Files_Trashbin\BackgroundJob\ExpireTrash Object (...) is an instance of class "\Test\BackgroundJob\TestJob"


Also fixes #18509

👍

@MorrisJobke
Copy link
Contributor

@DeepDiver1975 Merge or retrigger CI?

DeepDiver1975 added a commit that referenced this pull request Sep 24, 2015
…atches

Prevent wrong matches in getRelativePath
@DeepDiver1975 DeepDiver1975 merged commit df75c17 into master Sep 24, 2015
@DeepDiver1975 DeepDiver1975 deleted the core-fixgetrelativepathwrongmatches branch September 24, 2015 08:25
@lock lock bot locked as resolved and limited conversation to collaborators Aug 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

view->getPath($id) returns strange path for delete files File restore from trash to ext storage appears twice in web UI

7 participants