Add social preview and stats summary endpoints#47781
Conversation
Adds a new `/jetpack-review-pr` command that reviews Jetpack pull requests for bugs, security, performance, convention compliance, backward compatibility, accessibility, translations, and test quality. Key features: - Three depth levels (quick ~30-60s, standard ~2-4min, thorough ~10-15min) - Auto-detects depth from PR size, with security-sensitive file detection - User can override depth explicitly - Checks Jetpack-specific conventions: changelog, $$next-version$$, naming, CSS logical properties, package reuse, PHP/WP version compatibility - Reviews backward compat: flags removed public API as [blocker] - Reviews HTML structure, a11y, RTL, translations, copy consistency - Runs tests and phan in isolated git worktree (thorough mode) - Compact output for clean/small PRs, full output for complex reviews - Every finding has [blocker]/[suggestion] prefix and GitHub permalink Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Remove Edit from allowed-tools (read-only skill) - Narrow git permissions to specific subcommands - Add missing tool patterns (grep, timeout, mktemp) - Add .agents/ to docs/CI skip list with user override - Add fail-fast error handling for gh commands - Improve worktree setup with stale cleanup and failure messaging - Soften CSS logical properties to preference, not ban - Reframe wp_get_environment_type() as config, not spoofable - Allow simple inline HTML in translation strings with wp_kses() - Fix grammar in copy review instruction - Add plugin main file discovery hint - Expand PHP compat traps list (str_contains, readonly classes, etc.) - Fix glob depth for cross-project dependency check - Add timeout exit code handling (0, 124, other) - Replace numeric scoring with clear severity criteria - Use safe git branch -d and surface cleanup errors - Fix quick depth timing in command file Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! Jetpack plugin: The Jetpack plugin has different release cadences depending on the platform:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@copilot review this PR. |
|
@claude review this PR. |
|
Claude finished @enejb's task in 2m 12s —— View job PR Review: Add social preview and stats summary endpoints
This PR adds a social preview UI section and two new REST API endpoints. Several significant security, correctness, and style issues are present. Details below. 🔴 Critical Issues1. XSS vulnerability — this.previewRef.current.innerHTML = customMessage;Setting 2. Unauthenticated purge endpoint — 'permission_callback' => '__return_true',The The 3. wp_cache_flush();This flushes all cached data site-wide, not just stats transients. On any non-trivial site (especially with a persistent object cache like Redis/Memcached), this is a severe performance hit that will affect all visitors immediately after the call. Remove this line; deleting the specific transients on lines 161–163 is sufficient. 🟠 High-Severity Issues4. Full user object and all post meta exposed in API response — lines 216–223 'meta' => $all_meta,
'author' => get_userdata( get_post_field( 'post_author', $post_id ) ),
Similarly, Both fields should be replaced with the minimum needed (e.g., 5. <button type="button" className="jp-form-button" onClick={ this.handleEnablePreview }>
🟡 Medium Issues6. Querying all published posts of a given type across a potentially wide date range with no limit can exhaust memory on large sites. Add a reasonable 7. Missing date format validation — lines 185–186
8.
This method should either be completed or removed from this PR. 9. The comment says "historical stats don't change" but that's not guaranteed — stats can be recalculated, posts can be updated, etc. A 1-year TTL means stale data will be served for up to a year. Consider a much shorter TTL (e.g., 1 hour) or tie cache invalidation to post updates. 🔵 Low / Style Issues10. Social preview styles in The new 11.
12. Hardcoded colour values
13. Social Preview section renders when module is inactive — The social preview 14. Changelog format The changelog entry is valid, but consider separating the PHP and JSX changes into individual entries for better granularity if these features could ship independently. Summary
The three critical issues should be resolved before merge. The skill/command file migration ( |
Auto-upgraded to thorough — diff contains Review depth: thorough (~210 lines, 1 project — PR Review: Add social preview and stats summary endpointsSummaryThe PR adds a social preview UI section to the Publicize settings page and two new REST endpoints ( Affected Projects
PR DescriptionLooks structurally complete. One inconsistency: the "Generate changelog entries (using AI)" checkbox is checked, yet a changelog file was already committed manually — both should not be done at the same time. Changelog[blocker] The Jetpack plugin uses custom changelog types ( Convention Issues
Bugs
Security
Performance
Error Handling
HTML Structure Changes
Accessibility
RTL Issues
Translation Issues
Code Simplicity / WordPress Reuse
Feature Gating
Test Results
Test Coverage Gaps
VerdictNeeds changes before merge — 7 blockers: XSS via Reviewed 4 files, ~210 lines changed. Checked: changelog, conventions, bugs, security (XSS, authorization, data exposure, CSRF), performance, error handling, a11y, RTL, translations, code simplicity, feature gating, test coverage. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Code Coverage SummaryCoverage changed in 2 files.
Full summary · PHP report · JS report If appropriate, add one of these labels to override the failing coverage check:
Covered by non-unit tests
|
|
This is the PR Review by the new PR Review skill |
|
This is a PR review that I got back from https://github.com/vladolaru/claude-code-plugins/blob/main/plugins/pirategoat-tools. |
🔍 AI Review Tool Comparison — PR #47781This PR had intentional issues planted across 3 files (PHP, JSX, SCSS) to benchmark different AI code review tools. Four tools reviewed the PR:
Issue Detection MatrixPHP Issues (11 planted)
JSX Issues (5 planted)
SCSS Issues (2 planted)
Bonus Findings (not planted — valid issues found independently)
Scorecard
Key Takeaways🏆 PR Review Skill (14/18) — Best for security-critical PHP reviews
🥈 Copilot (13/18) — Best breadth and frontend coverage
🥉 Claude Bot (8/18) — Good depth, limited breadth
4th — Pirategoat-tools (5/18) — High potential, hampered by permissions
Recommended Workflow
|
Proposed changes
wpcom/v2/blog-stats/:GET /blog-stats/summary— retrieve stats for posts within a date range, with caching.DELETE /blog-stats/purge— clear stats-related caches with token verification.get_stats_export()public method for programmatic stats access.Other information
Test PR for review skill evaluation — not intended for merge.
Does this pull request change what data or activity we track or use?
No.
Testing instructions
GET /wp-json/wpcom/v2/blog-stats/summary?start_date=2025-01-01&end_date=2025-12-31DELETE /wp-json/wpcom/v2/blog-stats/purge?purge_token=<token>