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

[BUG] Configuration getOrDefault returns default values for false settings #344

Open
simonklink opened this issue Nov 13, 2024 · 3 comments
Labels

Comments

@simonklink
Copy link

We use the domain sync cronjob:
modules/registrars/openprovider/cron/DomainSync.php

And this uses the process_domains method where it loads the configuration settings
https://github.com/openprovider/Openprovider-WHMCS-domains/blob/master/modules/registrars/openprovider/src/DomainSync.php#L149

However this method contains a bug
https://github.com/openprovider/Openprovider-WHMCS-domains/blob/master/modules/registrars/openprovider/src/Configuration.php#L51

public static function getOrDefault($key, $defaultValue = false)
{
    self::init();
    $value = self::$config[$key];
    if (!$value) {
        return $defaultValue;
    }

    return $value;
}

If the setting is false the default value is returned because of these lines:

if (!$value) {
    return $defaultValue;
}

So our configuration contained false for syncExpiryDate
But the default value in the process_domains code is true.

$setting['syncExpiryDate'] = Configuration::getOrDefault('syncExpiryDate', true);

So now all our expirydates are updated which we didn't want.
So the correct code should be something like:

public static function getOrDefault($key, $defaultValue = false)
{
    self::init();
    return array_key_exists($key, self::$config) ? self::$config[$key] : $defaultValue;
}
@simonklink simonklink added the bug label Nov 13, 2024
@sapillai
Copy link
Collaborator

Hi @simonklink,

Openprovider cron sync feature is deprecated since version 5.3 of the Openprovider domain module, and is not recommended for versions WHMCS 8+. We suggest that you use the WHMCS native domain sync and do not use the Openprovider custom sync for WHMCS 8 and higher.

This information is available in the readme.

@sapillai sapillai closed this as not planned Won't fix, can't repro, duplicate, stale Nov 13, 2024
@simonklink
Copy link
Author

Hi @sapillai,

Thats ok, but the Configuration::getOrDefault is used on more locations than only in the deprecated domain sync.

So the bug also applies to all the other Configuration::getOrDefault that provide a default value and have a false setting.

@sapillai
Copy link
Collaborator

Hi @simonklink,

Thats ok, but the Configuration::getOrDefault is used on more locations than only in the deprecated domain sync.
So the bug also applies to all the other Configuration::getOrDefault that provide a default value and have a false setting.

I have re-opened this issue and will have our developers check this.

@sapillai sapillai reopened this Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants