Jump to content

Welcome, Guest!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Pilou

Impossible to save modification in product

Recommended Posts

 

4 hours ago, Pilou said:

Hey Petr,

Thank you for your answer.

Here is the paygreen Module

This module contains a bug. With every request, file /var/paygreen/autoload.cache.php is over-written with list (subset) of module classes used by current thread. This file is also used by autoloader to load classes.

This can (and does) lead to race condition -- one thread can write new content to this file, while other thread is reading it. 

Note that this is bug in the module, not in the thirtybees. You are experiencing it in back office, because thirtybees trigger multiple ajax requests at the same time, creating ideal conditions for this race condition to happen. But it's more than likely the same problem occurs on your frontend as well, if there is enough visitors so multiple request arrives at the same time (or close enough)

You need to fix the module, or ask its developer to do that. 

 

  • Like 1

Share this post


Link to post
Share on other sites

Hi Petr,

Thank you very much for your professional opinion.
Not being able to solve this bug alone, I will wait patiently for the reaction of Paygreen.

Share this post


Link to post
Share on other sites
13 minutes ago, Pilou said:

Hi Petr,

Thank you very much for your professional opinion.
Not being able to solve this bug alone, I will wait patiently for the reaction of Paygreen.

Meanwhile, this is what you can do:

edit file /modules/paygreen/bundles/PGFramework/Services/Autoloader.php

and delete content of function extendCache. -- find this code 

    protected function extendCache($className, $src)
    {
        $this->classNames[$className] = $src;

        $cache = '<?php return ' . var_export($this->classNames, true) . ';' . PHP_EOL;

        @file_put_contents($this->getCacheFilename(), $cache, LOCK_EX);
    }

and replace it with

    protected function extendCache($className, $src)
    {
    }

And it should work. 

  • Like 2

Share this post


Link to post
Share on other sites

YES ! It seems to work.
You're great Petr, thanks a lot. 🙂

Share this post


Link to post
Share on other sites

It's possible the connection type or speed or perhaps IP address might have something to do with this @datakick when I was on "true wifFi", an actual wiFi connection today it worked fine, with the Save function fine, this evening I'm on "Wifi" but its actually a WifI connection to a phone thats running cell data... and the Save in products does not work again, everything else is the same... apart from the connection.

It doesnt work regardless of device/ browser

 

 

Edited by Mark

Share this post


Link to post
Share on other sites
24 minutes ago, Mark said:

It's possible the connection type or speed or perhaps IP address might have something to do with this @datakick when I was on "true wifFi", an actual wiFi connection today it worked fine, with the Save function fine, this evening I'm on "Wifi" but its actually a WifI connection to a phone thats running cell data... and the Save in products does not work again, everything else is the same... apart from the connection.

It doesnt work regardless of device/ browser

@Mark it is really hard to tell what's wrong without any technical information. Does the system show popup window with any error? Is there any javascript error in browser's console? Is there any failed (404/502/527/...) http request to the server displayed in Network tab in browser's console? If so, what is the returned content of this failed request? (look into preview subtab)

Share this post


Link to post
Share on other sites

CONSOLE:

 

Loading failed for the <script> with source “blob:https://product.solutions.org.nz/4d36e740-8dfb-4afe-a1f7-1ba2157fd731”. index.php:1:1
The character encoding of a framed document was not declared. The document may appear different if viewed without the document framing it. enquire.min.js
The character encoding of a framed document was not declared. The document may appear different if viewed without the document framing it. admin-theme.js

 

Network attached as HAR @datakick

Edited by datakick: removed HAR file, as it contains sensitive information

 

Share this post


Link to post
Share on other sites

@Mark you are not on the latest bleeding edge, or you didn't clear your browser/server/cloudflare cache.

File js/admin/products.js does not contain the fix. Line 213 contains 

if (typeof this.current_request !== 'undefined' && typeof this.current_request === "function") {

instead of the correct one

if (typeof this.current_request !== 'undefined' && typeof this.current_request.complete === "function") {

You need to upgrade to latest version, and clear *all* caches. Don't forget the cloudflare one.

Share this post


Link to post
Share on other sites
1 hour ago, datakick said:

 

Don't forget the cloudflare one.

It was cloudflare, thanks @datakick Maybe one day via an API than we can clear the cloudflare cache, and browser and server cache in one button?

Share this post


Link to post
Share on other sites

Hey @datakick

Paygreen updated their module to v2.6.3 and the same problem came back... (can't save product modification).

I modified the file /modules/paygreen/bundles/PGFramework/Services/Autoloader.php as you mentionned before and it works.

But I hope I do not make mistakes, so I attached the module to this post.
If you have time to take a look at it 😉

Kind regards

v2.6.3-paygreen.zip

Share this post


Link to post
Share on other sites

Yeah, you are right. It still doesn't work.

They use flock to lock the file, but it's not enough. Probably one of these kicked in (from php documentation):

Quote

Because flock() requires a file pointer, you may have to use a special lock file to protect access to a file that you intend to truncate by opening it in write mode (with a "w" or "w+" argument to fopen()).

Quote

On some operating systems flock() is implemented at the process level. When using a multithreaded server API like ISAPI you may not be able to rely on flock() to protect files against other PHP scripts running in parallel threads of the same server instance!

 

You should report this bug once again. And while you are at it, tell them to remove this 'cache' functionality completely. The extendCache method tries very hard to create var/paygreen/autoload.cache.php cache file. But they don't actually use this file at all - the module reads it in constructor into property $classNames, but this variable is never used for anything.

This means that if we modify the file and delete:

  • property $classNames
  • constructor
  • extendCache method
  • and the call $this->extendCache

we will end up with much smaller, faster code doing exactly the same. But without this race-condition bug.

I'm attaching modified file, please pass it to the dev of the module when you report this issue. 

Autoloader.php

 
  • Thanks 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...