[Request] Redis object cache pro wordpress plugin

Legolas

Active member
Trusted Uploader
Feb 26, 2019
175
216
43
Its
It works if you just replace the License.php from the previously nulled version. Put the code below under src/License.php, replace the existing content with the attached one. That should do it.

PHP:
<?php

declare(strict_types=1);

namespace RedisCachePro;

use WP_Error;

class License
{
    /**
     * The license is valid.
     *
     * @var string
     */
    const Valid = 'valid';

    /**
     * The license was canceled.
     *
     * @var string
     */
    const Canceled = 'canceled';

    /**
     * The license is unpaid.
     *
     * @var string
     */
    const Unpaid = 'unpaid';

    /**
     * The license is invalid.
     *
     * @var string
     */
    const Invalid = 'invalid';

    /**
     * The license was deauthorized.
     *
     * @var string
     */
    const Deauthorized = 'deauthorized';

    /**
     * The license plan.
     *
     * @var string
     */
    protected $plan;

    /**
     * The license plan.
     *
     * @var string
     */
    protected $state;

    /**
     * The license plan.
     *
     * @var string
     */
    protected $token;

    /**
     * The license plan.
     *
     * @var array
     */
    protected $organization;

    /**
     * The last time the license was checked.
     *
     * @var int
     */
    protected $last_check;

    /**
     * The last time the license was verified.
     *
     * @var int
     */
    protected $valid_as_of;

    /**
     * The last error associated with the license.
     *
     * @var \WP_Error
     */
    protected $_error;

    /**
     * The license token.
     *
     * @return bool
     */
    public function token()
    {
        return $this->token;
    }

    /**
     * The license state.
     *
     * @return bool
     */
    public function state()
    {
        return $this->state;
    }

    /**
     * Whether the license is valid.
     *
     * @return bool
     */
    public function isValid()
    {
        return $this->state === self::Valid;
    }

    /**
     * Whether the license was canceled.
     *
     * @return bool
     */
    public function isCanceled()
    {
        return $this->state === self::Valid;
    }

    /**
     * Whether the license is unpaid.
     *
     * @return bool
     */
    public function isUnpaid()
    {
        return $this->state === self::Valid;
    }

    /**
     * Whether the license is invalid.
     *
     * @return bool
     */
    public function isInvalid()
    {
        return $this->state === self::Valid;
    }

    /**
     * Whether the license was deauthorized.
     *
     * @return bool
     */
    public function isDeauthorized()
    {
        return $this->state === self::Valid;
    }

    /**
     * Whether the license token matches the given token.
     *
     * @return bool
     */
    public function isToken($token)
    {
        return $this->token === $token;
    }

    /**
     * Load the plugin's license from the database.
     *
     * @return self|null
     */
    public static function load()
    {
        $license = get_site_option('rediscache_license');

        if (
            is_object($license) &&
            property_exists($license, 'token') &&
            property_exists($license, 'state') &&
            property_exists($license, 'last_check')
        ) {
            return static::fromObject($license);
        }
    }

    /**
     * Transform the license into a generic object.
     *
     * @return object
     */
    protected function toObject()
    {
        return (object) [
            'plan' => $this->plan,
            'state' => $this->state,
            'token' => $this->token,
            'organization' => $this->organization,
            'last_check' => $this->last_check,
            'valid_as_of' => $this->valid_as_of,
        ];
    }

    /**
     * Instanciate a new license from the given generic object.
     *
     * @param  object  $object
     * @return self
     */
    public static function fromObject(object $object)
    {
        $license = new self;

        foreach (get_object_vars($object) as $key => $value) {
            property_exists($license, $key) && $license->{$key} = $value;
        }

        return $license;
    }

    /**
     * Instanciate a new license from the given response object.
     *
     * @param  object  $response
     * @return self
     */
    public static function fromResponse(object $response)
    {
        $license = static::fromObject($response);
        $license->last_check = current_time('timestamp');

        if ($license->isValid()) {
            $license->valid_as_of = current_time('timestamp');
        }

        if (is_null($license->state)) {
            $license->state = self::Invalid;
        }

        return $license->save();
    }

