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

Php84 #563

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Php84 #563

wants to merge 2 commits into from

Conversation

phpfui
Copy link

@phpfui phpfui commented Oct 24, 2024

  • Added configuration options to PHPUnit to show depreciations and warning messages.
  • Removed PHP 8.4 depreciations for functions that set parameters to null.
  • Added types to all function parameters based on DocBlock types.

I could not run the composer scripts on my Windows machine, but PHPUnit runs in the normal way. I did not run PHPCSFixer.

No logic changes were made.

Copy link

google-cla bot commented Oct 24, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@3kbest
Copy link

3kbest commented Nov 23, 2024

@rowan-m

PHP 8.4 has been released.

@cnizzardini
Copy link

Bump, lets get this merged.

@phpfui
Copy link
Author

phpfui commented Dec 3, 2024

Is there anything I need to do to get this merged?

Thanks.

@Flo354
Copy link

Flo354 commented Dec 11, 2024

Maybe sign their Contributor License Agreement (CLA) if you did not do it already?

@rowan-m
Copy link
Contributor

rowan-m commented Dec 11, 2024

Catching up, would this be backwards incompatible with earlier PHP versions? If so, this should include updates in the package.json as well.

@cnizzardini
Copy link

cnizzardini commented Dec 11, 2024

Not the author, but this appears to add typed args that have been supported since probably at least 7.4. The package version is set to >= 8. So this seems safe, but I'd say this package should also consider adding a minimum and maximum php version to its test actions:
https://github.com/google/recaptcha/blob/master/.github/workflows/php.yml

That would quickly fail the PR.

@NiklasBr
Copy link

would this be backwards incompatible with earlier PHP versions?

It should be backwards compatible. Changes such as RequestMethod $requestMethod = null to ?RequestMethod $requestMethod = null works in all PHP 8 versions. But from a strict SemVer point of view the changes like setExpectedHostname($hostname) to setExpectedHostname(string $hostname) adds a bit of problem for anyone extending these classes.

@cnizzardini
Copy link

would this be backwards incompatible with earlier PHP versions?

It should be backwards compatible. Changes such as RequestMethod $requestMethod = null to ?RequestMethod $requestMethod = null works in all PHP 8 versions. But from a strict SemVer point of view the changes like setExpectedHostname($hostname) to setExpectedHostname(string $hostname) adds a bit of problem for anyone extending these classes.

Good catch. Are those changes actually needed?

@phpfui
Copy link
Author

phpfui commented Dec 11, 2024

Original author here. I signed the agreement.

Nullable types have existed since 7.1. Type parameters since 7.0. Return types since 7.1. Typed properties since 7.4. This package also only support PHP 8.0 and higher, so it should use all these features by default. We can't keep catering to people who refuse to update PHP on a timely basis.

While typed parameters may break an extended class, you really should update your class. Also people not wanting to upgrade can still use an older version.

Will ping someone I know at Google to see if we can move this forward.

@cnizzardini
Copy link

We can't keep catering to people who refuse to update PHP on a timely basis.

Yes, but, you know full well many of us have to work in broken ass organizations.

@cnizzardini
Copy link

This entire package probably needs a true maintainer. It doesn't even follow semver, its 1.3 release bumped to php8... Shouldn't that have been a major version bump as it dropped support for 7.x?

@NiklasBr
Copy link

NiklasBr commented Dec 11, 2024

I 100% support you adding these typed parameters! However, such breaking changes should go in a new major version, not in a minor/patch update which should be backwards compatible.

you really should update your class

This attitude has caused so many problems over the years and is one of the reasons semver.org had to be created. Can we please not go back to the dark days of updates? People need to be able to trust software to work like it says it does.

This entire package probably needs a true maintainer. It doesn't even follow semver, its 1.3 release bumped to php8... Shouldn't that have been a major version bump as it dropped support for 7.x?

Yes. Agreed. But that update changed requirements in composer.json so nobody with PHP < 8 would have gotten a nasty surprise.

@Flo354
Copy link

Flo354 commented Dec 12, 2024

Then,

What has to be done to have this PR accepted?
If it's just something like bumping to version 2.0.0, let's just update that composer.json, some documentation and move forward.

PR adding support for PHP 8 (#517) was merged on February 2023, which is more than two years after the release of PHP 8.0
It would be great to avoid waiting for an official fix more than two years this time.

@NiklasBr
Copy link

What has to be done to have this PR accepted?

I would vote to split this PR into two:

  1. One to fix the implicitly nullable parameters (type $var = null to ?type $var = null) which can be merged early, tagged as a minor change.
  2. One to add additional explicit parameter types which can be merged later, tagged as a major change.

@Flo354
Copy link

Flo354 commented Dec 12, 2024

@phpfui do you agree with the proposal of @NiklasBr?

@phpfui
Copy link
Author

phpfui commented Dec 12, 2024

I am happy to do what ever the maintainer of this repo wants. We just need a response.

@Flo354
Copy link

Flo354 commented Dec 13, 2024

@rowan-m can you eventually check on this as you seem to have merging capabilities?
Thanks,

@NiklasBr
Copy link

Related, the release for PHP 8.4 compatibility in the enterprise repo: https://github.com/googleapis/google-cloud-php-recaptcha-enterprise/releases/tag/v1.17.2

@Flo354
Copy link

Flo354 commented Dec 13, 2024

the problem is that for my use case, this library is just used by a library I am using (https://github.com/karser/KarserRecaptcha3Bundle), so I would avoid having to use this because I should rewrite the symfony extension, or ask the dev to do it

@phpfui
Copy link
Author

phpfui commented Dec 17, 2024

My contact at Google says there is apparently no group responsible for public repos.

I am thinking to just publish my fork on Packagist. If @rowan-m or someone else decides to merge and stamp this PR, then I could just point it back to this repo.

Unfortunately I have seen this from multiple companies with "Open Source" packages. They just don't seem to care about merging PR requests to keep the package up to date with the latest PHP releases.

@cnizzardini
Copy link

This should be left in the hands of a group we can trust. I wonder if someone at thephpleague (mentioning a random maintainer here @alcohol) or similar would assist with maintaining a fork.

@phpfui
Copy link
Author

phpfui commented Dec 18, 2024

You can't really trust anyone. I don't for sure. That is why I check all code into git and do diffs on every composer update. Otherwise you open yourself up to supply chain attacks. Luckily PHP is all uncompressed text based, so easy to check. See my blog here for the solution.

@alcohol
Copy link

alcohol commented Dec 19, 2024

My contact at Google says there is apparently no group responsible for public repos.

Any idea if they are willing/open to adding collaborators to public repositories?

@glo71317
Copy link

glo71317 commented Jan 4, 2025

@rowan-m and all, I hope you're doing well! As we understand there are several contributors eager to collaborate on updating the package for compatibility with PHP 8.4. With PHP 8.4 having been GA for over a month and a half now, many consumers of the package are facing blockers when trying to use it with earlier PHP versions.

We believe that updating the package to be fully compatible with PHP 8.4, while also addressing potential backwards incompatibilities with previous PHP versions, would greatly benefit the community. Many contributors are ready to assist and work together to make this happen as soon as possible.

Would you be able to provide any updates on the status of the PR or let us know if there's anything further we can do to help move this forward?

Thank you so much for your time and consideration. We're looking forward to collaborating and helping make this update happen.

@MonsieurV
Copy link

Hi all,

@phpfui could you go forward publishing your fork/PR to packagist?

With no one responsible, this could go on for months.

@phpfui
Copy link
Author

phpfui commented Jan 9, 2025

Will do. Should have something next week. I want to convert it to GitHub actions, as I seem to remember that needed work.

@phpfui
Copy link
Author

phpfui commented Jan 9, 2025

OK, I had some time. This should be a drop in replacement for google/recaptcha

https://github.com/phpfui/recaptcha

phpfui/recaptcha

Just replace google with phpfui in your composer.json file and you should be good to go. It is modernized library with full type checking so run PHPStan on your code again to double check things.

@cnizzardini
Copy link

OK, I had some time. This should be a drop in replacement for google/recaptcha

https://github.com/phpfui/recaptcha

phpfui/recaptcha

Just replace google with phpfui in your composer.json file and you should be good to go. It is modernized library with full type checking so run PHPStan on your code again to double check things.

Post on php subreddit to get some traction on a fork because there is strength in numbers imo. I am leary of trusting forks to be maintained, but I will probably move my code over to your fork.

@Flo354
Copy link

Flo354 commented Jan 14, 2025

@phpfui it would be great if you open the "issues" section on your new repository in case someone needs to open one

@phpfui
Copy link
Author

phpfui commented Jan 14, 2025

Thanks for the heads up on the Issues tab. Now fixed. I thought that was the default, but GitHub has been adding so many features recently, maybe the defaults changed.

@cnizzardini I tried to post in the PHP subredit, but it was instantly blocked by moderators (auto blocked I suspect). I really dislike Redit for a variety of reasons. Can you post it there? This package is getting a lot of downloads daily, and that has to be from this repo and the comments, as it has not been promoted anywhere else.

Also I am a very conscientious open source maintainer. I respond to issues and pull requests within days if I am not traveling. Check out the NeonXP/MathExecutor project, or my ConstantContact or ICalendar repos for examples.

@jamieburchell
Copy link

jamieburchell commented Jan 29, 2025

I suspect this package will be/has been abandoned in favour of cloud-recaptcha-enterprise. Certainly, Google has pushed to migrate to that with "secret key" now being renamed "legacy secret key". I'm sure at some point they will drop support for that too. Feels like Google are trying to overcomplicate as many of their services as possible at the moment (Custom Search, Maps, GA4 - I'm looking at you).

@phpfui
Copy link
Author

phpfui commented Jan 29, 2025

I just received this email yesterday from Google Cloud: Migrate Google reCAPTCHA key to a Google Cloud Project by the end of 2025

So yes, @jamieburchell it looks like this library will go away. But for now, my PHP 8.4 port is gaining 100-200 installs a day, so people need a solution for PHP 8.4 now.

@jamieburchell
Copy link

jamieburchell commented Jan 29, 2025

I just received this email yesterday from Google Cloud: Migrate Google reCAPTCHA key to a Google Cloud Project by the end of 2025

Me too. That's what ultimately led me here. I have been migrating sites to Google Cloud Platform this morning so that Google doesn't take it upon itself to create a mess of new projects in my console.

So yes, @jamieburchell it looks like this library will go away. But for now, my PHP 8.4 port is gaining 100-200 installs a day, so people need a solution for PHP 8.4 now.

Absolutely. There must be millions of websites and third party software still using the "classic reCAPTCHA" - mine included. It's good to know there's a PHP 8.4 fork I can use.

@cnizzardini
Copy link

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.

10 participants