BUG hook on transition_post_status throws errors

3.06K viewsUpdates

Not sure you are in Slack, I’ll report it here. After updating from 2.4.4 to 2.4.5 latest, my transfer script is throwing errors. I traced it down to a new method:

$ap->add_action( 'transition_post_status',  $this, 'change_activity_status', 10, 3 );

	 * Update status of activities if parent status get updated.
	 * @param  string $new_status New status of post.
	 * @param  string $old_status Previous status of post.
	 * @param  object $post       Post object.
	public function change_activity_status( $new_status, $old_status, $post ) {
		if ( 'question' == $post->post_type ) {
			ap_update_activities( array( 'question_id' => $post->ID, 'parent_type' => 'post' ) , array( 'status' => $new_status ) );
		} elseif ( 'answer' == $post->post_type ) {
			ap_update_activities( array( 'answer_id' => $post->ID, 'parent_type' => 'post' ) , array( 'status' => $new_status ) );

Happens when adding answers. Error is

<p class="wpdberror"><strong>Ошибка базы данных WordPress:</strong> [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1]<br /><code>UPDATE `wp_ap_activity` SET `status` = 'publish' WHERE </code></p></div>

Looks like “where” is not set.

More bugs in latest, like upvotes giving 2 rep and counters turn into (serialize) strings instead of numbers.
Ok my bad I’ll stick to wordpress release 🙂

Thanks for letting me know, I will check this issue.

Which counter?

Total votes count, meta stored in usermeta. Can’t be sure it’s your code fault, didn’t had time to really debug.
With 2.4.4 nothing like that happens and I’m living happily for now 🙂