Skip to content

Commit 506f8e2

Browse files
author
Marco Pereirinha
committed
Merge branch 'develop' into uat
2 parents dc35023 + 6f235bc commit 506f8e2

26 files changed

+160
-109
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
},
99
"require-dev": {
1010
"wp-coding-standards/wpcs": "^2.3",
11-
"automattic/vipwpcs": "^2.2",
11+
"automattic/vipwpcs": "dev-develop",
1212
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
13-
"phpcompatibility/phpcompatibility-wp": "^2.1",
13+
"phpcompatibility/phpcompatibility-wp": "dev-master",
1414
"phpcompatibility/php-compatibility": "dev-develop as 9.99.99"
1515
},
1616
"config": {

composer.lock

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

package-lock.json

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

php/cache/class-cache-point.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -869,9 +869,13 @@ public function query_cached_items( $urls ) {
869869
foreach ( $indexes as $key ) {
870870
$url = $urls[ $key ];
871871

872-
if ( ! isset( $meta[ self::META_KEYS['cached_urls'] ][ $url ] )
873-
|| $url === $meta[ self::META_KEYS['cached_urls'] ][ $url ]
874-
&& $meta[ self::META_KEYS['last_updated'] ] < time() - MINUTE_IN_SECONDS * 10 ) {
872+
if (
873+
! isset( $meta[ self::META_KEYS['cached_urls'] ][ $url ] )
874+
|| (
875+
$url === $meta[ self::META_KEYS['cached_urls'] ][ $url ]
876+
&& $meta[ self::META_KEYS['last_updated'] ] < time() - MINUTE_IN_SECONDS * 10
877+
)
878+
) {
875879
// Send to upload prep.
876880
$this->prepare_for_sync( $post->ID );
877881
$meta[ self::META_KEYS['cached_urls'] ][ $url ] = $url;
@@ -972,6 +976,6 @@ protected function register_post_type() {
972976
'rewrite' => false,
973977
'capability_type' => 'page',
974978
);
975-
$this->post_type = register_post_type( self::POST_TYPE_SLUG, $args );
979+
$this->post_type = register_post_type( self::POST_TYPE_SLUG, $args ); // phpcs:ignore WordPress.NamingConventions.ValidPostTypeSlug.NotStringLiteral
976980
}
977981
}

php/class-assets.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1156,7 +1156,7 @@ protected function register_post_type() {
11561156
'rewrite' => false,
11571157
'capability_type' => 'page',
11581158
);
1159-
$this->post_type = register_post_type( self::POST_TYPE_SLUG, $args );
1159+
$this->post_type = register_post_type( self::POST_TYPE_SLUG, $args ); // phpcs:ignore WordPress.NamingConventions.ValidPostTypeSlug.NotStringLiteral
11601160
}
11611161

11621162
/**

php/class-media.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ public function maybe_file_exist_in_url( $url ) {
356356
if ( ! filter_var( $url, FILTER_VALIDATE_URL ) ) {
357357
return false;
358358
}
359+
// phpcs:disable WordPress.WP.AlternativeFunctions
359360
$ch = curl_init( $url );
360361
curl_setopt( $ch, CURLOPT_NOBODY, true );
361362
curl_exec( $ch );
@@ -368,6 +369,7 @@ public function maybe_file_exist_in_url( $url ) {
368369
}
369370

370371
curl_close( $ch );
372+
// phpcs:enable
371373

372374
return $status;
373375
}
@@ -990,8 +992,8 @@ public function get_transformations( $attachment_id, $transformations = array(),
990992
*/
991993
public function get_crop_transformations( $attachment_id, $size ) {
992994
static $transformations = array();
993-
$size_dim = $size['width'] . 'x' . $size['height'];
994-
$key = $attachment_id . $size_dim;
995+
$size_dim = $size['width'] . 'x' . $size['height'];
996+
$key = $attachment_id . $size_dim;
995997
if ( empty( $transformations[ $key ] ) ) {
996998

997999
if ( empty( $size['transformation'] ) ) {
@@ -3033,13 +3035,15 @@ public function apply_media_library_filters( $query ) {
30333035
if ( SYNC::META_KEYS['unsynced'] === $request ) {
30343036
global $wpdb;
30353037
$wpdb->cld_table = Utils::get_relationship_table();
3036-
$result = $wpdb->get_col( "SELECT post_id FROM $wpdb->cld_table WHERE public_id IS NULL" );
3038+
$result = $wpdb->get_col( "SELECT post_id FROM $wpdb->cld_table WHERE public_id IS NULL" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching
30373039

3040+
// phpcs:disable WordPressVIPMinimum.Hooks.PreGetPosts.PreGetPosts
30383041
if ( ! empty( $result ) ) {
30393042
$query->set( 'post__in', $result );
30403043
} else {
30413044
$query->set( 'post__in', array( 0 ) );
30423045
}
3046+
// phpcs:enable
30433047
}
30443048
}
30453049
}

php/class-plugin.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ final class Plugin {
8282
*/
8383
public $dir_url;
8484

85+
/**
86+
* The plugin file.
87+
*
88+
* @var string
89+
*/
90+
protected $plugin_file;
91+
8592
/**
8693
* Directory in plugin containing autoloaded classes.
8794
*
@@ -190,7 +197,7 @@ private function get_settings_page_structure() {
190197

191198
foreach ( $parts as $slug => $part ) {
192199
if ( file_exists( $this->dir_path . "ui-definitions/settings-{$slug}.php" ) ) {
193-
$parts[ $slug ] = include $this->dir_path . "ui-definitions/settings-{$slug}.php";
200+
$parts[ $slug ] = include $this->dir_path . "ui-definitions/settings-{$slug}.php"; // phpcs:ignore WordPressVIPMinimum.Files.IncludingFile.UsingVariable
194201
}
195202
}
196203

php/class-report.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ static function( &$row ) {
223223
"SELECT * FROM {$wpdb->cld_table} WHERE post_id = %d;",
224224
$post->ID
225225
);
226-
$relationship = $wpdb->get_row( $prepare ); // phpcs:ignore WordPress.DB.PreparedSQL
226+
$relationship = $wpdb->get_row( $prepare ); // phpcs:ignore WordPress.DB.PreparedSQL,WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching
227227

228228
ksort( $attachment );
229229
ksort( $meta );

php/class-string-replace.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public function init_debug( $template ) {
168168
if ( defined( 'CLD_DEBUG' ) && true === CLD_DEBUG && ! Utils::get_sanitized_text( '_bypass' ) ) {
169169
$this->context = 'view';
170170
ob_start();
171-
include $template;
171+
include $template; // phpcs:ignore WordPressVIPMinimum.Files.IncludingFile.UsingVariable
172172
$html = ob_get_clean();
173173
echo $this->replace_strings( $html ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
174174
$template = $this->plugin->template_path . 'blank-template.php';

php/class-utils.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ public static function pathinfo( $path, $flags = 15 ) {
500500
*
501501
* @see wp-includes/formatting.php
502502
*/
503-
$path = str_replace( array( '%2F', '%5C' ), '/', urlencode( $path ) );
503+
$path = str_replace( array( '%2F', '%5C' ), '/', urlencode( $path ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.urlencode_urlencode
504504

505505
$pathinfo = pathinfo( $path, $flags );
506506

@@ -914,4 +914,28 @@ public static function get_registered_sizes( $attachment_id = null ) {
914914
*/
915915
return apply_filters( 'cloudinary_registered_sizes', $all_sizes );
916916
}
917+
918+
/**
919+
* Get the attachment ID from the attachment URL.
920+
*
921+
* @param string $url The attachment URL.
922+
*
923+
* @return int
924+
*/
925+
public static function attachment_url_to_postid( $url ) {
926+
$key = "postid_{$url}";
927+
928+
if ( function_exists( 'wpcom_vip_attachment_url_to_postid' ) ) {
929+
$attachment_id = wpcom_vip_attachment_url_to_postid( $url );
930+
} else {
931+
$attachment_id = wp_cache_get( $key, 'cloudinary' );
932+
}
933+
934+
if ( empty( $attachment_id ) ) {
935+
$attachment_id = attachment_url_to_postid( $url ); // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.attachment_url_to_postid_attachment_url_to_postid
936+
wp_cache_set( $key, $attachment_id, 'cloudinary' );
937+
}
938+
939+
return $attachment_id;
940+
}
917941
}

0 commit comments

Comments
 (0)