Skip to content

Commit

Permalink
Remove dependencies check
Browse files Browse the repository at this point in the history
This is a check for whether the server has successfully implemented the
extension. This is both a rare occurence (haven't seen this in practice
yet) and/or something we should just ignore anyway.

We already do the important client side check - implied extensions -
elsewhere.
  • Loading branch information
slusarz committed Jul 17, 2014
1 parent fe17f30 commit 96a5068
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 53 deletions.
Expand Up @@ -26,32 +26,6 @@
class Horde_Imap_Client_Data_Capability_Imap
extends Horde_Imap_Client_Data_Capability
{
/**
* Capability dependencies.
*
* @var array
*/
static public $dependencies = array(
// RFC 5182 [2.1]
'SEARCHRES' => array(
'ESEARCH'
),
// RFC 5255 [3.1]
'LANGUAGE' => array(
'NAMESPACE'
),
// RFC 5957 [1]
'SORT=DISPLAY' => array(
'SORT'
),
// RFC 7162 [3.2]
'QRESYNC' => array(
// QRESYNC requires CONDSTORE, but the latter is implied and is
// not required to be listed.
'ENABLE'
)
);

/**
*/
public function __get($name)
Expand All @@ -77,33 +51,19 @@ public function __get($name)
*/
public function query($capability, $parameter = null)
{
$capability = strtoupper($capability);
if (parent::query($capability, $parameter)) {
return true;
}

switch ($capability) {
switch (strtoupper($capability)) {
case 'CONDSTORE':
case 'ENABLE':
/* RFC 7162 [3.2.3] - QRESYNC implies CONDSTORE and ENABLE,
* even if not listed as a capability. */
if (is_null($parameter)) {
return parent::query($capability) || parent::query('QRESYNC');
}
break;
}

if (!parent::query($capability, $parameter)) {
return false;
}

/* Check for capability dependencies. */
if (isset(self::$dependencies[$capability])) {
foreach (self::$dependencies[$capability] as $val) {
if (!$this->query($val)) {
return false;
}
}
return (is_null($parameter) && $this->query('QRESYNC'));
}

return true;
return false;
}

}
Expand Up @@ -26,17 +26,16 @@
class Horde_Imap_Client_Data_Capability_ImapTest
extends PHPUnit_Framework_TestCase
{
public function testQueryWithDependencies()
public function testImpliedExtensions()
{
/* LANGUAGE requires NAMESPACE */
$c = new Horde_Imap_Client_Data_Capability_Imap();
$c->add('LANGUAGE');
$c->add('QRESYNC');

$this->assertFalse($c->query('LANGUAGE'));
$this->assertTrue($c->query('QRESYNC'));

$c->add('NAMESPACE');

$this->assertTrue($c->query('LANGUAGE'));
/* QRESYNC implies CONDSTORE and ENABLE. */
$this->assertTrue($c->query('CONDSTORE'));
$this->assertTrue($c->query('ENABLE'));
}

public function testCmdlengthProperty()
Expand Down

0 comments on commit 96a5068

Please sign in to comment.