Compare commits

...

16 Commits
v2.10.0 ... 2.x

Author SHA1 Message Date
Alejandro Celaya
356b33ced0 Merge pull request #1350 from acelaya-forks/feature/fix-memory-leak
Updated to shlink-common 4.4, which no longer uses doctrine/cache
2022-01-23 18:14:00 +01:00
Alejandro Celaya
77088d55f9 Updated to shlink-common 4.4, which no longer uses doctrine/cache 2022-01-23 17:54:49 +01:00
Alejandro Celaya
470c62d993 Merge pull request #1313 from acelaya-forks/feature/redis-memory-usage
Added a default lifetime for cache entries when using redis
2022-01-07 21:50:31 +01:00
Alejandro Celaya
364734094b Added a default lifetime for cache entries when using redis 2022-01-07 21:37:24 +01:00
Alejandro Celaya
dc648b0142 Merge pull request #1311 from acelaya-forks/feature/ip-in-logs
Ensured remote IP address is not logged when using swoole/openswoole
2022-01-07 14:44:19 +01:00
Alejandro Celaya
1d14140986 Ensured remote IP address is not logged when using swoole/openswoole 2022-01-07 14:30:06 +01:00
Alejandro Celaya
2b693dc492 Merge pull request #1310 from acelaya-forks/feature/title-max-length
Feature/title max length
2022-01-07 14:24:58 +01:00
Alejandro Celaya
38bea6c086 Added edge case tests for SHortUrlMetaTest on title field 2022-01-07 14:07:07 +01:00
Alejandro Celaya
cbdc5f121e Updated changelog 2022-01-07 14:04:21 +01:00
Alejandro Celaya
562763199a Ensured URL titles are trimmed to avoid error when persisted in database 2022-01-07 13:13:45 +01:00
Alejandro Celaya
30207ce0c2 Merge pull request #1287 from acelaya-forks/bugfix/db-error
Bugfix/db error
2021-12-21 14:43:13 +01:00
Alejandro Celaya
0f37f1cb23 Updated changelog 2021-12-21 14:25:21 +01:00
Alejandro Celaya
99a905cdee Updated to latest shlink-common with support to close EM on middleware 2021-12-21 14:22:11 +01:00
Alejandro Celaya
6eac079440 Ensured EM is closed and not cleared after running an async task 2021-12-21 14:10:06 +01:00
Alejandro Celaya
4a1e7b8d5a Changed condition to pipe RequestIdMiddleware, so that it applies to non-rest requests too 2021-12-19 10:23:55 +01:00
Alejandro Celaya
351e36b273 Added missing 8.1 to clean-artifacts job in publish-release pipeline 2021-12-12 17:45:56 +01:00
13 changed files with 110 additions and 13 deletions

View File

@@ -53,7 +53,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
php-version: [ '8.0' ]
php-version: [ '8.0', '8.1' ]
swoole: [ 'yes', 'no' ]
steps:
- uses: geekyeggo/delete-artifact@v1

View File

