-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
topics script alert fix improved adding oauth clientin upgrade script
- Loading branch information
Showing
4 changed files
with
89 additions
and
23 deletions.
There are no files selected for viewing
65 changes: 64 additions & 1 deletion
65
newscoop/install/Resources/sql/upgrade/4.4.x/2015.02.24/add_client.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,65 @@ | ||
<?php | ||
exec(__DIR__.'/../../../../../../application/console oauth:create-client newscoop '.$_SERVER['HTTP_HOST'].' '.$_SERVER['HTTP_HOST'].' --default', $output, $code); | ||
|
||
$newscoopDir = realpath(dirname(__FILE__).'/../../../../../../'); | ||
|
||
require_once $newscoopDir.'/vendor/autoload.php'; | ||
require $newscoopDir.'/conf/database_conf.php'; | ||
|
||
use Monolog\Logger; | ||
use Newscoop\Installer\Services; | ||
use Symfony\Component\Process\Process; | ||
use Symfony\Component\Process\PhpExecutableFinder; | ||
|
||
$upgradeErrors = array(); | ||
$app = new Silex\Application(); | ||
$app->register(new Silex\Provider\MonologServiceProvider(), array( | ||
'monolog.logfile' => $newscoopDir.'/log/upgrade.log', | ||
'monolog.level' => Logger::NOTICE, | ||
'monolog.name' => 'upgrade', | ||
)); | ||
|
||
$app->register(new Silex\Provider\DoctrineServiceProvider(), array( | ||
'db.options' => array( | ||
'driver' => 'pdo_mysql', | ||
'host' => $Campsite['db']['host'], | ||
'dbname' => $Campsite['db']['name'], | ||
'user' => $Campsite['db']['user'], | ||
'password' => $Campsite['db']['pass'], | ||
'port' => $Campsite['db']['port'], | ||
'charset' => 'utf8', | ||
), | ||
)); | ||
|
||
$app['upgrade_service'] = $app->share(function () use ($app) { | ||
return new Services\UpgradeService($app['db'], $app['monolog']); | ||
}); | ||
|
||
$logger = $app['monolog']; | ||
|
||
$newscoopConsole = escapeshellarg($newscoopDir.'/application/console'); | ||
$phpFinder = new PhpExecutableFinder(); | ||
$phpPath = $phpFinder->find(); | ||
if (!$phpPath) { | ||
throw new \RuntimeException('The php executable could not be found, add it to your PATH environment variable and try again'); | ||
} | ||
|
||
try { | ||
$alias = $app['upgrade_service']->getDefaultAlias(); | ||
if (!$alias) { | ||
$msg = "Could not find default alias! Aborting..."; | ||
$upgradeErrors[] = $msg; | ||
$logger->addError($msg); | ||
} else { | ||
$php = escapeshellarg($phpPath); | ||
$process = new Process("$php $newscoopConsole oauth:create-client newscoop ".$alias." ".$alias." --default"); | ||
$process->run(); | ||
if (!$process->isSuccessful()) { | ||
throw new \RuntimeException($process->getErrorOutput()); | ||
} | ||
} | ||
} catch (\Exception $e) { | ||
$msg = $e->getMessage(); | ||
$upgradeErrors[] = $msg; | ||
$logger->addError($msg); | ||
array_splice($upgradeErrors, 0, 0, array($msg)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters