Skip to content
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

Merge release 2.8.3 into 2.9.x #8582

Merged
merged 4 commits into from
Apr 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
name: Static Analysis

name: "Static Analysis"

on:
pull_request:
branches:
- "*.x"
push:
branches:
- "*.x"

jobs:
static-analysis-phpstan:
name: "PHPStan"
runs-on: "ubuntu-latest"
name: "Static Analysis with PHPStan"
runs-on: "ubuntu-20.04"

strategy:
matrix:
Expand All @@ -22,17 +28,18 @@ jobs:
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
tools: cs2pr

- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v1"
with:
dependency-versions: "highest"

- name: "Run a static analysis with phpstan/phpstan"
run: "php vendor/bin/phpstan analyse --error-format=checkstyle | cs2pr"
run: "vendor/bin/phpstan analyse"

static-analysis-psalm:
name: "Psalm"
runs-on: "ubuntu-latest"
name: "Static Analysis with Psalm"
runs-on: "ubuntu-20.04"

strategy:
matrix:
Expand All @@ -51,6 +58,8 @@ jobs:

- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v1"
with:
dependency-versions: "highest"

- name: "Run a static analysis with vimeo/psalm"
run: "vendor/bin/psalm --show-info=false --stats --output-format=github --threads=$(nproc)"
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ public function update($entity)
$this->updateTable($entity, $quotedTableName, $data, $isVersioned);

if ($isVersioned) {
$id = $this->em->getUnitOfWork()->getEntityIdentifier($entity);
$id = $this->class->getIdentifierValues($entity);

$this->assignDefaultVersionValue($entity, $id);
}
Expand Down
103 changes: 103 additions & 0 deletions tests/Doctrine/Tests/ORM/Functional/Ticket/GH6394Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<?php

declare(strict_types=1);

namespace Doctrine\Tests\ORM\Functional\Ticket;

use Doctrine\Tests\OrmFunctionalTestCase;

class GH6394Test extends OrmFunctionalTestCase
{
protected function setUp(): void
{
parent::setUp();

$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(A::class),
$this->_em->getClassMetadata(B::class),
]
);
}

/**
* Test the the version of an entity can be fetched, when the id field and
* the id column are different.
*
* @group 6393
*/
public function testFetchVersionValueForDifferentIdFieldAndColumn(): void
{
$a = new A(1);
$this->_em->persist($a);

$b = new B($a, 'foo');
$this->_em->persist($b);
$this->_em->flush();

self::assertSame(1, $b->version);

$b->something = 'bar';
$this->_em->flush();

self::assertSame(2, $b->version);
}
}

/**
* @Entity
*/
class A
{
/**
* @Id
* @Column(type="integer")
* @var int
*/
public $id;

/**
* @Version
* @Column(type="integer")
* @var int
*/
public $version;

public function __construct(int $id)
{
$this->id = $id;
}
}

/**
* @Entity
*/
class B
{
/**
* @Id
* @ManyToOne(targetEntity="A")
* @JoinColumn(name="aid", referencedColumnName="id")
* @var A
*/
public $a;

/**
* @Column(type="string")
* @var string
*/
public $something;

/**
* @Version
* @Column(type="integer")
* @var int
*/
public $version;

public function __construct(A $a, string $something)
{
$this->a = $a;
$this->something = $something;
}
}