Repository navigation
Handle PHP 8.4 headers & Pressable SFTP retries - #132
Conversation
Avoid reading the local $http_response_header on PHP 8.4+ by using http_get_last_response_headers() when available, falling back to the legacy variable otherwise; make header parsing and http_code extraction null-safe. In Pressable_Site_Shell_Open, add creation/polling for asynchronously provisioned SFTP users, introduce find_site_sftp_user(), and implement retry/backoff logic when connecting to the SSH gateway for newly created users. Improve related messages and verbosity and return clearer failures when provisioning or SSH access does not become available in time.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThis PR replaces scoped $http_response_header usage with a version-aware call to http_get_last_response_headers() (falling back when unavailable) in get_remote_content() and Jetpack_Site_Connection_Triage to parse http_code safely. It also adds Pressable SFTP improvements: a find_site_sftp_user() helper, polling for asynchronous SFTP user provisioning when creating a collaborator, and a retry loop for SSH/SFTP connections that retries on gateway exit code 255 with adaptive back-off. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 PHPStan (2.2.1)/commands/CLI_Commands_Export.php ... [truncated 108638 characters] ... vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/EnqueuedResourcesSniff.php Comment |
|
No prior Poseidon reviews exist on this PR ( 🔱 Poseidon ReviewSummary — Hardens Walkthrough
🟡 Suggestions
💡 Nitpicks (1)
🤖 Prompt for AI agents — fix all findingsℹ️ Review info
Notes on what was checked and cleared (no findings): the |
Use ($http_response_header ?? array()) when falling back to response headers to avoid undefined variable/reading warnings on newer PHP versions. Also change the WP.com status check from the string '400' to the integer 400 for proper type comparison in Jetpack_Site_Connection_Triage.php.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
includes/functions.php (1)
67-69: 💤 Low valueAlign legacy
$http_response_headerfallback with the null-safe pattern
parse_http_headers()accepts anarray, but the legacy branch passes$http_response_headerdirectly. After a successfulfile_get_contents()it should usually be an array, yet for non-HTTP/HTTPS URLs (or wrapper edge cases) it can be unset/null, which risks aTypeError. Aligning with the existing null-safe intent keeps behavior consistent:♻️ Optional: align fallback with the null-safe pattern
$response_headers = function_exists( 'http_get_last_response_headers' ) ? ( http_get_last_response_headers() ?? array() ) - : $http_response_header; + : ( $http_response_header ?? array() );🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@includes/functions.php` around lines 67 - 69, $response_headers may be null/undefined when falling back to the legacy $http_response_header and parse_http_headers() expects an array; update the fallback in the $response_headers assignment to mirror the null-safe pattern used for http_get_last_response_headers() so it supplies an empty array when $http_response_header is null (i.e., use $http_response_header ?? array()), ensuring parse_http_headers() always receives an array.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@commands/Jetpack_Site_Connection_Triage.php`:
- Around line 207-212: The check against the parsed HTTP status is using a
string literal ('400') but parse_http_headers() sets ['http_code'] as an int, so
change the strict comparison to use an integer: replace the condition "if (
'400' === $wpcom_status )" with "if ( 400 === $wpcom_status )" (or cast
$wpcom_status to int first) so the $wpcom_status check correctly detects a 400
response coming from parse_http_headers().
---
Nitpick comments:
In `@includes/functions.php`:
- Around line 67-69: $response_headers may be null/undefined when falling back
to the legacy $http_response_header and parse_http_headers() expects an array;
update the fallback in the $response_headers assignment to mirror the null-safe
pattern used for http_get_last_response_headers() so it supplies an empty array
when $http_response_header is null (i.e., use $http_response_header ?? array()),
ensuring parse_http_headers() always receives an array.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7c696b14-96fe-45bf-94c6-334a0dae74a2
📒 Files selected for processing (3)
commands/Jetpack_Site_Connection_Triage.phpcommands/Pressable_Site_Shell_Open.phpincludes/functions.php
Avoid reading the local $http_response_header on PHP 8.4+ by using http_get_last_response_headers() when available, falling back to the legacy variable otherwise; make header parsing and http_code extraction null-safe. In Pressable_Site_Shell_Open, add creation/polling for asynchronously provisioned SFTP users, introduce find_site_sftp_user(), and implement retry/backoff logic when connecting to the SSH gateway for newly created users. Improve related messages and verbosity and return clearer failures when provisioning or SSH access does not become available in time.
Fixes #122
Fixes #104
Summary by CodeRabbit
Bug Fixes
Chores