Keyword

Error in system plugin v2.10.3

  • Bill Tomczak
  • Bill Tomczak's Avatar Topic Author
  • Offline
  • New Member
More
4 years 3 months ago #176639 by Bill Tomczak
Error in system plugin v2.10.3 was created by Bill Tomczak
In this block of code:
            if ($caching) {
                preg_match("#<script type=\"application/x\-k2\-headers\">(.*?)</script>#is", $response, $getK2CacheHeaders);
                $getK2CacheHeaders = json_decode(trim($getK2CacheHeaders[1]));
                if (is_object($getK2CacheHeaders)) {
                    JResponse::allowCache(true);
                    foreach ($getK2CacheHeaders as $type => $value) {
                        JResponse::setHeader($type, $value, true);
                    }
                }
            }

There are some cases where the preg_match evaluates to false causing the json_decode() to throw an error.

Would be nice to have that fixed to something like:
            if ($caching) {
                if (preg_match("#<script type=\"application/x\-k2\-headers\">(.*?)</script>#is", $response, $getK2CacheHeaders)) {
                    $getK2CacheHeaders = json_decode(trim($getK2CacheHeaders[1]));
                    if (is_object($getK2CacheHeaders)) {
                        JResponse::allowCache(true);
                        foreach ($getK2CacheHeaders as $type => $value) {
                            JResponse::setHeader($type, $value, true);
                        }
                    }
                }
            }

Please Log in or Create an account to join the conversation.

More
4 years 3 months ago #176640 by JoomlaWorks
Replied by JoomlaWorks on topic Error in system plugin v2.10.3
It's already been improved in K2 v2.10.4 (dev) - see github.com/getk2/k2/blob/master/plugins/system/k2.php#L690 - as I also stumbled into some notices/warnings as well.

You can get K2 v2.10.4 (dev) from: getk2.org/downloads/?f=K2_Development_Release.zip

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Bill Tomczak
  • Bill Tomczak's Avatar Topic Author
  • Offline
  • New Member
More
4 years 3 months ago #176641 by Bill Tomczak
Replied by Bill Tomczak on topic Error in system plugin v2.10.3
Excellent! Many thanks!

Please Log in or Create an account to join the conversation.

More
4 years 3 months ago #176650 by JoomlaWorks
Replied by JoomlaWorks on topic Error in system plugin v2.10.3
You're welcome.

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum