arangodb / arangodb-php

PHP ODM for ArangoDB
https://www.arangodb.com
Apache License 2.0
183 stars 44 forks source link

v3.5.0 , DocumentHandler, Undefined index: revision #269

Open RysQ opened 4 years ago

RysQ commented 4 years ago

https://github.com/arangodb/arangodb-php/blob/54f7800f9297507b3a3f2d9ba0be27597a67bb2c/lib/ArangoDBClient/DocumentHandler.php#L648-L655

Line 651 may cause "Undefined index" Notice

'revision' option may not be set in $options param of put. Docs of replace and replaceById methods doesn't mention it should be provided. Instead it points out to Document's _rev.

So please consider (accordingly to patch method), to base the condition on something like:

$revision = $document->getRevision();
if (null !== $revision) { ... 

or provide 'revision' option/param within replace or replaceById methods (ie. like it's done in remove)


The issue doesn't appears in < 3.5.0 , since in previous versions includeOptionsInParams in ArangoDBClient/Handler returns empty array when its $options param is empty. Condition result:

if (isset($params[ConnectionOptions::OPTION_REPLACE_POLICY]) && 
    $params[ConnectionOptions::OPTION_REPLACE_POLICY] === UpdatePolicy::ERROR 
)

is always false then

jsteemann commented 3 years ago

@RysQ : I am probably a bit late to the game, but there is a PR now to address this issue: https://github.com/arangodb/arangodb-php/pull/284

jsteemann commented 3 years ago

Fixed via the above PR in devel and 3.8 branches.