Problem with publishing topic after moving to a new server

We have a WordPress site where we use Discource to log in and comment on WordPress.
Everything worked fine until we moved WordPress (which has always run on a different server) to a new IP and a different server.

Since then, we started to get articles in the classic editor that have the settings shown in the image below not getting a Discourse link even after they are automatically published.

I always have to manually go into a particular article and just translate the article, then the Discourse link is created and everything is OK

Any ideas where to look for the cause of the problem?

This image shows a dialog box or interface section related to the Discourse platform, which allows creating a new topic, linking to an existing topic, publishing a post, and selecting a category labeled "Komentáře ke článkům" (which likely means "Comments on Articles" in a language such as Czech or Slovak). (Captioned by AI)

Is anyone dropping clues as to where the problem might be?
The only mention of error I found in the log was this one, but I couldn’t manage to track down anything on this message.

[2024-06-14 06:45:38] webhook_topic.INFO: update_topic_content.update_post_metadata_success {"post_ids":"771554"} 
[2024-06-14 06:45:43] publish.INFO: create_post.post_success {"wp_title":"Konec ikonického designu. Galaxy Buds 3 dostanou zcela nový vzhled","wp_author_id":"94147","wp_post_id":771981} 
[2024-06-14 06:45:43] publish.INFO: create_post.body_valid {"wp_title":"Konec ikonického designu. Galaxy Buds 3 dostanou zcela nový vzhled","wp_author_id":"94147","wp_post_id":771981} 
[2024-06-14 06:45:43] publish.INFO: create_post.after_publish {"post_id":771981,"remote_post_type":"create_post","discourse_post_id":"10416","discourse_topic_id":"5899","discourse_permalink":"https://komunita.svetandroida.cz/t/konec-ikonickeho-designu-galaxy-buds-3-dostanou-zcela-novy-vzhled/5899"} 
[2024-06-14 06:45:43] webhook_topic.ERROR: update_topic_content.response_body_error

Probably worth searching Meta for update_topic_content.response_body_error :wink:

Hey @Petr_Mišák

Have you got an example of such a topic? The example in your logs shows that the Discourse topic was successfully published. That’s what these lines mean

[2024-06-14 06:45:43] publish.INFO: create_post.post_success {"wp_title":"Konec ikonického designu. Galaxy Buds 3 dostanou zcela nový vzhled","wp_author_id":"94147","wp_post_id":771981} 
[2024-06-14 06:45:43] publish.INFO: create_post.body_valid {"wp_title":"Konec ikonického designu. Galaxy Buds 3 dostanou zcela nový vzhled","wp_author_id":"94147","wp_post_id":771981} 
[2024-06-14 06:45:43] publish.INFO: create_post.after_publish {"post_id":771981,"remote_post_type":"create_post","discourse_post_id":"10416","discourse_topic_id":"5899","discourse_permalink":"https://komunita.svetandroida.cz/t/konec-ikonickeho-designu-galaxy-buds-3-dostanou-zcela-novy-vzhled/5899"} 

You can see a link to the successfully published topic in the last line of those logs, i.e.

"discourse_permalink":"https://komunita.svetandroida.cz/t/konec-ikonickeho-designu-galaxy-buds-3-dostanou-zcela-novy-vzhled/5899"

The webhook error you see immediately after that suggests an issue with the webhook, but it’s not necessarily indicative of an issue with publication per se.

If you could run a new test where you reproduce the issue, and have a look at the publish logs that were created, that will give us some insight as to the issue you’ve described.

Also, could you share what you mean by “translate the article”?

I always have to manually go into a particular article and just translate the article

What exactly are you doing here?

I suspect that your Discourse install might have cached the DNS entry and is using the IP address of your old WP installation. The quickest way to try that is to restart the container and see if the problem goes away.

2 Likes

The log probably shows a record from the state when I save the article manually. Sorry it was a typo, it should have said save manually.

I thought of the DNS thing too, and did the “./launcher rebuild app” right after moving WordPress to the new server, but maybe it was too early from a DNS perspective. I’ll try again then.

Sorry, just to confirm, you mean that the log is not connected to the issue with automatic publishing you’ve reported? If not, could you share a log of an automatic publishing event?

