Skip to content

Commit 9a4fbff

Browse files
authored
Merge pull request #1100 from cloudinary/uat
3.2.14
2 parents 0a69bf6 + 6555770 commit 9a4fbff

File tree

8 files changed

+45428
-38739
lines changed

8 files changed

+45428
-38739
lines changed

.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.2.13
1+
3.2.14

languages/cloudinary.pot

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ msgid ""
44
msgstr ""
55
"Project-Id-Version: Cloudinary STABLETAG\n"
66
"Report-Msgid-Bugs-To: https://github.com/cloudinary/cloudinary_wordpress\n"
7-
"POT-Creation-Date: 2025-09-12 09:34:43+00:00\n"
7+
"POT-Creation-Date: 2025-09-29 13:51:03+00:00\n"
88
"MIME-Version: 1.0\n"
99
"Content-Type: text/plain; charset=utf-8\n"
1010
"Content-Transfer-Encoding: 8bit\n"
@@ -22,7 +22,7 @@ msgstr ""
2222
"X-Poedit-SearchPath-0: .\n"
2323
"X-Poedit-Bookmarks: \n"
2424
"X-Textdomain-Support: yes\n"
25-
"X-Generator: grunt-wp-i18n 1.0.3\n"
25+
"X-Generator: grunt-wp-i18n 1.0.4\n"
2626

2727
#: cloudinary.php:63
2828
msgid ""
@@ -808,17 +808,17 @@ msgstr ""
808808
msgid "Clean up sync metadata for %d"
809809
msgstr ""
810810

811-
#: php/class-utils.php:1279
811+
#: php/class-utils.php:1293
812812
msgid "Cloudinary global transformations"
813813
msgstr ""
814814

815-
#: php/class-utils.php:1286
815+
#: php/class-utils.php:1300
816816
#. translators: %1$s is the taxonomy label and the %2$s is the context of the
817817
#. use.
818818
msgid "%1$s %2$s transformations"
819819
msgstr ""
820820

821-
#: php/class-utils.php:1296
821+
#: php/class-utils.php:1310
822822
#. translators: %s is the term name.
823823
msgid "%s transformations"
824824
msgstr ""

package-lock.json

Lines changed: 45334 additions & 38699 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@
8080
"chart.js": "^3.5.0",
8181
"classnames": "^2.3.1",
8282
"codemirror": "^5.65.0",
83-
"coveralls": "^3.1.0",
8483
"cross-env": "^7.0.2",
8584
"css-loader": "^5.0.1",
8685
"css-minimizer-webpack-plugin": "^4.2.2",
@@ -144,5 +143,5 @@
144143
"webpack-cli": "^4.2.0",
145144
"webpackbar": "^5.0.2"
146145
},
147-
"version": "3.2.13"
146+
"version": "3.2.14"
148147
}

