Skip to content

Commit 6210615

Browse files
authored
Migration: flush post caches (#1181)
* Migration: flush post caches for Followers after meta renaming
1 parent 2f347b1 commit 6210615

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Fixed
1111

1212
* More robust handling of `_activityPubOptions` in scripts, using a `useOptions()` helper.
13+
* Flush post caches after Followers migration.
1314

1415
### Added
1516

activitypub.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: ActivityPub
44
* Plugin URI: https://github.com/Automattic/wordpress-activitypub
55
* Description: The ActivityPub protocol is a decentralized social networking protocol based upon the ActivityStreams 2.0 data format.
6-
* Version: 4.7.1
6+
* Version: 4.7.2
77
* Author: Matthias Pfefferle & Automattic
88
* Author URI: https://automattic.com/
99
* License: MIT
@@ -19,7 +19,7 @@
1919

2020
use WP_CLI;
2121

22-
\define( 'ACTIVITYPUB_PLUGIN_VERSION', '4.7.1' );
22+
\define( 'ACTIVITYPUB_PLUGIN_VERSION', '4.7.2' );
2323

2424
// Plugin related constants.
2525
\define( 'ACTIVITYPUB_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );

includes/class-migration.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ public static function maybe_migrate() {
164164
if ( \version_compare( $version_from_db, '4.7.1', '<' ) ) {
165165
self::migrate_to_4_7_1();
166166
}
167+
if ( \version_compare( $version_from_db, '4.7.2', '<' ) ) {
168+
self::migrate_to_4_7_2();
169+
}
167170

168171
/**
169172
* Fires when the system has to be migrated.
@@ -410,6 +413,20 @@ public static function migrate_to_4_7_1() {
410413
}
411414
}
412415

416+
/**
417+
* Clears the post cache for Followers, we should have done this in 4.7.1 when we renamed those keys.
418+
*/
419+
public static function migrate_to_4_7_2() {
420+
global $wpdb;
421+
// phpcs:ignore WordPress.DB
422+
$followers = $wpdb->get_col(
423+
$wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_type = %s", Followers::POST_TYPE )
424+
);
425+
foreach ( $followers as $id ) {
426+
clean_post_cache( $id );
427+
}
428+
}
429+
413430
/**
414431
* Update comment counts for posts in batches.
415432
*

readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ For reasons of data protection, it is not possible to see the followers of other
137137
* Added: Support for WPML post locale
138138
* Removed: Built-in support for nodeinfo2. Use the [NodeInfo plugin](https://wordpress.org/plugins/nodeinfo/) instead.
139139
* Fixed: More robust handling of `_activityPubOptions` in scripts, using a `useOptions()` helper.
140+
* Fixed: Flush post caches after Followers migration.
140141

141142
= 4.7.1 =
142143

0 commit comments

Comments
 (0)