Fix migration query and update version

This commit is contained in:
Jeremy Dormitzer 2018-10-30 16:53:17 -04:00
parent 21479922b7
commit 2d5f488e3d
2 changed files with 7 additions and 5 deletions

View File

@ -253,10 +253,11 @@ function migration_1_2_0() {
$query = "INSERT INTO {$wpdb->prefix}pterotype_objects (activitypub_id, url) VALUES";
// build values
foreach( $ids_to_urls as $activitypub_id => $url ) {
$query = $query . $wpdb->prepare( " (%s, %s) ", $activitypub_id, $url );
$query = $query . $wpdb->prepare( " (%s, %s),", $activitypub_id, $url );
}
$query = $query . "ON DUPLICATE KEY UPDATE url=VALUES(url);";
$wpdb->query( $query );
$query = substr( $query, 0, -1 );
$query = $query . " ON DUPLICATE KEY UPDATE url=VALUES(url)";
$res = $wpdb->query( $query );
// Compact existing objects so we only store 1 copy of each object
foreach( $objects as $row ) {
$object = \json_decode( $row->object, true );
@ -287,7 +288,8 @@ function migration_1_2_0() {
$wpdb->update(
"{$wpdb->prefix}pterotype_objects",
array( 'object' => wp_json_encode( $updated ) ),
array( 'activitypub_id', $row->activitypub_id )
array( 'activitypub_id' => $row->activitypub_id ),
'%s', '%s'
);
}
}

View File

@ -12,7 +12,7 @@ License URI: https://github.com/jdormit/blob/master/LICENSE
require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php';
require_once plugin_dir_path( __FILE__ ) . 'includes/init.php';
define( 'PTEROTYPE_VERSION', '1.1.2' );
define( 'PTEROTYPE_VERSION', '1.2.0' );
define( 'PTEROTYPE_BLOG_ACTOR_SLUG', '-blog' );
define( 'PTEROTYPE_BLOG_ACTOR_USERNAME', 'blog' );