It is very difficult for me to tell from the log whether specific lines are related to the problem or not. I’ve made a few changes towards DNS and we’ll see if it helped when the next article comes out at 10 o’clock.

So the current problem is that when an article in WordPress is supposed to come out automatically at a certain time, the link to the Discourse community is not created. But when I subsequently edit the problematic article manually and just save it without any changes, the link to the Discourse community is created.

Next time an article goes out look for logs with publish.INFO or publish.ERROR with a similar timestamp and share what you find here.

1 Like

Currently, the automatically scheduled article Vaše hodinky Amazfit zřejmě budou ještě lepší! Blíží se velká aktualizace is out and still no link to Discourse

Which has the ID 772581

Unfortunately, all I see in the log since our last communication is this information.

[2024-06-21 07:09:01] connection.INFO: check_connection_status.successful_connection  
[2024-06-21 07:09:01] connection.INFO: check_connection_status.valid_scopes  
[2024-06-21 07:23:30] webhook_topic.INFO: update_topic_content.update_post_metadata_success {"post_ids":"772615"} 
[2024-06-21 07:25:57] webhook_topic.INFO: update_topic_content.update_post_metadata_success {"post_ids":"772615"} 
[2024-06-21 07:42:03] webhook_topic.INFO: update_topic_content.update_post_metadata_success {"post_ids":"772857"} 
[2024-06-21 07:47:37] sso_client.INFO: auth_user.success {"user_id":129795} 
[2024-06-21 07:48:05] sso_client.INFO: auth_user.success {"user_id":152766} 
[2024-06-21 08:04:20] webhook_topic.INFO: update_topic_content.update_post_metadata_success {"post_ids":"772857"}

Here I am sending the meta log. I couldn’t read anything in it

### This file is included in log downloads ###

### Server ###

WordPress - 6.5.4
PHP - 8.0.30
MySQL - 11.3.2

### Active Plugins ###

Advanced Google reCAPTCHA - 1.21
Allviews - 1.0.1
APS Arena Products - 2.5.5
Classic Editor - 1.6.3
Error Log Monitor - 1.7.8
FS Poster - 6.5.9
GTM4WP - A Google Tag Manager (GTM) plugin for WordPress - 1.20.2
Head, Footer and Post Injections - 3.2.8
Kontrola uploadovaných obrázků - 1.0
Limit Modified Date - 1.0.0
Lnk.Bio - 0.2.2
Lokální ukládání Gravatarů - 1.4
Lynt Custom Functions - 1.0.3
Pixwords Scenes Nápověda - 1.0.2
Rank Math SEO PRO - 3.0.64
Rank Math SEO with AI SEO Tools - 1.0.221
Redakční Tools - bez expirace - 2.0.12
SA Partner Products Feed - 1.0
Simple Local Avatars - 2.7.10
Speculative Loading - 1.3.1
Super Progressive Web Apps - 2.2.27
SZ Ad Manager API - 1.3.21
Webpushr Push Notifications - 4.36.0
WordPress Editorial Calendar - 3.8.5
WP-Appbox - 4.4.19
WP-Discourse - 2.5.3
WP-PostViews - 1.77
Wpify Performance Helper - master
WP Shortcode by MyThemeShop - 1.4.17
WP Shortcode by MyThemeShop extend by Svět Zítřka - 1.16

### WP Discourse Settings (Secrets Excluded) ###

connection-logs - 1
display-subcategories - 0
allow-tags - 0
max-tags - 5
publish-as-unlisted - 1
full-post-content - 0
custom-excerpt-length - 55
add-featured-link - 1
auto-publish - 1
force-publish - 1
force-publish-max-age - 0
publish-failure-notice - 1
auto-track - 1
allowed_post_types - post,page
exclude_tags - 
hide-discourse-name-field - 0
discourse-username-editable - 0
direct-db-publication-flags - 0
verbose-publication-logs - 1
enable-discourse-comments - 1
comment-type - display-comments-link
ajax-load - 0
load-comment-css - 0
discourse-new-tab - 0
hide-wordpress-comments - 0
show-existing-comments - 1
max-comments - 0
min-replies - 1
min-score - 0
min-trust-level - 1
bypass-trust-level-score - 50
only-show-moderator-liked - 0
custom-datetime-format - 
cache-html - 1
clear-cached-comment-html - 0
verbose-comment-logs - 1
use-discourse-webhook - 1
webhook-match-old-topics - 0
use-discourse-user-webhook - 0
webhook-match-user-email - 0
verbose-webhook-logs - 1
verbose-sso-logs - 1
enable-sso - 0
auto-create-sso-user - 0
real-name-as-discourse-name - 0
force-avatar-update - 0
redirect-without-login - 0
sso-client-enabled - 1
sso-client-login-form-change - 1
sso-client-sync-by-email - 1
sso-client-disable-create-user - 0
sso-client-sync-logout - 1
logs-enabled - 1

