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

BUGFIX: Adjust to Php 83 get_parent_class deprecation #3351

Merged

Conversation

mhsdesign
Copy link
Member

@mhsdesign mhsdesign commented May 11, 2024

see https://www.php.net/manual/en/function.get-parent-class.php

Upgrade instructions

Review instructions

Checklist

  • Code follows the PSR-2 coding style
  • Tests have been created, run and adjusted as needed
  • The PR is created against the lowest maintained branch
  • Reviewer - PR Title is brief but complete and starts with FEATURE|TASK|BUGFIX
  • Reviewer - The first section explains the change briefly for change-logs
  • Reviewer - Breaking Changes are marked with !!! and have upgrade-instructions

@mhsdesign
Copy link
Member Author

Must have gone missing while upmerging #3032 i guess

@mhsdesign mhsdesign force-pushed the bugfix/adjustToPhp83GetParentClassDeprecation branch from 7e7fc98 to f6e9010 Compare May 12, 2024 11:26
Php 8.3 deprecates allow passing NULL to `strtolower`
@mhsdesign mhsdesign merged commit a7a2dab into neos:9.0 May 14, 2024
7 checks passed
@mhsdesign mhsdesign changed the title TASK: Adjust to Php 83 get_parent_class deprecation BUGFIX: Adjust to Php 83 get_parent_class deprecation May 15, 2024
@github-actions github-actions bot added the Bug label May 15, 2024
@lorenzulrich
Copy link
Contributor

@mhsdesign I suspect that this change has regressions. In #3406, I backported this change to 8.3 and applied it as a patch in an installation.

Now, when I call an own repository that extends a Neos repository and call a method that creates a query, I get this error:

Call to a member function createQueryForType() on null

  Type: Error
  File: Packages/Framework/Neos.Flow/Classes/Persistence/Repository.php
  Line: 137

So somehow DI fails in this case. I suspect it is because PHP <8.3 get_parent_class() is not identical to PHP 8.3 get_parent_class($this).

https://www.php.net/manual/en/function.get-parent-class.php#refsect1-function.get-parent-class-changelog

@lorenzulrich
Copy link
Contributor

It seems that using method_exists(parent::class as mentioned here seems to work in my situation. However I'd be surprised if that part of Flow wasn't covered by a test.

@kdambekalns
Copy link
Member

As mentioned in the post you linked, parent::class fails without a parent and the proper replacement would be get_parent_class($this). Also the PHP documentation says:

previously, calling this function inside a class returned the name of that class.

And inside a class, $this is, well, "that class". Also, https://3v4l.org/6TtkP shows no difference for PHP < 8.3

@kitsunet
Copy link
Member

Given that this here happens in a proxy class we can safely assume a parent::class cannot fail?!

@kdambekalns
Copy link
Member

Yep, in this case, true. I was more trying to prove that the change as a reason for the "mthod call on null" seems… strange?!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants