Skip to content

Conversation

@bret-miller
Copy link

@bret-miller bret-miller commented Jul 19, 2022

Use version number instead of timestamp to keep the latest version of each cached package.

Prior: prune command did nothing because it was looking for a timestamp suffix for each package which was replaced at some point by a version number.

After: prune command uses highest version number to keep latest package version for each page, removing the rest.

See issue #5467

Use version number instead of timestamp to keep the latest version of each cached package.
@bret-miller bret-miller requested a review from a team as a code owner July 19, 2022 15:27
@wojsmol
Copy link
Contributor

wojsmol commented Jul 19, 2022

@bret-miller I send a PR with code style fixes bret-miller#1

@bret-miller
Copy link
Author

@wojsmol Thank you. I understand better the coding style now.

@wojsmol
Copy link
Contributor

wojsmol commented Jul 20, 2022

@bret-miller You can apply changes by merging bret-miller#1

Still trying to figure out when to align equal signs and when not to... Apparently this one shouldn't be aligned with the two the follow.
@wojsmol
Copy link
Contributor

wojsmol commented Jul 20, 2022

This tests failure is related to your PR.

Copy link
Member

@danielbachhuber danielbachhuber left a comment

Choose a reason for hiding this comment

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

Thanks for the pull request, @bret-miller !

It's a little confusing to figure out what's going on with the diff.

Could you update your pull request description with more detail on the before and after behaviors?

Alternatively or in addition to, would it be possible to incorporate some test coverage documenting the change?

@bret-miller
Copy link
Author

Fixed description at the top.

@danielbachhuber
Copy link
Member

Fixed description at the top.

@bret-miller Thank you! I'll test this out when I have some time in the next week or so.

Move comment below else so it can be properly indented.
Copy link
Member

@danielbachhuber danielbachhuber left a comment

Choose a reason for hiding this comment

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

In looking at this a little further, I think we should change the approach slightly.

public function prune( $method = 'timestamp' )

More specifically:

  1. We'd default to 'timestamp' to avoid a breaking change on the existing behavior.
  2. Your new behavior could be applied with $method = 'version'.

Then, we could offer a flag in wp cli cache prune to prune based on 'version' instead of 'timestamp'. I'm not sure if we should change the default behavior, however.

@bret-miller
Copy link
Author

@danielbachhuber, since the current approach to prune removes nothing in the cache since nothing in the cache uses a timestamp anymore, at least as far as I can tell. So your solution would require people to enter another parameter beyond the "wp cli cache prune" command in order to actually prune the cache. Perhaps a modification that uses either the timestamp or a version number based on what it finds in the cache would be a solution?

I am just trying to fix a command that is currently completely broken from a functional standpoint. I think it would be confusing for wp cli users to need to add an additional parameter to make a command work when it should just work. It broke when wp cli changed it's approach to suffix downloaded modules with a version number instead of a timestamp. Does it ever use a timestamp anymore? If not, why keep a default that renders a command ineffective?

@danielbachhuber
Copy link
Member

@bret-miller Ok, I'm amenable to changing wp cli cache prune to default to --method=version.

However, the change should be applied to WP_CLI/FileCache in a backwards-compatible manner.

@bret-miller
Copy link
Author

Unfortunately I don't have the time to work on this. So I am pulling back on this for now. Hopefully someone will fix it.

@bret-miller bret-miller closed this Aug 8, 2022
@danielbachhuber
Copy link
Member

@bret-miller Sounds good! Appreciate the time you put into the pull request. It will serve as a good point of reference for whomever picks it up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants