Merge branch 'fix'

This commit is contained in:
Yurii
2026-05-18 07:41:10 +03:00
6 changed files with 85 additions and 20 deletions

View File

@@ -208,6 +208,21 @@ class Params
{
$this->entityType = $data['entityType'];
$this->ids = $data['ids'];
$this->searchParams = unserialize($data['searchParams']);
$this->searchParams = unserialize($data['searchParams'], [
'allowed_classes' => [SearchParams::class],
]);
}
/**
* @internal
*/
public static function fromSerializedRaw(string $raw): self
{
/** @var Params $params */
$params = unserialize(base64_decode($raw), [
'allowed_classes' => [Params::class],
]);
return $params;
}
}

View File

@@ -52,10 +52,7 @@ class Export extends Entity
throw new RuntimeException("No 'params'.");
}
/** @var Params $params */
$params = unserialize(base64_decode($raw));
return $params;
return Params::fromSerializedRaw($raw);
}
public function getStatus(): string

View File

@@ -43,15 +43,11 @@ use stdClass;
class MassAction extends Entity
{
public const ENTITY_TYPE = 'MassAction';
public const STATUS_PENDING = 'Pending';
public const STATUS_RUNNING = 'Running';
public const STATUS_SUCCESS = 'Success';
public const STATUS_FAILED = 'Failed';
public const string ENTITY_TYPE = 'MassAction';
public const string STATUS_PENDING = 'Pending';
public const string STATUS_RUNNING = 'Running';
public const string STATUS_SUCCESS = 'Success';
public const string STATUS_FAILED = 'Failed';
public function getParams(): Params
{
@@ -61,10 +57,7 @@ class MassAction extends Entity
throw new RuntimeException("No 'params'.");
}
/** @var Params $params */
$params = unserialize(base64_decode($raw));
return $params;
return Params::fromSerializedRaw($raw);
}
public function getData(): Data

View File

@@ -321,4 +321,20 @@ class Params
{
return $this->applyAccessControl;
}
/**
* @internal
*/
public static function fromSerializedRaw(string $raw): self
{
/** @var Params $params */
$params = unserialize(base64_decode($raw), [
'allowed_classes' => [
Params::class,
SearchParams::class,
],
]);
return $params;
}
}

View File

@@ -172,8 +172,7 @@ class ParamsTest extends \PHPUnit\Framework\TestCase
'Test'
);
/** @var Params $params2 */
$params2 = unserialize(serialize($params1));
$params2 = Params::fromSerializedRaw(base64_encode(serialize($params1)));
$this->assertEquals($params1, $params2);

View File

@@ -0,0 +1,45 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* Website: https://www.espocrm.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace tests\unit\Espo\Tools\Export;
use Espo\Tools\Export\Params;
use PHPUnit\Framework\TestCase;
class ParamsTest extends TestCase
{
public function testSerialize(): void
{
$params = new Params('Test');
$params = Params::fromSerializedRaw(base64_encode(serialize($params)));
$this->assertEquals('Test', $params->getEntityType());
}
}