Skip to content
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

handle no domain in a PHP7.4 compatable way #370

Merged
merged 2 commits into from
Oct 5, 2019

Conversation

aaronjorbin
Copy link
Member

PHP 7.4 introduces a "Trying to access array offset on value of type ..." warning for accessing null/bool/int/float/resource (everything but array, string and object) as if it were an array.

Fixes #369

PHP 7.4 introduces a "Trying to access array offset on value of type ..." warning for accessing null/bool/int/float/resource (everything but array, string and object) as if it were an array.

Fixes WordPress#369
@codecov-io
Copy link

codecov-io commented Oct 5, 2019

Codecov Report

Merging #370 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #370      +/-   ##
============================================
+ Coverage     92.11%   92.12%   +<.01%     
- Complexity      760      761       +1     
============================================
  Files            21       21              
  Lines          1762     1764       +2     
============================================
+ Hits           1623     1625       +2     
  Misses          139      139
Impacted Files Coverage Δ Complexity Δ
library/Requests/Cookie.php 99.35% <100%> (ø) 63 <0> (+1) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a009398...355e379. Read the comment docs.

aaronjorbin added a commit to aaronjorbin/wordpress-develop that referenced this pull request Oct 5, 2019
@jrfnl jrfnl added this to the 1.7.1 milestone Oct 5, 2019
Copy link
Member

@jrfnl jrfnl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aaronjorbin Thanks for this & good find!

I've tested and confirmed the issue.

I've also checked whether this was the best place to solve it or whether this should have been solved in the Cookie::parse() method by filtering out any empty attributes there.

https://github.com/rmccue/Requests/blob/56286a0b8ea1d3976f66b335ef9ba2b52998d2c3/library/Requests/Cookie.php#L413-L416

As, based on RFC 6265, the Secure and HttpOnly attributes can exist with an empty value, filtering out empties in Cookie::parse() would not be the right solution.

So, this solution is 👍

@jrfnl jrfnl merged commit 58a0bbc into WordPress:master Oct 5, 2019
nylen pushed a commit to nylen/wordpress-develop-svn that referenced this pull request Oct 6, 2019
…ibrary.

Moves WordPress/Requests#370 into WordPress.

Previous [46258].

See #47746.


git-svn-id: https://develop.svn.wordpress.org/trunk@46416 602fd350-edb4-49c9-b593-d223f7449a82
pento pushed a commit to WordPress/wordpress-develop that referenced this pull request Oct 6, 2019
…ibrary.

Moves WordPress/Requests#370 into WordPress.

Previous [46258].

See #47746.


git-svn-id: https://develop.svn.wordpress.org/trunk@46416 602fd350-edb4-49c9-b593-d223f7449a82
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Oct 6, 2019
…ibrary.

Moves WordPress/Requests#370 into WordPress.

Previous [46258].

See #47746.

Built from https://develop.svn.wordpress.org/trunk@46416


git-svn-id: http://core.svn.wordpress.org/trunk@46214 1a063a9b-81f0-0310-95a4-ce76da25c4cd
gMagicScott pushed a commit to gMagicScott/core.wordpress-mirror that referenced this pull request Oct 6, 2019
…ibrary.

Moves WordPress/Requests#370 into WordPress.

Previous [46258].

See #47746.

Built from https://develop.svn.wordpress.org/trunk@46416


git-svn-id: https://core.svn.wordpress.org/trunk@46214 1a063a9b-81f0-0310-95a4-ce76da25c4cd
miya0001 pushed a commit to cjk4wp/wordpress that referenced this pull request Oct 26, 2019
…ibrary.

Moves WordPress/Requests#370 into WordPress.

Previous [46258].

See #47746.


git-svn-id: http://develop.svn.wordpress.org/trunk@46416 602fd350-edb4-49c9-b593-d223f7449a82
nylen added a commit to ClassicPress/ClassicPress that referenced this pull request Feb 19, 2020
This PR merges all known PHP 7.4 compatibility fixes from WordPress to ClassicPress, and also sets the Travis CI job for PHP 7.4 as a required job.

Closes #494.

* WP-r45487: Upgrade/Install: Correct operator precedence for an error code in `WP_Ajax_Upgrader_Skin::error()`.

WP:Props jrf.
Fixes https://core.trac.wordpress.org/ticket/47441.

Conflicts:
  src/wp-admin/includes/class-wp-ajax-upgrader-skin.php
----
Merges https://core.trac.wordpress.org/changeset/45487 / WordPress/wordpress-develop@9172b9c16b to ClassicPress.

* WP-r45730: PHP 7.4 compatibility fix / accessing arrays/string using curly brace syntax

PHP used to allow both square brackets and curly braces to be used interchangeably for accessing array elements and string offsets. The curly bracket syntax is only allowed in a limited set of cases and can be confusing for people not used to it.
PHP 7.4 will deprecate the curly brace syntax for accessing array elements and string offsets and it is expected that support will be completely removed in PHP 8.0.
Ref: https://wiki.php.net/rfc/deprecate_curly_braces_array_access

See https://core.trac.wordpress.org/ticket/47751.
WP:Props jrf.

Conflicts:
  src/wp-admin/includes/class-wp-filesystem-ftpext.php
  src/wp-admin/includes/class-wp-importer.php
  src/wp-includes/class-json.php
  src/wp-includes/script-loader.php
----
Merges https://core.trac.wordpress.org/changeset/45730 / WordPress/wordpress-develop@5ed5587545 to ClassicPress.

* WP-r45730: PHP 7.4 compatibility fix / accessing arrays/string using curly brace syntax

PHP used to allow both square brackets and curly braces to be used interchangeably for accessing array elements and string offsets. The curly bracket syntax is only allowed in a limited set of cases and can be confusing for people not used to it.
PHP 7.4 will deprecate the curly brace syntax for accessing array elements and string offsets and it is expected that support will be completely removed in PHP 8.0.
Ref: https://wiki.php.net/rfc/deprecate_curly_braces_array_access

See https://core.trac.wordpress.org/ticket/47751.
WP:Props jrf.

Conflicts:
  src/wp-admin/includes/class-wp-importer.php
  src/wp-includes/class-json.php
----
Merges https://core.trac.wordpress.org/changeset/45730 / WordPress/wordpress-develop@5ed5587545 to ClassicPress.

* WP-r46149: Code Modernisation: Remove redundant PHP 4 code from `do_action()`.

As of PHP 5, objects are always passed by reference, so this has not been needed for quite some time.

WP:Props jrf.
See https://core.trac.wordpress.org/ticket/47678.

Conflicts:
  src/wp-includes/plugin.php
----
Merges https://core.trac.wordpress.org/changeset/46149 / WordPress/wordpress-develop@31fa37f06d to ClassicPress.

* WP-r46112: Update getID3 library to fix issues with PHP7.4

Updates to trunk version that includes fixes for PHP7.4

Changelog:
JamesHeinrich/getID3@v1.9.14...00f3fbf

See: https://core.trac.wordpress.org/ticket/47751,https://core.trac.wordpress.org/ticket/47783.
Fixes: https://core.trac.wordpress.org/ticket/48040.

----
Merges https://core.trac.wordpress.org/changeset/46112 / WordPress/wordpress-develop@43fd102495 to ClassicPress.

* WP-r46113: Comment out magic quote functions

Follow up to r46112.

See: https://core.trac.wordpress.org/ticket/47751,https://core.trac.wordpress.org/ticket/47783, https://core.trac.wordpress.org/ticket/48040.

----
Merges https://core.trac.wordpress.org/changeset/46113 / WordPress/wordpress-develop@926bcf1278 to ClassicPress.

* WP-r46378: General: Patch PHMailer for PHP 7.4 compatibility.

This patches the PHPMailer library in Core to be PHP 7.4 compatible by adding a version check before calling `get_magic_quotes_runtime()`.

WP:Props ayeshrajans, jrf.
See https://core.trac.wordpress.org/ticket/47783.

----
Merges https://core.trac.wordpress.org/changeset/46378 / WordPress/wordpress-develop@f13714d9d1 to ClassicPress.

* WP-r46097: Mail: Update PHPMailer to 5.2.27.

The full list of changes is available here:
PHPMailer/PHPMailer@v5.2.22...PHPMailer:v5.2.27

WP:Props MattyRob, ayeshrajans, rogueresearch, bgermann, slaFFik, Presskopp, aaroncampbell.
Fixes https://core.trac.wordpress.org/ticket/40472.

----
Merges https://core.trac.wordpress.org/changeset/46097 / WordPress/wordpress-develop@1b7bba613d to ClassicPress.

* WP-r46260: External Libraries: Fix PHP 7.4 compatibility issues in the SimplePie library.

See: simplepie/simplepie@38b5049

WP:Props jrf, stevenkword, jorbin, desrosj.
See https://core.trac.wordpress.org/ticket/47746.

----
Merges https://core.trac.wordpress.org/changeset/46260 / WordPress/wordpress-develop@63bf8c8316 to ClassicPress.

* WP-r46258: External Libraries: Fix PHP 7.4 compatibility issues in the Requests library.

See: WordPress/Requests@v1.7.0...3470169

WP:Props jrf, jorbin, desrosj.
See https://core.trac.wordpress.org/ticket/47746.

----
Merges https://core.trac.wordpress.org/changeset/46258 / WordPress/wordpress-develop@58bd8a48e6 to ClassicPress.

* WP-r45639: Code Modernisation: Fix known instances of array access on data types that can't be accessed as arrays.

PHP 7.4 addes a warning when trying access a null/bool/int/float/resource (everything but array, string and object) as if it were an array.

This change fixes all of these warnings visible in unit tests.

WP:Props jrf.
See https://core.trac.wordpress.org/ticket/47704.

Conflicts:
  src/wp-includes/class-wp-customize-manager.php
  src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php
  src/wp-includes/meta.php
  src/wp-includes/theme.php
  tests/phpunit/tests/query/generatePostdata.php
----
Merges https://core.trac.wordpress.org/changeset/45639 / WordPress/wordpress-develop@2da7f9f524 to ClassicPress.

