Skip to content

Commit

Permalink
Fix issues found in PR
Browse files Browse the repository at this point in the history
  • Loading branch information
balexey88 committed Mar 28, 2024
1 parent e93b755 commit 5266f88
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
3 changes: 2 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* NEW - use custom database tables to store GCS file data. This increases plugin performance and will be used for future improvements.
* NEW - added filter `wp_stateless_get_file`, retrieves the GCS file data, should be used instead of getting `sm_cloud` postmeta directly.
* NEW - added filter `wp_stateless_get_file_sizes`, retrieves the GCS file data for image sizes, should be used instead of getting `sm_cloud` postmeta directly.
* NEW - added filter `wp_stateless_get_file_meta`, retrieves the GCS file meta data, should be used instead of getting `sm_cloud` postmeta directly.
* NEW - added filter `wp_stateless_get_file_meta`, retrieves all GCS file meta data, should be used instead of getting `sm_cloud` postmeta directly.
* NEW - added filter `wp_stateless_get_file_meta_value`, retrieves the GCS file meta data by meta_key, should be used instead of getting `sm_cloud` postmeta directly.
* NEW - added setting allowing to change email for WP-Stateless notifications.
* NEW - added new Settings tab `Addons`, which contains the list of WP-Stateless Addons, which replace Compatibilities.
* NEW - added new Settings tab `Status`, which contains status and health information related to Google Cloud Storage and WP-Stateless.
Expand Down
3 changes: 2 additions & 1 deletion changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
* NEW - use custom database tables to store GCS file data. This increases plugin performance and will be used for future improvements.
* NEW - added filter `wp_stateless_get_file`, retrieves the GCS file data, should be used instead of getting `sm_cloud` postmeta directly.
* NEW - added filter `wp_stateless_get_file_sizes`, retrieves the GCS file data for image sizes, should be used instead of getting `sm_cloud` postmeta directly.
* NEW - added filter `wp_stateless_get_file_meta`, retrieves the GCS file meta data, should be used instead of getting `sm_cloud` postmeta directly.
* NEW - added filter `wp_stateless_get_file_meta`, retrieves all GCS file meta data, should be used instead of getting `sm_cloud` postmeta directly.
* NEW - added filter `wp_stateless_get_file_meta_value`, retrieves the GCS file meta data by meta_key, should be used instead of getting `sm_cloud` postmeta directly.
* NEW - added setting allowing to change email for WP-Stateless notifications.
* NEW - added new Settings tab `Addons`, which contains the list of WP-Stateless Addons, which replace Compatibilities.
* NEW - added new Settings tab `Status`, which contains status and health information related to Google Cloud Storage and WP-Stateless.
Expand Down
7 changes: 4 additions & 3 deletions lib/classes/class-db.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ private function _init() {
add_filter('wp_stateless_get_file', [$this, 'get_file'], 10, 3);
add_filter('wp_stateless_get_file_sizes', [$this, 'get_file_sizes'], 10, 2);
add_filter('wp_stateless_get_file_meta', [$this, 'get_file_meta'], 10, 2);
add_filter('wp_stateless_get_file_meta_value', [$this, 'get_file_meta_value'], 10, 4);
add_action('wp_stateless_set_file', [$this, 'set_file'], 10, 2);
add_action('wp_stateless_set_file_size', [$this, 'set_file_size'], 10, 3);
add_action('wp_stateless_set_file_meta', [$this, 'update_file_meta'], 10, 3);
Expand Down Expand Up @@ -730,10 +731,10 @@ public function get_file($meta, $attachment_id, $with_sizes = false) {

if ( empty($meta) ) {
return get_post_meta($attachment_id, 'sm_cloud', true);
} else {
wp_cache_set($cache_key, $meta, $this->cache_group);
}

wp_cache_set($cache_key, $meta, $this->cache_group);

// Get file size meta data
if ( $with_sizes ) {
$meta['sizes'] = apply_filters('wp_stateless_get_file_sizes', [], $attachment_id);
Expand Down Expand Up @@ -794,7 +795,7 @@ public function get_file_sizes($sizes, $attachment_id) {
* @param mixed $default
* @return mixed
*/
public function get_file_meta_value($post_id, $key, $default = null) {
public function get_file_meta_value($value, $post_id, $key, $default = null) {
if ( defined('WP_STATELESS_POSTMETA') && WP_STATELESS_POSTMETA ) {
$meta = get_post_meta($post_id, 'sm_cloud', []);

Expand Down
10 changes: 4 additions & 6 deletions lib/classes/compatibility/lite-speed-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private function _get_md5_meta($attachment_id) {
// If WP-Stateless version >= 4.0.0
if ( function_exists('ud_stateless_db') ) {
$cloud_meta = [
'fileMd5' => ud_stateless_db()->get_file_meta_value($attachment_id, 'fileMd5', []),
'fileMd5' => apply_filters('wp_stateless_get_file_meta_value', [], $attachment_id, 'fileMd5', []),
];
} else {
$cloud_meta = get_post_meta($attachment_id, 'sm_cloud', true);
Expand Down Expand Up @@ -94,9 +94,7 @@ private function _update_md5_meta($attachment_id, $cloud_meta) {
update_post_meta($attachment_id, 'sm_cloud', $cloud_meta);

// If WP-Stateless version >= 4.0.0
if ( function_exists('ud_stateless_db') ) {
ud_stateless_db()->update_file_meta($attachment_id, 'fileMd5', $cloud_meta['fileMd5']);
}
do_action('wp_stateless_set_file_meta', $attachment_id, 'fileMd5', $cloud_meta['fileMd5']);
}

/**
Expand Down Expand Up @@ -336,10 +334,10 @@ public function cloud_meta_add_file_md5($cloud_meta, $media, $image_size, $img,
$post_id = $metadata['child-of'];
}

$meta = ud_stateless_db()->get_file_meta_value($post_id, 'fileMd5', []);
$meta = apply_filters('wp_stateless_get_file_meta_value', [], $post_id, 'fileMd5', []);
$meta[$gs_name] = $file_hash;

ud_stateless_db()->update_file_meta($post_id, 'fileMd5', $meta);
do_action('wp_stateless_set_file_meta', $post_id, 'fileMd5', $meta);
}
}

Expand Down
3 changes: 2 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ Before upgrading to WP-Stateless 3.0, please, make sure you tested it on your de
* NEW - use custom database tables to store GCS file data. This increases plugin performance and will be used for future improvements.
* NEW - added filter `wp_stateless_get_file`, retrieves the GCS file data, should be used instead of getting `sm_cloud` postmeta directly.
* NEW - added filter `wp_stateless_get_file_sizes`, retrieves the GCS file data for image sizes, should be used instead of getting `sm_cloud` postmeta directly.
* NEW - added filter `wp_stateless_get_file_meta`, retrieves the GCS file meta data, should be used instead of getting `sm_cloud` postmeta directly.
* NEW - added filter `wp_stateless_get_file_meta`, retrieves all GCS file meta data, should be used instead of getting `sm_cloud` postmeta directly.
* NEW - added filter `wp_stateless_get_file_meta_value`, retrieves the GCS file meta data by meta_key, should be used instead of getting `sm_cloud` postmeta directly.
* NEW - added setting allowing to change email for WP-Stateless notifications.
* NEW - added new Settings tab `Addons`, which contains the list of WP-Stateless Addons, which replace Compatibilities.
* NEW - added new Settings tab `Status`, which contains status and health information related to Google Cloud Storage and WP-Stateless.
Expand Down

0 comments on commit 5266f88

Please sign in to comment.