Skip to content

Conversation

thijsvdanker
Copy link
Contributor

I was a little bit to trigger happy on #130 as the client in #130 is not available to me in this example #129

$this->setupFirstQuery();
try {
    $this->client->executeQuery();
} catch (Exception $e) {
   $this->client->clear();
    $this->setupSecondQuery();
    $this->client->executeQuery();
}

This merge request adds a removePendingRequest() method to the ClientRuntimeContext which is available to the code example above.
The result would be:

$this->setupFirstQuery();
try {
    $this->client->executeQuery();
} catch (Exception $e) {
   $this->client->removePendingRequest();
    $this->setupSecondQuery();
    $this->client->executeQuery();
}

I'm sorry for the confusion. The clear() method from #130 might not be that useful so we could consider removing it again...

@vgrem vgrem merged commit 471b977 into vgrem:master Oct 24, 2018
@vgrem
Copy link
Owner

vgrem commented Oct 27, 2018

Hi @thijsvdanker,

First of all, much appreciated your contributions!
This was indeed an important issue and I like the idea and changes you proposed but i think we could improve it a bit.

Instead of introducing removePendingRequest and clear methods i propose the change which allows to manage request queue in automatic matter as the following example demonstrates:

   try{
        //lets try to load non-existent list to simulate the exception
        $listTitle = "Orders_" . rand(1,100000);
        $list = $context->getWeb()->getLists()->getByTitle($listTitle);
        $context->load($list);
        $context->executeQuery();
    }
    catch(Exception $e){
        //in case if previous request failed, the next request from a queue could be executed like this
        $user = $context->getWeb()->getCurrentUser();
        $context->load($user);
        $context->executeQuery();          
    }

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

Successfully merging this pull request may close these issues.

2 participants