@@ -4,6 +4,60 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com), and this project adheres to [Semantic Versioning](https://semver.org).
## [2.10.3] - 2022-01-23
### Added
* *Nothing*
### Changed
* *Nothing*
### Deprecated
* *Nothing*
### Removed
* *Nothing*
### Fixed
* [#1349](https://github.com/shlinkio/shlink/issues/1349) Fixed memory leak in cache implementation.
## [2.10.2] - 2022-01-07
### Added
* *Nothing*
### Changed
* *Nothing*
### Deprecated
* *Nothing*
### Removed
* *Nothing*
### Fixed
* [#1293](https://github.com/shlinkio/shlink/issues/1293) Fixed error when trying to create/import short URLs with a too long title.
* [#1306](https://github.com/shlinkio/shlink/issues/1306) Ensured remote IP address is not logged when using swoole/openswoole.
* [#1308](https://github.com/shlinkio/shlink/issues/1308) Fixed memory leak when using redis due to the amount of non-expiring keys created by doctrine. Now they have a 24h expiration by default.
## [2.10.1] - 2021-12-21
### Added
* *Nothing*
### Changed
* *Nothing*
### Deprecated
* *Nothing*
### Removed
* *Nothing*
### Fixed
* [#1285](https://github.com/shlinkio/shlink/issues/1285) Fixed error caused by database connections expiring after some hours of inactivity.
* [#1286](https://github.com/shlinkio/shlink/issues/1286) Fixed `x-request-id` header not being generated during non-rest requests.
## [2.10.0] - 2021-12-12
### Added
* [#1163](https://github.com/shlinkio/shlink/issues/1163) Allowed setting not-found redirects for default domain in the same way it's done for any other domain.

View File

@@ -48,7 +48,7 @@
"predis/predis": "^1.1",
"pugx/shortid-php": "^1.0",
"ramsey/uuid": "^4.2",
"shlinkio/shlink-common": "^4.2",
"shlinkio/shlink-common": "^4.4",
"shlinkio/shlink-config": "^1.4",
"shlinkio/shlink-event-dispatcher": "^2.3",
"shlinkio/shlink-importer": "^2.5",
@@ -192,6 +192,12 @@
},
"config": {
"sort-packages": true,
"platform-check": false
"platform-check": false,
"allow-plugins": {
"composer/package-versions-deprecated": true,
"dealerdirect/phpcodesniffer-composer-installer": true,
"infection/extension-installer": true,
"veewee/composer-run-parallel": true
}
}
}

View File

@@ -11,7 +11,6 @@ return [
'driver' => 'pdo_mysql',
'host' => 'shlink_db_mysql',
'dbname' => 'shlink',
'charset' => 'utf8',
],
],

View File

@@ -82,7 +82,7 @@ return [
'swoole-http-server' => [
'logger' => [
'logger-name' => 'Logger_Access',
'format' => '%h %l %u "%r" %>s %b',
'format' => '%u "%r" %>s %B',
],
],
],

View File

@@ -17,6 +17,7 @@ return [
'error-handler' => [
'middleware' => [
ContentLengthMiddleware::class,
RequestIdMiddleware::class,
ErrorHandler::class,
Rest\Middleware\CrossDomainMiddleware::class,
],
@@ -24,7 +25,6 @@ return [
'error-handler-rest' => [
'path' => '/rest',
'middleware' => [
RequestIdMiddleware::class,
ProblemDetails\ProblemDetailsMiddleware::class,
],
],

View File

@@ -22,7 +22,7 @@ return (static function () {
'options' => [
'worker_num' => (int) env('WEB_WORKER_NUM', 16),
'task_worker_num' => $taskWorkers < MIN_TASK_WORKERS ? MIN_TASK_WORKERS : $taskWorkers,
'task_worker_num' => max($taskWorkers, MIN_TASK_WORKERS),
],
],
],

View File

@@ -55,7 +55,6 @@ $buildDbConnection = static function (): array {
'user' => 'postgres',
'password' => 'root',
'dbname' => 'shlink_test',
'charset' => 'utf8',
],
'mssql' => [
'driver' => 'pdo_sqlsrv',
@@ -71,7 +70,6 @@ $buildDbConnection = static function (): array {
'user' => 'root',
'password' => 'root',
'dbname' => 'shlink_test',
'charset' => 'utf8',
],
};
};

View File

@@ -24,7 +24,7 @@ class CloseDbConnectionEventListener
($this->wrapped)($event);
} finally {
$this->em->getConnection()->close();
$this->em->clear();
$this->em->close();
}
}
}

View File

@@ -194,6 +194,9 @@ class ShortUrlRepository extends EntitySpecificationRepository implements ShortU
return $this->doShortCodeIsInUse($identifier, $spec, LockMode::PESSIMISTIC_WRITE);
}
/**
* @param LockMode::PESSIMISTIC_WRITE|null $lockMode
*/
private function doShortCodeIsInUse(ShortUrlIdentifier $identifier, ?Specification $spec, ?int $lockMode): bool
{
$qb = $this->createFindOneQueryBuilder($identifier, $spec)->select('s.id');

View File

@@ -6,6 +6,7 @@ namespace Shlinkio\Shlink\Core\Validation;
use Cocur\Slugify\Slugify;
use DateTime;
use Laminas\Filter;
use Laminas\InputFilter\Input;
use Laminas\InputFilter\InputFilter;
use Laminas\Validator;
@@ -13,6 +14,8 @@ use Shlinkio\Shlink\Common\Validation;
use Shlinkio\Shlink\Core\Util\CocurSymfonySluggerBridge;
use Shlinkio\Shlink\Rest\Entity\ApiKey;
use function substr;
use const Shlinkio\Shlink\CUSTOM_SLUGS_REGEXP;
use const Shlinkio\Shlink\MIN_SHORT_CODES_LENGTH;
@@ -107,7 +110,11 @@ class ShortUrlInputFilter extends InputFilter
$this->add($this->createTagsInput(self::TAGS, false));
$this->add($this->createInput(self::TITLE, false));
$title = $this->createInput(self::TITLE, false);
$title->getFilterChain()->attach(new Filter\Callback(
static fn (?string $value) => $value === null ? $value : substr($value, 0, 512),
));
$this->add($title);
$this->add($this->createBooleanInput(self::CRAWLABLE, false));
}

View File

@@ -35,7 +35,7 @@ class CloseDbConnectionEventListenerTest extends TestCase
$close = $conn->close()->will(function (): void {
});
$getConn = $this->em->getConnection()->willReturn($conn->reveal());
$clear = $this->em->clear()->will(function (): void {
$close = $this->em->close()->will(function (): void {
});
$open = $this->em->open()->will(function (): void {
});
@@ -51,7 +51,7 @@ class CloseDbConnectionEventListenerTest extends TestCase
self::assertTrue($wrappedWasCalled);
$close->shouldHaveBeenCalledOnce();
$getConn->shouldHaveBeenCalledOnce();
$clear->shouldHaveBeenCalledOnce();
$close->shouldHaveBeenCalledOnce();
$open->shouldHaveBeenCalledOnce();
}

View File

@@ -11,6 +11,10 @@ use Shlinkio\Shlink\Core\Model\ShortUrlMeta;
use Shlinkio\Shlink\Core\Validation\ShortUrlInputFilter;
use stdClass;
use function str_pad;
use const STR_PAD_BOTH;
class ShortUrlMetaTest extends TestCase
{
/**
@@ -99,4 +103,30 @@ class ShortUrlMetaTest extends TestCase
yield ['谷歌', '谷歌'];
yield ['гугл', 'гугл'];
}
/**
* @test
* @dataProvider provideTitles
*/
public function titleIsCroppedIfTooLong(?string $title, ?string $expectedTitle): void
{
$meta = ShortUrlMeta::fromRawData([
'title' => $title,
'longUrl' => '',
]);
self::assertEquals($expectedTitle, $meta->getTitle());
}
public function provideTitles(): iterable
{
yield [null, null];
yield ['foo', 'foo'];
yield [str_pad('bar', 600, ' ', STR_PAD_BOTH), 'bar'];
yield [str_pad('', 511, 'a'), str_pad('', 511, 'a')];
yield [str_pad('', 512, 'b'), str_pad('', 512, 'b')];
yield [str_pad('', 513, 'c'), str_pad('', 512, 'c')];
yield [str_pad('', 600, 'd'), str_pad('', 512, 'd')];
yield [str_pad('', 800, 'e'), str_pad('', 512, 'e')];
}
}