Skip to content

calling hasVertex on a graph with more then one vertex is failing #279

Open
@FLasH3r

Description

@FLasH3r

My Environment

Latest version (3.6.0), PHP 7.3

Component, Query & Data

Affected feature:
Unable to use HasHandler on a graph with more then one vertex.
error: ArangoDBClient\\ClientException: A collection must be provided.

Steps to reproduce

  1. create a graph with more than one vertex
  2. call hasVertex on any vertex, get the error

Problem:
when calling GraphHandler method HasHandler, the signature is as described in the code:

     /**
     * Check if a vertex exists
     *
     * This will call self::getVertex() internally and checks if there
     * was an exception thrown which represents an 404 request.
     *
     * @throws Exception When any other error than a 404 occurs
     *
     * @param mixed $graph    - graph name as a string or instance of Graph
     * @param mixed $vertexId - the vertex identifier
     *
     * @return boolean
     */
    public function hasVertex($graph, $vertexId)
    {
        try {
            // will throw ServerException if entry could not be retrieved
            $this->getVertex($graph, $vertexId);

            return true;
        } catch (ServerException $e) {
            // we are expecting a 404 to return boolean false
            if ($e->getCode() === 404) {
                return false;
            }

            // just rethrow
            throw $e;
        }
    }

My graph has more then one vertex as described in the doc block of getVertex, so I need to pass the $collection parameter, but it does not exists in the hasVertex method

     /**
     * Get a single vertex from a graph
     *
     * This will throw if the vertex cannot be fetched from the server<br><br>
     *
     * @throws Exception
     *
     * @param mixed  $graph      - graph name as a string or instance of Graph
     * @param mixed  $vertexId   - the vertex identifier
     * @param array  $options    optional, an array of options:
     *                           <p>
     *                           <li><b>_includeInternals</b> - true to include the internal attributes. Defaults to false</li>
     *                           <li><b>_ignoreHiddenAttributes</b> - true to show hidden attributes. Defaults to false</li>
     *                           </p>
     * @param string $collection - if one uses a graph with more than one vertex collection one must provide the collection
     *                           to load the vertex.
     *
     * @return Document
     * @since 1.2
     */
    public function getVertex($graph, $vertexId, array $options = [], $collection = null)

Expected result:
hasVertex should work on a graph setup with more then one vertex

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions