Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sspak-sniffter doesn't work with SS4 app object #59

Open
sminnee opened this issue Jun 25, 2017 · 4 comments
Open

sspak-sniffter doesn't work with SS4 app object #59

sminnee opened this issue Jun 25, 2017 · 4 comments
Labels

Comments

@sminnee
Copy link
Member

sminnee commented Jun 25, 2017

https://github.com/silverstripe/sspak/blob/master/src/sspak-sniffer.php relies on Core.php and global $databaseConfig. For SilverStripe 4 this will need to change.

Ideally, the pre-app-object support for SS4 will still work.

@mikenz
Copy link
Contributor

mikenz commented Jun 28, 2017

Our quick fix is:

} else if(file_exists(BASE_PATH.'/framework/src/Core/CoreKernel.php')) {
	//SS 4 OO
    use SilverStripe\Control\HTTPApplication;
    use SilverStripe\Control\HTTPRequest;
    use SilverStripe\Core\CoreKernel;
	
	require_once(BASE_PATH. '/vendor/autoload.php');

	if (!file_exists($autoloadPath = BASE_PATH. '/vendor/autoload.php')) {
	    exit;
	}

	require_once $autoloadPath;

	// Mock request
	$request = new HTTPRequest('GET', '/');
	$request->setSession(new Session([])));
	$kernel = new CoreKernel(BASE_PATH);
	$app = new HTTPApplication($kernel);
	
	$app->execute($request, function (HTTPRequest $request) {
		global $databaseConfig;
		$output = array();
		foreach($databaseConfig as $k => $v) {
		    $output['db_' . $k] = $v;
		}
		$output['assets_path'] = ASSETS_PATH;

		echo serialize($output);
		echo "\n";
		
	});
	exit;
} else {

phptek pushed a commit to phptek/sspak that referenced this issue Nov 8, 2017
…ourtest @mikenz)

- Replaced `use` keyword with full-namespace construction
- Forced various $_SERVER env vars required by HTTPResponse.php
- Uses .env file for DB credentials
@phptek
Copy link

phptek commented Nov 8, 2017

The branch ss4rc1-compat works in Dev, but I have only tested the save command. Our sysadmins use sspak with Fabricdeploy so will ensure it works for their use-cases and report back...sometime.

Thanks to @mikenz that formed the basis of this.

@dhensby
Copy link
Contributor

dhensby commented Dec 19, 2017

see #64

@LABCAT
Copy link

LABCAT commented Aug 15, 2019

This code seems to be very SS3 centric because there is no mention of

vendor/silverstripe/framework/core.php or something like that.

https://github.com/silverstripe/sspak/blob/master/src/DataExtractor/DatabaseConnector.php#L28-L44

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants