Skip to content

Merge small changes#343

Merged
NeilWJames merged 13 commits intowp-document-revisions:mainfrom
NeilWJames:main
Mar 12, 2024
Merged

Merge small changes#343
NeilWJames merged 13 commits intowp-document-revisions:mainfrom
NeilWJames:main

Conversation

@NeilWJames
Copy link
Copy Markdown
Collaborator

This addresses 4 changes:

  1. The 3 dependabot updates (merged on my fork) Bump actions/cache from 3 to 4 #338, Bump peter-evans/create-pull-request from 5 to 6 #340, and Bump codecov/codecov-action from 3 to 4 #341 so they can be closed here.
  2. A fix to Plugin overtaking post thumbnail size #339. Whilst the post-thumbnail image size is defined only if it is not already defined bt the theme. this adds a filter so that it can be defined to whatever size is wanted.
  3. An update to Update class-wp-document-revisions.php - property subdir is required. #342. the component subdir can be set to '' if the standard year/month subdirectories are not used. but should be set to the input value. [The small change of order is to match that of _wp_upload_dir]
  4. Update of pot file.

NeilWJames and others added 13 commits January 18, 2024 23:23
Bumps [actions/cache](https://github.com/actions/cache) from 3 to 4.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](actions/cache@v3...v4)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
…ons/cache-4

Bump actions/cache from 3 to 4
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 3 to 4.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](codecov/codecov-action@v3...v4)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [peter-evans/create-pull-request](https://github.com/peter-evans/create-pull-request) from 5 to 6.
- [Release notes](https://github.com/peter-evans/create-pull-request/releases)
- [Commits](peter-evans/create-pull-request@v5...v6)

---
updated-dependencies:
- dependency-name: peter-evans/create-pull-request
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
…r-evans/create-pull-request-6

Bump peter-evans/create-pull-request from 5 to 6
…cov/codecov-action-4

Bump codecov/codecov-action from 3 to 4
Also directly use the image, size and not use css to resize..
…t-revisions#342)

A fix has been made available. This updates the fix to make it consistent.
[If the option "Organize my uploads into month- and year-based folders" is ticked, then the value should be set to yyyy/mm.
@codecov-commenter

This comment was marked as outdated.

@NeilWJames NeilWJames requested a review from benbalter March 11, 2024 22:19
Copy link
Copy Markdown
Contributor

@earthlingdavey earthlingdavey left a comment

Choose a reason for hiding this comment

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

Hi @NeilWJames thanks for following up on #342

I've left one comment for your consideration.

@@ -1800,8 +1813,8 @@ public function document_upload_dir_set( $dir ) {
$new_dir = array(
'path' => $doc_dir . '/' . $dir['subdir'],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we need to know the reasoning why subdir set to empty, and concatenated to the end of path.

Adding it in here, could lead to an incorrect path if a later function looks at both path and subdir.

e.g. uploads/2024/02/2024/02.

I'm not familiar with this codebase, but that's my first cautious impression.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

With respect, subdir is set empty because the recent Pull Request set it empty.

Clearly the combination of base WordPress and the existing plugin does not need the component subdir as it works without it. It only needs path and basedir.

Seemingly it is the further processing by

Now the source of the values (input to the filter) ultimately comes from _wp_upload_dir. This contains the code:
` $basedir = $dir;
$baseurl = $url;

$subdir = '';
if ( get_option( 'uploads_use_yearmonth_folders' ) ) {
	// Generate the yearly and monthly directories.
	if ( ! $time ) {
		$time = current_time( 'mysql' );
	}
	$y      = substr( $time, 0, 4 );
	$m      = substr( $time, 5, 2 );
	$subdir = "/$y/$m";
}

$dir .= $subdir;
$url .= $subdir;

`
where $dir is the standard upload directory. So it gets the Uploads directory, finds out the subdir part and adds it to dir and url.

So my assumption is that if I'm going to modify the array, then I need to make it consistent with whatever standard WordPress does.

And that means that I need to set the output value of subdir to be the same as what was input to the filter - which is what my change does.

If there is further concatenation that creates the issue above, then it will also do it when this plugin is not active.

FWIW. If sub-directories are used then with my change I expect the standard logic of wp-amazon-s3-and-cloudfront to work fine where you have proposed a change to it, Leaving it as empty will fail.

Copy link
Copy Markdown
Contributor

@earthlingdavey earthlingdavey Mar 12, 2024

Choose a reason for hiding this comment

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

With respect, subdir is set empty because the recent Pull Request set it empty.

My question was, why was it not set in the first place? And why is it concatenated to the end of path?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Apologies for nit finishing the sentence:
Seemingly it is the further processing by

It was to be:
Seemingly it is the further processing by the S3 plugin that is having an issue.

@benbalter
Thanks for approving the request.

@earthlingdavey
Whilst I am convinced that this corrects the logic, there might be additional issues with this plugin.
I have not had time to delve into the processing. Why may there be issues?
Because, if you have used a different directory from the standard one, then WPDR changes the upload directory from the standard one to the document library when it wants to serve the file.
If the S3 does this in an offline mode, say, then the replacement process may not occur properly.

Put simply, if you want to move the documents into S3 (or another remote store), then I would recommend that you initially load them into the standard upload directory.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see. Obviously we have different POV. You have significant experience with this plugin. Which I'm grateful for BTW :) And I, on the other hand don't have so much.

I would be super cautious about changing too much on a plugin that was initially written by someone else over a decade ago. But, that's just me.

Copy link
Copy Markdown
Collaborator

@benbalter benbalter 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 this!

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.

4 participants