Skip to content

Commit 6e5cb57

Browse files
authored
Address some of things found in #633 (#634)
* Address some of things found in #633 * Improve "state"
1 parent 4c297ac commit 6e5cb57

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

includes/collection/class-interactions.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ function () {
102102
*
103103
* @param array $activity The activity-object
104104
*
105-
* @return array|false The commentdata or false on failure
105+
* @return array|string|int|\WP_Error|false The commentdata or false on failure
106106
*/
107107
public static function update_comment( $activity ) {
108108
$meta = get_remote_metadata_by_actor( $activity['actor'] );
@@ -135,14 +135,18 @@ function () {
135135
);
136136
\add_filter( 'wp_kses_allowed_html', array( self::class, 'allowed_comment_html' ), 10, 2 );
137137

138-
$comment = \wp_update_comment( $commentdata, true );
138+
$state = \wp_update_comment( $commentdata, true );
139139

140140
\remove_filter( 'wp_kses_allowed_html', array( self::class, 'allowed_comment_html' ), 10 );
141141
\remove_filter( 'pre_option_require_name_email', '__return_false' );
142142
// re-add flood control
143143
\add_action( 'check_comment_flood', 'check_comment_flood_db', 10, 4 );
144144

145-
return $comment;
145+
if ( 1 === $state ) {
146+
return $commentdata;
147+
} else {
148+
return $state; // Either `false` or a `WP_Error` instance or `0` or `1`!
149+
}
146150
}
147151

148152
/**

includes/handler/class-update.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,14 @@ public static function handle_update( $array ) {
6666
* @return void
6767
*/
6868
public static function update_interaction( $activity ) {
69-
$state = Interactions::update_comment( $activity );
70-
$reaction = null;
69+
$commentdata = Interactions::update_comment( $activity );
70+
$reaction = null;
7171

72-
if ( $state && ! \is_wp_error( $reaction ) ) {
73-
$reaction = \get_comment( $state );
72+
if ( ! empty( $commentdata['comment_ID'] ) ) {
73+
$state = 1;
74+
$reaction = \get_comment( $commentdata['comment_ID'] );
75+
} else {
76+
$state = $commentdata;
7477
}
7578

7679
\do_action( 'activitypub_handled_update', $activity, null, $state, $reaction );

0 commit comments

Comments
 (0)