Skip to content

Commit

Permalink
Clean up null/typehinted int handling
Browse files Browse the repository at this point in the history
  • Loading branch information
asmecher committed May 11, 2024
1 parent 24b1062 commit f29ce26
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion classes/user/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public function delete(User $user)
*
* @return bool
*/
public function canCurrentUserGossip($userId)
public function canCurrentUserGossip(int $userId)
{
$request = Application::get()->getRequest();
$context = $request->getContext();
Expand Down
12 changes: 6 additions & 6 deletions controllers/grid/settings/user/form/UserDetailsForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
namespace PKP\controllers\grid\settings\user\form;

use APP\author\Author;
use Illuminate\Support\Facades\Auth;
use APP\core\Application;
use APP\facades\Repo;
use APP\notification\NotificationManager;
use APP\template\TemplateManager;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Str;
use PKP\core\Core;
Expand Down Expand Up @@ -327,11 +327,6 @@ public function execute(...$functionParams)
$this->user->setBiography($this->getData('biography'), null); // Localized
$this->user->setMustChangePassword($this->getData('mustChangePassword') ? 1 : 0);

// Users can never view/edit their own gossip fields
if (Repo::user()->canCurrentUserGossip($this->user->getId())) {
$this->user->setGossip($this->getData('gossip'));
}

$site = $request->getSite();
$availableLocales = $site->getSupportedLocales();

Expand All @@ -346,6 +341,11 @@ public function execute(...$functionParams)
parent::execute(...$functionParams);

if ($this->user->getId() != null) {
// Users can never view/edit their own gossip fields
if (Repo::user()->canCurrentUserGossip($this->user->getId())) {
$this->user->setGossip($this->getData('gossip'));
}

if ($this->getData('password') !== '') {
$this->user->setPassword(Validation::encryptCredentials($this->user->getUsername(), $this->getData('password')));

Expand Down

0 comments on commit f29ce26

Please sign in to comment.