* WP-r46105: GENERAL: Remove magic quote functions

The path to magic quote sanity took a fun and exciting turn: PHP core removed it and WordPress updated the minimum version.

For the formally external pclzip, the code is commented out to make investigating easier and in case we ever need to merge upstream (if that still exists) changes.

WP:Props ayeshrajans, jrf, jorbin.
See https://core.trac.wordpress.org/ticket/47783.
Fixes https://core.trac.wordpress.org/ticket/18322.

Conflicts:
  src/wp-includes/formatting.php
  src/wp-includes/load.php
----
Merges https://core.trac.wordpress.org/changeset/46105 / WordPress/wordpress-develop@08df15ab58 to ClassicPress.

* WP-r46185: PHP 7.4: Fix another instance of array access on a datatype that cannot be accessed as an array.

PHP 7.4 adds a warning when trying access a null/bool/int/float/resource (everything but array, string and object) as if it were an array.

Follow up of https://core.trac.wordpress.org/changeset/45639.

WP:Props desrosj, jrf.
See https://core.trac.wordpress.org/ticket/47704.

Conflicts:
  src/wp-admin/includes/update.php
----
Merges https://core.trac.wordpress.org/changeset/46185 / WordPress/wordpress-develop@3514a52019 to ClassicPress.

* WP-r46416: External Libraries: Fix PHP 7.4 compatibility issue in the Requests library.

Moves WordPress/Requests#370 into WordPress.

Previous https://core.trac.wordpress.org/changeset/46258.

See https://core.trac.wordpress.org/ticket/47746.

----
Merges https://core.trac.wordpress.org/changeset/46416 / WordPress/wordpress-develop@2215a9bbb3 to ClassicPress.

* Clean merge conflicts

* Remove gutenberg build scripts & processes

* Clean merge conflicts

* Clean merge conflicts

* Clean merge conflicts

* Add PHP 7.4 build in travis

* Clean merge conflicts

* Add allow 7.4 fail

* Revert "Add allow 7.4 fail"

This reverts commit 9d8d204.

* Fix merge conflict

* WP-r46166: External Library: Update getid3 to 1.9.18

Follow up to r46112 as getid3 has tagged an official release.

Changes: JamesHeinrich/getID3@00f3fbf...v1.9.18

WP:Props desrosj, jkitchen.
Fixes https://core.trac.wordpress.org/ticket/47751 https://core.trac.wordpress.org/ticket/40883 https://core.trac.wordpress.org/ticket/43836.

----
Merges https://core.trac.wordpress.org/changeset/46166 / WordPress/wordpress-develop@b7df2ea08c to ClassicPress.

* Resolve conflict

* Fix more conflicts

* WP-r46155: General: Ensure the arguments passed to `implode()` are in the correct order.

The `implode()` function accepts two. parameters, `$glue` and `$pieces`. For historical reasons, these parameters have been accepted in any order, though it was recommended that the documented order of `$glue, $pieces` be used.

Starting in PHP 7.4, specifying the parameters in the reverse order will trigger a deprecation notice with the plan to remove this tolerance in PHP 8.0.

This change fixes the occurrences of reversed arguments in Core with the exception of those contained in included external libraries. These will be handled separately.

WP:Props jrf, jorbin.
See https://core.trac.wordpress.org/ticket/47746.

Conflicts:
- src/wp-admin/includes/upgrade.php

---

Merges https://core.trac.wordpress.org/changeset/46155 / WordPress/wordpress-develop@352665d6df to ClassicPress.

* Resolve conflicts

* Add a script to update the importer plugin

See #42.

This is related to PHP 7.4 compatibility, the closest equivalent WP
changeset is https://core.trac.wordpress.org/changeset/46542 but
ClassicPress includes the importer code directly in the source tree so
we need a different approach to this problem.

* Update importer plugin for automated tests

Revision: WordPress/wordpress-importer@1ab709553

* Update Travis distribution:

- Switch to Xenial (16.04) which is the current default
- Remove `sudo: false` as this no longer does anything and causes a
  Travis warning:
  - https://blog.travis-ci.com/2018-11-19-required-linux-infrastructure-migration
  - https://docs.travis-ci.com/user/reference/overview/#deprecated-virtualization-environments
- Enable required services by default:
  - https://docs.travis-ci.com/user/reference/xenial/#services-disabled-by-default

* Bump object cache job to PHP 7.2

* Fix services for build with object cache

We still need to start MySQL here, and it looks like this job-specific
`services` entry overrides the main entry rather than adding to it.

Co-authored-by: Sergey Biryukov <sergeybiryukov.ru@gmail.com>
Co-authored-by: Aaron Jorbin <aaronjorbin@users.noreply.github.com>
Co-authored-by: Jon Desrosiers <desrosj@users.noreply.github.com>
Co-authored-by: Gary Pendergast <gary@pento.net>
Co-authored-by: James Nylen <jnylen@gmail.com>
@jrfnl jrfnl mentioned this pull request Apr 18, 2021
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.

Trying to access array offset on value of type null when a domain value is null/false
4 participants