Skip to content

Release version 0.1.3.3#504

Merged
randhirinsta merged 8 commits into
mainfrom
develop
May 19, 2026
Merged

Release version 0.1.3.3#504
randhirinsta merged 8 commits into
mainfrom
develop

Conversation

@randhirinsta
Copy link
Copy Markdown
Collaborator

  • Added: WordPress core rollback support — the plugin now snapshots the current core version before every core upgrade and can roll back to that recorded version on request.

dev5 and others added 8 commits May 13, 2026 05:09
- New LAST_CORE_VERSION_OPTION + get/set snapshot helpers
- update() routes type=core with allow_downgrade/action=rollback to core_downgrade()
- core_updater() writes pre-upgrade snapshot before Core_Upgrader::upgrade()
- core_downgrade() verifies snapshot, HEAD-checks the WP.org package URL,
  rewrites the update_core transient via filters, and DELEGATES to
  core_updater() — single Core_Upgrader path, strictly DRY
- Filters always removed before returning, even on failure
- Bump version to 0.1.3.3 in plugin header, INSTAWP_PLUGIN_VERSION,
  and readme.txt Stable tag
- readme.txt: add 0.1.3.3 (Beta) changelog entry for core rollback
- doc/core-update.md: document REST payload, the
  instawp_last_core_version snapshot, and the core_downgrade →
  core_updater DRY flow
- Updater.php: write pre-upgrade snapshot in core_updater() before
  Core_Upgrader::upgrade(); drop the unreliable get_bloginfo()
  before/after equality check ($wp_version is a cached PHP global
  Core_Upgrader does not refresh in-process)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The core rollback edits previously committed here belong upstream in
