KoolReport's Forum

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

Koolreport 3.25 "Warning: strpos(): Empty needle" line 493 utility.php #669

Open Andrew Borell opened this topic on on Feb 13, 2019 - 14 comments

Andrew Borell commented on Feb 13, 2019

Just updated to 3.25 and get the following stack:

Warning: strpos(): Empty needle in C:\wamp\www\_priv\libs\koolreport\src\core\Utility.php on line 493
Call Stack
#	Time	Memory	Function	Location
1	0.0004	373024	{main}( )	...\request.php:0
2	0.0022	464872	DataWrapper->trip( )	...\request.php:57
3	0.2720	1044976	Trip->render( )	...\DataWrapper.php:33
4	0.2729	1108728	koolreport\core\ResourceManager->init( )	...\KoolReport.php:397
5	0.2729	1108808	Trip->fireEvent( )	...\ResourceManager.php:62
6	0.2729	1108808	Trip->koolreport\{closure}( )	...\KoolReport.php:146
7	0.2730	1108888	koolreport\core\ResourceManager->publishAssetFolder( )	...\KoolReport.php:390
8	0.2730	1108912	koolreport\core\Utility::getSymbolicPath( )	...\ResourceManager.php:78
9	0.2730	1108936	strpos ( )	...\Utility.php:493

This only happens on reports where I pass in parameters as an array. Havent spent much time trying to narrow the scope yet.

KoolReport commented on Feb 13, 2019

I have told team to look into that

Andrew Borell commented on Feb 13, 2019

Also of note, these reports use the assets directory and my config in the reports is like this:

 "assets"=>array(
	"path"=> "c:\wamp\www\dbo\api\assets",
	"url"=>"/api/assets",
	),

I'm thinking this has something to do with the assets, and I see a secondary issue in console :

VM370:3 Uncaught SyntaxError: Unexpected token <

which is inside KoolReport.widget.init function

 KoolReport.widget.init(
        <br />

But this might be a secondary issue to the other stack trace which triggers the unexpected token error .

David Winterburn commented on Feb 13, 2019

Hi Andrew,

Would you please post your report's php code where this happens? Thanks!

Andrew Borell commented on Feb 13, 2019

The view or class?

David Winterburn commented on Feb 13, 2019

Which code has "This only happens on reports where I pass in parameters as an array"?

David Winterburn commented on Feb 13, 2019

Hi Andrew,

Please try the following method: open the file core/Utility.php and replace function getSymbolicPath with this:

static function getSymbolicPath($realpath)
    {
        $root = $_SERVER['DOCUMENT_ROOT'];
        $script = $_SERVER['SCRIPT_FILENAME'];
        $root = str_replace('\\', '/', $root);
        $script = str_replace('\\', '/', $script);
        $realpath = str_replace('\\', '/', $realpath);
        
        $dir = str_replace($root, '', $script);
        $pos = false;
        $dir = self::getDir($dir);
        while (! empty($dir)) {
            $pos = strpos($realpath, $dir);
            if ($pos) {
                break;
            }
            $dir = self::getDir($dir);
        }
        if ($pos) {
            $realpath = $root . substr($realpath, $pos);
        }
        return $realpath;
    }

Then let us know if it fixes your warning message. Thanks!

Andrew Borell commented on Feb 13, 2019

That fixed it.

Here is my code after I substituted a few variable and field names with dummy names. I realize after posting this my paths look messed up. That was just in prep to migrate this over to my nginx on ubuntu. Don't think it was the cause though.

Trip.php:

	require_once ('c:\wamp\www\_priv\libs\koolreport\autoload.php');
	
	class Trip extends \koolreport\KoolReport {
	
		function settings()
		{
				return array(
				 "assets"=>array(
					"path"=> "c:////wamp//www//dbo//api//assets",
					"url"=>"/api/assets"
					),
				 "dataSources"=>array(
					"report"=>array(
						'host' => '0.0.0.0',
						'username' => 'username',
						'password' => 'password',
						'dbname' => 'database',
						'class' => '\koolreport\datasources\MySQLDataSource' 
					),
				),
			);
		}

		function setup()
		{
			
			$this->src('report')->query(
				"select t1.date as svc_dt
					  , t1.field1
					  , t1.field2
					  , t1.field3
					  from table1 t1  
					  where t1.id = :my_id ;" 
				)
				->params(array(
					":my_id"=>$this->params["my_id"]
					)
				)
				->pipe($this->dataStore("trip"))->data();
		}
	}	

Trip.view.php

	use \koolreport\datagrid\DataTables;

	echo  '<div>
			<div>
				<h5>' . $this->params["section"] . '</h5>
			</div>
                   <div class="section_body">';
			
				DataTables::create(array(
				"dataSource"=>$this->dataStore('trip_status')
					,"name"=>"example"
					,"columns"=>array(
						"svc_dt"=>array(
							"label"=>"Service Date",
							"type"=>"datetime",
							"format"=>"Y-m-d H:i:s.u",
							"displayFormat"=>"Y-m-d"
							)
						,"field1"=>array(
							"label"=>"Field 1",
							)
						,"field2"=>array(
							"label"=>"Field 2",
							)
						,"field3"=>array(
							"label"=>"Field 3",
							)
					)
				);
		
echo "	</div>
	   </div>";
KoolReport commented on Feb 13, 2019

So is everything working well now? Do you receive the javascript error:

VM370:3 Uncaught SyntaxError: Unexpected token <

anymore?

Andrew Borell commented on Feb 13, 2019

Nope. All errors are cleared up. Thanks for the speedy response. Check the tip jar.

KoolReport commented on Feb 13, 2019

Thank you very much for your generosity!

Eugene commented on Feb 13, 2019

Does everybody also need to do the same update?

KoolReport commented on Feb 13, 2019

This method was there in the previous version, this rare case does not happen in our development environment and passed all of our tests so we could not aware. So if KoolReport works well in your environment, it is fine. Probably we will release new version today and include this fix. Thanks Engene for asking.

David Winterburn commented on Feb 13, 2019

Only necessary if you have the same bug as Andrew. Otherwise, you could wait till the next minor version update. Thanks!

KoolReport commented on Feb 13, 2019

We have just released new version 3.25.1 containing the fix. Also there is upgrade of cloudexport 1.1.0 in KoolReport Pro.

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
None yet

None