Commit Graph

610 Commits

Author SHA1 Message Date
Nicolas Grekas c0d4ed0c3e Bump branch-version 2020-11-11 12:27:31 +01:00
Nicolas Grekas 5bf6bbe96c Merge branch '5.1' into 5.x
* 5.1:
  [Process] Dont test TTY if there is no TTY support
  Fixing some Mongolian
  translating the validators for european portuguese language
  Fix CI
  Update validators.he.xlf
  Update security.he.xlf
  Update validators.he.xlf
  Improve performances in CircualReference detection
  [PHPUnitBridge] Fixed crash on Windows with PHP 8
  Fix session called initized several time
2020-11-02 16:47:15 +01:00
Alexander M. Turek 0fee41a617 Merge branch '5.1' into 5.x 2020-10-28 22:46:03 +01:00
Alexander M. Turek 294cffea25 Merge branch '4.4' into 5.1 2020-10-28 22:31:18 +01:00
Grégoire Paris ed80bcc82c
Remove dependency on doctrine/reflection
That package is being phased out, and there are good chances that the
classes involved at runtime are completely different from the classes
involved in the test changed in that commit. That test was the only
piece of code I could find still referencing the
Doctrine\Common\Reflection namespace.
2020-10-28 19:09:12 +01:00
Nicolas Grekas c417fd700a Merge branch '5.1' into 5.x
* 5.1:
  Disable platform checks
  Put branch-version in the source for CI
  Bump default PHPUnit version for PHP 8 to 9.4.
2020-10-24 17:54:31 +02:00
Nicolas Grekas 50a61b5392 Merge branch '4.4' into 5.1
* 4.4:
  Disable platform checks
  Put branch-version in the source for CI
  Bump default PHPUnit version for PHP 8 to 9.4.
2020-10-24 17:53:55 +02:00
Nicolas Grekas 138f611f75 Merge branch '3.4' into 4.4
* 3.4:
  Put branch-version in the source for CI
2020-10-24 17:45:11 +02:00
Nicolas Grekas 008f2da031 Put branch-version in the source for CI 2020-10-24 17:39:57 +02:00
Nicolas Grekas 605a5674a8 Merge branch '5.1' into 5.x
* 5.1:
  fix merge
  fix merge
  Remove branch-version (keep them for contracts only)
  [HttpClient] relax auth bearer format requirements
  [PHPUnitBridge] Silence errors from mkdir()
  [DependencyInjection] Preload classes with union types correctly.
  [Serializer] fix decoding float XML attributes starting with 0
  add missing dutch translations
  [TwigBridge] Remove "transchoice" from the code base
  Support PHPUnit 8 and PHPUnit 9 in constraint compatibility trait
  Add expectDeprecation, expectNotice, expectWarning, and expectError to TestCase polyfill
  [String] fix before/after[Last]() returning the empty string instead of the original one on non-match
  Add missing exporter function for PHPUnit 7
  [Validator] Add missing romanian translations
  [String] fix slicing in UnicodeString
  [Cache] Use correct expiry in ChainAdapter
  do not translate null placeholders or titles
2020-10-24 14:08:07 +02:00
Nicolas Grekas 65f2620bc4 Merge branch '4.4' into 5.1
* 4.4:
  fix merge
  Remove branch-version (keep them for contracts only)
  [HttpClient] relax auth bearer format requirements
  [PHPUnitBridge] Silence errors from mkdir()
  [DependencyInjection] Preload classes with union types correctly.
  [Serializer] fix decoding float XML attributes starting with 0
  add missing dutch translations
  Support PHPUnit 8 and PHPUnit 9 in constraint compatibility trait
  Add expectDeprecation, expectNotice, expectWarning, and expectError to TestCase polyfill
  Add missing exporter function for PHPUnit 7
  [Validator] Add missing romanian translations
  [Cache] Use correct expiry in ChainAdapter
  do not translate null placeholders or titles
2020-10-24 14:01:57 +02:00
Nicolas Grekas 77aa17401d Merge branch '3.4' into 4.4
* 3.4:
  Remove branch-version (keep them for contracts only)
  [Serializer] fix decoding float XML attributes starting with 0
  add missing dutch translations
  [Validator] Add missing romanian translations
  do not translate null placeholders or titles
2020-10-24 13:50:19 +02:00
Nicolas Grekas f8fe4bf9f5 Remove branch-version (keep them for contracts only) 2020-10-24 12:57:07 +02:00
Nicolas Grekas 01b064d97a Merge branch '5.1' into 5.x
* 5.1:
  Fix branch-version
2020-10-13 15:22:54 +02:00
Nicolas Grekas 1a0ea4d2f7 Merge branch '4.4' into 5.1
* 4.4:
  Fix branch-version
