Skip to content

Commit a7e7bb4

Browse files
Merge pull request #1114 from cloudinary/prepare-upgrade-logic-3.3
Prepare upgrade logic 3.3.0
2 parents 12e1e5e + 07e8f41 commit a7e7bb4

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

php/class-utils.php

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,9 @@ protected static function get_upgrade_sequence() {
376376
'range' => array( '3.0.1', '3.1.9' ),
377377
'method' => array( 'Cloudinary\Utils', 'upgrade_3_1_9' ),
378378
),
379-
'3.2.15' => array(
380-
'range' => array( '3.1.9', '3.2.15' ),
381-
'method' => array( 'Cloudinary\Utils', 'upgrade_3_2_15' ),
379+
'3.3.0' => array(
380+
'range' => array( '3.1.9', '3.3.0' ),
381+
'method' => array( 'Cloudinary\Utils', 'upgrade_3_3_0' ),
382382
),
383383

384384
);
@@ -459,14 +459,35 @@ public static function upgrade_3_1_9() {
459459
* Upgrade DB from v3.1.9 to v3.2.15.
460460
* Adds columns for overlay data.
461461
*/
462-
public static function upgrade_3_2_15() {
462+
public static function upgrade_3_3_0() {
463463
global $wpdb;
464464
$tablename = self::get_relationship_table();
465465

466466
// Add new columns for overlays.
467467
$wpdb->query( "ALTER TABLE {$tablename} ADD COLUMN `text_overlay` TEXT DEFAULT NULL AFTER `transformations`" ); // phpcs:ignore WordPress.DB
468468
$wpdb->query( "ALTER TABLE {$tablename} ADD COLUMN `image_overlay` TEXT DEFAULT NULL AFTER `text_overlay`" ); // phpcs:ignore WordPress.DB
469469

470+
// Update sample.jpg to leather_bag.jpg in media_display settings.
471+
$media_display = get_option( 'cloudinary_media_display', array() );
472+
473+
if ( ! empty( $media_display ) && is_array( $media_display ) ) {
474+
$updated = false;
475+
$fields = array( 'image_preview', 'lazyload_preview', 'breakpoints_preview' );
476+
477+
foreach ( $fields as $field ) {
478+
if ( isset( $media_display[ $field ] ) && is_string( $media_display[ $field ] ) ) {
479+
if ( false !== strpos( $media_display[ $field ], 'sample.jpg' ) ) {
480+
$media_display[ $field ] = str_replace( 'sample.jpg', 'leather_bag.jpg', $media_display[ $field ] );
481+
$updated = true;
482+
}
483+
}
484+
}
485+
486+
if ( $updated ) {
487+
update_option( 'cloudinary_media_display', $media_display );
488+
}
489+
}
490+
470491
// Set DB Version.
471492
update_option( Sync::META_KEYS['db_version'], get_plugin_instance()->version );
472493
}

0 commit comments

Comments
 (0)