Skip to content

Commit 4a96d27

Browse files
committed
Use correct type
1 parent cccc4a8 commit 4a96d27

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ a release.
2424
- [NestedSet] childrenQueryBuilder() to allow specifying sort order separately for each field
2525
- [NestedSet] Added option to reorder only direct children in reorder() method
2626

27-
### Sortable
27+
## Changed
28+
- Tree: In `ClosureTreeRepository::removeFromTree()` and `NestedTreeRepository::removeFromTree()` when something fails in the transaction, it uses the `code` from the original exception to construct the `\Gedmo\Exception\RuntimeException` instance instead of `null`.
29+
2830
#### Fixed
2931
- [SortableGroup] Fix sorting date columns in SQLite (#2462).
3032

src/Tree/Entity/Repository/ClosureTreeRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ public function removeFromTree($node)
292292
$this->_em->close();
293293
$this->_em->getConnection()->rollback();
294294

295-
throw new \Gedmo\Exception\RuntimeException('Transaction failed: '.$e->getMessage(), null, $e);
295+
throw new \Gedmo\Exception\RuntimeException('Transaction failed: '.$e->getMessage(), $e->getCode(), $e);
296296
}
297297
// remove from identity map
298298
$this->_em->getUnitOfWork()->removeFromIdentityMap($node);

src/Tree/Entity/Repository/NestedTreeRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ public function removeFromTree($node)
749749
$this->_em->close();
750750
$this->_em->getConnection()->rollback();
751751

752-
throw new \Gedmo\Exception\RuntimeException('Transaction failed', null, $e);
752+
throw new \Gedmo\Exception\RuntimeException('Transaction failed', $e->getCode(), $e);
753753
}
754754
} else {
755755
throw new InvalidArgumentException('Node is not related to this repository');

tests/Gedmo/IpTraceable/IpTraceableTest.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212
namespace Gedmo\Tests\IpTraceable;
1313

1414
use Doctrine\Common\EventManager;
15+
use Doctrine\Persistence\Mapping\ClassMetadata;
1516
use Gedmo\Exception\InvalidArgumentException;
1617
use Gedmo\IpTraceable\IpTraceable;
1718
use Gedmo\IpTraceable\IpTraceableListener;
19+
use Gedmo\Mapping\Event\AdapterInterface;
1820
use Gedmo\Tests\IpTraceable\Fixture\Article;
1921
use Gedmo\Tests\IpTraceable\Fixture\Comment;
2022
use Gedmo\Tests\IpTraceable\Fixture\Type;
@@ -59,14 +61,22 @@ public function testIpV4(): void
5961
{
6062
$listener = new IpTraceableListener();
6163
$listener->setIpValue('123.218.45.39');
62-
static::assertSame('123.218.45.39', $listener->getFieldValue(null, null, null));
64+
static::assertSame('123.218.45.39', $listener->getFieldValue(
65+
$this->createStub(ClassMetadata::class),
66+
'ip',
67+
$this->createStub(AdapterInterface::class)
68+
));
6369
}
6470

6571
public function testIpV6(): void
6672
{
6773
$listener = new IpTraceableListener();
6874
$listener->setIpValue('2001:0db8:0000:85a3:0000:0000:ac1f:8001');
69-
static::assertSame('2001:0db8:0000:85a3:0000:0000:ac1f:8001', $listener->getFieldValue(null, null, null));
75+
static::assertSame('2001:0db8:0000:85a3:0000:0000:ac1f:8001', $listener->getFieldValue(
76+
$this->createStub(ClassMetadata::class),
77+
'ip',
78+
$this->createStub(AdapterInterface::class)
79+
));
7080
}
7181

7282
public function testIpTraceable(): void

0 commit comments

Comments
 (0)