Openprovider-WHMCS-domains icon indicating copy to clipboard operation
Openprovider-WHMCS-domains copied to clipboard

[BUG] Another conflict with PHP8.1

Open maverick85 opened this issue 2 years ago • 14 comments

Describe the bug After updating to WHMCS to v8.6.1 I am no longer able to access the "Domains" tab under Client if the domain is using the OpenProvider integration.

To Reproduce Steps to reproduce the behavior:

  1. Go to "Clients > View/Search Clients"
  2. Click on a client with OP domains
  3. Go to the Domains tab/view
  4. See error

Expected behavior See domain details.

Error Info:

TypeError: Cannot access offset of type string on string in /var/www/sites/public_html/panel/modules/registrars/openprovider/vendor/wedevelopcoffee/wpower/src/Domain/AdditionalFields.php:96
Stack trace:
#0 /var/www/sites/public_html/panel/modules/registrars/openprovider/src/AdditionalFields.php(93): WeDevelopCoffee\wPower\Domain\AdditionalFields->getFilteredAdditionalFields()
#1 /var/www/sites/public_html/panel/modules/registrars/openprovider/helpers.php(18): OpenProvider\WhmcsRegistrar\src\AdditionalFields->get()
#2 /var/www/sites/public_html/panel/resources/domains/additionalfields.php(8): openprovider_additional_fields()
#3 /var/www/sites/public_html/panel/vendor/whmcs/whmcs-foundation/lib/Domains/AdditionalFields.php(0): unknown()
#4 /var/www/sites/public_html/panel/vendor/whmcs/whmcs-foundation/lib/Domains/AdditionalFields.php(0): WHMCS\Domains\AdditionalFields->fetch()
#5 /var/www/sites/public_html/panel/vendor/whmcs/whmcs-foundation/lib/Domains/AdditionalFields.php(0): WHMCS\Domains\AdditionalFields->loadFieldsData()
#6 /var/www/sites/public_html/panel/vendor/whmcs/whmcs-foundation/lib/Domains/AdditionalFields.php(0): WHMCS\Domains\AdditionalFields->setTLD()
#7 /var/www/sites/public_html/panel/op/clientsdomains.php(0): WHMCS\Domains\AdditionalFields->setDomain()
#8 {main}

Server info:

  • Distro: AlmaLinux 9
  • PHP: 8.1.13
  • Web server: httpd -> Apache

Additional context Same error happens if I go to "Clients > Domain Registrations" and click on any OP domain.

maverick85 avatar Dec 12 '22 13:12 maverick85

Hi @maverick85,

Thank you for reporting the issue.

I tried to recreate the problem with PHP 8.1.3 and WHMCS 8.6.1, but I couldn't. Is the issue occurring with all domains or specific TLDs? Can you also please confirm the WHMCS module version you are using?

sapillai avatar Dec 14 '22 11:12 sapillai

Hi there, replied to this all in the email. All up to date and happening with any domain. If we remove the file resources/domains/additionalfields.php that has:

<?php
/**
* Openprovider only overrides additional fields that are configured in WHMCS Domain Pricing with Openprovider as registrar.
* Put this code above the other fields. Don't override additional fields manually for Openprovider: we maintain this for you.
*/

if (function_exists('openprovider_additional_fields'))
	$additionaldomainfields = openprovider_additional_fields();

with the distribution provided file dist.additionalfields.php the error no longer appears.

maverick85 avatar Dec 15 '22 13:12 maverick85

I'm also getting the same issue.

Either I will have to switch to PHP 7.4.x or remove the additionalfields.php, as @maverick85 said.

pmjcreations avatar Dec 15 '22 17:12 pmjcreations

I have been contacted by the support who asked me to update my module with the latest downloaded from here.

I download the latest, replaced all folders on my installation, the issue persists.

  • WHMCS version: 8.6.1 (latest to date)
  • OpenProvider WHMCS module: latest downloaded a couple hours ago
  • PHP Version: 8.1.13
  • OpenProvider Additional Fields: If I want the application to stop working.

maverick85 avatar Dec 21 '22 11:12 maverick85

@maverick85 @pmjcreations,

Thank you for sharing the details, we will investigate the problem.

sapillai avatar Dec 21 '22 12:12 sapillai

Hello all

I´m experiencing the same error, yet in a different place (while ordering a domain). As it´s pretty similar, I thought I would just join this threat instead of creating a new one.

It works without the additionalfields.php, but I´m not sure about the possible impact of removing it...

