KoolReport's Forum

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

Full server filepath appearing in koolreport_assets path #1984

Open James Caws opened this topic on on Mar 20, 2021 - 11 comments

James Caws commented on Mar 20, 2021

Hi. Recently the shared hosting I use with SiteGround was upgraded. Since then KoolReport is broken. When I look at the HTML source code I find:

<script type='text/javascript' src='/home/$user/www/$sitename/public_html/koolreport_assets/3409401219/KoolReport.js'></script>

Previously it was:

<script type='text/javascript' src='/koolreport_assets/3409401219/KoolReport.js'></script>

What might be causing the change? Any advice on how I can fix or configure KoolReport to use the correct path please? If not, I will speak to tech support at SiteGround.

Website uses Laravel framework.

KoolReport commented on Mar 20, 2021

Do you use Laravel package?

use \koolreport\laravel\Friendship;

If you have not, please try to use this.

Let us know if it works.

James Caws commented on Mar 20, 2021

I have tried using Friendship but it didn't change anything. Seems settings() not being called/run?

use \koolreport\KoolReport;

class MyKoolReport extends \koolreport\KoolReport
{
        //use \koolreport\cloudexport\Exportable;
        use \koolreport\laravel\Friendship;

        function settings()
        {
                return array(
                        "assets"=>array(
                                "path"=>"../../public/resources/kool",
                                "url"=>"resources/kool"
                        )
                );
        }
James Caws commented on Mar 21, 2021

Just noticed that the 'view' seems to be making static calls:

ComboChart::create($aChart);

At the top there is:

use \koolreport\widgets\google\ComboChart

My old developer set this up and it looks like he didn't do it like your demo and my PHP is very basic, so I find this hard to explain.

Is there somewhere I can hardcode assets url and path? Ideally somewhere that won't get overwritten when I update KoolReport next time.

Currently on 5.0.1.

Sebastian Morales commented on Mar 22, 2021

James, if you already used trait \koolreport\laravel\Friendship please try to comment out the "assets" setting like this:

        function settings()
        {
                //return array(
                //        "assets"=>array(
                //                "path"=>"../../public/resources/kool",
                //                "url"=>"resources/kool"
                //        )
                //);
        }

Let us know if this solution works for you. Tks,

James Caws commented on Mar 23, 2021

No, that doesn't help, sorry.

Sebastian Morales commented on Mar 23, 2021

Well, if automatic resources setting doesn't work pls try to set it manually:


        function settings()
        {
                return array(
                        "assets"=>array(
                                "path"=>$kool_assets_path, //absolute or relative path to Laravel's public's kool_assets subdirectory. Create the subdirectory "kool_assets" if it hasn't existed yet
                                "url"=>$kool_assets_url //url to Laravel's public's kool_assets subdirectory, says "/public/kool_assets"
                        )
                );
        }
James Caws commented on Mar 23, 2021

I think the way my old developer set things up is not right and the function override isn't working.

Anyway, I did some further investigation and found this:

In file koolreport/core/src/core/ResourceManager.php and function publishAssetFolder, I noticed the SCRIPT_FILENAME is not run through realpath() function, which is used in core/src/core/Utility.php function getDocumentRoot.

My web host's server does something to the file path and depending on whether you use realpath() or not, you get a different path, e.g.

                $script_folder = Utility::standardizePathSeparator(
                    dirname($_SERVER["SCRIPT_FILENAME"])
                );

                // returns /home/u12345/www/mysite.com/public_html/index.php
		$script_folder = Utility::standardizePathSeparator(
                    dirname(realpath($_SERVER["SCRIPT_FILENAME"]))
                );

                // returns /home/customer/www/mysite.com/public/index.php

I've updated function publishAssetFolder to also use realpath() and now graphs are showing.

Do you need to update the core files to be consistent?

Sebastian Morales commented on Mar 23, 2021

Thanks much, James, for the detail information. Your server hosting could be using symlink linking your project directory to the web directory, which in some cases does break the resources path. We will consider your case and find a solution so you won't have to manually fix it yourself. Thanks again!

James Caws commented on Mar 23, 2021

Yes, they are also doing something “clever” with the username after /home — actual path uses a username (e.g. /home/u1234). But when run through KoolReport realpath() function the unique username is changed to the word “customer” (I.e. /home/customer).

James Caws commented on Mar 25, 2021

@Sebastian - Do you think you will be able to update this thread with the outcome of your review please? I would like to be confident I don't push an update live that breaks things again, so if a fix won't be made to core files I will need to remember to apply my own. Thank you.

Sebastian Morales commented on Mar 26, 2021

James, I think it's best you use your own fix right now and keep note of it. We don't release the Core framework too often. When we do you could check if the new release solves your problem. If it doesn't you can always fall back on your fix. Regards,

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
help needed
solved

None