Skip to content
This repository was archived by the owner on May 10, 2018. It is now read-only.

Possible Fix for issue #34 #35

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
6 changes: 3 additions & 3 deletions Splunk/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/
class Splunk_Collection extends Splunk_Endpoint
{
private $entitySubclass;
protected $entitySubclass;

/**
* @internal
Expand Down Expand Up @@ -137,7 +137,7 @@ private function loadEntitiesFromResponse($response)
* @param SimpleXMLElement $entry an <entry> element.
* @return Splunk_Entry
*/
private function loadEntityFromEntry($entry)
protected function loadEntityFromEntry($entry)
{
return new $this->entitySubclass(
$this->service,
Expand Down Expand Up @@ -275,7 +275,7 @@ public function delete($name, $args=array())
/**
* Returns the absolute path of the child entity with the specified name.
*/
private function getEntityPath($name)
protected function getEntityPath($name)
{
return $this->path . $this->getEntityRelativePath($name);
}
Expand Down
70 changes: 59 additions & 11 deletions Splunk/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,30 @@
*/
class Splunk_Entity extends Splunk_Endpoint implements ArrayAccess
{
/**
* Indicates whether the entity has been loaded
*
* @var boolean
*/
private $loaded = FALSE;

/**
*
* @var SimpleXMLElement
*/
private $entry;

/**
*
* @var string
*/
private $namespace;

/**
* Holds the available properties for this entity
*
* @var array
*/
private $content;

/**
Expand Down Expand Up @@ -88,9 +109,9 @@ protected function validate($fetchArgs=array())
*
* @throws Splunk_IOException
*/
private function load($fetchArgs)
private function load()
{
$response = $this->fetch($fetchArgs);
$response = $this->fetch();
$xml = new SimpleXMLElement($response->body);

$this->entry = $this->extractEntryFromRootXmlElement($xml);
Expand All @@ -100,9 +121,10 @@ private function load($fetchArgs)
/**
* Fetches this entity's Atom feed from the Splunk server.
*
* @return Splunk_HttpResponse
* @throws Splunk_IOException
*/
protected function fetch($fetchArgs)
protected function fetch()
{
return $this->sendGet('');
}
Expand All @@ -123,14 +145,20 @@ protected function extractEntryFromRootXmlElement($xml)
return $xml->entry;
}

/** Parses the entry's contents. */
/**
* Parses the entry's contents.
*/
private function parseContentsFromEntry()
{
$this->content = Splunk_AtomFeed::parseValueInside($this->entry->content);
$this->loaded = TRUE;
}

/** Returns a value that indicates whether the entity has been loaded. */
/**
* Returns a value that indicates whether the entity has been loaded.
*
* @return boolean
*/
protected function isLoaded()
{
return $this->loaded;
Expand Down Expand Up @@ -189,7 +217,11 @@ protected function getTitle()
return (string) $this->validate()->entry->title;
}

/** Gets the namespace in which this entity resides. */
/**
* Gets the namespace in which this entity resides.
*
* @return string
*/
protected function getSearchNamespace()
{
return $this->namespace;
Expand Down Expand Up @@ -222,7 +254,8 @@ public function getNamespace()
// === ArrayAccess Methods ===

/**
* Gets the value of the specified entity property.
* ArrayAccess Interface Method to get the value of the
* specified entity property.
*
* @param string $key The name of an entity property.
* @return string The value of the specified entity property.
Expand All @@ -231,21 +264,36 @@ public function offsetGet($key)
{
return $this->validate()->content[$key];
}

/** @internal */

/**
* unsupported ArrayAccess Interface Method to assign a value to an offset
*
* @internal
* @param mixed $key
* @param mixed $value
* @throws Splunk_UnsupportedOperationException
*/
public function offsetSet($key, $value)
{
throw new Splunk_UnsupportedOperationException();
}

/** @internal */
/**
* unsupported ArrayAccess Interface Method to unset an offset
*
* @internal
* @param mixed $key
* @param mixed $value
* @throws Splunk_UnsupportedOperationException
*/
public function offsetUnset($key)
{
throw new Splunk_UnsupportedOperationException();
}

/**
* Gets a value that indicates whether the specified entity property exists.
* ArrayAccess Interface Method to gets a value that indicates whether
* the specified entity property exists.
*
* @param string $key The name of an entity property.
* @return string Whether the specified entity property exists.
Expand Down
8 changes: 6 additions & 2 deletions Splunk/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,13 @@ public function request(
'max_redirects' => 0, // [PHP 5.2] don't follow HTTP 3xx automatically
'ignore_errors' => TRUE, // don't throw exceptions on bad status codes
),
'ssl' => array(
'verify_peer' => false, // don't verify ssl peer. Since php 5.6 this defaults to true
'verify_peer_name' => false // allow certificate CN missmtach
)
));
// NOTE: PHP does not perform certificate validation for HTTPS URLs.

// NOTE: PHP does not perform certificate validation for HTTPS URLs prior version 5.6.
// NOTE: fopen() magically sets the $http_response_header local variable.
$bodyStream = @fopen($url, 'rb', /*use_include_path=*/FALSE, $fopenContext);
if ($bodyStream === FALSE)
Expand Down
Loading