** Steps to reproduce ** Add any available domain to cart -> Press buy No sign in required. Domain tld does not matter.

Error:

TypeError: Cannot access offset of type string on string in /var/> www/html/modules/registrars/openprovider/vendor/wedevelopcoffee/> wpower/src/Domain/AdditionalFields.php:96 Stack trace: #0 /var/www/html/modules/registrars/openprovider/src/> AdditionalFields.php(93): > WeDevelopCoffee\wPower\Domain\AdditionalFields->getFilteredAdditiona> lFields() #1 /var/www/html/modules/registrars/openprovider/helpers.php(18): > OpenProvider\WhmcsRegistrar\src\AdditionalFields->get() #2 /var/www/html/resources/domains/additionalfields.php(8): > openprovider_additional_fields() #3 /var/www/html/vendor/whmcs/whmcs-foundation/lib/Domains/> AdditionalFields.php(0): unknown() #4 /var/www/html/vendor/whmcs/whmcs-foundation/lib/Domains/> AdditionalFields.php(0): WHMCS\Domains\AdditionalFields->fetch> ('additionalfield...') #5 /var/www/html/vendor/whmcs/whmcs-foundation/lib/Domains/> AdditionalFields.php(0): > WHMCS\Domains\AdditionalFields->loadFieldsData() #6 /var/www/html/cart.php(0): WHMCS\Domains\AdditionalFields->setTLD> ('.com') #7 {main}

Server info:

  • Distro: Rocky Linux release 8.7 (Green Obsidian)
  • PHP: 8.1.13
  • Web server: Apache
  • WHMCS: 8.6.1

Falscher42 avatar Dec 23 '22 19:12 Falscher42

Any solution?

AndyAlvarezDev avatar Jan 01 '23 21:01 AndyAlvarezDev

Hi there,

So there's no fix yet I'd say, but I will share the message I got from OP this morning asking to test a fix.

To fix the error in https://github.com/openprovider/Openprovider-WHMCS-domains/issues/252, could you please change line 96 of the file: modules/registrars/openprovider/vendor/wedevelopcoffee/wpower/src/Domain/AdditionalFields.php and test?

From if(!isset($tmpRegistrarFields[$whmcsField['Name']]))

To: if (is_array($tmpRegistrarFields) && !isset($tmpRegistrarFields[$whmcsField['Name']]))

It didn't fix for me, but it would be interesting to have others testing as well.

maverick85 avatar Jan 03 '23 12:01 maverick85

Well, I have added the project to PhpStorm by myself and I have solved several things, now it works normally! I could not wait!

If the project admins agree, I can collaborate and send a pull request of what I have done...

Screenshot

AndyAlvarezDev avatar Jan 03 '23 18:01 AndyAlvarezDev

I believe it would be very interesting, but that's my opinion. Basing on the interactions of the OpenProvider team here... my opinion is my own.

maverick85 avatar Jan 03 '23 18:01 maverick85

@AndyAlvarezDev yes, please submit a pull request and I will ask our developers to review and merge it or to create it as a pre-release so that others can test it before merging it to master.

sapillai avatar Jan 04 '23 05:01 sapillai

@AndyAlvarezDev could you please submit a pull request. We are looking forward to get a solution to this. Thank you.

maverick85 avatar Jan 06 '23 18:01 maverick85

@maverick85 @pmjcreations @Falscher42

Thank you for your patience.

Based on our developers' analysis, the error indicates an issue with the value of $whmcsField['Name']. Our developers have proposed two fixes for this issue, both of which add additional conditions.

Unfortunately, we are unable to test the fixes since we couldn't reproduce the issue even with fresh installations of WHMCS and the module. Therefore I am attaching two copies of the 'AdditionalFields.php' files with the proposed fixes - Fixes-252.zip

Please backup or rename existing file: 'modules/registrars/openprovider/vendor/wedevelopcoffee/wpower/src/Domain/AdditionalFields.php' and replace it with the copies attached. Please test with both copies of 'AdditionalFields.php' and let us know if that fixes the problem with accessing the Domains tab and domain registration with PHP 8.1.

We are looking forward to your feedback.

sapillai avatar Feb 02 '23 08:02 sapillai

It seems good on my install :-)

lonyai avatar Feb 02 '23 08:02 lonyai

Hi,

A proper official fix has been added for error "Cannot access offset of type string on string" with 'AdditionalFields.php' in the latest version of the module - version 5.8.0. Please upgrade the module to latest version if you are experiencing this problem.

sapillai avatar Jun 03 '24 10:06 sapillai