Ok, so your issue is the old issue of auto-publishing with scheduled posts.

The most likely cause is one of your other plugins on your site is also hooking into your scheduling system, producing the issues others have seen in the past. Looking at your plugin list, this seems like a possible candidate:

WordPress Editorial Calendar - 3.8.5

Could you try disabling that and see if the problem persists?

Thank you for the tip. I’ve filled out the plugin, and we’ll see at 12 o’clock our time if the article comes out.

But the same plugin setup was also on the previous server, where everything worked OK.

Warning: Undefined variable $status_url in /.../www/wp-content/plugins/wp-discourse/lib/sync-discourse-topic.php on line 230

Which should be this piece of code $response = $this->discourse_request( $status_url, $args );

Are you 100% sure the setups were identical? How have you verified that?

This concerns webhooks and is unrelated to your issue.

Yes the Discourse plugin setup was identical on the previous server, as both server and DB data was physically moved.

So unfortunately it wasn’t this plugin. It is currently disabled and the article that just came out linking to Discourse didn’t get Skvělý na cesty! Xiaomi vydalo maličký holicí strojek s nabíjením přes USB-C

There is nothing in the log about the article with ID 772245

But if I open the problem article manually and save it. The following appears in the log

[2024-06-21 10:13:07] publish.INFO: create_post.post_success {"wp_title":"Skvělý na cesty! Xiaomi vydalo maličký holicí strojek s nabíjením přes USB-C","wp_author_id":"150202","wp_post_id":772245} 
[2024-06-21 10:13:07] publish.INFO: create_post.body_valid {"wp_title":"Skvělý na cesty! Xiaomi vydalo maličký holicí strojek s nabíjením přes USB-C","wp_author_id":"150202","wp_post_id":772245} 
[2024-06-21 10:13:07] publish.INFO: create_post.after_publish {"post_id":772245,"remote_post_type":"create_post","discourse_post_id":"10809","discourse_topic_id":"6138","discourse_permalink":"https://komunita.svetandroida.cz/t/skvely-na-cesty-xiaomi-vydalo-malicky-holici-strojek-s-nabijenim-pres-usb-c/6138"} 
[2024-06-21 10:13:07] webhook_topic.ERROR: update_topic_content.response_body_error  
[2024-06-21 10:13:07] webhook_topic.INFO: update_topic_content.update_post_metadata_success {"post_ids":"772245"}

Could it be a problem that we run WP cron using WP CLI?

Yup, that could be it. Try scheduling a post in the Wordpress UI and see if that works.

Hmm, when we plugged in a normal cron, not just the WP CLI, everything works as it should.

But I don’t understand why this is so. Could the WordPress plugin be modified to be compatible with WP CLI as well?

Wouldn’t it help @simon

How are you calling the cron job? Note that when you call wp cron, the call is affected by any global wp parameters: Config – WP-CLI – WordPress.org. It’s possible something in your wp config is affecting how the job is handled.

This will call all scheduled WordPress cron jobs:

wp cron event run --due-now

If you’re just calling wp cron event run publish_future_post, it’s possible that events that are required by the WP Discourse plugin to publish a post aren’t being triggered. I think this is the equivalent to how WordPress deals internally with scheduled posts:

wp cron event run publish_future_post future_to_publish publish_post transition_post_status

I haven’t tested this. I’m setting up a new computer and haven’t got WordPress site on it yet. I’ll do that soon.

2 Likes