[PR #84] [CLOSED] Update DynamoDbStorage::find #111

Closed
opened 2026-01-23 11:35:14 +01:00 by admin · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/doctrine/KeyValueStore/pull/84
Author: @south634
Created: 5/18/2017
Status: Closed

Base: masterHead: master


📝 Commits (10+)

  • 4951789 Check for item after get attempt instead of before
  • 869a8e3 Added test
  • 1f34f52 Merge pull request #1 from ConsumerTrack/fix-fatal-error-on-missing-table-key
  • 0174f75 Adding QueryBuilder support for dynamo
  • 7e8dc70 Adding Orx, fixing parenthesis
  • 97239b5 Adding support for embeddable entities
  • 8624f2d Adding support for loading
  • 819d389 Allow find all entities
  • 00185b9 Updating
  • 7be8d2f Fixing function key names, fix parenthesis, adding single result

📊 Changes

21 files changed (+1569 additions, -23 deletions)

View changed files

📝 lib/Doctrine/KeyValueStore/EntityManager.php (+15 -0)
📝 lib/Doctrine/KeyValueStore/Mapping/AnnotationDriver.php (+41 -4)
lib/Doctrine/KeyValueStore/Mapping/Annotations/Embeddable.php (+33 -0)
lib/Doctrine/KeyValueStore/Mapping/Annotations/Embedded.php (+36 -0)
📝 lib/Doctrine/KeyValueStore/Mapping/Annotations/Entity.php (+5 -0)
📝 lib/Doctrine/KeyValueStore/Mapping/ClassMetadata.php (+3 -1)
📝 lib/Doctrine/KeyValueStore/Mapping/ClassMetadataFactory.php (+1 -1)
lib/Doctrine/KeyValueStore/Query/Expr.php (+281 -0)
lib/Doctrine/KeyValueStore/Query/Expr/Andx.php (+63 -0)
lib/Doctrine/KeyValueStore/Query/Expr/Base.php (+124 -0)
lib/Doctrine/KeyValueStore/Query/Expr/Comparison.php (+100 -0)
lib/Doctrine/KeyValueStore/Query/Expr/Composite.php (+71 -0)
lib/Doctrine/KeyValueStore/Query/Expr/Func.php (+78 -0)
lib/Doctrine/KeyValueStore/Query/Expr/Orx.php (+63 -0)
lib/Doctrine/KeyValueStore/Query/Parameter.php (+94 -0)
lib/Doctrine/KeyValueStore/Query/Query.php (+34 -0)
lib/Doctrine/KeyValueStore/Query/QueryBuilder.php (+322 -0)
lib/Doctrine/KeyValueStore/Query/QueryBuilderStorage.php (+41 -0)
📝 lib/Doctrine/KeyValueStore/Storage/DynamoDbStorage.php (+116 -3)
📝 lib/Doctrine/KeyValueStore/UnitOfWork.php (+45 -13)

...and 1 more files

📄 Description

The code below returns an object of Aws\Result even when the table key does not exist in DynamoDB:

$item = $this->client->getItem([
    self::TABLE_NAME_KEY      => $storageName,
    self::CONSISTENT_READ_KEY => true,
    self::TABLE_KEY           => $this->prepareKey($storageName, $key),
]);

Causing this check to pass:

if (! $item) {
   throw NotFoundException::notFoundByKey($key);
}

Since the key does not exist a null value is set here:
$item = $item->get(self::TABLE_ITEM_KEY);
Then that null $item is passed to:
$this->marshaler->unmarshalItem($item);
Which causes a fatal error.

This fix checks $item after attempting to get it instead of before.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/doctrine/KeyValueStore/pull/84 **Author:** [@south634](https://github.com/south634) **Created:** 5/18/2017 **Status:** ❌ Closed **Base:** `master` ← **Head:** `master` --- ### 📝 Commits (10+) - [`4951789`](https://github.com/doctrine/KeyValueStore/commit/4951789fd27e9707e0af4e173c741977b2ded48c) Check for item after get attempt instead of before - [`869a8e3`](https://github.com/doctrine/KeyValueStore/commit/869a8e395e9d2932036852ca04ec163145c531b8) Added test - [`1f34f52`](https://github.com/doctrine/KeyValueStore/commit/1f34f52eadf15b76dbc3d5a46b7d8ccd64906eab) Merge pull request #1 from ConsumerTrack/fix-fatal-error-on-missing-table-key - [`0174f75`](https://github.com/doctrine/KeyValueStore/commit/0174f7547b336b2f35bfad77a62734e20cec62da) Adding QueryBuilder support for dynamo - [`7e8dc70`](https://github.com/doctrine/KeyValueStore/commit/7e8dc70e48b550ea89958d4026adf301bf7f9027) Adding Orx, fixing parenthesis - [`97239b5`](https://github.com/doctrine/KeyValueStore/commit/97239b521c736565139d8d3effb0dcfb041f6e48) Adding support for embeddable entities - [`8624f2d`](https://github.com/doctrine/KeyValueStore/commit/8624f2d2a22d7aaf7cd413bb7e57ae9fa3128628) Adding support for loading - [`819d389`](https://github.com/doctrine/KeyValueStore/commit/819d38950d5406baae2dd32a15f0a2175e54563e) Allow find all entities - [`00185b9`](https://github.com/doctrine/KeyValueStore/commit/00185b9732d5acc9b72d69a6f3807e05ae59f87f) Updating - [`7be8d2f`](https://github.com/doctrine/KeyValueStore/commit/7be8d2f8df9995e44abe8c6f8c68e2c3597bff5b) Fixing function key names, fix parenthesis, adding single result ### 📊 Changes **21 files changed** (+1569 additions, -23 deletions) <details> <summary>View changed files</summary> 📝 `lib/Doctrine/KeyValueStore/EntityManager.php` (+15 -0) 📝 `lib/Doctrine/KeyValueStore/Mapping/AnnotationDriver.php` (+41 -4) ➕ `lib/Doctrine/KeyValueStore/Mapping/Annotations/Embeddable.php` (+33 -0) ➕ `lib/Doctrine/KeyValueStore/Mapping/Annotations/Embedded.php` (+36 -0) 📝 `lib/Doctrine/KeyValueStore/Mapping/Annotations/Entity.php` (+5 -0) 📝 `lib/Doctrine/KeyValueStore/Mapping/ClassMetadata.php` (+3 -1) 📝 `lib/Doctrine/KeyValueStore/Mapping/ClassMetadataFactory.php` (+1 -1) ➕ `lib/Doctrine/KeyValueStore/Query/Expr.php` (+281 -0) ➕ `lib/Doctrine/KeyValueStore/Query/Expr/Andx.php` (+63 -0) ➕ `lib/Doctrine/KeyValueStore/Query/Expr/Base.php` (+124 -0) ➕ `lib/Doctrine/KeyValueStore/Query/Expr/Comparison.php` (+100 -0) ➕ `lib/Doctrine/KeyValueStore/Query/Expr/Composite.php` (+71 -0) ➕ `lib/Doctrine/KeyValueStore/Query/Expr/Func.php` (+78 -0) ➕ `lib/Doctrine/KeyValueStore/Query/Expr/Orx.php` (+63 -0) ➕ `lib/Doctrine/KeyValueStore/Query/Parameter.php` (+94 -0) ➕ `lib/Doctrine/KeyValueStore/Query/Query.php` (+34 -0) ➕ `lib/Doctrine/KeyValueStore/Query/QueryBuilder.php` (+322 -0) ➕ `lib/Doctrine/KeyValueStore/Query/QueryBuilderStorage.php` (+41 -0) 📝 `lib/Doctrine/KeyValueStore/Storage/DynamoDbStorage.php` (+116 -3) 📝 `lib/Doctrine/KeyValueStore/UnitOfWork.php` (+45 -13) _...and 1 more files_ </details> ### 📄 Description The code below returns an object of Aws\Result even when the table key does not exist in DynamoDB: ``` $item = $this->client->getItem([ self::TABLE_NAME_KEY => $storageName, self::CONSISTENT_READ_KEY => true, self::TABLE_KEY => $this->prepareKey($storageName, $key), ]); ``` Causing this check to pass: ``` if (! $item) { throw NotFoundException::notFoundByKey($key); } ``` Since the key does not exist a null value is set here: `$item = $item->get(self::TABLE_ITEM_KEY);` Then that null $item is passed to: `$this->marshaler->unmarshalItem($item);` Which causes a fatal error. This fix checks $item after attempting to get it instead of before. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
admin added the pull-request label 2026-01-23 11:35:14 +01:00
admin closed this issue 2026-01-23 11:35:14 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/KeyValueStore#111