]> git.mxchange.org Git - friendica.git/commitdiff
Add explicit parameter to IHandleUserSession->setvisitorContacts
authorHypolite Petovan <hypolite@mrpetovan.com>
Sun, 26 Mar 2023 23:00:48 +0000 (19:00 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Tue, 28 Mar 2023 01:31:54 +0000 (21:31 -0400)
- Convert some remaining $_SESSION references to object calls
- Address part of https://github.com/friendica/friendica/issues/12486#issuecomment-1428489772

src/Core/Session/Capability/IHandleUserSessions.php
src/Core/Session/Model/UserSession.php
src/Model/Profile.php
src/Security/Authentication.php

index 507b9e0429e8399975ade3925b14cdb42574530b..5734eafdf788d62955948ae93493d0ed4cb8cd62 100644 (file)
@@ -109,6 +109,8 @@ interface IHandleUserSessions extends IHandleSessions
 
        /**
         * Set the session variable that contains the contact IDs for the visitor's contact URL
+        *
+        * @param string $my_url
         */
-       public function setVisitorsContacts();
+       public function setVisitorsContacts(string $my_url);
 }
index a544487bd223fd5125fe7bc1c1ec46a4b75b4801..8dfc3d8321386cb421cdc5c9926f6c289b4ec5bd 100644 (file)
@@ -140,9 +140,9 @@ class UserSession implements IHandleUserSessions
        }
 
        /** {@inheritDoc} */
-       public function setVisitorsContacts()
+       public function setVisitorsContacts(string $my_url)
        {
-               $this->session->set('remote', Contact::getVisitorByUrl($this->session->get('my_url')));
+               $this->session->set('remote', Contact::getVisitorByUrl($my_url));
        }
 
        /** {@inheritDoc} */
index e2857947c0fcf56f34658efbcfb584195fb04d8a..e6c8e4822d17d3df1d47f75579b0d98fabd70849 100644 (file)
@@ -795,14 +795,16 @@ class Profile
                $visitor = Contact::getById($cid);
 
                // Authenticate the visitor.
-               $_SESSION['authenticated'] = 1;
-               $_SESSION['visitor_id'] = $visitor['id'];
-               $_SESSION['visitor_handle'] = $visitor['addr'];
-               $_SESSION['visitor_home'] = $visitor['url'];
-               $_SESSION['my_url'] = $visitor['url'];
-               $_SESSION['remote_comment'] = $visitor['subscribe'];
-
-               DI::userSession()->setVisitorsContacts();
+               DI::userSession()->setMultiple([
+                       'authenticated'  => 1,
+                       'visitor_id'     => $visitor['id'],
+                       'visitor_handle' => $visitor['addr'],
+                       'visitor_home'   => $visitor['url'],
+                       'my_url'         => $visitor['url'],
+                       'remote_comment' => $visitor['subscribe'],
+               ]);
+
+               DI::userSession()->setVisitorsContacts($visitor['url']);
 
                $a->setContactId($visitor['id']);
 
index 4db5fdfed56242fd4dccd4d1c6b92dbb8343b1dc..91963ee399d130748b2d48df7277761f0cfe0615 100644 (file)
@@ -323,19 +323,21 @@ class Authentication
         */
        public function setForUser(App $a, array $user_record, bool $login_initial = false, bool $interactive = false, bool $login_refresh = false)
        {
+               $my_url = $this->baseUrl . '/profile/' . $user_record['nickname'];
+
                $this->session->setMultiple([
                        'uid'           => $user_record['uid'],
                        'theme'         => $user_record['theme'],
                        'mobile-theme'  => $this->pConfig->get($user_record['uid'], 'system', 'mobile_theme'),
                        'authenticated' => 1,
                        'page_flags'    => $user_record['page-flags'],
-                       'my_url'        => $this->baseUrl . '/profile/' . $user_record['nickname'],
+                       'my_url'        => $my_url,
                        'my_address'    => $user_record['nickname'] . '@' . substr($this->baseUrl, strpos($this->baseUrl, '://') + 3),
                        'addr'          => $this->remoteAddress,
                        'nickname'      => $user_record['nickname'],
                ]);
 
-               $this->session->setVisitorsContacts();
+               $this->session->setVisitorsContacts($my_url);
 
                $member_since = strtotime($user_record['register_date']);
                $this->session->set('new_member', time() < ($member_since + (60 * 60 * 24 * 14)));