]> git.mxchange.org Git - friendica.git/blobdiff - src/Console/DatabaseStructure.php
Added post update to remove duplicated contacts
[friendica.git] / src / Console / DatabaseStructure.php
index 3feaa64d6005cdea8442ef6756e045bad3e6851e..ca210064527af673f700cac9467dbd4396dfc108 100644 (file)
@@ -2,9 +2,9 @@
 
 namespace Friendica\Console;
 
-use Friendica\Core;
+use Friendica\Core\Config\Cache\ConfigCache;
 use Friendica\Core\Update;
-use Friendica\Database\DBA;
+use Friendica\Database\Database;
 use Friendica\Database\DBStructure;
 use RuntimeException;
 
@@ -17,6 +17,15 @@ class DatabaseStructure extends \Asika\SimpleConsole\Console
 {
        protected $helpOptions = ['h', 'help', '?'];
 
+       /**
+        * @var Database
+        */
+       private $dba;
+       /**
+        * @var ConfigCache
+        */
+       private $configCache;
+
        protected function getHelp()
        {
                $help = <<<HELP
@@ -39,6 +48,14 @@ HELP;
                return $help;
        }
 
+       public function __construct(Database $dba, ConfigCache $configCache, $argv = null)
+       {
+               parent::__construct($argv);
+
+               $this->dba = $dba;
+               $this->configCache = $configCache;
+       }
+
        protected function doExecute()
        {
                if ($this->getOption('v')) {
@@ -56,26 +73,24 @@ HELP;
                        throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
                }
 
-               if (!DBA::connected()) {
+               if (!$this->dba->isConnected()) {
                        throw new RuntimeException('Unable to connect to database');
                }
 
-               Core\Config::load();
-
-               $a = get_app();
+               $basePath = $this->configCache->get('system', 'basepath');
 
                switch ($this->getArgument(0)) {
                        case "dryrun":
-                               $output = DBStructure::update($a->getBasePath(), true, false);
+                               $output = DBStructure::update($basePath, true, false);
                                break;
                        case "update":
                                $force    = $this->getOption(['f', 'force'], false);
                                $override = $this->getOption(['o', 'override'], false);
-                               $output = Update::run($a->getBasePath(), $force, $override,true, false);
+                               $output = Update::run($basePath, $force, $override,true, false);
                                break;
                        case "dumpsql":
                                ob_start();
-                               DBStructure::printStructure($a->getBasePath());
+                               DBStructure::printStructure($basePath);
                                $output = ob_get_clean();
                                break;
                        case "toinnodb":