instawp/connect-helpers (PR InstaWP/connect-helpers#17, v1.1.1).
After that PR merges, `composer update instawp/connect-helpers` will
restore these changes here as a regenerated vendor/ — sourced from
the helpers package instead of edited in place.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Pulls upstream changes resolved by `composer update`:

  - instawp/connect-helpers   dev-main d864992 → e886995
    (PR InstaWP/connect-helpers#17 — core rollback via
    core_downgrade + pre-upgrade wp_options snapshot, plus the
    dropped get_bloginfo equality check in core_updater)

Incidental transitive patch bumps composer also resolved against the
existing composer.json constraints (no committed composer.lock —
\`*.lock\` is gitignored, so every install is a fresh resolution):

  - phpseclib/phpseclib                3.0.50 → 3.0.52
  - wp-cli/wp-config-transformer       v1.4.5 → v1.4.6

vendor/composer/installed.json and installed.php regenerated to match.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
feat(core): WordPress core update rollback (0.1.3.3)
Runs composer update for instawp/connect-helpers, pulling in the
core_updater transient-refresh fix (connect-helpers PR #18): core
updates now force a fresh wp_version_check() before find_core_update(),
so an update right after a rollback succeeds on the first attempt
instead of failing with "WordPress is at the latest version.".

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Finalises the 0.1.3.3 changelog heading (Beta → 19 May 2026).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
chore(deps): regenerate connect-helpers vendor
@claude
Copy link
Copy Markdown
Contributor

claude Bot commented May 19, 2026

Claude finished @randhirinsta's task —— View job


PR Review: Core Rollback Feature

Context loaded:

  • CLAUDE.md (project guidelines)
  • .claude/randhirinsta.claude (developer preferences)

Review Checklist:

  • Load and review new documentation
  • Analyze core Updater.php implementation
  • Check architectural principles compliance
  • Review security considerations
  • Assess performance implications
  • Verify WordPress coding standards
  • Check error handling and edge cases
  • Review other modified files

Overall Assessment: APPROVED with Minor Recommendations

This is a well-architected, secure, and maintainable implementation of WordPress core rollback functionality. The code demonstrates excellent adherence to the project's architectural principles and WordPress best practices.


🏗️ Architectural Principles Compliance: EXCELLENT

✅ Data Layer Abstraction

  • Correctly uses wp_options table directly (instawp_last_core_version) instead of high-level APIs
  • Persistent storage with autoload=false for performance optimization
  • Direct database interaction for snapshot management at storage layer

✅ DRY (Don't Repeat Yourself)

  • Brilliant delegation pattern: rollback doctoring the transient then calling core_updater()
  • Shared Core_Upgrader path eliminates code duplication between forward/rollback flows
  • Single update orchestration logic in core_updater()

✅ SSOT (Single Source of Truth)

  • Plugin-owned snapshot at instawp_last_core_version is authoritative rollback source
  • Caller cannot override snapshot-verified rollback targets (security benefit)
  • Clear unidirectional flow from snapshot → validation → execution

✅ SoC (Separation of Concerns)

  • Clean separation: core_downgrade() handles validation/setup, core_updater() handles execution
  • REST API (perform_update()) separated from business logic (Updater class)
  • Filter management isolated to rollback flow only

✅ Proper Abstraction

  • Core utilities properly reused across update types
  • Abstraction level appropriate (not too high/low)
  • WordPress upgrader classes used correctly

🔒 Security Analysis: SECURE

✅ Input Validation

  • Version string regex validation prevents malformed inputs: /^\d+(\.\d+){1,2}([\-\.][A-Za-z0-9]+)?$/
  • Snapshot verification prevents arbitrary rollback targets
  • REST API properly uses bearer token validation via validate_api_request()

✅ Output Escaping

  • All user-facing messages properly escaped with esc_html()
  • Translatable strings with proper context
  • Error messages don't expose sensitive internal details

✅ External Resource Validation

  • Pre-flight HEAD check validates WordPress.org package availability
  • Package URL construction with rawurlencode() for safety
  • Network timeout limits (15s) and redirection limits (5) prevent abuse

✅ Data Integrity

  • Atomic snapshot writes before upgrades
  • Graceful filter cleanup in all cases (success/failure)
  • No file system dependencies (reliable on shared hosting)

Performance Analysis: OPTIMIZED

✅ Minimal Database Impact

  • Single wp_options read/write for snapshot management
  • autoload=false prevents loading snapshot in normal requests
  • Transient manipulation instead of redundant API calls

✅ Network Efficiency

  • HEAD check catches missing packages before expensive downloads
  • Conditional skip_core_check in rollback to avoid duplicate API calls
  • Proper transient cache management

✅ Memory Management

  • No large data structures held in memory
  • WordPress core upgrader handles file operations efficiently
  • Minimal filter footprint during operation

📝 WordPress Coding Standards: COMPLIANT

✅ Style & Structure

  • Proper PSR-4 namespace usage
  • Correct indentation with tabs
  • PHPDoc blocks present for all public methods
  • Snake_case constants with proper prefixing

✅ WordPress APIs

  • Correct use of WordPress core functions
  • Proper hook management (add/remove filters)
  • Standard upgrader class patterns followed
  • Appropriate use of transients and options

🛡️ Error Handling: ROBUST

✅ Comprehensive Edge Cases

  • Missing snapshot handling
  • Malformed version strings
  • Network failures (package unavailable)
  • Version mismatch validation
  • Upgrader failure scenarios

✅ Proper Logging

  • Uses Helper::add_error_log() correctly (failures only)
  • Structured error messages with context
  • No sensitive data exposure in logs

✅ Graceful Degradation

  • Filter cleanup in all paths
  • Meaningful error messages for users
  • No partial state corruption

🎯 Minor Recommendations

  1. Documentation Enhancement: Consider adding inline code example in doc/core-update.md showing how to read the current snapshot for rollback requests.

  2. Logging Consistency: Line 277-280 could be simplified - the sprintf formatting is good but could extract the error details to a variable for readability.

  3. Version Comparison: Consider adding version comparison validation to prevent "rollback" to same version, though current implementation will handle this gracefully.


📋 Testing Recommendations

Critical Paths to Test:

  • Forward upgrade with snapshot creation
  • Successful rollback to valid snapshot version
  • Rollback rejection with invalid version
  • Rollback rejection with missing snapshot
  • Network failure scenarios (package unavailable)
  • Filter cleanup on both success and failure paths

Edge Cases:

  • Malformed version strings
  • Concurrent update requests
  • Database write failures during snapshot creation

Final Verdict: EXCELLENT IMPLEMENTATION

This PR demonstrates exemplary WordPress plugin development with:

  • Strong architectural principles adherence
  • Comprehensive security measures
  • Excellent performance optimization
  • Robust error handling
  • Clean, maintainable code structure

The implementation correctly addresses all project requirements while maintaining the high standards expected for production WordPress plugins.


@randhirinsta randhirinsta merged commit 0a8ca3a into main May 19, 2026
3 checks passed
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.

1 participant