]> git.mxchange.org Git - friendica.git/commitdiff
Fix return type or UserSession::getUserIDForVisitorContactID()
authorArt4 <art4@wlabs.de>
Thu, 13 Mar 2025 11:50:15 +0000 (11:50 +0000)
committerArt4 <art4@wlabs.de>
Thu, 13 Mar 2025 11:50:15 +0000 (11:50 +0000)
src/Core/Session/Model/UserSession.php
src/Object/Post.php
tests/src/Core/Session/UserSessionTest.php

index cc3db7f80619b1dc2e385013fa12f8c028136362..70370371ff2b5270f4dc65cba23cdfdfb5e4665e 100644 (file)
@@ -101,7 +101,7 @@ class UserSession implements IHandleUserSessions
        public function getUserIDForVisitorContactID(int $cid): int
        {
                if (empty($this->session->get('remote'))) {
-                       return false;
+                       return 0;
                }
 
                return array_search($cid, $this->session->get('remote'));
@@ -142,7 +142,7 @@ class UserSession implements IHandleUserSessions
        {
                return !$this->session->get('authenticated', false);
        }
-       
+
        /** {@inheritDoc} */
        public function setVisitorsContacts(string $my_url)
        {
index 4dd5cdea30baff3f1d09e5a835437c87ddfdc8dd..7c19a99842f42d584e4589a3dcf6d6be45d0ad2b 100644 (file)
@@ -71,7 +71,7 @@ class Post
                $this->setTemplate('wall');
                $this->toplevel = $this->getId() == $this->getDataValue('parent');
 
-               if (!empty(DI::userSession()->getUserIDForVisitorContactID($this->getDataValue('contact-id')))) {
+               if (DI::userSession()->getUserIDForVisitorContactID($this->getDataValue('contact-id')) !== 0) {
                        $this->visiting = true;
                }
 
index 64c7d8b95038c61f149c9aebf23b8d4605376535..cecae1d90c05342cfe5913ecd23b7c7de0fa6030 100644 (file)
@@ -152,13 +152,13 @@ class UserSessionTest extends MockedTestCase
                                'data' => [
                                        'remote' => ['3' => '21'],
                                ],
-                               'expected' => false,
+                               'expected' => 0,
                        ],
                        'empty' => [
                                'cid'  => 21,
                                'data' => [
                                ],
-                               'expected' => false,
+                               'expected' => 0,
                        ],
                ];
        }
@@ -167,7 +167,7 @@ class UserSessionTest extends MockedTestCase
        public function testGetUserIdForVisitorContactID(int $cid, array $data, $expected)
        {
                $userSession = new UserSession(new ArraySession($data));
-               $this->assertEquals($expected, $userSession->getUserIDForVisitorContactID($cid));
+               $this->assertSame($expected, $userSession->getUserIDForVisitorContactID($cid));
        }
 
        public function dataAuthenticated()