AJAX: Fix compatibility with PHP 8.2

This commit is contained in:
veselcraft 2023-08-15 01:47:43 +03:00
parent d9412b2df8
commit 195cf9807e
No known key found for this signature in database
GPG key ID: 9CF0B42766CCF7BA
9 changed files with 32 additions and 27 deletions

View file

@ -48,11 +48,11 @@ class APIToken extends RowModel
$this->delete();
}
function save(): void
function save(?bool $log = false): void
{
if(is_null($this->getRecord()))
$this->stateChanges("secret", bin2hex(openssl_random_pseudo_bytes(36)));
parent::save();
parent::save($log);
}
}

View file

@ -105,11 +105,11 @@ class IP extends RowModel
$this->stateChanges("ip", $ip);
}
function save(): void
function save(?bool $log = false): void
{
if(is_null($this->getRecord()))
$this->stateChanges("first_seen", time());
parent::save();
parent::save($log);
}
}

View file

@ -121,14 +121,14 @@ abstract class Media extends Postable
$this->stateChanges("hash", $hash);
}
function save(): void
function save(?bool $log = false): void
{
if(!is_null($this->processingPlaceholder) && is_null($this->getRecord())) {
$this->stateChanges("processed", 0);
$this->stateChanges("last_checked", time());
}
parent::save();
parent::save($log);
}
function delete(bool $softly = true): void

View file

@ -54,11 +54,11 @@ class PasswordReset extends RowModel
}
}
function save(): void
function save(?bool $log = false): void
{
$this->stateChanges("key", base64_encode(openssl_random_pseudo_bytes(46)));
$this->stateChanges("timestamp", time());
parent::save();
parent::save($log);
}
}

View file

@ -279,12 +279,12 @@ class Poll extends Attachable
return $poll;
}
function save(): void
function save(?bool $log = false): void
{
if(empty($this->choicesToPersist))
throw new InvalidStateException;
parent::save();
parent::save($log);
foreach($this->choicesToPersist as $option) {
DatabaseConnection::i()->getContext()->table("poll_options")->insert([
"poll" => $this->getId(),

View file

@ -151,7 +151,7 @@ abstract class Postable extends Attachable
throw new ISE("Setting virtual id manually is forbidden");
}
function save(): void
function save(?bool $log = false): void
{
$vref = $this->upperNodeReferenceColumnName;
@ -170,7 +170,7 @@ abstract class Postable extends Attachable
$this->stateChanges("edited", time());
}
parent::save();
parent::save($log);
}
use Traits\TAttachmentHost;

View file

@ -197,8 +197,10 @@ abstract class OpenVKPresenter extends SimplePresenter
{
$user = Authenticator::i()->getUser();
if(!is_null($this->template)) {
$this->template->isXmas = intval(date('d')) >= 1 && date('m') == 12 || intval(date('d')) <= 15 && date('m') == 1 ? true : false;
$this->template->isTimezoned = Session::i()->get("_timezoneOffset");
}
$userValidated = 0;
$cacheTime = OPENVK_ROOT_CONF["openvk"]["preferences"]["nginxCacheTime"] ?? 0;
@ -208,8 +210,10 @@ abstract class OpenVKPresenter extends SimplePresenter
$this->user->raw = $user;
$this->user->identity = (new Users)->getByChandlerUser($user);
$this->user->id = $this->user->identity->getId();
if(!is_null($this->template)) {
$this->template->thisUser = $this->user->identity;
$this->template->userTainted = $user->isTainted();
}
if($this->user->identity->isDeleted() && !$this->deactivationTolerant) {
if($this->user->identity->isDeactivated()) {
@ -257,8 +261,9 @@ abstract class OpenVKPresenter extends SimplePresenter
$this->user->identity->save();
}
if(!is_null($this->template))
$this->template->ticketAnsweredCount = (new Tickets)->getTicketsCountByUserId($this->user->id, 1);
if($user->can("write")->model("openvk\Web\Models\Entities\TicketReply")->whichBelongsTo(0))
if(!is_null($this->template) && $user->can("write")->model("openvk\Web\Models\Entities\TicketReply")->whichBelongsTo(0))
$this->template->helpdeskTicketNotAnsweredCount = (new Tickets)->getTicketCount(0);
}
@ -275,7 +280,7 @@ abstract class OpenVKPresenter extends SimplePresenter
$this->redirect("/maintenances/");
}
}
if(!is_null($this->template))
$this->template->__isAjax= $this->requestParam("al");
parent::onStartup();
}

View file

@ -182,7 +182,7 @@ final class WallPresenter extends OpenVKPresenter
$this->template->paginatorConf = (object) [
"count" => $count,
"page" => (int) ($_GET["p"] ?? 1),
"amount" => sizeof($posts),
"amount" => sizeof((array) $posts),
"perPage" => $pPage,
];
foreach($posts as $post)

View file

@ -23,7 +23,7 @@
style="position: absolute; top: 40%; left: 50%; background: #4C4C4C; padding: 20px 30px; border-radius: 3px; opacity: 0.8;"/>
</div>
<input type="hidden" id="__current_url" value="{=$_SERVER[REQUEST_URI]}" />
<input type="hidden" id="__current_url" value="{=$_SERVER['REQUEST_URI']}" />
<div id="sudo-banner" n:if="isset($thisUser) && $userTainted">
<p>
Вы вошли как <b>{$thisUser->getCanonicalName()}</b>. Пожалуйста, уважайте