Skip to content

Commit

Permalink
Do not return error id if we know we did not send the error
Browse files Browse the repository at this point in the history
  • Loading branch information
stayallive committed Oct 6, 2018
1 parent 37a2df7 commit efeda8a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
15 changes: 9 additions & 6 deletions lib/Raven/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,11 @@ public function capture($data, $stack = null, $vars = null)
$this->process($data);

if (!$this->store_errors_for_bulk_send) {
$this->send($data);
if ($this->send($data) === false) {
$this->_last_event_id = null;

return null;
}
} else {
$this->_pending_events[] = $data;
}
Expand Down Expand Up @@ -1032,21 +1036,20 @@ public function send(&$data)
&& call_user_func_array($this->send_callback, array(&$data)) === false
) {
// if send_callback returns false, end native send
return;
return false;
}

if (!$this->server) {
return;
return false;
}

if ($this->transport) {
call_user_func($this->transport, $this, $data);
return;
return call_user_func($this->transport, $this, $data);
}

// should this event be sampled?
if (rand(1, 100) / 100.0 > $this->sample_rate) {
return;
return false;
}

$message = $this->encode($data);
Expand Down
19 changes: 17 additions & 2 deletions test/Raven/Tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,14 @@ public function send(&$data)
{
if (is_callable($this->send_callback) && call_user_func_array($this->send_callback, array(&$data)) === false) {
// if send_callback returns falsely, end native send
return;
return false;
}

$this->__sent_events[] = $data;

if (!$this->server) {
return false;
}
}

public static function is_http_request()
Expand Down Expand Up @@ -1337,11 +1342,21 @@ public function testCaptureLastError()
*/
public function testGetLastEventID()
{
$client = new Dummy_Raven_Client();
$client = new Dummy_Raven_Client('http://public:secret@example.com/1');
$client->capture(array('message' => 'test', 'event_id' => 'abc'));
$this->assertEquals('abc', $client->getLastEventID());
}

/**
* @covers Raven_Client::getLastEventID
*/
public function testGetLastEventIDWithoutServer()
{
$client = new Dummy_Raven_Client();
$client->capture(array('message' => 'test', 'event_id' => 'abc'));
$this->assertEquals(null, $client->getLastEventID());
}

/**
* @covers Raven_Client::setTransport
*/
Expand Down

0 comments on commit efeda8a

Please sign in to comment.