Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[HttpFoundation] Setting REQUEST_TIME_FLOAT when constructing a Request object #39952

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4,599 commits into from

Conversation

ctasada
Copy link

@ctasada ctasada commented Jan 23, 2021

Q A
Branch? 4.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets Fix #38019
License MIT
Doc PR -

When creating a new Request object REQUEST_TIME_FLOAT was not set by default.

xabbuh and others added 30 commits January 2, 2021 17:29
This PR was merged into the 5.3-dev branch.

Discussion
----------

[Messenger] Deprecate option prefetch_count

| Q             | A
| ------------- | ---
| Branch?       | 5.x
| Bug fix?      | no
| New feature?  | no
| Deprecations? | yesno
| Tickets       | -
| License       | MIT
| Doc PR        | -

Revert #30671

Commits
-------

5b55097 Deprecate option prefetch_count
…rmatSame() (dunglas)

This PR was squashed before being merged into the 5.3-dev branch.

Discussion
----------

[FrameworkBundle][HttpFoundation] add assertResponseFormatSame()

| Q             | A
| ------------- | ---
| Branch?       | 5.x
| Bug fix?      | no
| New feature?  | yes <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | Fix n/a
| License       | MIT
| Doc PR        | todo

Add a new PHPUnit assertion checking the format of the HTTP request.

Example:

```php
namespace App\Tests;

use ApiPlatform\Core\Bridge\Symfony\Bundle\Test\ApiTestCase;
use App\Entity\Book;

class BooksTest extends ApiTestCase
{
    public function testGetCollection(): void
    {
        static::createClient()->request('GET', '/books');
        $this->assertResponseFormatSame('jsonld');
    }
}
```

Commits
-------

8fffa2c [FrameworkBundle][HttpFoundation] add assertResponseFormatSame()
…() (xabbuh)

This PR was merged into the 5.3-dev branch.

Discussion
----------

[DomCrawler] deprecate parents() in favor of ancestors()

| Q             | A
| ------------- | ---
| Branch?       | 5.x
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | yes
| Tickets       | Fix #26432
| License       | MIT
| Doc PR        |

Commits
-------

8baafa2 deprecate parents() in favor of ancestors()
* 4.4:
  remove unneeded sprintf() call
  Fix CS
  Fix config merging in lock
  keep trailing newlines when dumping multi-line strings
  disable error bubbling by default when inherit_data is configured
* 5.1:
  remove unneeded sprintf() call
  Fix CS
  Fix config merging in lock
  keep trailing newlines when dumping multi-line strings
  disable error bubbling by default when inherit_data is configured
* 5.2:
  remove unneeded sprintf() call
  Fix CS
  Fix config merging in lock
  keep trailing newlines when dumping multi-line strings
  disable error bubbling by default when inherit_data is configured
This PR was merged into the 5.1 branch.

Discussion
----------

[FrameworkBundle] Dump abstract arguments

| Q             | A
| ------------- | ---
| Branch?       | 5.1
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #24138
| License       | MIT
| Doc PR        | -

This PR fixes n exception thrown when dumping abstract arguments (ie. `./bin/console  debug:containter session.abstract_handler --show-arguments`)

Commits
-------

df769ec Dump abstract arguments
…st namespace (wouterj)

This PR was squashed before being merged into the 5.3-dev branch.

Discussion
----------

[DoctrineBridge] Deprecate internal test helpers in Test namespace

| Q             | A
| ------------- | ---
| Branch?       | 5.x
| Bug fix?      | no
| New feature?  | no
| Deprecations? | yes
| Tickets       | -
| License       | MIT
| Doc PR        | -

These helper classes are only used internally in the DoctrineBridge and, as far as I can see, only make sense within the test suite of the DoctrineBridge. Having them in `Test` means they are covered by the BC promise, I think we can make our lives more easy by moving them to `Tests`.

Commits
-------

a174e6b [DoctrineBridge] Deprecate internal test helpers in Test namespace
* 4.4:
  harden test to not depend on the actual time
  [ProxyManager] fix tests
  actually compare the order of entries when any sorting is applied
* 5.1:
  harden test to not depend on the actual time
  [ProxyManager] fix tests
  actually compare the order of entries when any sorting is applied
  Dump abstract arguments
* 5.2:
  harden test to not depend on the actual time
  [ProxyManager] fix tests
  actually compare the order of entries when any sorting is applied
  Dump abstract arguments
…xabbuh)

This PR was merged into the 5.2 branch.

Discussion
----------

[Cache] use the clock mock to make test more resilient

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

see for example https://ci.appveyor.com/project/fabpot/symfony/builds/37097868#L1534

Commits
-------

35f836a use the clock mock to make test more resilient
* 4.4:
  Cleanup CI scripts
  fix code style
  fix code style
  take query and request parameters into account when matching routes
  mistake
  fix tests to run assertions on returned Crawler instances
This PR was merged into the 5.1 branch.

Discussion
----------

[Validator] propagate groups to nested constraints

| Q             | A
| ------------- | ---
| Branch?       | 5.1
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #39386
| License       | MIT
| Doc PR        |

Commits
-------

13a4610 propagate groups to nested constraints
* 5.1:
  Cleanup CI scripts
  fix code style
  fix code style
  take query and request parameters into account when matching routes
  mistake
  fix tests to run assertions on returned Crawler instances
  propagate groups to nested constraints
…s are passed (xabbuh)

This PR was merged into the 5.2 branch.

Discussion
----------

[PropertyAccess] throw type error when incompatible types are passed

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

Commits
-------

4c5cff6 throw type error when incompatible types are passed
This PR was merged into the 5.2 branch.

Discussion
----------

[FrameworkBundle] Fix UidNormalizer priority

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

`AbstractUid` implements `\JsonSerializable`. `JsonSerializableNormalizer` has a priority of `-900`, so it's actually this normalizer that is used instead of the good one. It does not change the result but it adds an extra layer.

Commits
-------

1c652a7 [FrameworkBundle] Fix UidNormalizer priority
* 5.2:
  Cleanup CI scripts
  use the clock mock to make test more resilient
  fix code style
  fix code style
  take query and request parameters into account when matching routes
  mistake
  throw type error when incompatible types are passed
  fix tests to run assertions on returned Crawler instances
  [FrameworkBundle] Fix UidNormalizer priority
  propagate groups to nested constraints
This PR was merged into the 5.1 branch.

Discussion
----------

[Cache] allow HttpKernel 5.x

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

Commits
-------

47385a1 allow HttpKernel 5.x
* 5.1:
  allow HttpKernel 5.x
xabbuh and others added 6 commits January 22, 2021 18:02
… methods (YaFou)

This PR was merged into the 5.1 branch.

Discussion
----------

[PropertyInfo] Fix breaking change with has*(arguments...) methods

| Q             | A
| ------------- | ---
| Branch?       | 5.1
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #39885
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->
<!--
Replace this notice by a short README for your feature/bugfix. This will help people
understand your PR and can be used as a start for the documentation.

Additionally (see https://symfony.com/releases):
 - Always add tests and ensure they pass.
 - Never break backward compatibility (see https://symfony.com/bc).
 - Bug fixes must be submitted against the lowest maintained branch where they apply
   (lowest branches are regularly merged to upper ones so they get the fixes too.)
 - Features and deprecations must be submitted against branch 5.x.
-->

Until 5.0:
```php
class Dummy
{
    private $elements;

    public function hasElement($element): bool
    {
        // ...
    }
}

$extractor = new ReflectionExtractor();
$extractor->isReadable('Dummy', 'element'); // false
```

After 5.0:
```php
class Dummy
{
    private $elements;

    public function hasElement($element): bool
    {
        // ...
    }
}

$extractor = new ReflectionExtractor();
$extractor->isReadable('Dummy', 'element'); // true => BREAKING CHANGE
```

Commits
-------

37cc16e [PropertyInfo] Fix breaking change with has*(arguments...) methods
This PR was merged into the 5.2 branch.

Discussion
----------

[Notifier] fix test

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

Commits
-------

542dddc fix test
* 4.4:
  "export-ignore" contracts and phpunit-bridge
  [Console][Command] Fix Closure code binding when it is a static anonymous function
* 5.1:
  "export-ignore" contracts and phpunit-bridge
  [Console][Command] Fix Closure code binding when it is a static anonymous function
  Use class const in test
  [Security] [HttpFoundation] Use class const in test
  [PropertyInfo] Fix breaking change with has*(arguments...) methods
* 5.2:
  fix test
  "export-ignore" contracts and phpunit-bridge
  [Console][Command] Fix Closure code binding when it is a static anonymous function
  Use class const in test
  [Security] [HttpFoundation] Use class const in test
  [Notifier] [OvhCloud] “Invalid signature” for message with slashes
  Remove wrong test
  [PropertyInfo] Fix breaking change with has*(arguments...) methods
  [Uid] Unable to extend Uuid/Ulid and use fromString()
  Fix typo in property name
@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has a contribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (see https://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (see https://symfony.com/releases)
  • Features and deprecations must be submitted against the 5.x branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

Carlos Tasada added 2 commits January 23, 2021 18:19
Creating a `Request`, which already included a `REQUEST_TIME` field, was already time sensitive in the way the asserts where executed, due to the test execution speed, this case was not obvious, but adding the new `REQUEST_TIME_FLOAT` the time differences became obvious, making the tests to fail.
@nicolas-grekas nicolas-grekas added this to the 4.4 milestone Jan 23, 2021
@carsonbot
Copy link

Hey!

Nice work here, I this makes me happy.

I think @andersonamuller has recently worked with this code. Maybe they can help review this?

Cheers!

Carsonbot

class InlineFragmentRendererTest extends TestCase
{
protected function setUp(): void
{
ClockMock::register(Request::class);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not needed

Carlos Tasada added 2 commits January 31, 2021 13:58
…a/issue-38019

# Conflicts:
#	src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php
@ctasada ctasada closed this Jan 31, 2021
@ctasada ctasada deleted the ctasada/issue-38019 branch January 31, 2021 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Why is not REQUEST_TIME_FLOAT set by default when constructing a Request object?