    /**
     * Instanciate a new license from the given response object.
     *
     * @param  object  $response
     * @return self
     */
    public static function fromError(WP_Error $error)
    {
        $license = new self;

        foreach ($error->get_error_data() as $key => $value) {
            property_exists($license, $key) && $license->{$key} = $value;
        }

        $license->_error = $error;
        $license->last_check = current_time('timestamp');

        error_log('objectcache.warning: ' . $error->get_error_message());

        return $license->save();
    }

    /**
     * Persist the license as a network option.
     *
     * @return self
     */
    public function save()
    {
        update_site_option('rediscache_license', $this->toObject());

        return $this;
    }

    /**
     * Deauthorize the license.
     *
     * @return self
     */
    public function deauthorize()
    {
        $this->valid_as_of = null;
        $this->state = self::Deauthorized;

        return $this->save();
    }

    /**
     * Bump the `last_check` timestamp on the license.
     *
     * @return self
     */
    public function checkFailed(WP_Error $error)
    {
        $this->_error = $error;
        $this->last_check = current_time('timestamp');

        error_log('objectcache.notice: ' . $error->get_error_message());

        return $this->save();
    }

    /**
     * Whether it's been given minutes since the last check.
     *
     * @return bool
     */
    public function minutesSinceLastCheck(int $minutes)
    {
        if (! $this->last_check) {
            delete_site_option('rediscache_license_last_check');

            return true;
        }

        $validUntil = $this->last_check + ($minutes * MINUTE_IN_SECONDS);

        return $validUntil < current_time('timestamp');
    }

    /**
     * Whether it's been given hours since the license was successfully verified.
     *
     * @return bool
     */
    public function hoursSinceVerification(int $hours)
    {
        if (! $this->valid_as_of) {
            return true;
        }

        $validUntil = $this->valid_as_of + ($hours * HOUR_IN_SECONDS);

        return $validUntil < current_time('timestamp');
    }
}
It’s not enough just replacing that code into the License file. That way it display licensed on screen but it’s not really working. To get it working other things needs to be done. And you can verify it by going into the health report, were there is other warnings after replacing that code into the license.php file.

For me, main problem is that plugin is not detecting phpredis and igbinary already loaded as I can see with phpinfo() function. There are critical error being logged as exceptions into my php logs. So I’m having other issues. May be 1.14.1 works better
 
Last edited:

ckeeper

Well-known member
Nov 8, 2019
623
376
63
Its

It’s not enough just replacing that code into the License file. That way it display licensed on screen but it’s not really working. To get it working other things needs to be done. And you can verify it by going into the health report, were there is other warnings after replacing that code into the license.php file.

For me, main problem is that plugin is not detecting phpredis and igbinary already loaded as I can see with phpinfo() function. There are critical error being logged as exceptions into my php logs. So I’m having other issues. May be 1.14.1 works better
Asides from token error everything else works fine on my end. Of course you can not update either, due to unlicensed token we are using. If you still have issues read my earlier post in regards to parameters you need to add into your wp-config.php file.
 
Last edited:

Legolas

Active member
Trusted Uploader
Feb 26, 2019
175
216
43
Asides from token error everything else works fine on my end. Of course you can not update either, due to unlicensed token we are using. If you still have issues read my earlier post in regards to parameters you need to add into your wp-config.php file.
May be you are right but after some investigations I’ve discovered that the problem rises from WP-CLI. When the plugin is being used from php-fpm it works fine, but can’t understand why, when I use WP-CLI to execute the cron schedules there is critical errors from Redis cache plugin. It’s not detecting loaded phpredis or igbinary.
 

ckeeper

Well-known member
Nov 8, 2019
623
376
63
May be you are right but after some investigations I’ve discovered that the problem rises from WP-CLI. When the plugin is being used from php-fpm it works fine, but can’t understand why, when I use WP-CLI to execute the cron schedules there is critical errors from Redis cache plugin. It’s not detecting loaded phpredis or igbinary.
It is best to check your server logs to find out about the error messages, you can also install query monitor to see all kinds of warnings and errors as well.
 

danielli

Member
Mar 29, 2020
200
21
18
Here you have. It's nulled



Here you go:



Hello,

I tested both 1.13.1 and 1.14.1, but only the version 1.13.1 works, and here are screenshots:




