-
Notifications
You must be signed in to change notification settings - Fork 736
PHP 8.1 & Ubuntu 22.04 Compatibility Update #3167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
DmitriyStoyanov
wants to merge
14
commits into
catchpoint:master
Choose a base branch
from
DmitriyStoyanov:aws_sdk_v3
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…efore opening them
Fixed three PHP 8+ type errors that were causing warnings in WPT Server: 1. Unsupported operand types: string / int - Fixed in filmstrip.inc.php: Added is_numeric() check before dividing test['end'] by interval - Fixed in compare.php (2 locations): Added type checks when calculating filmstrip_end_time and testEnd - All division operations now validate types and use explicit float casting 2. imagerectangle(): Argument catchpoint#1 must be of type GdImage, null given - Fixed in waterfall.inc: Added check to ensure imagecreatetruecolor() succeeds before using image resource - Returns null if image creation fails to prevent null pointer errors 3. round(): Argument catchpoint#1 must be of type int|float, string given - Fixed in visualProgress.inc.php: Added is_numeric() check before calling round() on visual_progress values - Ensures values are numeric before rounding operations All fixes include: - Type validation using is_numeric() where needed - Explicit type casting with (float) for arithmetic operations - Null/false checks for image resource creation - Safe fallback values when operations cannot proceed These changes maintain backward compatibility while preventing PHP 8+ type errors.
Added comprehensive null checks for image resource to prevent PHP 8+ type errors: 1. Enhanced image creation validation: - Added check for both resource (PHP 7) and GdImage object (PHP 8+) - Added @ suppression operator to prevent warnings on failure - Returns null early if image creation fails 2. Added defensive checks in helper functions: - DrawPerfLabel(): Validates $im before using it - DrawPerfBackground(): Validates $im before using it - Both functions now return early if image is invalid 3. Added guards before all imagerectangle() calls: - Line 530: Main border drawing - Line 570: Interactive section border - Line 912: Long tasks border - Line 1025: Left column border This ensures that imagerectangle() is never called with a null or invalid image resource, preventing the PHP 8+ type error: 'imagerectangle(): Argument catchpoint#1 ($image) must be of type GdImage, null given'
Fixed PHP 8+ type error when custom metric values are arrays: 'htmlspecialchars(): Argument catchpoint#1 ($string) must be of type string, array given' The issue occurred when custom metrics contain array values that were passed directly to Blade's {{ }} syntax, which automatically calls htmlspecialchars() on the value. Solution: - Added type checking before output in the template - Arrays and objects are now converted to JSON strings using json_encode() - String and numeric values are output normally - This prevents the type error while preserving data for display This ensures compatibility with PHP 8+ strict type checking while maintaining backward compatibility with existing data structures.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR addresses critical compatibility issues that arose after upgrading from Ubuntu 20.04 to 22.04 and PHP 7.4 to 8.1. The upgrade was necessary to maintain system security and receive ongoing OS support, but initially broke several application components as documented in issue #3133
The PHP 8.1 upgrade introduced breaking changes that affected:
Without these fixes, the application was unable to run on Ubuntu 22.04, preventing essential OS security updates.
So I've implemented next changes:
AWS SDK Migration:
PHP 8.1 Compatibility Fixes:
Tested successfully on our Private WPT Server with WPT Agents