Skip to content

fix: guard post signup tracking without post object#1420

Open
superdav42 wants to merge 2 commits into
mainfrom
fix/post-signup-null-post
Open

fix: guard post signup tracking without post object#1420
superdav42 wants to merge 2 commits into
mainfrom
fix/post-signup-null-post

Conversation

@superdav42

@superdav42 superdav42 commented Jun 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Accept a missing WordPress post object in post-signup activity tracking.
  • Bail before reading post fields when transition_post_status fires after a failed post insert.
  • Add regression coverage for the null-post hook argument and update stale test method references.

Verification

  • php -l inc/managers/class-post-signup-activity-manager.php && php -l tests/WP_Ultimo/Managers/Post_Signup_Activity_Manager_Test.php
  • vendor/bin/phpcs inc/managers/class-post-signup-activity-manager.php tests/WP_Ultimo/Managers/Post_Signup_Activity_Manager_Test.php
  • git diff --check -- inc/managers/class-post-signup-activity-manager.php tests/WP_Ultimo/Managers/Post_Signup_Activity_Manager_Test.php
  • vendor/bin/phpunit --filter Post_Signup_Activity_Manager_Test could not run locally because /tmp/wordpress-tests-lib/includes/functions.php is not installed.

aidevops.sh v3.20.58 plugin for OpenCode v1.17.4 with gpt-5.5 spent 21m and 237,343 tokens on this with the user in an interactive session.

Summary by CodeRabbit

  • Bug Fixes

    • Improved robustness when handling post objects that fail to load from the database, preventing potential errors.
  • Tests

    • Expanded test coverage to verify proper handling of edge cases and null post scenarios.

@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7fe144c4-586f-4bb2-9744-4240fadec6a3

📥 Commits

Reviewing files that changed from the base of the PR and between 651407e and 06ab93e.

📒 Files selected for processing (2)
  • inc/managers/class-post-signup-activity-manager.php
  • tests/WP_Ultimo/Managers/Post_Signup_Activity_Manager_Test.php

📝 Walkthrough

Walkthrough

The track_post_published method signature is updated to accept a nullable ?\WP_Post parameter, with an early guard to handle null posts. All test methods are renamed and invocations updated to align with the new parameter type and method semantics.

Changes

Nullable post parameter and safety guard

Layer / File(s) Summary
Nullable post parameter and guard
inc/managers/class-post-signup-activity-manager.php
The track_post_published method updates its third parameter from required \WP_Post to nullable ?\WP_Post. PHPDoc is updated, and an early return guard (if ( ! $post) return;) prevents property access on null posts.
Test updates for nullable parameter
tests/WP_Ultimo/Managers/Post_Signup_Activity_Manager_Test.php
Test method names are renamed from on_post_published_* to track_post_published_*. Test invocations are updated to call track_post_published(...) with the same parameters. A new test_track_post_published_ignores_null_post() test validates that null posts do not create events. Docblocks are updated for consistency across all test methods.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A null post arrives without a fret,
The guard catches it, no need to sweat,
Tests renamed true to match the way,
Safe code wins the dev's day! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: making post signup tracking handle cases where the post object is null/missing, which is the core fix in this PR.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/post-signup-null-post

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@superdav42 superdav42 added the origin:interactive Created by interactive user session label Jun 13, 2026
@github-actions

Copy link
Copy Markdown

🔨 Build Complete - Ready for Testing!

📦 Download Build Artifact (Recommended)

Download the zip build, upload to WordPress and test:

🌐 Test in WordPress Playground (Very Experimental)

Click the link below to instantly test this PR in your browser - no installation needed!
Playground support for multisite is very limitied, hopefully it will get better in the future.

🚀 Launch in Playground

Login credentials: admin / password

@github-actions

Copy link
Copy Markdown

🔨 Build Complete - Ready for Testing!

📦 Download Build Artifact (Recommended)

Download the zip build, upload to WordPress and test:

🌐 Test in WordPress Playground (Very Experimental)

Click the link below to instantly test this PR in your browser - no installation needed!
Playground support for multisite is very limitied, hopefully it will get better in the future.

🚀 Launch in Playground

Login credentials: admin / password

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

origin:interactive Created by interactive user session

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant