Skip to content

Instant Sharing queue: stale entries never expire and drain oldest-first, batch size broken by ignored numberposts, edits of old posts re-queue by default #1102

Description

@milicavs

Summary

Posts queued for Instant Sharing (rop_publish_now_status = queued) are stored indefinitely with no staleness check. If the queue is not consumed promptly (dead/irregular WP-cron — common on shared hosting), entries accumulate for months. When cron later recovers, the consumer drains the backlog oldest-modified first, blasting months-old articles to every connected account, while newly published posts wait at the tail of the line and do not share at publish time. Three distinct defects compound this (details below).

Related to but distinct from #1101 — same customer site; #1101 covers the recurring queue, this covers the Instant Sharing path, which turned out to be the primary cause of the customer's "old posts shared / new posts not shared" report.

Customer context

Source: HelpScout #3393452110 (reportersatlarge.com — news site, 8 Facebook pages)
Versions: Revive Social 9.4.0, Pro Add-on 3.3.3, WordPress 7.0.2, PHP 8.3.30
Impact: Facebook pages flooded with Oct 2025–Feb 2026 articles on a breaking-news brand; articles published now do not share on publish.

Field evidence (runtime, customer site, 2026-07-30)

  • Sharing Log bursts group exactly by post modified date: 06:29 UTC burst = posts modified Feb 6–7; 08:13 = Feb 8; 08:48 = Feb 9 — the fingerprint of get_publish_now_posts() (orderby modified, ASC). Example: "Ayinke Alagbo…" published 2025-12-18, modified 2026-02-09, shared 2026-07-30 08:50 to multiple pages.
  • Via public REST (rop_publish_now* meta is show_in_rest): ≥77 posts still queued with modified dates Feb–Apr 2026, plus 37 queued from Jul 22–30 (count incomplete; May–Jul not walked). Zero done entries existed before the drain began, i.e. Instant Sharing had never executed on this site.
  • The recurring schedule on the same site shares correctly (0–3 day window respected), confirming the stale shares come from the publish-now path.

Defects

  1. No staleness guard on the publish-now queue. includes/admin/models/class-rop-posts-selector-model.phpget_publish_now_posts() (~L813–836) selects rop_publish_now = yes + rop_publish_now_status = queued ordered by modified ASC, with no cutoff. An entry queued in February is treated the same as one queued 10 seconds ago. rop_publish_now_history already stores a timestamp per queue event that could be used for expiry.
  2. Batch size silently broken. The same query passes 'numberposts' => 300 to WP_Query, which ignores that parameter (it's a get_posts() arg). The effective batch is the site's posts_per_page (~5–10), so the drain crawls and fresh posts stay behind the backlog indefinitely.
  3. Editing an old post re-queues it by default. maybe_publish_now() (includes/admin/class-rop-admin.php ~L922–1029) runs on wp_after_insert_post for any save of a published post, and with instant_share_default enabled (plugin default) the metabox checkbox is pre-checked — so routine edits of archive content queue full re-shares to all accounts. This is how the customer's February backlog was created.
  4. Minor: build_queue_publish_now() (includes/admin/models/class-rop-queue-model.php L360–389) skips entries whose rop_publish_now_accounts is empty via continue without clearing rop_publish_now_status, leaving permanent queued orphans in the query window.

Reproduction

  1. Fresh site, connect ≥1 account, enable Instant Sharing (+ By Default). Disable WP-cron (DISABLE_WP_CRON, no real cron) to simulate a stalled site.
  2. Publish or edit several posts on different days — each gets rop_publish_now_status = queued.
  3. Re-enable cron and publish one new post.
  4. Observe: the old entries share first (oldest modified first), ~one posts_per_page batch per drain event; the new post shares only after the entire backlog drains. With enough backlog, "share on publish" is effectively dead while months-old content floods the accounts.

Suggested direction

  • Expire or skip queue entries older than a threshold (e.g. 1 hour) using the existing history timestamp; optionally log "skipped N stale instant-share entries".
  • Replace numberposts with posts_per_page.
  • Only queue on transition to publish (or default the checkbox to unchecked when editing an already-published post).
  • Clear rop_publish_now_status when an entry is skipped for missing accounts.

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions