Opened 9 years ago
Closed 8 years ago
#36435 closed task (blessed) (maybelater)
Explicitly cast numeric values
Reported by: | pento | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | General | Keywords: | |
Focuses: | Cc: |
Description
PHP 7.1 will include warnings when invalid values are being used in numeric operations, per this RFC.
This is currently manifesting itself as a single unit test error against PHP Nightly, but it's likely that there are more places we'll see this warning, which aren't being covered by unit tests.
I'm not aware of any static analysis tools that are covering this case yet, but in the mean time, we could potentially look for problem code with some simple searching.
Attachments (3)
Change History (21)
This ticket was mentioned in Slack in #core by pento. View the logs.
8 years ago
#3
@
8 years ago
src$ ack --php --ignore-dir=ID3 --ignore-dir=wp-content/plugins --ignore-dir=SimplePie --ignore-dir=Requests '^\s*((?!//|\*).)*(\+\+|--)?\$[^ (),'\''";]+((\+\+|--[^>])| ([+*-]|/[^>]))' | wc -l 794
This ticket was mentioned in Slack in #core-multisite by jeremyfelt. View the logs.
8 years ago
#7
@
8 years ago
That's the general idea. We should also be adding unit tests as we go.
PHP 7.1 is scheduled for release in November or maybe December, so we're going to need to make a serious dent in this task in 4.6.
#8
@
8 years ago
Scrutinizer are investigating adding a check for this.
#9
follow-up:
↓ 10
@
8 years ago
Added a patch, let me know if i got it right and I'll happily go over a few more files.
#10
in reply to:
↑ 9
;
follow-up:
↓ 11
@
8 years ago
Replying to joostdevalk:
Added a patch, let me know if i got it right and I'll happily go over a few more files.
Seems good, however random_compat is an external library, so the fix should probably be submitted upstream.
#11
in reply to:
↑ 10
@
8 years ago
Replying to SergeyBiryukov:
Replying to joostdevalk:
Added a patch, let me know if i got it right and I'll happily go over a few more files.
Seems good, however random_compat is an external library, so the fix should probably be submitted upstream.
You're right. done.
#12
@
8 years ago
The patch was accepted upstream, but of course there's no new release of it yet. What's the best way to go about that @SergeyBiryukov ?
This ticket was mentioned in Slack in #core by ocean90. View the logs.
8 years ago
#14
@
8 years ago
PclZip can produce a warning when it's used:
Notice: A non well formed numeric value encountered in /wp-admin/includes/class-pclzip.php on line 1849
Patched in 36435-PclZip.2.diff.
This ticket was mentioned in Slack in #core by ocean90. View the logs.
8 years ago
#17
@
8 years ago
I'm using a fork of VVV which installs PHP 7.1 and haven't noticed any more warnings so far.
Milestoning this as it's something we should really start looking into before the PHP 7.1 release, at least to know where/what will be affected.