KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Bug in ResourceManager, publishAssetFolder function #1275

Open Eric opened this topic on on Jan 24, 2020 - 6 comments

Eric commented on Jan 24, 2020

We were trying to solve an issue where when we pushed from a windows development environment to a linux horizontally scaled production environment some of the VMs would not create all of the necessary files for our reports to run (table.css,koolreports.js, etc.). We tried to get around this by modifying the hashing function to no longer rely on the assets local path and manually push the created folders to our production environment.

So we went from this:

$objectHashFolderName = crc32(
                "koolreport"
                .$fullLocalPath
                .@filemtime($fullLocalPath)
                .$this->report->version().$version
            );

to this:

$objectHashFolderName = crc32(
                "koolreport"
                .$this->report->version().$version
            );

After making that modification, some of the files stopped being created even in our testing environment. In order to solve this we had to add a recurseCopy line to the following section of code in order to generate all of the files correctly. We then have to remove that line so the files do not get created over and over again.

            if (!is_dir($objectTargetPath)) {
                Utility::recurseCopy($fullLocalPath, $objectTargetPath);
            } else {
                Utility::recurseCopy($fullLocalPath, $objectTargetPath);
                //Do the check if file in widgetSourceAssetPath is changed,
                //If there is then copy again.
                //Currently do nothing for now
            }

I believe that means there is a bug somewhere on the file creation side if modifying something as small as the hashing function breaks the it.

KoolReport commented on Jan 24, 2020

If you just remove your custom recursiveCopy in later of the if structure, remove all generated resources folder. And then you run report again. Does the new resource folder be created?

P.S: I have inform dev.team about yout issue

Eric commented on Jan 27, 2020

One folder was created containing KoolReport.js and KoolReport.subReport.js. The chart and table js and css files are not created.

KoolReport commented on Jan 27, 2020

I understand the issue now, Please try to replace with this part

            $objectHashFolderName = crc32(
                "koolreport".
                substr($fullLocalPath,strpos($fullLocalPath,"koolreport"))
                .$this->report->version().$version
            );

Let me know if it works.

Eric commented on Jan 29, 2020

That seems to have worked fine for the most part, but every once in a while on our production environment I get this error.

"Trait 'koolreport\laravel\Friendship' not found"

This does not happen in testing, and in production it looks like most of the servers are fine. Any ideas on why this might be happening?

KoolReport commented on Jan 29, 2020

I have no ideas yet since it never happens before. I guess it could be a server with different settings than other. May be you should try to send request to each server to locate which server goes wrong first.

KoolReport commented on Feb 1, 2020

Dear Eric,

Were you able to find out what went wrong?

Regards, KoolReport Team

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
bug
solved

None