Skip to content

Migrate all ability error returns to WP_Error, fix broken chat tools#107

Merged
chubes4 merged 1 commit into
mainfrom
refactor/ability-contract-alignment
Mar 30, 2026
Merged

Migrate all ability error returns to WP_Error, fix broken chat tools#107
chubes4 merged 1 commit into
mainfrom
refactor/ability-contract-alignment

Conversation

@chubes4
Copy link
Copy Markdown
Member

@chubes4 chubes4 commented Mar 30, 2026

Summary

The largest PR in this series — migrates all 43 ability callbacks across 8 social platforms from ['success' => false, ...] to WP_Error returns, per data-machine#999.

Ability providers (35 files, 293 error returns converted)

Platform Files Instances
Instagram 5 ~65
Pinterest 6 ~40
Facebook 4 ~37
Twitter 4 ~35
Bluesky 4 ~33
Threads 4 ~32
LinkedIn 4 ~23
Reddit 4 ~28

Bug fixes

  • Fixed 13 broken chat tools that used an undefined $ability variable — would fatal at runtime. Now properly call wp_get_ability().
    • Affected: Read{Twitter,Facebook,Bluesky,Threads,Pinterest}, Update{Threads,Pinterest,Bluesky}, plus 5 others
  • Fixed 3 LinkedIn chat tools missing function_exists guards (now removed per contract — abilities are always available)

Consumer updates (45 files)

  • 57 function_exists('wp_get_ability') guards removed across CLI commands (34), RestApi (8), chat tools (15)
  • All error handling updated to is_wp_error() pattern
  • RestApi.php: Added WP_Error-to-array conversion for REST responses

80 files changed, -972 lines net.

Refs Extra-Chill/data-machine#999
Closes #105

…_exists guards

Ability providers (35 files):
- Convert all 'success' => false returns to WP_Error across 8 platforms
  (Instagram, Pinterest, Facebook, Twitter, Bluesky, Threads, LinkedIn, Reddit)
- Update return type hints to array|\WP_Error
- Standardized error codes: missing_param (400), missing_auth (401),
  not_found (404), api_error (500), invalid_action (400)

Chat tools (35 files):
- Fix 13 broken chat tools that used undefined $ability variable
  (Read/Update for Twitter, Facebook, Bluesky, Threads, Pinterest)
- Remove all function_exists('wp_get_ability') guards
- Update error handling to check is_wp_error() before $result['success']

CLI commands (9 files):
- Remove 34 function_exists guard blocks
- Update $result['success'] checks to handle WP_Error

RestApi.php:
- Remove 8 function_exists ternary guards
- Add WP_Error-to-array conversion for REST responses

Refs Extra-Chill/data-machine#999, #105
@chubes4 chubes4 merged commit 6c2e80b into main Mar 30, 2026
1 check failed
@chubes4 chubes4 deleted the refactor/ability-contract-alignment branch March 30, 2026 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Align ability callers with core WP_Ability contract

1 participant