1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-27 03:34:42 +01:00

Test igbinary serialization

This commit is contained in:
Daniil Gentili 2023-05-27 12:03:09 +02:00
parent 115497e4f6
commit 93af384d96
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
4 changed files with 20 additions and 10 deletions

View File

@ -49,7 +49,11 @@ final class DbPropertiesFactory
'enableCache' => true,
'cacheTtl' => $dbSettingsCopy->getCacheTtl(),
], $config);
if ($config['innerMadelineProto']) {
if ($config['innerMadelineProto']
&& $config['serializer'] !== SerializerType::IGBINARY
&& $config['serializer'] !== SerializerType::SERIALIZE
) {
$config['serializer'] = Magic::$can_use_igbinary
? SerializerType::IGBINARY
: SerializerType::SERIALIZE;

View File

@ -122,8 +122,9 @@ abstract class DriverDatabaseAbstract extends DatabaseAbstract
*
* If null, the best serializer is chosen.
*/
public function setSerializer(?SerializerType $serializer): void
public function setSerializer(?SerializerType $serializer): static
{
$this->serializer = $serializer;
return $this;
}
}

View File

@ -21,6 +21,7 @@ use danog\MadelineProto\Settings\Database\Memory;
use danog\MadelineProto\Settings\Database\Mysql;
use danog\MadelineProto\Settings\Database\Postgres;
use danog\MadelineProto\Settings\Database\Redis;
use danog\MadelineProto\Settings\Database\SerializerType;
$MadelineProto = new API(__DIR__.'/../testing.madeline');
@ -31,6 +32,8 @@ $map = [
'redis' => (new Redis)->setUri('redis://redis'),
];
$MadelineProto->updateSettings($map[$argv[1]]);
$MadelineProto->updateSettings(
$map[$argv[1]]->setSerializer($argv[2] === 'igbinary' ? SerializerType::IGBINARY : SerializerType::SERIALIZE)
);
var_dump($MadelineProto->getFullInfo('danogentili'));

View File

@ -96,15 +96,17 @@ cd $madelinePath
db()
{
php tests/db.php $1
php tests/db.php $1 $2
}
cycledb()
{
db memory
db mysql
db postgres
db redis
db memory
for f in serialize igbinary; do
db memory $f
db mysql $f
db postgres $f
db redis $f
db memory $f
done
}
runTestSimple()
@ -135,7 +137,7 @@ echo "Testing with previous version..."
export ACTIONS_FORCE_PREVIOUS=1
cp tools/phar.php madeline.php
runTest
db mysql
db mysql serialize
k
echo "Testing with new version (upgrade)..."