php/class-assets.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ class Assets extends Settings_Component {
117117
*/
118118
public function __construct( Plugin $plugin ) {
119119
parent::__construct( $plugin );
120+
$this->should_sanitize_slugs = true;
120121

121122
$this->media = $plugin->get_component( 'media' );
122123
$this->delivery = $plugin->get_component( 'delivery' );

php/class-utils.php

Lines changed: 66 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,9 @@ public static function is_admin() {
620620
* @return array
621621
*/
622622
public static function extract_urls( $content ) {
623+
// Remove inline SVG data URIs, as they can cause parsing issues when extracting URLs.
624+
$content = self::strip_inline_svg_data_uris( $content );
625+
623626
preg_match_all(
624627
"#([\"']?)("
625628
. '(?:[\w-]+:)?//?'
@@ -642,6 +645,25 @@ public static function extract_urls( $content ) {
642645
return array_values( $post_links );
643646
}
644647

648+
/**
649+
* Strip inline SVG data URIs from content.
650+
*
651+
* @param string $content The content to process.
652+
*
653+
* @return string The content with SVG data URIs removed.
654+
*/
655+
public static function strip_inline_svg_data_uris( $content ) {
656+
// Pattern to match the data URI structure: data:image/svg+xml;base64,<base64-encoded-data>.
657+
$svg_data_uri_pattern = '/data:image\/svg\+xml;base64,[a-zA-Z0-9\/\+\=]+/i';
658+
659+
// Remove all occurrences of SVG data URIs from the content.
660+
$cleaned_content = preg_replace( $svg_data_uri_pattern, '', $content );
661+
662+
// In case an error occurred, we return the original content to avoid data loss.
663+
return is_null( $cleaned_content ) ? $content : $cleaned_content;
664+
}
665+
666+
645667
/**
646668
* Is saving metadata.
647669
*
@@ -1009,19 +1031,16 @@ public static function attachment_url_to_postid( $url ) {
10091031
* @return array
10101032
*/
10111033
public static function query_relations( $public_ids, $urls = array() ) {
1012-
global $wpdb;
1013-
1014-
$wheres = array();
1015-
$searched_things = array();
1034+
$chunk_size = 25;
1035+
$results = array();
1036+
$tablename = self::get_relationship_table();
10161037

10171038
/**
10181039
* Filter the media context query.
10191040
*
10201041
* @hook cloudinary_media_context_query
10211042
* @since 3.2.0
1022-
*
10231043
* @param $media_context_query {string} The default media context query.
1024-
*
10251044
* @return {string}
10261045
*/
10271046
$media_context_query = apply_filters( 'cloudinary_media_context_query', 'media_context = %s' );
@@ -1031,43 +1050,60 @@ public static function query_relations( $public_ids, $urls = array() ) {
10311050
*
10321051
* @hook cloudinary_media_context_things
10331052
* @since 3.2.0
1034-
*
10351053
* @param $media_context_things {array} The default media context things.
1036-
*
10371054
* @return {array}
10381055
*/
10391056
$media_context_things = apply_filters( 'cloudinary_media_context_things', array( 'default' ) );
10401057

1058+
// Query for urls in chunks.
10411059
if ( ! empty( $urls ) ) {
1042-
// Do the URLS.
1043-
$list = implode( ', ', array_fill( 0, count( $urls ), '%s' ) );
1044-
$where = "(url_hash IN( {$list} ) AND {$media_context_query} )";
1045-
$searched_things = array_merge( $searched_things, array_map( 'md5', $urls ), $media_context_things );
1046-
$wheres[] = $where;
1060+
$results = array_merge( $results, self::run_chunked_query( 'url_hash', $urls, $chunk_size, $tablename, $media_context_query, $media_context_things ) );
10471061
}
1062+
// Query for public_ids in chunks.
10481063
if ( ! empty( $public_ids ) ) {
1049-
// Do the public_ids.
1050-
$list = implode( ', ', array_fill( 0, count( $public_ids ), '%s' ) );
1051-
$where = "(public_hash IN( {$list} ) AND {$media_context_query} )";
1052-
$searched_things = array_merge( $searched_things, array_map( 'md5', $public_ids ), $media_context_things );
1053-
$wheres[] = $where;
1064+
$results = array_merge( $results, self::run_chunked_query( 'public_hash', $public_ids, $chunk_size, $tablename, $media_context_query, $media_context_things ) );
10541065
}
10551066

1056-
$results = array();
1057-
1058-
if ( ! empty( array_filter( $wheres ) ) ) {
1059-
$tablename = self::get_relationship_table();
1060-
$sql = "SELECT * from {$tablename} WHERE " . implode( ' OR ', $wheres );
1061-
$prepared = $wpdb->prepare( $sql, $searched_things ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
1062-
$cache_key = md5( $prepared );
1063-
$results = wp_cache_get( $cache_key, 'cld_delivery' );
1064-
if ( empty( $results ) ) {
1065-
$results = $wpdb->get_results( $prepared, ARRAY_A );// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery
1066-
wp_cache_add( $cache_key, $results, 'cld_delivery' );
1067+
return $results;
1068+
}
1069+
/**
1070+
* Run a chunked query and merge results.
1071+
*
1072+
* @param string $field The DB field to query (url_hash or public_hash).
1073+
* @param array $items The items to query.
1074+
* @param int $chunk_size Number of items per chunk.
1075+
* @param string $tablename The table name.
1076+
* @param string $media_context_query The media context SQL.
1077+
* @param array $media_context_things The media context values.
1078+
* @return array
1079+
*/
1080+
protected static function run_chunked_query( $field, $items, $chunk_size, $tablename, $media_context_query, $media_context_things ) {
1081+
global $wpdb;
1082+
1083+
$all_results = array();
1084+
$chunks = array_chunk( $items, $chunk_size );
1085+
1086+
foreach ( $chunks as $chunk ) {
1087+
$list = implode( ', ', array_fill( 0, count( $chunk ), '%s' ) );
1088+
$where = "({$field} IN( {$list} ) AND {$media_context_query} )";
1089+
$searched_things = array_merge( array_map( 'md5', $chunk ), $media_context_things );
1090+
$sql = "SELECT * from {$tablename} WHERE {$where}";
1091+
$prepared = $wpdb->prepare( $sql, $searched_things ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
1092+
$cache_key = md5( $prepared );
1093+
$chunk_results = wp_cache_get( $cache_key, 'cld_delivery' );
1094+
1095+
if ( empty( $chunk_results ) ) {
1096+
$chunk_results = $wpdb->get_results( $prepared, ARRAY_A ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery
1097+
1098+
wp_cache_add( $cache_key, $chunk_results, 'cld_delivery' );
1099+
}
1100+
1101+
if ( ! empty( $chunk_results ) ) {
1102+
$all_results = array_merge( $all_results, $chunk_results );
10671103
}
10681104
}
10691105

1070-
return $results;
1106+
return $all_results;
10711107
}
10721108

10731109
/**

php/traits/trait-params.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ trait Params_Trait {
3030
*/
3131
public $separator = '.';
3232

33+
/**
34+
* Whether to sanitize slugs.
35+
*
36+
* @var boolean
37+
*/
38+
protected $should_sanitize_slugs = false;
39+
3340
/**
3441
* Sets the params recursively.
3542
*
@@ -77,7 +84,6 @@ protected function set_param_array( $parts, $param, $value ) {
7784
* @return $this
7885
*/
7986
public function set_param( $param, $value = null ) {
80-
8187
$sanitized_param = $this->sanitize_slug( $param );
8288
$parts = explode( $this->separator, $sanitized_param );
8389
$param = array_shift( $parts );
@@ -140,6 +146,9 @@ public function remove_param( $param ) {
140146
* @return string
141147
*/
142148
protected function sanitize_slug( $slug ) {
149+
if ( ! $this->should_sanitize_slugs || ! str_contains( $slug, $this->separator ) ) {
150+
return $slug;
151+
}
143152

144153
$sanitized = array_map( 'sanitize_file_name', explode( $this->separator, $slug ) );
145154

readme.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Contributors: Cloudinary, XWP, Automattic
33
Tags: image-optimizer, core-web-vitals, video, resize, performance
44
Requires at least: 4.7
5-
Tested up to: 6.8.2
5+
Tested up to: 6.8.3
66
Requires PHP: 5.6
77
Stable tag: STABLETAG
88
License: GPLv2
@@ -146,6 +146,15 @@ Your site is now setup to start using Cloudinary.
146146

147147
== Changelog ==
148148

149+
= 3.2.14 (22 October 2025) =
150+
151+
Fixes and Improvements:
152+
153+
* Upgraded dependencies: `form-data` and `@babel/traverse` packages updated for improved stability and security
154+
* Improved SQL queries for enhanced compatibility and performance with WP Engine environments
155+
* Improved initialization performance by optimizing the `sanitize_slug` method usage to reduce unnecessary processing
156+
* Fixed incompatibility causing broken media URLs when JetEngine dashboard styles loaded inline SVGs
157+
149158
= 3.2.13 (17 September 2025) =
150159

151160
Fixes and Improvements:

0 commit comments

Comments
 (0)