and here is the content in wp-config"


Code:
define( 'WP_CACHE', true);
define('WP_REDIS_CONFIG', [
'token' => 'Vwwz2Xjf3RLsjJlBxBpLJbJcIRoi9rfszjmOqecMzQ1RB3K8jYQAOMkrCFCi', // 60 chars random string
'host' => '127.0.0.1',
'port' => 6379,
'database' => 1, // change for each site
'maxttl' => 86400 * 7,
'timeout' => 1,
'read_timeout' => 0.5,
'async_flush' => true,
'split_alloptions' => true,
'prefetch' => true,
'debug' => false,
'save_commands' => false,
]);
define('WP_REDIS_DISABLED', getenv('WP_REDIS_DISABLED') ?: false);
define( 'WP_REDIS_PREFIX', 'mysite.com' );
define( 'WP_REDIS_SELECTIVE_FLUSH', true);



What did I miss please? any suggestion please?

By the way, question please?

1.# I noted this info:
'database' => 0, // change for each site

But, how to differentiate the database if there are two wordpress sites on one single server please?

2# Does Redis object cache pro relay on Nginx Helper too please?

Thanks in advance.
 

Legolas

Active member
Trusted Uploader
Feb 26, 2019
175
216
43
Hello,

I tested both 1.13.1 and 1.14.1, but only the version 1.13.1 works, and here are screenshots:




and here is the content in wp-config"


Code:
define( 'WP_CACHE', true);
define('WP_REDIS_CONFIG', [
'token' => 'Vwwz2Xjf3RLsjJlBxBpLJbJcIRoi9rfszjmOqecMzQ1RB3K8jYQAOMkrCFCi', // 60 chars random string
'host' => '127.0.0.1',
'port' => 6379,
'database' => 1, // change for each site
'maxttl' => 86400 * 7,
'timeout' => 1,
'read_timeout' => 0.5,
'async_flush' => true,
'split_alloptions' => true,
'prefetch' => true,
'debug' => false,
'save_commands' => false,
]);
define('WP_REDIS_DISABLED', getenv('WP_REDIS_DISABLED') ?: false);
define( 'WP_REDIS_PREFIX', 'mysite.com' );
define( 'WP_REDIS_SELECTIVE_FLUSH', true);



What did I miss please? any suggestion please?

By the way, question please?

1.# I noted this info:
'database' => 0, // change for each site

But, how to differentiate the database if there are two wordpress sites on one single server please?

2# Does Redis object cache pro relay on Nginx Helper too please?

Thanks in advance.
Just use one database for a site and another one for the other site. 0 and 1 for example. When you say that doesn't work, you didn't provide any details or info. There is no way to know what happens
 

danielli

Member
Mar 29, 2020
200
21
18
Just use one database for a site and another one for the other site. 0 and 1 for example. When you say that doesn't work, you didn't provide any details or info. There is no way to know what happens


Thanks for reply.

I am testing on a fresh server and fresh Wordpress installation,

For now, the 1.13.1 works, but 1.14.1 does not work.

Please let me know what kind of information should I post here for tracking issue, and I am glad to post here.

Thanks
 

Legolas

Active member
Trusted Uploader
Feb 26, 2019
175
216
43
After push "Enable Cache", it just show:
  • Status: Not connected
  • Drop-in: Valid
and here is the screenshot: https://prnt.sc/1xyhzow
For me it’s working fine. I can enable or disable the drop-in. Try to look into the error logs, may be there’s something that could indicate the problem. May be that Redis version is old or something else missing in your installation
 

danielli

Member
Mar 29, 2020
200
21
18
For me it’s working fine. I can enable or disable the drop-in. Try to look into the error logs, may be there’s something that could indicate the problem. May be that Redis version is old or something else missing in your installation
Hello,

Thanks.

What do you mean exactly by "error logs" please?

Should I enable debug in Wp-config.php? or any addons to enable "Log variables" as this article at https://querymonitor.com/docs/logging-variables/


Thanks
 

About us

  • Our community has been around for many years and pride ourselves on offering unbiased, critical discussion among people of all different backgrounds. We are working every day to make sure our community is one of the best.

Quick Navigation

User Menu