Skip to content

Commit

Permalink
Remove error suppression
Browse files Browse the repository at this point in the history
Don't suppress errors emitted by ext/ldap functions
  • Loading branch information
DaveRandom committed Sep 26, 2013
1 parent d9a953e commit 0be571b
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 33 deletions.
40 changes: 20 additions & 20 deletions src/LDAPi/Directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function add($dn, array $entry)
{
$this->checkBound();

if (!@ldap_add($this->link, $dn, $entry)) {
if (!ldap_add($this->link, $dn, $entry)) {
throw new WriteFailureException(ldap_error($this->link), ldap_errno($this->link));
}
}
Expand All @@ -65,7 +65,7 @@ public function bind($dn = null, $password = null)
{
$this->checkConnected();

if (!@ldap_bind($this->link, $dn, $password)) {
if (!ldap_bind($this->link, $dn, $password)) {
throw new BindFailureException(ldap_error($this->link), ldap_errno($this->link));
}

Expand All @@ -84,7 +84,7 @@ public function compare($dn, $attribute, $value)
{
$this->checkBound();

if (-1 === $result = @ldap_compare($this->link, $dn, $entry)) {
if (-1 === $result = ldap_compare($this->link, $dn, $entry)) {
throw new ReadFailureException(ldap_error($this->link), ldap_errno($this->link));
}

Expand All @@ -103,7 +103,7 @@ public function connect($host, $port = 389)
throw new AlreadyAvailableException('An active connection to the directory is already available');
}

if (!$this->link = @ldap_connect($host, $port)) {
if (!$this->link = ldap_connect($host, $port)) {
throw new ConnectFailureException(ldap_error($this->link), ldap_errno($this->link));
}
}
Expand All @@ -119,7 +119,7 @@ public function controlPagedResult($pageSize, $isCritical = false, $cookie = '')
{
$this->checkBound();

if (!@ldap_control_paged_result($this->link, $pageSize, $isCritical, $cookie)) {
if (!ldap_control_paged_result($this->link, $pageSize, $isCritical, $cookie)) {
throw new PaginationFailureException(ldap_error($this->link), ldap_errno($this->link));
}
}
Expand All @@ -133,7 +133,7 @@ public function delete($dn)
{
$this->checkBound();

if (!@ldap_delete($this->link, $dn)) {
if (!ldap_delete($this->link, $dn)) {
throw new WriteFailureException(ldap_error($this->link), ldap_errno($this->link));
}
}
Expand All @@ -148,7 +148,7 @@ public function getOption($opt)
{
$this->checkConnected();

if (!@ldap_get_option($this->link, $opt, $value)) {
if (!ldap_get_option($this->link, $opt, $value)) {
throw new OptionFailureException(ldap_error($this->link), ldap_errno($this->link));
}

Expand All @@ -171,7 +171,7 @@ public function listChildren($dn, $filter, array $attributes = null, $attrsOnly
{
$this->checkBound();

if (!$result = @ldap_list($this->link, $dn, $filter, (array)$attributes, (int)(bool)$attrsOnly, $sizeLimit, $timeLimit, $deRef)) {
if (!$result = ldap_list($this->link, $dn, $filter, (array)$attributes, (int)(bool)$attrsOnly, $sizeLimit, $timeLimit, $deRef)) {
throw new ReadFailureException(ldap_error($this->link), ldap_errno($this->link));
}

Expand All @@ -188,7 +188,7 @@ public function modAdd($dn, array $entry)
{
$this->checkBound();

if (!@ldap_mod_add($this->link, $dn, $entry)) {
if (!ldap_mod_add($this->link, $dn, $entry)) {
throw new WriteFailureException(ldap_error($this->link), ldap_errno($this->link));
}
}
Expand All @@ -203,7 +203,7 @@ public function modDel($dn, array $entry)
{
$this->checkBound();

if (!@ldap_mod_del($this->link, $dn, $entry)) {
if (!ldap_mod_del($this->link, $dn, $entry)) {
throw new WriteFailureException(ldap_error($this->link), ldap_errno($this->link));
}
}
Expand All @@ -218,7 +218,7 @@ public function modReplace($dn, array $entry)
{
$this->checkBound();

if (!@ldap_mod_replace($this->link, $dn, $entry)) {
if (!ldap_mod_replace($this->link, $dn, $entry)) {
throw new WriteFailureException(ldap_error($this->link), ldap_errno($this->link));
}
}
Expand All @@ -233,7 +233,7 @@ public function modify($dn, array $entry)
{
$this->checkBound();

if (!@ldap_modify($this->link, $dn, $entry)) {
if (!ldap_modify($this->link, $dn, $entry)) {
throw new WriteFailureException(ldap_error($this->link), ldap_errno($this->link));
}
}
Expand All @@ -254,7 +254,7 @@ public function read($dn, $filter, array $attributes = null, $attrsOnly = false,
{
$this->checkBound();

if (!$result = @ldap_read($this->link, $dn, $filter, (array)$attributes, (int)(bool)$attrsOnly, $sizeLimit, $timeLimit, $deRef)) {
if (!$result = ldap_read($this->link, $dn, $filter, (array)$attributes, (int)(bool)$attrsOnly, $sizeLimit, $timeLimit, $deRef)) {
throw new ReadFailureException(ldap_error($this->link), ldap_errno($this->link));
}

Expand All @@ -273,7 +273,7 @@ public function rename($dn, $newRDN, $newParent, $deleteOldRDN = true)
{
$this->checkBound();

if (!@ldap_rename($this->link, $dn, $newRDN, $newParent, $deleteOldRDN)) {
if (!ldap_rename($this->link, $dn, $newRDN, $newParent, $deleteOldRDN)) {
throw new WriteFailureException(ldap_error($this->link), ldap_errno($this->link));
}
}
Expand All @@ -293,7 +293,7 @@ public function saslBind($dn = null, $password = null, $saslMech = null, $saslRe
{
$this->checkConnected();

if (!@ldap_sasl_bind($this->link, $dn, $password, $saslMech, $saslRealm, $saslAuthcId, $saslAuthzId, $props)) {
if (!ldap_sasl_bind($this->link, $dn, $password, $saslMech, $saslRealm, $saslAuthcId, $saslAuthzId, $props)) {
throw new BindFailureException(ldap_error($this->link), ldap_errno($this->link));
}

Expand All @@ -316,7 +316,7 @@ public function search($dn, $filter, array $attributes = null, $attrsOnly = fals
{
$this->checkBound();

if (!$result = @ldap_search($this->link, $dn, $filter, (array)$attributes, (int)(bool)$attrsOnly, $sizeLimit, $timeLimit, $deRef)) {
if (!$result = ldap_search($this->link, $dn, $filter, (array)$attributes, (int)(bool)$attrsOnly, $sizeLimit, $timeLimit, $deRef)) {
throw new ReadFailureException(ldap_error($this->link), ldap_errno($this->link));
}

Expand All @@ -333,7 +333,7 @@ public function setOption($opt, $value)
{
$this->checkConnected();

if (!@ldap_set_option($this->link, $opt, $value)) {
if (!ldap_set_option($this->link, $opt, $value)) {
throw new OptionFailureException(ldap_error($this->link), ldap_errno($this->link));
}
}
Expand All @@ -347,7 +347,7 @@ public function setRebindProc(callable $callback)
{
$this->checkConnected();

if (!@ldap_set_rebind_proc($this->link, $callback)) {
if (!ldap_set_rebind_proc($this->link, $callback)) {
throw new OptionFailureException(ldap_error($this->link), ldap_errno($this->link));
}
}
Expand All @@ -364,7 +364,7 @@ public function startTLS()
throw new AlreadyAvailableException('An active bound connection to the directory is already available');
}

if (!@ldap_start_tls($this->link)) {
if (!ldap_start_tls($this->link)) {
throw new EncryptionFailureException(ldap_error($this->link), ldap_errno($this->link));
}
}
Expand All @@ -376,7 +376,7 @@ public function unbind()
{
$this->checkBound();

@ldap_unbind($this->link);
ldap_unbind($this->link);

$this->link = null;
$this->bound = false;
Expand Down
8 changes: 4 additions & 4 deletions src/LDAPi/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct($link, $entry)
*/
public function nextEntry()
{
if (!$entry = @ldap_next_entry($this->link, $this->entry)) {
if (!$entry = ldap_next_entry($this->link, $this->entry)) {
if (0 !== $errNo = ldap_errno($this->link)) {
throw new EntryRetrievalFailureException(ldap_error($this->link), $errNo);
}
Expand All @@ -47,7 +47,7 @@ public function nextEntry()
*/
public function getValues($attribute)
{
if (!$values = @ldap_get_values($this->link, $this->entry, $attribute)) {
if (!$values = ldap_get_values($this->link, $this->entry, $attribute)) {
throw new ValueRetrievalFailureException(ldap_error($this->link), ldap_errno($this->link));
}

Expand All @@ -60,7 +60,7 @@ public function getValues($attribute)
*/
public function getAttributes()
{
if (!$attributes = @ldap_get_attributes($this->link, $this->entry)) {
if (!$attributes = ldap_get_attributes($this->link, $this->entry)) {
throw new ValueRetrievalFailureException(ldap_error($this->link), ldap_errno($this->link));
}

Expand All @@ -73,7 +73,7 @@ public function getAttributes()
*/
public function getDN()
{
if (!$dn = @ldap_get_dn($this->link, $this->entry)) {
if (!$dn = ldap_get_dn($this->link, $this->entry)) {
throw new ValueRetrievalFailureException(ldap_error($this->link), ldap_errno($this->link));
}

Expand Down
4 changes: 2 additions & 2 deletions src/LDAPi/Reference.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct($link, $reference)
*/
public function nextReference()
{
if (!$reference = @ldap_next_reference($this->link, $this->reference)) {
if (!$reference = ldap_next_reference($this->link, $this->reference)) {
if (0 !== $errNo = ldap_errno($this->link)) {
throw new ReferenceRetrievalFailureException(ldap_error($this->link), $errNo);
}
Expand All @@ -48,7 +48,7 @@ public function nextReference()
*/
public function parse()
{
if (!@ldap_parse_reference($this->link, $this->reference, $referrals)) {
if (!ldap_parse_reference($this->link, $this->reference, $referrals)) {
throw new ValueRetrievalFailureException(ldap_error($this->link), ldap_errno($this->link));
}

Expand Down
14 changes: 7 additions & 7 deletions src/LDAPi/ResultSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct($link, $result)

public function __destruct()
{
@ldap_free_result($this->result);
ldap_free_result($this->result);
}

/**
Expand All @@ -36,7 +36,7 @@ public function __destruct()
*/
public function controlPagedResult(&$estimated = null)
{
if (!@ldap_control_paged_result_response($this->link, $this->result, $cookie, $estimated)) {
if (!ldap_control_paged_result_response($this->link, $this->result, $cookie, $estimated)) {
throw new PaginationFailureException(ldap_error($this->link), ldap_errno($this->link));
}

Expand All @@ -49,7 +49,7 @@ public function controlPagedResult(&$estimated = null)
*/
public function entryCount()
{
if (!$result = @ldap_count_entries($this->link, $this->result)) {
if (!$result = ldap_count_entries($this->link, $this->result)) {
throw new EntryCountRetrievalFailureException(ldap_error($this->link), ldap_errno($this->link));
}

Expand All @@ -62,7 +62,7 @@ public function entryCount()
*/
public function firstEntry()
{
if (!$entry = @ldap_first_entry($this->link, $this->result)) {
if (!$entry = ldap_first_entry($this->link, $this->result)) {
if (0 !== $errNo = ldap_errno($this->link)) {
throw new EntryRetrievalFailureException(ldap_error($this->link), $errNo);
}
Expand All @@ -79,7 +79,7 @@ public function firstEntry()
*/
public function firstReference()
{
if (!$reference = @ldap_first_reference($this->link, $this->result)) {
if (!$reference = ldap_first_reference($this->link, $this->result)) {
if (0 !== $errNo = ldap_errno($this->link)) {
throw new ReferenceRetrievalFailureException(ldap_error($this->link), $errNo);
}
Expand All @@ -96,7 +96,7 @@ public function firstReference()
*/
public function parse()
{
if (!@ldap_parse_result($this->link, $this->result, $errCode, $matchedDN, $errMsg, $referrals)) {
if (!ldap_parse_result($this->link, $this->result, $errCode, $matchedDN, $errMsg, $referrals)) {
throw new InformationRetrievalFailureException(ldap_error($this->link), ldap_errno($this->link));
}

Expand All @@ -114,7 +114,7 @@ public function parse()
*/
public function getEntries()
{
if (!$entries = @ldap_get_entries($this->link, $this->result)) {
if (!$entries = ldap_get_entries($this->link, $this->result)) {
throw new ValueRetrievalFailureException(ldap_error($this->link), ldap_errno($this->link));
}

Expand Down

0 comments on commit 0be571b

Please sign in to comment.