Skip to content

Commit

Permalink
flush cache and fix db-table-key
Browse files Browse the repository at this point in the history
  • Loading branch information
pfefferle committed Jun 12, 2023
1 parent c2db856 commit 6e4ed42
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions docker-compose-test.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
version: '2'
services:
test-db:
image: mysql:5.7
platform: linux/x86_64
image: mysql:5.7
environment:
MYSQL_DATABASE: webmention-test
MYSQL_ROOT_PASSWORD: webmention-test
Expand All @@ -15,4 +15,4 @@ services:
- test-db
volumes:
- .:/app
command: ["composer", "run-script", "test"]
command: ["composer", "run-script", "test"]
9 changes: 7 additions & 2 deletions includes/class-db.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ public static function update_options_key( $old, $new ) {
* @return void
*/
public static function migrate_to_1_0_0() {
wp_cache_flush();

// 1. rename comment meta
self::update_commentmeta_key( 'semantic_linkbacks_source', 'webmention_source_url' );
self::update_commentmeta_key( 'semantic_linkbacks_avatar', 'avatar' );
Expand All @@ -121,6 +123,8 @@ public static function migrate_to_1_0_0() {
* @return void
*/
public static function migrate_to_1_0_1() {
wp_cache_flush();

$comments = get_comments(
array(
'fields' => 'ids',
Expand All @@ -136,13 +140,14 @@ public static function migrate_to_1_0_1() {
),
)
);

foreach ( $comments as $comment_id ) {
$author = get_comment_meta( $comment_id, 'mf2_author', true );
$source = get_comment_meta( $comment_id, 'webmention_source_url', true );
if ( is_array( $author ) ) {
if ( array_key_exists( 'url', $author ) && ( $source !== $author['url'] ) ) {
$comment = get_comment( $comment_id, ARRAY_A );
$comment['author_url'] = $author['url'];
$comment = get_comment( $comment_id, ARRAY_A );
$comment['comment_author_url'] = $author['url'];
wp_update_comment( $comment );
}
}
Expand Down
1 change: 1 addition & 0 deletions tests/test-db.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public function test_update_database() {
'semantic_linkbacks_source' => 'https://example.org/source',
'semantic_linkbacks_avatar' => 'https://example.org/avatar',
'semantic_linkbacks_canonical' => 'https://example.org/canonical',
'semantic_linkbacks_author_url' => 'https://example.org/author_url',
'semantic_linkbacks_type' => 'reply',
'mf2_author' => array(
'name' => 'Test',
Expand Down

0 comments on commit 6e4ed42

Please sign in to comment.