The Events Calendar Error: “count(): Argument #1 must be of type Countable|array, int given” (Tribe/Error.php:159)

If your WordPress admin is throwing a fatal error like count(): Argument #1 must be of type Countable|array, int given in the-events-calendar/common/src/Tribe/Error.php, it’s usually triggered while The Events Calendar is rendering an admin notice, often tied to Event Aggregator imports. Below is a quick way to get back into wp‑admin, plus a thorough fix that won’t require editing plugin files.

I’m getting a fatal error from The Events Calendar that says:

Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, int given in /wp-content/plugins/the-events-calendar/common/src/Tribe/Error.php:159

It started after updates. I use Event Aggregator and now I can’t even open some admin screens. How can I fix this?

Here’s a safe, step‑by‑step fix. Start with recovery (so you can access wp‑admin), then apply permanent steps.

Quick recovery (copy–paste)

  1. Regain access via WP‑CLI (if the admin is crashing):
wp plugin deactivate the-events-calendar
wp plugin activate the-events-calendar
wp plugin update the-events-calendar --force

If you use companion plugins (Events Calendar Pro, Event Tickets, Filter Bar), update them together so their “Common” library matches:

wp plugin update events-calendar-pro event-tickets --force

Why this happens

The error is thrown by the plugin’s error/notice system (Tribe__Error) when it tries to count() something that should be an array but isn’t. This commonly occurs while Event Aggregator is building a service message or real‑time import queue notice in the admin; a non‑array value bubbles into the error stack and triggers count() on an int.

Permanent fix (do these in order)

1) Update TEC + companions to the latest

Ensure The Events Calendar and any related Modern Tribe/TEC add‑ons are fully up to date so the shared “Common” library versions align. Mismatched versions can produce notice/queue issues.

wp plugin update the-events-calendar events-calendar-pro event-tickets --force

2) Pause Aggregator imports and clear its state

  1. Go to Events → Settings → Imports.
  2. Check Disable Event Aggregator imports and click Save (this prevents new notices from firing while you fix things).
  3. Click Stop current processes to clear any stuck async queues.
  4. Visit Events → Imports → Scheduled Imports and temporarily pause each schedule.

3) Clear Aggregator cache/transients (optional but helpful)

You can clear TEC Aggregator transients to reset limits and cached service data:

# Cautious approach: delete only TEC-related transients by key if you know them
wp transient delete tribe-aggregator-limit-used_$(date +%Y%m%d) 2>/dev/null || true

# Broad approach: wipe all transients if the site is a safe staging copy
# wp transient delete --all

4) Re-enable imports and test

  1. In Events → Settings → Imports, uncheck Disable Event Aggregator imports.
  2. Resume a single Scheduled Import and run it manually to verify there are no fatal errors.

5) If the error persists, check conflicts

  • Temporarily switch themes (to a default theme) and retry a manual import.
  • Temporarily disable non‑TEC plugins and re‑enable them in batches to identify interference with admin notices or REST requests used by imports.

6) Last‑resort mitigation: throttle or disable notice rendering during imports

If admin notices still trigger fatals, keep imports disabled while you update/triage. You can continue with manual CSV imports as needed until a plugin update resolves the issue. Avoid editing TEC core files.

Verification checklist

  • No more fatal on wp‑admin screens (e.g., Events → Import or Posts list).
  • Manual import runs without errors; Aggregator status shows success.
  • Re‑enabled schedules run on the next cron tick without fatals.

Prevention tips

  • Update TEC + companions together to keep the shared Common library in sync.
  • Leave “Disable imports” checked on production while you test new plugin updates in staging.
  • Monitor WP‑Cron (or run a real server cron) so scheduled imports don’t pile up and surface a flood of notices at once.

Need help?

Still stuck? Pause imports, keep the public calendar visible, and consider a short professional triage, especially if this is impacting a high‑traffic events site.

Need human WordPress help?

WP Assistant is a free tool created by Atiba Software, a WordPress design and development company located in Nashville, TN. If you need more personalized WordPress assistance let us know, and we’ll get back to you ASAP!