]> git.mxchange.org Git - friendica.git/commitdiff
Fixup incrementQueue
authorPhilipp <admin@philipp.info>
Sun, 14 May 2023 18:52:07 +0000 (20:52 +0200)
committerPhilipp <admin@philipp.info>
Sun, 14 May 2023 18:52:07 +0000 (20:52 +0200)
src/Model/Post/DeliveryData.php
tests/src/Database/DatabaseTest.php

index 327e6f912194155ae9e1074fb4ffee8f491e382d..c1aad730c70be0749cf6db94af92763268d167ab 100644 (file)
@@ -86,19 +86,19 @@ class DeliveryData
 
                switch ($protocol) {
                        case self::ACTIVITYPUB:
-                               $increments[] = ["`activitypub` = `activitypub` + 1"];
+                               $increments[] = "`activitypub` = `activitypub` + 1";
                                break;
                        case self::DFRN:
-                               $increments[] = ["`dfrn` = `dfrn` + 1"];
+                               $increments[] = "`dfrn` = `dfrn` + 1";
                                break;
                        case self::LEGACY_DFRN:
-                               $increments[] = ["`legacy_dfrn` = `legacy_dfrn` + 1"];
+                               $increments[] = "`legacy_dfrn` = `legacy_dfrn` + 1";
                                break;
                        case self::DIASPORA:
-                               $increments[] = ["`diaspora` = `diaspora` + 1"];
+                               $increments[] = "`diaspora` = `diaspora` + 1";
                                break;
                        case self::OSTATUS:
-                               $increments[] = ["`ostatus` = `ostatus` + 1"];
+                               $increments[] = "`ostatus` = `ostatus` + 1";
                                break;
                }
 
index 47d40322099b58136a0f11f24836592792aa72d8..e90683461485f60b43e126fc13466c09ce5c3917 100644 (file)
@@ -85,4 +85,19 @@ class DatabaseTest extends FixtureTest
                ]));
                self::assertEquals(1, $db->selectFirst('gserver', ['registered-users'], ['nurl' => 'http://friendica.local'])['registered-users']);
        }
+
+       public function testUpdateWithArray()
+       {
+               $db = $this->getDbInstance();
+
+               self::assertTrue($db->update('gserver', ['active-week-users' => 0, 'registered-users' => 0], ['nurl' => 'http://friendica.local']));
+
+               $fields = ["`registered-users` = `registered-users` + 1"];
+               $fields[] = "`active-week-users` = `active-week-users` + 2";
+
+               self::assertTrue($db->update('gserver', $fields, ['nurl' => 'http://friendica.local']));
+
+               self::assertEquals(2, $db->selectFirst('gserver', ['active-week-users'], ['nurl' => 'http://friendica.local'])['active-week-users']);
+               self::assertEquals(1, $db->selectFirst('gserver', ['registered-users'], ['nurl' => 'http://friendica.local'])['registered-users']);
+       }
 }