When the test suite is run on PHP 7.3, there is a warning due to changes in PHP 7.3:
exception: [Deprecated] Line 3015 of modules/simpletest/drupal_web_test_case.php:
strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior
If the second parameter (needle) of the strpos call is an integer, PHP uses the chr() value of that integer, which is likely not the intended behavior. Because of this, PHP now warnings when it sees an integer. The caller is now responsible to call chr() if intended.
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | 3020771.patch | 1.69 KB | pol |
Comments
Comment #2
ayesh commentedComment #3
ayesh commentedComment #4
ayesh commentedComment #5
sjerdoI don't think the latest patch is the intended behavior for assertRaw. The method is for checking if a value is displayed at the page result. New behavior checks if the chr result is displayed, which doesn't equal the integer. E.g. chr(98) equals 'b'
Also this fix doesn't check for other types like floats. For instance in the following test is assert that floating number -1234.56 is displayed at the page: https://cgit.drupalcode.org/drupal/tree/modules/field/modules/number/num...
To avoid this and keep the current behavior we should cast the second argument passed to strpos ($raw) to a string.
Comment #6
ayesh commentedHello @sjerdo thanks for your reply
My first patch in #2 was with an explicit string cast, but it had a few test failures.
The second patch (#4) didn't fix the PHP warning with strpos() either. I will try a few more approaches later today.
Comment #7
sjerdoHi @Ayesh, my guess is the patch in #2 is correct and the failing test may be broken all along.
Just tried the strpos() method for a float needle and it seems like the decimals aren't accounted for! Check this test code snippet: https://3v4l.org/sT9CU
Seems like the test without string cast accepts all texts containing a dot.
Comment #8
polHi all,
I'm testing the patches locally and I re-rolled a version of the patch.
I will consolidate all the PHP 7.3 patches in a custom project of mine that you can find here: https://github.com/drupol/dockerdrupal7runnerngninxphpfpm
Basically, it allows you to test D7 with docker without changing anything locally.
With only 3 commands, you can get a D7 site setup with PHP 7.3.
Feel free to use it!
Comment #9
sjerdoLooks good to me! +1
The check in method assertRaw is now correct for decimal numbers and the bug in the number test has been fixed.
Comment #10
sjerdoDid a quick check in D8: This bug has already been fixed there: #2279339: NumberFieldTest is slightly and subtly broken
Comment #11
mfb👍 Looks good to me, I reran the 7.3 tests and now down to just #3009351: "session_id(): Cannot change session id"
Comment #12
polCool ! Moving this forward.
Comment #13
fabianx commentedWe should be fixing this in the same way as Drupal 8 did, e.g. just removing the round completely to match code and make further syncs easier.
The rest is good to go though.
Comment #14
polPatch updated based on feedback from #13.
Comment #15
sjerdoLooking good!
Comment #16
polUpdating credits.
Comment #18
polComment #20
joseph.olstadThis is fixed, thanks again everyone!
Removing the pending commit tag (it was already committed).