Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add params for put interface #1365

Merged
merged 4 commits into from
Nov 30, 2021
Merged

Conversation

phil-davis
Copy link
Contributor

This is a rebase of #1290

That PR comes from the master branch in https://github.com/yrong/dav and I don't want to mess with that (and maybe I can't)

@phil-davis phil-davis self-assigned this Nov 17, 2021
@codecov
Copy link

codecov bot commented Nov 17, 2021

Codecov Report

Merging #1365 (2df6a6c) into master (75e3e88) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #1365   +/-   ##
=========================================
  Coverage     97.35%   97.35%           
  Complexity     2810     2810           
=========================================
  Files           174      174           
  Lines          7978     7979    +1     
=========================================
+ Hits           7767     7768    +1     
  Misses          211      211           
Impacted Files Coverage Δ
lib/CalDAV/CalendarObject.php 100.00% <100.00%> (ø)
lib/CalDAV/Schedule/SchedulingObject.php 95.83% <100.00%> (ø)
lib/CardDAV/Card.php 100.00% <100.00%> (ø)
lib/DAV/CorePlugin.php 95.20% <100.00%> (+0.01%) ⬆️
lib/DAV/FS/File.php 100.00% <100.00%> (ø)
lib/DAV/FSExt/File.php 100.00% <100.00%> (ø)
lib/DAV/File.php 100.00% <100.00%> (ø)
lib/DAV/Server.php 97.19% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 75e3e88...2df6a6c. Read the comment docs.

@phil-davis
Copy link
Contributor Author

I added PHPdoc and some minor changes in an extra commit.

@phil-davis
Copy link
Contributor Author

@yrong do you still need this?
Please advise the details...

Copy link
Member

@staabm staabm left a comment

Choose a reason for hiding this comment

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

lgtm

*
* @return string|null
*/
public function put($data);
public function put($data, $params = null);
Copy link
Member

Choose a reason for hiding this comment

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

this param must be optional, to prevent a BC break. 👍

Choose a reason for hiding this comment

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

this still is a bc break: [php] Fatal Compile Error: Declaration of Pimcore\Model\Asset\WebDAV\File::put($data) must be compatible with Sabre\DAV\File::put($data, $params = null) ["exception" => Symfony\Component\ErrorHandler\Error\FatalError { …}]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's annoying!
It can nearly work because put($data) can be happily written when calling an instance of the parent and/or the child class. If PHP 7.2+ didn't check this, then actually this code could still work.

But if someone writes new code that calls an instance a IFile then they should be able to write put($data, $params) and pass the new parameter, if they wish. But then at run-time the object might be an instance of the child class, and that object will not know anything about the 2nd parameter. But the child should function as a fully-working drop-in replacement for the parent class - it doesn't.

Therefore this change is dangerous for future code (but could have worked for everyone's existing code, if PHP "let it past").

A good explanation of this stuff is in https://platform.sh/blog/watch-your-inheritance/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted in PR #1375

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Revert is released in https://github.com/sabre-io/dav/releases/tag/4.2.3

@dpfaffenbauer thanks for reporting! I will ask if that extra parameter to put($data) is really a needed thing. If it is, then we need to think if there is any BC way to implement it, or if it would have to be part of a major version.

Copy link

Choose a reason for hiding this comment

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

Thanks a lot for reacting so fast :) I owe you a beer now.

Regarding BC, add the new param like this /* $params = null */ and use func_get_args to check if there is a second param

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks a lot for reacting so fast :) I owe you a beer now.

Actually, I owe you a beer for reporting this quickly, so that it could be reverted before too many people bump their dependencies.

@phil-davis phil-davis mentioned this pull request Nov 30, 2021
@phil-davis phil-davis merged commit d1a3e9a into sabre-io:master Nov 30, 2021
@phil-davis phil-davis deleted the yrong-master branch November 30, 2021 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants