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

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

Open
FLasH3r opened this issue Dec 25, 2020 · 0 comments
Open

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

FLasH3r opened this issue Dec 25, 2020 · 0 comments

Comments

@FLasH3r
Copy link

FLasH3r commented Dec 25, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant