FuelSDK-PHP icon indicating copy to clipboard operation
FuelSDK-PHP copied to clipboard

[BUG] config.php file is already present in my project

Open Sokulev opened this issue 5 years ago • 5 comments

Describe the bug I'm using Magento. config.php file is already present in my project in root dir. I don't want / can't alter it class ET_Client is trying to load it first to get settings instead of using $params when class instantiated.

Causing error: Uncaught exception 'Exception' with message 'baseUrl is null: Must be provided in config file when instantiating ET_Client' in /src/LittlePassports/lpmage/vendor/salesforce-mc/fuel-sdk-php/src/ET_Client.php on line 131

To Reproduce Have empty config.php file in your app root folder.

Expected behavior ET_Client should use params supplied during instantiation or / and config file should be named differently than config.php.

Environment

  • SDK Version [e.g. 1.4.0]
  • PHP version 5.6

The bug has the severity

  • [X] Critical: The defect affects critical functionality or critical data. It does not have a workaround.
  • [X] Major: The defect affects major functionality or major data. It has a workaround but is not obvious and is difficult.
  • [ ] Minor: The defect affects minor functionality or non-critical data. It has an easy workaround.
  • [ ] Trivial: The defect does not affect functionality or data. It does not even need a workaround. It does not impact productivity or efficiency. It is merely an inconvenience.

Sokulev avatar Oct 11 '19 05:10 Sokulev

I've same problem with a Symfony application, any news? Thanks.

alessandrofilira avatar Oct 23 '19 10:10 alessandrofilira

You can move or create your own class for the config.php code. it doesn't have to live in the root.

garek007 avatar Jan 03 '20 14:01 garek007

Seriously, how difficult is it to add an extra optional parameter in the ET_Client constructor to avoid reading config.php?

function __construct($getWSDL = false, $debug = false, $params = null) 
	{

to

function __construct($getWSDL = false, $debug = false, $params = null, $readConfig = true) {

    //....
    if($readConfig && file_exists(realpath('config.php'))) {

    }
    
    // ...
}

That simple :)

aalwash avatar Feb 13 '20 09:02 aalwash

There you go a PR ;)

aalwash avatar Feb 13 '20 10:02 aalwash

It's ugly but it works...

$bak = getcwd();
chdir('/where/there/is/no/config.php/file...');
$client = new ET_Client(false, false, $params);
chdir($bak);

I hope it will be fixed soon !

Other solution : Instead of searching the config.php first, read the $params. If empty, search for the file, no constructor modification.

sp72 avatar Jul 10 '20 14:07 sp72