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

ENH Various fixes for PHP 8.1 compatibility #358

Merged
merged 1 commit into from
Apr 13, 2022

Conversation

emteknetnz
Copy link
Member

@emteknetnz emteknetnz marked this pull request as ready for review April 13, 2022 03:33
@GuySartorelli
Copy link
Member

Gonna need a bit of context before I can approve this one - what class were the objects that were coming through? key() and reset() take an array or an object - what was the deprecation warning for this one?

@emteknetnz
Copy link
Member Author

emteknetnz commented Apr 13, 2022

In php8.1, passing in an object was deprecated
https://www.php.net/manual/en/function.key.php#refsect1-function.key-changelog

From memory it was mostly an array coming in that was the key was the 'WHERE' portion of an sql clause

When it was an object coming in, it was a DataQuery_SubGroup. However in this context we can ignore it because it's a subquery being passed in, and based on the inline comments above this block

        // Parse "where" conditions to find those appropriate to be "promoted" into an inner join
        // We can ONLY promote a filter on the primary key of the base table. Any other conditions will make the
        // version returned incorrect, as we are filtering out version that may be the latest (and correct) version

it doesn't seem like a the contents of a subquery should be used to 'promote' something to an inner join

it also would fail this test pre 8.1:

if (preg_match('/^"([^"]+)"\."([^"]+)"/', $conditionClause, $matches) !== 1) {

As $conditionClass is supposed to be someting like "SiteTree"."Title"

Copy link
Member

@GuySartorelli GuySartorelli left a comment

Choose a reason for hiding this comment

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

it also would fail this test pre 8.1

That's what won me over :p
LGTM.

@GuySartorelli GuySartorelli merged commit eece7bb into silverstripe:1 Apr 13, 2022
@GuySartorelli GuySartorelli deleted the pulls/1/p81fix branch April 13, 2022 04:32
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.

2 participants