Skip to content

Commit

Permalink
Small simplifications
Browse files Browse the repository at this point in the history
  • Loading branch information
flack committed Jan 18, 2024
1 parent 8740f6b commit 9e8e87d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 15 deletions.
5 changes: 1 addition & 4 deletions lib/midcom/application.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,7 @@ public function __construct(string $environment, bool $debug)

private function get_request() : Request
{
if (!$this->request) {
$this->request = Request::createFromGlobals();
}
return $this->request;
return $this->request ?? Request::createFromGlobals();
}

public function registerContainerConfiguration(LoaderInterface $loader)
Expand Down
4 changes: 1 addition & 3 deletions lib/midcom/core/account.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,7 @@ private function _update() : bool

if ( !empty($this->_old_username)
&& $this->_old_username !== $new_username) {
if (!$history = @unserialize($this->_person->get_parameter('midcom', 'username_history'))) {
$history = [];
}
$history = @unserialize($this->_person->get_parameter('midcom', 'username_history')) ?: [];
$history[time()] = ['old' => $this->_old_username, 'new' => $new_username];
$this->_person->set_parameter('midcom', 'username_history', serialize($history));
}
Expand Down
10 changes: 2 additions & 8 deletions lib/midcom/core/dbaobject.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,17 +299,11 @@ public function is_locked() : bool
}
public function lock() : bool
{
if ($this->__object->is_locked()) {
return true;
}
return $this->__object->lock();
return $this->__object->is_locked() || $this->__object->lock();
}
public function unlock() : bool
{
if (!$this->__object->is_locked()) {
return true;
}
return $this->__object->unlock();
return !$this->__object->is_locked() || $this->__object->unlock();
}
public function is_approved() : bool
{
Expand Down

0 comments on commit 9e8e87d

Please sign in to comment.