2020-10-13 15:21:37 +02:00
Nicolas Grekas 58f803f356 Merge branch '3.4' into 4.4
* 3.4:
  Fix branch-version
2020-10-13 15:20:53 +02:00
Nicolas Grekas 44a7e3e920 Fix branch-version 2020-10-13 15:20:16 +02:00
Nicolas Grekas 7f0015ee35 Merge branch '5.1' into 5.x
* 5.1:
  Remove "version" from composer.json files, use "branch-version" instead
  [String] fix "is too large" ValueError on PHP 8
2020-10-13 14:43:06 +02:00
Nicolas Grekas 23ab908213 Merge branch '4.4' into 5.1
* 4.4:
  Remove "version" from composer.json files, use "branch-version" instead
2020-10-13 14:35:38 +02:00
Nicolas Grekas e953dd3e0d Merge branch '3.4' into 4.4
* 3.4:
  Remove "version" from composer.json files, use "branch-version" instead
2020-10-13 14:30:56 +02:00
Nicolas Grekas f9ed6940fd Remove "version" from composer.json files, use "branch-version" instead 2020-10-13 14:21:16 +02:00
Nicolas Grekas 6066462be2 Merge branch '5.1' into 5.x
* 5.1:
  Update versions in composer.json
  [Mime] Fix serialization of RawMessage
2020-10-06 17:53:16 +02:00
Nicolas Grekas 55396f90a3 Merge branch '3.4' into 4.4
* 3.4:
  Update versions in composer.json
2020-10-06 17:45:41 +02:00
Nicolas Grekas 8f714a2fd6 Update versions in composer.json 2020-10-06 17:25:25 +02:00
Nicolas Grekas 11c4f28137 Merge branch '5.1' into 5.x
* 5.1:
  fix merge
  [appveyor] fix checking for the .x branch
  Remove "branch-alias", populate "version"
2020-10-06 14:00:29 +02:00
Nicolas Grekas 097c8c6f27 Merge branch '4.4' into 5.1
* 4.4:
  [appveyor] fix checking for the .x branch
  Remove "branch-alias", populate "version"
2020-10-06 13:49:34 +02:00
Nicolas Grekas e553f424d0 Merge branch '3.4' into 4.4
* 3.4:
  Remove "branch-alias", populate "version"
2020-10-06 13:41:17 +02:00
Nicolas Grekas 9d40c796c4 Remove "branch-alias", populate "version" 2020-10-06 13:22:52 +02:00
Fabien Potencier 9b81056503 Add a missing replace rule in the main composer.json file 2020-09-16 18:15:11 +02:00
Fabien Potencier 40022972f6 bug #37578 [HttpClient] fix pausing AmpResponse (kelunik)
This PR was merged into the 5.2-dev branch.

Discussion
----------

[HttpClient] fix pausing AmpResponse

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | None
| License       | MIT
| Doc PR        | None

This fixes the pause handler while streaming bodies in `AmpHttpClient`.

Needs to be rebased onto the target branch and needs some test fixes. @nicolas-grekas FYI.

Commits
-------

bf2d1cf6e7 Improve pause handler
2020-08-27 16:48:24 +02:00
Grégoire Pineau 891285475e [Semaphore] Added the component
Few years ago, we have introduced the Lock component. This is a very nice component, but sometime it is not enough. Sometime you need semaphore.

This is why I'm introducing this new component.

From wikipedia:

> In computer science, a semaphore is a variable or abstract data type used to control access to a common resource by multiple processes in a concurrent system such as a multitasking operating system. A semaphore is simply a variable. This variable is used to solve critical section problems and to achieve process synchronization in the multi processing environment. A trivial semaphore is a plain variable that is changed (for example, incremented or decremented, or toggled) depending on programmer-defined conditions.

This new component is more than a variable. This is an abstraction on top of different storage.

To make a quick comparison with a lock:

 * A lock allows only 1 process to access a resource;
 * A semaphore allow N process to access a resource.

Basically, a lock is a semaphore where `N = 1`.

