]> git.mxchange.org Git - friendica.git/commitdiff
Merge remote-tracking branch 'upstream/develop' into contact-update
authorMichael <heluecht@pirati.ca>
Fri, 12 Jul 2019 20:51:27 +0000 (20:51 +0000)
committerMichael <heluecht@pirati.ca>
Fri, 12 Jul 2019 20:51:27 +0000 (20:51 +0000)
src/Core/Config/Cache/ConfigCache.php
src/Core/Installer.php
src/Protocol/ActivityPub/Receiver.php
tests/src/Console/AutomaticInstallationConsoleTest.php
tests/src/Core/Config/Cache/ConfigCacheTest.php

index 441cdee811cc550c3e0bb748c8fdb26887b0dc59..6679b55ab91c8aebe96f2172273fb717fc0ef4c5 100644 (file)
@@ -95,7 +95,7 @@ class ConfigCache implements IConfigCache, IPConfigCache
 
                if ($this->hidePasswordOutput &&
                    $key == 'password' &&
-                   !empty($value) && is_string($value)) {
+                   is_string($value)) {
                        $this->config[$cat][$key] = new HiddenString((string) $value);
                } else {
                        $this->config[$cat][$key] = $value;
index 046b34ea6f7e3e87d495e7ff23908d4b848c5ca6..f49dde4e560adf9f136941e1fedf33287a80d93b 100644 (file)
@@ -7,8 +7,8 @@ namespace Friendica\Core;
 use DOMDocument;
 use Exception;
 use Friendica\Core\Config\Cache\IConfigCache;
-use Friendica\Database\DBA;
 use Friendica\Database\DBStructure;
+use Friendica\Factory\DBFactory;
 use Friendica\Object\Image;
 use Friendica\Util\Logger\VoidLogger;
 use Friendica\Util\Network;
@@ -600,23 +600,18 @@ class Installer
         */
        public function checkDB(IConfigCache $configCache, Profiler $profiler)
        {
-               $dbhost = $configCache->get('database', 'hostname');
-               $dbuser = $configCache->get('database', 'username');
-               $dbpass = $configCache->get('database', 'password');
-               $dbdata = $configCache->get('database', 'database');
+               $database = DBFactory::init($configCache, $profiler, [], new VoidLogger());
 
-               if (!DBA::connect($configCache, $profiler, new VoidLogger(), $dbhost, $dbuser, $dbpass, $dbdata)) {
-                       $this->addCheck(L10n::t('Could not connect to database.'), false, true, '');
-
-                       return false;
-               }
-
-               if (DBA::connected()) {
+               if ($database->connected()) {
                        if (DBStructure::existsTable('user')) {
                                $this->addCheck(L10n::t('Database already in use.'), false, true, '');
 
                                return false;
                        }
+               } else {
+                       $this->addCheck(L10n::t('Could not connect to database.'), false, true, '');
+
+                       return false;
                }
 
                return true;
index a8b5a18db10136a78c01ad15961b479ae3b5f508..f830f857a745e0752ccf5bc2de2a5c575db4b839 100644 (file)
@@ -657,27 +657,14 @@ class Receiver
         */
        public static function switchContact($cid, $uid, $url)
        {
-               $profile = ActivityPub::probeProfile($url);
-               if (empty($profile)) {
-                       return;
-               }
-
-               Logger::log('Switch contact ' . $cid . ' (' . $profile['url'] . ') for user ' . $uid . ' to ActivityPub');
-
-               $photo = defaults($profile, 'photo', null);
-               unset($profile['photo']);
-               unset($profile['baseurl']);
-               unset($profile['guid']);
-
-               $profile['nurl'] = Strings::normaliseLink($profile['url']);
-               DBA::update('contact', $profile, ['id' => $cid]);
+               Contact::updateFromProbe($cid, '', true);
 
-               Contact::updateAvatar($photo, $uid, $cid);
+               Logger::log('Switch contact ' . $cid . ' (' . $url . ') for user ' . $uid . ' to ActivityPub');
 
                // Send a new follow request to be sure that the connection still exists
                if (($uid != 0) && DBA::exists('contact', ['id' => $cid, 'rel' => [Contact::SHARING, Contact::FRIEND]])) {
-                       ActivityPub\Transmitter::sendActivity('Follow', $profile['url'], $uid);
-                       Logger::log('Send a new follow request to ' . $profile['url'] . ' for user ' . $uid, Logger::DEBUG);
+                       ActivityPub\Transmitter::sendActivity('Follow', $url, $uid);
+                       Logger::log('Send a new follow request to ' . $url . ' for user ' . $uid, Logger::DEBUG);
                }
        }
 
index acf5dac7bdc01d192f3f45ce80cfc35696ba7b59..a5df0e92aa2d71b4156987d7145c03c4e43a3898 100644 (file)
@@ -16,8 +16,6 @@ use org\bovigo\vfs\vfsStream;
 use org\bovigo\vfs\vfsStreamFile;
 
 /**
- * @runTestsInSeparateProcesses
- * @preserveGlobalState disabled
  * @requires PHP 7.0
  */
 class AutomaticInstallationConsoleTest extends ConsoleTest
@@ -43,6 +41,8 @@ class AutomaticInstallationConsoleTest extends ConsoleTest
 
        public function setUp()
        {
+               $this->markTestSkipped('Needs class \'Installer\' as constructing argument for console tests');
+
                parent::setUp();
 
                if ($this->root->hasChild('config' . DIRECTORY_SEPARATOR . 'local.config.php')) {
index f8f81f9ee721c8193bfbe656d3ad9279efb2bdbf..9c93c44f26c3fda466a2250d54706069239ca0b3 100644 (file)
@@ -4,6 +4,7 @@ namespace Friendica\Test\src\Core\Config\Cache;
 
 use Friendica\Core\Config\Cache\ConfigCache;
 use Friendica\Test\MockedTest;
+use ParagonIE\HiddenString\HiddenString;
 
 class ConfigCacheTest extends MockedTest
 {
@@ -322,7 +323,8 @@ class ConfigCacheTest extends MockedTest
                        ]
                ]);
 
-               $this->assertEmpty($configCache->get('database', 'password'));
+               $this->assertNotEmpty($configCache->get('database', 'password'));
+               $this->assertInstanceOf(HiddenString::class, $configCache->get('database', 'password'));
                $this->assertEmpty($configCache->get('database', 'username'));
        }