reCaptcha V2 Manual upgrade steps

Hey All,

I have a customer using OJS 2.4.8.1 and there is a lot of customizations where upgrading tot he latest version will take a fair amount of planning and time. I was just notified that reCaptcha v1 will stop working at the end of March.

Are there any steps or a list of files I need to update to get reCaptcha V2 updated? I found 3 files (recaptchalib.inc.php, notificationmailinglistform.inc.php and formvalidartorrecaptcha.inc.php) that i have updated to what appears to be the latest versions but it is not working.

If someone could throw out which files need to be replaced and where to get them that would be great.

Thanks,
jAC

Hi @jcanning,

See ReCAPTCHA broken in OJS 2.4.8-3 · Issue #3425 · pkp/pkp-lib · GitHub – in particular the two pull requests tagged in that issue. One is for the OJS application repository, the other for the lib/pkp submodule.

Regards,
Alec Smecher
Public Knowledge Project Team

Hey Alec

Github messes me up with the pull requests so i am not sure which versions of the file i should be updating.

These are the two sets of pulls i am seeing, are these the ones i should be updating?

https://github.com/pkp/pkp-lib/pull/3427/files
https://github.com/pkp/ojs/pull/1852/files

Thanks!

I replaced those 5 files mentioned in those 2 pulls but still have the old reCaptcha. I have got to be doing something wrong (clearly :)). Any thoughts?

Hi @jcanning,

I’ll tag @ctgraham, who wrote those PRs – Clinton, those two pull requests are all that’s required to get ReCaptcha V2 working in OJS 2.4.x, correct?

Regards,
Alec Smecher
Public Knowledge Project Team

1 Like

Did you also configure the values in config.inc.php?

The recaptcha_version setting will need to be changed to “2”, and you will probably need a new reCaptcha key pair, at the least.

That is exactly what i was missing :slight_smile:
Thank you so much!

@jcanning can you explain where file and what code you add more detail?
I cannot find file classes/form/validation/FormValidatorReCaptcha.inc.php on OJS 2.4.8.1

There are two different pulls, with two different bases: the OJS application, and the shared library (which lives under the OJS application in lib/pkp). The FormValidatorReCaptcha.inc.php file is in the shared library, so the full path is:
lib/pkp/classes/form/validation/FormValidatorReCaptcha.inc.php

Hi Andrew,

these are all the files i backed up and modified.

Replaced the following files with updated versions for the OJS website

  • /public_html/lib/pkp/classes/form/validation/FormValidatorReCaptcha.inc.php
  • /public_html/lib/pkp/classes/notification/form/NotificationMailingListForm.inc.php
  • Added: /public_html/lib/pkp/classes/notification/form/NotificationMailingListForm.inc.php.swp
    ****Not sure if this one was needed but put it there anyways
  • /public_html/classes/comment/form/CommentForm.inc.php
  • /public_html/classes/user/form/RegistrationForm.inc.php

File updated to include the option for reCaptcha v2
/html_public/Config.inc.php

Hope this helps.

Thanks,
jAC

The .swp file is not needed and was removed in this subsequent commit:
https://github.com/pkp/pkp-lib/commit/367644685074f20974aa32b6e0c83a9048526bbf

1 Like

Great post. Very helpful.
Thanks

Hey All,

I ran into a small hiccup when a user tries to register now

Fatal error: Class ‘PKPString’ not found in /home/username/public_html/classes/user/form/RegistrationForm.inc.php on line 372

Any thoughts on why that might be barking (i mean i know it cannot find that class but it was a complete replacement of the file)?

Thanks,
jAC

Hi @jcanning,

There’s a reference in classes/user/form/RegistrationForm.inc.php to the PKPString class, which should be to String in your version of OJS. You should be able to change that and it’ll work.

I’ll review whether the wrong name got committed to the stable codebase by accident and change it if needed.

Regards,
Alec Smecher
Public Knowledge Project Team

I’ve successfully installed recaptcha v2 on ojs2.4.8-1. Woo-hoo!

However, from some initial tests it seems that the recaptcha v2 form always validates with no checks. I’m just checking the I’m not a robot box and it passes.

Follow up:

I’ve tested on Chrome and Firefox: always passes.
Safari: works as expected.

I have been trying to do this on my website bjohns.in but without success. Could you please help me? New users are not able to register as the recaptcha ver 1 has expired. Please help.

I have been trying to do this on my website bjohns.in but without success. Could you please help me? New users are not able to register as the recaptcha ver 1 has expired. Please help.

The most straightforward way to handle this is to do the standard upgrade to OJS 2.4.8-3, and then edit the config.inc.php settings with your new settings and keys. This will enable ReCAPTHA v2 for registrations and comments (notification mailing list subscriptions is broken).

To fix notifications mailing lists will take the patch described here:

Do you use ReCAPTCHA for notification mailing list subscriptions?

Thank you ctgraham. I updated with ssh patching to ojs 2.4.8.3 and then replaced the files in those two pull requests (the lib pkp files were the same, the class comment and registration form files were different probably) and it is working now.