PHP exposes some `sem_*` functions like [`sem_acquire`](http://php.net/sem_acquire). This module provides wrappers for the System V IPC family of functions. It includes semaphores, shared memory and inter-process messaging (IPC).

The Lock component has a storage that works with theses functions. It uses it with `N = 1`.

Wikipedia has some [examples](https://en.wikipedia.org/wiki/Semaphore_(programming)#Examples)

But I can add one more commun use case.

If you are building an async system that process user data, you may want to priorise all jobs. You can achieve that by running at maximum N jobs per user at the same time. If the user has more resources, you give him more concurrent jobs (so a bigger `N`).

Thanks to semaphores, it's pretty easy to know if a new job can be run.

I'm not saying the following services are using semaphore, but they may solve the previous problematic with semaphores. Here is some examples:

 * services like testing platform where a user can test N projects concurrently (travis, circle, appveyor, insight, ...)
 * services that ingest lots of data (newrelic, datadog, blackfire, segment.io, ...))
 * services that send email in batch (campaign monitor, mailchimp, ...)
 * etc...

To do so, since PHP is mono-threaded, you run M PHP workers. And in each worker, you look for for the next job. When you grab a job, you try to acquires a semaphore. If you got it, you process the job. If not you try another job.

FTR in other language, like Go, there are no need to run M workers, one is enough.

```php
<?php

use Symfony\Component\Lock\LockFactory;
use Symfony\Component\Lock\Store\RedisStore as LockRedisStore;
use Symfony\Component\Semaphore\SemaphoreFactory;
use Symfony\Component\Semaphore\Store\RedisStore;

require __DIR__.'/vendor/autoload.php';

$redis = new Redis();
$redis->connect('172.17.0.2');

// Internally, Semaphore needs a lock
$lock = (new LockFactory(new LockRedisStore($redis)))->createLock('test:lock', 1);

// Create a semaphore:
// * name = test
// * limit = 3 (it means only 3 process are allowed)
// * ttl = 10 seconds : Maximum expected semaphore duration in seconds
$semaphore = (new SemaphoreFactory($lock, new RedisStore($redis)))->createSemaphore('test', 3, 10);

if (!$semaphore->acquire()) {
    echo "Could not acquire the semaphore\n";
    exit(1);
}

// The semaphore has been acquired

// Do the heavy job
for ($i = 0; $i < 100; ++$i) {
    sleep(1);
    // Before the expiration, refresh the semaphore if the job is not finished yet
    if ($i % 9 === 0) {
        $semaphore->refresh();
    }
}

// Release it when finished
$semaphore->release();
```

I looked at [packagist](https://packagist.org/?query=semaphore) and:

 * most of packages are using a semaphore storage for creating a lock. So there are not relevant here;
 * some packages need an async framework to be used (amphp for example);
 * the only packages really implementing a semaphore, has a really low code quality and some bugs.

1. I initially copied the Lock component since the external API is quite similar;
1. I simplified it a lot for the current use case;
1. I implemented the RedisStorage according the [redis book](https://redislabs.com/ebook/part-2-core-concepts/chapter-6-application-components-in-redis/6-3-counting-semaphores/;)
1. I forced a TTL on the storage.
2020-08-27 14:35:29 +02:00
Niklas Keller bf2d1cf6e7 Improve pause handler 2020-08-26 12:30:57 +02:00
Fabien Potencier 374a0b2eb5 Merge branch '5.1'
* 5.1:
  fix passing arguments to call_user_func_array() on PHP 8
  allow Doctrine DBAL 3
  [Filesystem] fix test on PHP 8
2020-08-21 19:20:41 +02:00
Fabien Potencier 0611b6331c Merge branch '4.4' into 5.1
* 4.4:
  fix passing arguments to call_user_func_array() on PHP 8
  allow Doctrine DBAL 3
  [Filesystem] fix test on PHP 8
2020-08-21 19:19:47 +02:00
Christian Flothmann 967331e63a allow Doctrine DBAL 3 2020-08-21 14:55:23 +02:00
Antonio Pauletich 8e6d0df3ec
Add Beanstalkd Messenger bridge 2020-08-13 09:43:16 +02:00
Fabien Potencier b912af9261 Merge branch '5.1'
* 5.1:
  Fix typo
  Fix deprecated libxml_disable_entity_loader
  Add Tagalog translations for validator messages 94, 95, 96 and 99
  PHPUnit's assertContains() performs strict comparisons now.
  [ClassLoader][Routing] Fix namespace parsing on php 8.
  Fix deprecated libxml_disable_entity_loader
  Made reference to PHPUnit\Util\XML::loadfile php5-compatible.
  [Validator] Add missing translations for german and vietnamese
  Modernized deprecated PHPUnit assertion calls
  [Console] The message of "class not found" errors has changed in php 8.
  The PHPUnit\Util\XML class has been removed in PHPUnit 9.3.
  [Console] Make sure we pass a numeric array of arguments to call_user_func_array().
  Remove outdated references from base_js.html.twig file
  [String] We cannot have a "provides" function in test cases.
  Typo: somes styles fixed
  [Serializer] Fix that it will never reach DOMNode
  [Validator] sync translations
  [VarDumper] Improve previous fix on light array coloration
  [Cache] Fix #37667
2020-08-10 10:10:48 +02:00
Fabien Potencier c44c606b11 Merge branch '4.4' into 5.1
* 4.4:
  Fix typo
  Fix deprecated libxml_disable_entity_loader
  Add Tagalog translations for validator messages 94, 95, 96 and 99
  PHPUnit's assertContains() performs strict comparisons now.
  [ClassLoader][Routing] Fix namespace parsing on php 8.
  Fix deprecated libxml_disable_entity_loader
  Made reference to PHPUnit\Util\XML::loadfile php5-compatible.
  [Validator] Add missing translations for german and vietnamese
  Modernized deprecated PHPUnit assertion calls
  [Console] The message of "class not found" errors has changed in php 8.
  The PHPUnit\Util\XML class has been removed in PHPUnit 9.3.
  [Console] Make sure we pass a numeric array of arguments to call_user_func_array().
  [Serializer] Fix that it will never reach DOMNode
  [Validator] sync translations
  [VarDumper] Improve previous fix on light array coloration
  [Cache] Fix #37667
2020-08-10 10:03:57 +02:00
Fabien Potencier 3a04739a83 Merge branch '3.4' into 4.4
* 3.4:
  Add Tagalog translations for validator messages 94, 95, 96 and 99
  PHPUnit's assertContains() performs strict comparisons now.
  [ClassLoader][Routing] Fix namespace parsing on php 8.
  Fix deprecated libxml_disable_entity_loader
  Made reference to PHPUnit\Util\XML::loadfile php5-compatible.
  [Validator] Add missing translations for german and vietnamese
  Modernized deprecated PHPUnit assertion calls
  [Console] The message of "class not found" errors has changed in php 8.
  The PHPUnit\Util\XML class has been removed in PHPUnit 9.3.
  [Console] Make sure we pass a numeric array of arguments to call_user_func_array().
  [Serializer] Fix that it will never reach DOMNode
  [Validator] sync translations
  [VarDumper] Improve previous fix on light array coloration
  [Cache] Fix #37667
2020-08-10 09:27:51 +02:00
Alexander M. Turek ab417f7040 Modernized deprecated PHPUnit assertion calls 2020-08-09 10:13:48 +02:00
Nicolas Grekas 91487707db Merge branch '5.1'
* 5.1:
  Allow doctrine/persistence 2
  Fix Redis tests
  [DoctrineBridge] Bump doctrine/data-fixtures.
2020-07-23 18:56:54 +02:00
Nicolas Grekas 20cf5df00b Merge branch '5.0' into 5.1
* 5.0:
  Allow doctrine/persistence 2
  Fix Redis tests
  [DoctrineBridge] Bump doctrine/data-fixtures.
2020-07-23 18:55:47 +02:00
Nicolas Grekas 081ad138f7 Merge branch '4.4' into 5.0
* 4.4:
  Allow doctrine/persistence 2
  Fix Redis tests
  [DoctrineBridge] Bump doctrine/data-fixtures.
2020-07-23 18:54:02 +02:00
Alexander M. Turek cd22fe6c92 Allow doctrine/persistence 2 2020-07-23 18:49:41 +02:00
Nicolas Grekas 4a8f11c1dd Merge branch '3.4' into 4.4
* 3.4:
  Fix Redis tests
  [DoctrineBridge] Bump doctrine/data-fixtures.
2020-07-23 18:48:29 +02:00
Alexander M. Turek 4b611015d5 [DoctrineBridge] Bump doctrine/data-fixtures. 2020-07-23 14:17:19 +02:00
Nicolas Grekas 092632dc14 Merge branch '5.1'
* 5.1: (28 commits)
  [DI] fix
  Use "composer/package-versions-deprecated" when possible
  Fix
  Small update in our internal terminology
  Fix support for PHP8 union types
  [VarDumper] fix typo
  [Lock][Messenger] Fix precedence of DSN options for 5.1
  Fix support for PHP8 union types
  [FrameworkBundle] preserve dots in query-string when redirecting
  [3.4] Fix support for PHP8 union types
  [PhpUnitBridge] Streamline ansi/no-ansi of composer according to phpunit --colors option
  [3.4] Small update in our internal terminology
  [Cache] fix compat with DBAL v3
  Remove unnecessary null check
  [HttpFoundation] Allow `null` in InputBag@set
  [HttpClient] Convert CurlHttpClient::handlePush() to instance method
  Fix package rename when releasing
  bumped Symfony version to 5.1.3
  updated VERSION for 5.1.2
  updated CHANGELOG for 5.1.2
  ...
2020-06-18 21:55:03 +02:00
Nicolas Grekas eea6abf318 Merge branch '5.0' into 5.1
* 5.0:
  [DI] fix
  Use "composer/package-versions-deprecated" when possible
  Fix
2020-06-18 21:54:27 +02:00
Nicolas Grekas f3d9cfe8db Merge branch '4.4' into 5.0
* 4.4:
  [DI] fix
  Use "composer/package-versions-deprecated" when possible
  Fix
2020-06-18 21:53:24 +02:00
Nicolas Grekas 03b9ff177d Use "composer/package-versions-deprecated" when possible 2020-06-18 21:48:48 +02:00