package.xml 0000664 0001750 0001750 00000127603 12741242607 011315 0 ustar jan jan
Horde_Mongopear.horde.orgHorde Mongo ConfigurationProvides an API to ensure that the PECL Mongo extension can be used consistently across various Horde packages.Michael Slusarzslusarzslusarz@horde.orgyes2016-07-121.1.01.0.0stablestableLGPL-2.1
* [jan] Support mongodb extension too (Remi Collet <fedora@famillecollet.com>).
5.3.08.0.0alpha18.0.0alpha11.7.0mongopecl.php.net1.3.0mongomongodbpecl.php.netmongodb2013-05-021.0.0beta11.0.0beta1betabetaLGPL-2.1
* First beta release.
1.0.0RC11.0.0beta1betabeta2013-05-28LGPL-2.1
* [mms] Add Horde_Mongo_Client#checkIndices() and Horde_Mongo_Client#createIndices().
* [mms] Add Horde_Mongo_Collection_Index interface.
1.0.01.0.0stablestable2013-06-04LGPL-2.1
* Final release.
1.0.11.0.0stablestable2013-06-13LGPL-2.1
* [mms] Fix checking/creating indices when a MongoCollection object is passed to checkIndices()/createIndices() (Bug #12353).
1.0.21.0.0stablestable2013-10-16LGPL-2.1
* [mjr] Prevent data loss due to forced selection of incorrect database.
1.0.31.0.0stablestable2015-01-09LGPL-2.1
* [jan] Add Composer definition.
1.1.01.0.0stablestable2016-07-12LGPL-2.1
* [jan] Support mongodb extension too (Remi Collet <fedora@famillecollet.com>).
././@LongLink 0 0 0 156 0 003740 L Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/lib/Alcaeus/MongoDbAdapter/Helper/ReadPreference.php Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/lib/Alcaeus/MongoDbAdapter/Helper/ReadPref0000664 0001750 0001750 00000012223 12741242607 031332 0 ustar jan jan readPreference === null) {
$this->readPreference = new \MongoDB\Driver\ReadPreference(\MongoDB\Driver\ReadPreference::RP_PRIMARY);
}
$mode = $this->readPreference->getMode();
switch ($mode) {
case \MongoDB\Driver\ReadPreference::RP_PRIMARY_PREFERRED:
$type = \MongoClient::RP_PRIMARY_PREFERRED;
break;
case \MongoDB\Driver\ReadPreference::RP_SECONDARY:
$type = \MongoClient::RP_SECONDARY;
break;
case \MongoDB\Driver\ReadPreference::RP_SECONDARY_PREFERRED:
$type = \MongoClient::RP_SECONDARY_PREFERRED;
break;
case \MongoDB\Driver\ReadPreference::RP_NEAREST:
$type = \MongoClient::RP_NEAREST;
break;
default:
$type = \MongoClient::RP_PRIMARY;
}
$readPreference = ['type' => $type];
if ($this->readPreference->getTagSets() !== null && $this->readPreference->getTagSets() !== []) {
$readPreference['tagsets'] = $this->readPreference->getTagSets();
}
return $readPreference;
}
/**
* @return bool
*/
protected function getSlaveOkayFromReadPreference()
{
return $this->readPreference->getMode() != \MongoDB\Driver\ReadPreference::RP_PRIMARY;
}
/**
* @param string $readPreference
* @param array $tags
* @return bool
*/
protected function setReadPreferenceFromParameters($readPreference, $tags = null)
{
// @internal Passing an array for $readPreference is necessary to avoid conversion voodoo
// It should not be used externally!
if (is_array($readPreference)) {
return $this->setReadPreferenceFromArray($readPreference);
}
switch ($readPreference) {
case \MongoClient::RP_PRIMARY:
$mode = \MongoDB\Driver\ReadPreference::RP_PRIMARY;
break;
case \MongoClient::RP_PRIMARY_PREFERRED:
$mode = \MongoDB\Driver\ReadPreference::RP_PRIMARY_PREFERRED;
break;
case \MongoClient::RP_SECONDARY:
$mode = \MongoDB\Driver\ReadPreference::RP_SECONDARY;
break;
case \MongoClient::RP_SECONDARY_PREFERRED:
$mode = \MongoDB\Driver\ReadPreference::RP_SECONDARY_PREFERRED;
break;
case \MongoClient::RP_NEAREST:
$mode = \MongoDB\Driver\ReadPreference::RP_NEAREST;
break;
default:
trigger_error("The value '$readPreference' is not valid as read preference type", E_WARNING);
return false;
}
if ($readPreference == \MongoClient::RP_PRIMARY && count($tags)) {
trigger_error("You can't use read preference tags with a read preference of PRIMARY", E_WARNING);
return false;
}
$this->readPreference = new \MongoDB\Driver\ReadPreference($mode, $tags);
return true;
}
/**
* @param array $readPreferenceArray
* @return bool
*/
protected function setReadPreferenceFromArray($readPreferenceArray)
{
$readPreference = $readPreferenceArray['type'];
$tags = isset($readPreferenceArray['tagsets']) ? $readPreferenceArray['tagsets'] : [];
return $this->setReadPreferenceFromParameters($readPreference, $tags);
}
/**
* @param bool $ok
* @return bool
*/
protected function setReadPreferenceFromSlaveOkay($ok = true)
{
$result = $this->getSlaveOkayFromReadPreference();
$readPreference = new \MongoDB\Driver\ReadPreference(
$ok ? \MongoDB\Driver\ReadPreference::RP_SECONDARY_PREFERRED : \MongoDB\Driver\ReadPreference::RP_PRIMARY,
$ok ? $this->readPreference->getTagSets() : []
);
$this->readPreference = $readPreference;
return $result;
}
}
././@LongLink 0 0 0 151 0 003733 L Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/lib/Alcaeus/MongoDbAdapter/Helper/SlaveOkay.php Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/lib/Alcaeus/MongoDbAdapter/Helper/SlaveOka0000664 0001750 0001750 00000003065 12741242607 031353 0 ustar jan jan getSlaveOkayFromReadPreference();
}
/**
* @link http://www.php.net/manual/en/mongocollection.setslaveokay.php
* @param bool $ok
* @return bool
*/
public function setSlaveOkay($ok = true)
{
return $this->setReadPreferenceFromSlaveOkay($ok);
}
}
././@LongLink 0 0 0 154 0 003736 L Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/lib/Alcaeus/MongoDbAdapter/Helper/WriteConcern.php Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/lib/Alcaeus/MongoDbAdapter/Helper/WriteCon0000664 0001750 0001750 00000004045 12741242607 031377 0 ustar jan jan writeConcern === null) {
$this->writeConcern = new \MongoDB\Driver\WriteConcern(1);
}
return [
'w' => $this->writeConcern->getW(),
'wtimeout' => $this->writeConcern->getWtimeout(),
];
}
/**
* @param string|int $wstring
* @param int $wtimeout
* @return bool
*/
protected function setWriteConcernFromParameters($wstring, $wtimeout = 0)
{
$this->writeConcern = $this->createWriteConcernFromParameters($wstring, $wtimeout);
return true;
}
/**
* @param array $writeConcernArray
* @return bool
*/
protected function setWriteConcernFromArray($writeConcernArray)
{
$this->writeConcern = $this->createWriteConcernFromArray($writeConcernArray);
return true;
}
}
././@LongLink 0 0 0 165 0 003740 L Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/lib/Alcaeus/MongoDbAdapter/Helper/WriteConcernConverter.php Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/lib/Alcaeus/MongoDbAdapter/Helper/WriteCon0000664 0001750 0001750 00000003441 12741242607 031376 0 ustar jan jan createWriteConcernFromParameters($wstring, $wtimeout);
}
}
././@LongLink 0 0 0 147 0 003740 L Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/lib/Alcaeus/MongoDbAdapter/AbstractCursor.php Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/lib/Alcaeus/MongoDbAdapter/AbstractCursor.0000664 0001750 0001750 00000026053 12741242607 031450 0 ustar jan jan connection = $connection;
$this->ns = $ns;
$nsParts = explode('.', $ns);
$dbName = array_shift($nsParts);
$collectionName = implode('.', $nsParts);
$this->db = $connection->selectDB($dbName)->getDb();
if ($collectionName) {
$this->collection = $connection->selectCollection($dbName, $collectionName)->getCollection();
}
}
/**
* Returns the current element
* @link http://www.php.net/manual/en/mongocursor.current.php
* @return array
*/
public function current()
{
return $this->current;
}
/**
* Returns the current result's _id
* @link http://www.php.net/manual/en/mongocursor.key.php
* @return string The current result's _id as a string.
*/
public function key()
{
return $this->key;
}
/**
* Advances the cursor to the next result, and returns that result
* @link http://www.php.net/manual/en/mongocursor.next.php
* @throws \MongoConnectionException
* @throws \MongoCursorTimeoutException
* @return array Returns the next object
*/
public function next()
{
if (! $this->startedIterating) {
$this->ensureIterator();
$this->startedIterating = true;
} else {
if ($this->cursorNeedsAdvancing) {
$this->ensureIterator()->next();
}
$this->cursorNeedsAdvancing = true;
$this->position++;
}
return $this->storeIteratorState();
}
/**
* Returns the cursor to the beginning of the result set
* @throws \MongoConnectionException
* @throws \MongoCursorTimeoutException
* @return void
*/
public function rewind()
{
// We can recreate the cursor to allow it to be rewound
$this->reset();
$this->startedIterating = true;
$this->position = 0;
$this->ensureIterator()->rewind();
$this->storeIteratorState();
}
/**
* Checks if the cursor is reading a valid result.
* @link http://www.php.net/manual/en/mongocursor.valid.php
* @return boolean If the current result is not null.
*/
public function valid()
{
return $this->valid;
}
/**
* Limits the number of elements returned in one batch.
*
* @link http://docs.php.net/manual/en/mongocursor.batchsize.php
* @param int $batchSize The number of results to return per batch
* @return $this Returns this cursor.
*/
public function batchSize($batchSize)
{
$this->batchSize = $batchSize;
return $this;
}
/**
* Checks if there are documents that have not been sent yet from the database for this cursor
* @link http://www.php.net/manual/en/mongocursor.dead.php
* @return boolean Returns if there are more results that have not been sent to the client, yet.
*/
public function dead()
{
return $this->ensureCursor()->isDead();
}
/**
* @return array
*/
public function info()
{
return $this->getCursorInfo() + $this->getIterationInfo();
}
/**
* @link http://www.php.net/manual/en/mongocursor.setreadpreference.php
* @param string $readPreference
* @param array $tags
* @return $this Returns this cursor.
*/
public function setReadPreference($readPreference, $tags = null)
{
$this->setReadPreferenceFromParameters($readPreference, $tags);
return $this;
}
/**
* Sets a client-side timeout for this query
* @link http://www.php.net/manual/en/mongocursor.timeout.php
* @param int $ms The number of milliseconds for the cursor to wait for a response. By default, the cursor will wait forever.
* @return $this Returns this cursor
*/
public function timeout($ms)
{
trigger_error('The ' . __METHOD__ . ' method is not implemented in mongo-php-adapter', E_USER_WARNING);
return $this;
}
/**
* Applies all options set on the cursor, overwriting any options that have already been set
*
* @param array $optionNames Array of option names to be applied (will be read from properties)
* @return array
*/
protected function getOptions($optionNames = null)
{
$options = [];
if ($optionNames === null) {
$optionNames = $this->optionNames;
}
foreach ($optionNames as $option) {
$converter = 'convert' . ucfirst($option);
$value = method_exists($this, $converter) ? $this->$converter() : $this->$option;
if ($value === null) {
continue;
}
$options[$option] = $value;
}
return $options;
}
/**
* @return \Iterator
*/
protected function ensureIterator()
{
if ($this->iterator === null) {
// MongoDB\Driver\Cursor needs to be wrapped into a \Generator so that a valid \Iterator with working implementations of
// next, current, valid, key and rewind is returned. These methods don't work if we wrap the Cursor inside an \IteratorIterator
$this->iterator = $this->wrapTraversable($this->ensureCursor());
}
return $this->iterator;
}
/**
* @param \Traversable $traversable
* @return \Generator
*/
protected function wrapTraversable(\Traversable $traversable)
{
foreach ($traversable as $key => $value) {
yield $key => $value;
}
}
/**
* @throws \MongoCursorException
*/
protected function errorIfOpened()
{
if ($this->cursor === null) {
return;
}
throw new \MongoCursorException('cannot modify cursor after beginning iteration.');
}
/**
* @return array
*/
protected function getIterationInfo()
{
$iterationInfo = [
'started_iterating' => $this->cursor !== null,
];
if ($this->cursor !== null) {
switch ($this->cursor->getServer()->getType()) {
case \MongoDB\Driver\Server::TYPE_RS_ARBITER:
$typeString = 'ARBITER';
break;
case \MongoDB\Driver\Server::TYPE_MONGOS:
$typeString = 'MONGOS';
break;
case \MongoDB\Driver\Server::TYPE_RS_PRIMARY:
$typeString = 'PRIMARY';
break;
case \MongoDB\Driver\Server::TYPE_RS_SECONDARY:
$typeString = 'SECONDARY';
break;
default:
$typeString = 'STANDALONE';
}
$cursorId = (string) $this->cursor->getId();
$iterationInfo += [
'id' => (int) $cursorId,
'at' => $this->position,
'numReturned' => $this->position, // This can't be obtained from the new cursor
'server' => sprintf('%s:%d;-;.;%d', $this->cursor->getServer()->getHost(), $this->cursor->getServer()->getPort(), getmypid()),
'host' => $this->cursor->getServer()->getHost(),
'port' => $this->cursor->getServer()->getPort(),
'connection_type_desc' => $typeString,
];
}
return $iterationInfo;
}
/**
* @throws \Exception
*/
protected function notImplemented()
{
throw new \Exception('Not implemented');
}
/**
* Clears the cursor
*
* This is generic but implemented as protected since it's only exposed in MongoCursor
*/
protected function reset()
{
$this->startedIterating = false;
$this->cursor = null;
$this->iterator = null;
$this->storeIteratorState();
}
/**
* @return array
*/
public function __sleep()
{
return ['batchSize', 'connection', 'iterator', 'ns', 'optionNames', 'position', 'startedIterating'];
}
/**
* Stores the current cursor element.
*
* This is necessary because hasNext() might advance the iterator but we still
* need to be able to return the current object.
*/
protected function storeIteratorState()
{
if (! $this->startedIterating) {
$this->current = null;
$this->key = null;
$this->valid = false;
return null;
}
$this->current = $this->ensureIterator()->current();
$this->key = $this->ensureIterator()->key();
$this->valid = $this->ensureIterator()->valid();
if ($this->current !== null) {
$this->current = TypeConverter::toLegacy($this->current);
}
return $this->current;
}
}
././@LongLink 0 0 0 153 0 003735 L Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/lib/Alcaeus/MongoDbAdapter/ExceptionConverter.php Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/lib/Alcaeus/MongoDbAdapter/ExceptionConver0000664 0001750 0001750 00000006436 12741242607 031547 0 ustar jan jan getMessage();
$code = $e->getCode();
switch (get_class($e)) {
case Exception\AuthenticationException::class:
case Exception\ConnectionException::class:
case Exception\ConnectionTimeoutException::class:
case Exception\SSLConnectionException::class:
$class = 'MongoConnectionException';
break;
case Exception\BulkWriteException::class:
case Exception\WriteException::class:
$writeResult = $e->getWriteResult();
if ($writeResult) {
$writeError = $writeResult->getWriteErrors()[0];
$message = $writeError->getMessage();
$code = $writeError->getCode();
}
switch ($code) {
// see https://github.com/mongodb/mongo-php-driver-legacy/blob/ad3ed45739e9702ae48e53ddfadc482d9c4c7e1c/cursor_shared.c#L540
case 11000:
case 11001:
case 12582:
$class = 'MongoDuplicateKeyException';
break;
default:
$class = 'MongoCursorException';
}
break;
case Exception\ExecutionTimeoutException::class:
$class = 'MongoExecutionTimeoutException';
break;
default:
$class = $fallbackClass;
}
if (strpos($message, 'No suitable servers found') !== false) {
return new \MongoConnectionException($message, $code, $e);
}
if ($message === "cannot use 'w' > 1 when a host is not replicated") {
return new \MongoWriteConcernException($message, $code, $e);
}
return new $class($message, $code, $e);
}
/**
* Converts an exception to
*
* @param Exception\Exception $e
* @return array
*/
public static function toResultArray(Exception\Exception $e)
{
return [
'ok' => 0.0,
'errmsg' => $e->getMessage(),
'code' => $e->getCode(),
];
}
}
././@LongLink 0 0 0 146 0 003737 L Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/lib/Alcaeus/MongoDbAdapter/TypeConverter.php Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/lib/Alcaeus/MongoDbAdapter/TypeConverter.p0000664 0001750 0001750 00000012170 12741242607 031473 0 ustar jan jan toBSONType();
case is_array($value):
case is_object($value);
$result = [];
foreach ($value as $key => $item) {
$result[$key] = self::fromLegacy($item);
}
return self::ensureCorrectType($result, is_object($value));
default:
return $value;
}
}
/**
* Converts a BSON type to the legacy types
*
* This method handles type conversion from ext-mongodb to ext-mongo:
* - For all instances of BSON\Type it returns an object of the
* corresponding legacy type (MongoId, MongoDate, etc.)
* - For arrays and objects it iterates over properties and converts each
* item individually
* - For other types it returns the value unconverted
*
* @param mixed $value
* @return mixed
*/
public static function toLegacy($value)
{
switch (true) {
case $value instanceof BSON\Type:
return self::convertBSONObjectToLegacy($value);
case is_array($value):
case is_object($value):
$result = [];
foreach ($value as $key => $item) {
$result[$key] = self::toLegacy($item);
}
return $result;
default:
return $value;
}
}
/**
* Helper method to find out if an array has numerical indexes
*
* For performance reason, this method checks the first array index only.
* More thorough inspection of the array might be needed.
* Note: Returns true for empty arrays to preserve compatibility with empty
* lists.
*
* @param array $array
* @return bool
*/
public static function isNumericArray(array $array)
{
return $array === [] || is_numeric(array_keys($array)[0]);
}
/**
* Converter method to convert a BSON object to its legacy type
*
* @param BSON\Type $value
* @return mixed
*/
private static function convertBSONObjectToLegacy(BSON\Type $value)
{
switch (true) {
case $value instanceof BSON\ObjectID:
return new \MongoId($value);
case $value instanceof BSON\Binary:
return new \MongoBinData($value);
case $value instanceof BSON\Javascript:
return new \MongoCode($value);
case $value instanceof BSON\MaxKey:
return new \MongoMaxKey();
case $value instanceof BSON\MinKey:
return new \MongoMinKey();
case $value instanceof BSON\Regex:
return new \MongoRegex($value);
case $value instanceof BSON\Timestamp:
return new \MongoTimestamp($value);
case $value instanceof BSON\UTCDatetime:
return new \MongoDate($value);
case $value instanceof Model\BSONDocument:
case $value instanceof Model\BSONArray:
return array_map(
['self', 'toLegacy'],
$value->getArrayCopy()
);
default:
return $value;
}
}
/**
* Converts all arrays with non-numeric keys to stdClass
*
* @param array $array
* @param bool $wasObject
* @return array|Model\BSONArray|Model\BSONDocument
*/
private static function ensureCorrectType(array $array, $wasObject = false)
{
if ($wasObject || ! static::isNumericArray($array)) {
return new Model\BSONDocument($array);
}
return $array;
}
}
././@LongLink 0 0 0 146 0 003737 L Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/lib/Alcaeus/MongoDbAdapter/TypeInterface.php Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/lib/Alcaeus/MongoDbAdapter/TypeInterface.p0000664 0001750 0001750 00000001777 12741242607 031437 0 ustar jan jan notImplemented();
}
/**
* Get pool size for connection pools
*
* @link http://php.net/manual/en/mongo.getpoolsize.php
* @return int Returns the current pool size.
*
* @deprecated This feature has been DEPRECATED as of version 1.2.3. Relying on this feature is highly discouraged. Please use MongoPool::getSize() instead.
*/
public function getPoolSize()
{
$this->notImplemented();
}
/**
* Returns the address being used by this for slaveOkay reads
*
* @link http://php.net/manual/en/mongo.getslave.php
* @return bool The address of the secondary this connection is using for
* reads. This returns NULL if this is not connected to a replica set or not yet
* initialized.
*/
public function getSlave()
{
$this->notImplemented();
}
/**
* Get slaveOkay setting for this connection
*
* @link http://php.net/manual/en/mongo.getslaveokay.php
* @return bool Returns the value of slaveOkay for this instance.
*/
public function getSlaveOkay()
{
$this->notImplemented();
}
/**
* Connects to paired database server
*
* @link http://www.php.net/manual/en/mongo.pairconnect.php
* @throws MongoConnectionException
* @return boolean
*
* @deprecated Pass a string of the form "mongodb://server1,server2" to the constructor instead of using this method.
*/
public function pairConnect()
{
$this->notImplemented();
}
/**
* Returns information about all connection pools.
*
* @link http://php.net/manual/en/mongo.pooldebug.php
* @return array
* @deprecated This feature has been DEPRECATED as of version 1.2.3. Relying on this feature is highly discouraged. Please use MongoPool::info() instead.
*/
public function poolDebug()
{
$this->notImplemented();
}
/**
* Change slaveOkay setting for this connection
*
* @link http://php.net/manual/en/mongo.setslaveokay.php
* @param bool $ok
* @return bool returns the former value of slaveOkay for this instance.
*/
public function setSlaveOkay ($ok)
{
$this->notImplemented();
}
/**
* Set the size for future connection pools.
*
* @link http://php.net/manual/en/mongo.setpoolsize.php
* @param $size
The max number of connections future pools will be able to create. Negative numbers mean that the pool will spawn an infinite number of connections.
* @return bool Returns the former value of pool size.
* @deprecated Relying on this feature is highly discouraged. Please use MongoPool::setSize() instead.
*/
public function setPoolSize($size)
{
$this->notImplemented();
}
/**
* Creates a persistent connection with a database server
*
* @link http://www.php.net/manual/en/mongo.persistconnect.php
* @param string $username A username used to identify the connection.
* @param string $password A password used to identify the connection.
* @throws MongoConnectionException
* @return boolean If the connection was successful.
* @deprecated Pass array("persist" => $id) to the constructor instead of using this method.
*/
public function persistConnect($username = "", $password = "")
{
$this->notImplemented();
}
/**
* Creates a persistent connection with paired database servers
*
* @link http://www.php.net/manual/en/mongo.pairpersistconnect.php
* @param string $username A username used to identify the connection.
* @param string $password A password used to identify the connection.
* @throws MongoConnectionException
* @return boolean If the connection was successful.
* @deprecated Pass "mongodb://server1,server2" and array("persist" => $id) to the constructor instead of using this method.
*/
public function pairPersistConnect($username = "", $password = "")
{
$this->notImplemented();
}
/**
* Connects with a database server
*
* @link http://www.php.net/manual/en/mongo.connectutil.php
* @throws MongoConnectionException
* @return boolean If the connection was successful.
*/
protected function connectUtil()
{
$this->notImplemented();
}
/**
* Check if there was an error on the most recent db operation performed
*
* @link http://www.php.net/manual/en/mongo.lasterror.php
* @return array|null Returns the error, if there was one, or NULL.
* @deprecated Use MongoDB::lastError() instead.
*/
public function lastError()
{
$this->notImplemented();
}
/**
* Checks for the last error thrown during a database operation
*
* @link http://www.php.net/manual/en/mongo.preverror.php
* @return array Returns the error and the number of operations ago it occurred.
* @deprecated Use MongoDB::prevError() instead.
*/
public function prevError()
{
$this->notImplemented();
}
/**
* Clears any flagged errors on the connection
*
* @link http://www.php.net/manual/en/mongo.reseterror.php
* @return array Returns the database response.
* @deprecated Use MongoDB::resetError() instead.
*/
public function resetError()
{
$this->notImplemented();
}
/**
* Choose a new secondary for slaveOkay reads
*
* @link www.php.net/manual/en/mongo.switchslave.php
* @return string The address of the secondary this connection is using for reads. This may be the same as the previous address as addresses are randomly chosen. It may return only one address if only one secondary (or only the primary) is available.
* @throws MongoException (error code 15) if it is called on a non-replica-set connection. It will also throw MongoExceptions if it cannot find anyone (primary or secondary) to read from (error code 16).
*/
public function switchSlave()
{
$this->notImplemented();
}
/**
* Creates a database error on the database.
*
* @link http://www.php.net/manual/en/mongo.forceerror.php
* @return boolean The database response.
* @deprecated Use MongoDB::forceError() instead.
*/
public function forceError()
{
$this->notImplemented();
}
protected function notImplemented()
{
throw new \Exception('The Mongo class is deprecated and not supported through mongo-php-adapter');
}
}
Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/lib/Mongo/MongoBinData.php 0000664 0001750 0001750 00000006647 12741242607 026404 0 ustar jan jan bin = $data->getData();
$this->type = $data->getType();
} else {
$this->bin = $data;
$this->type = $type;
}
}
/**
* Returns the string "". To access the contents of a MongoBinData, use the bin field.
*
* @return string
*/
public function __toString()
{
return '';
}
/**
* Converts this MongoBinData to the new BSON Binary type
*
* @return Binary
* @internal This method is not part of the ext-mongo API
*/
public function toBSONType()
{
return new Binary($this->bin, $this->type);
}
}
Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/lib/Mongo/MongoClient.php 0000664 0001750 0001750 00000031517 12741242607 026312 0 ustar jan jan true], array $driverOptions = [])
{
if ($server === 'default') {
$server = 'mongodb://' . self::DEFAULT_HOST . ':' . self::DEFAULT_PORT;
}
$this->applyConnectionOptions($server, $options);
$this->server = $server;
if (false === strpos($this->server, 'mongodb://')) {
$this->server = 'mongodb://'.$this->server;
}
$this->client = new Client($this->server, $options, $driverOptions);
$info = $this->client->__debugInfo();
$this->manager = $info['manager'];
if (isset($options['connect']) && $options['connect']) {
$this->connect();
}
}
/**
* Closes this database connection
*
* @link http://www.php.net/manual/en/mongoclient.close.php
* @param boolean|string $connection
* @return boolean If the connection was successfully closed.
*/
public function close($connection = null)
{
$this->connected = false;
return false;
}
/**
* Connects to a database server
*
* @link http://www.php.net/manual/en/mongoclient.connect.php
*
* @throws MongoConnectionException
* @return boolean If the connection was successful.
*/
public function connect()
{
$this->connected = true;
return true;
}
/**
* Drops a database
*
* @link http://www.php.net/manual/en/mongoclient.dropdb.php
* @param mixed $db The database to drop. Can be a MongoDB object or the name of the database.
* @return array The database response.
* @deprecated Use MongoDB::drop() instead.
*/
public function dropDB($db)
{
return $this->selectDB($db)->drop();
}
/**
* Gets a database
*
* @link http://php.net/manual/en/mongoclient.get.php
* @param string $dbname The database name.
* @return MongoDB The database name.
*/
public function __get($dbname)
{
return $this->selectDB($dbname);
}
/**
* Gets the client for this object
*
* @internal This part is not of the ext-mongo API and should not be used
* @return Client
*/
public function getClient()
{
return $this->client;
}
/**
* Get connections
*
* Returns an array of all open connections, and information about each of the servers
*
* @return array
*/
public static function getConnections()
{
return [];
}
/**
* Get hosts
*
* This method is only useful with a connection to a replica set. It returns the status of all of the hosts in the
* set. Without a replica set, it will just return an array with one element containing the host that you are
* connected to.
*
* @return array
*/
public function getHosts()
{
$this->forceConnect();
$results = [];
try {
$servers = $this->manager->getServers();
} catch (\MongoDB\Driver\Exception\Exception $e) {
throw ExceptionConverter::toLegacy($e);
}
foreach ($servers as $server) {
$key = sprintf('%s:%d;-;.;%d', $server->getHost(), $server->getPort(), getmypid());
$info = $server->getInfo();
switch ($server->getType()) {
case \MongoDB\Driver\Server::TYPE_RS_PRIMARY:
$state = 1;
break;
case \MongoDB\Driver\Server::TYPE_RS_SECONDARY:
$state = 2;
break;
default:
$state = 0;
}
$results[$key] = [
'host' => $server->getHost(),
'port' => $server->getPort(),
'health' => (int) $info['ok'],
'state' => $state,
'ping' => $server->getLatency(),
'lastPing' => null,
];
}
return $results;
}
/**
* Kills a specific cursor on the server
*
* @link http://www.php.net/manual/en/mongoclient.killcursor.php
* @param string $server_hash The server hash that has the cursor.
* @param int|MongoInt64 $id The ID of the cursor to kill.
* @return bool
*/
public function killCursor($server_hash , $id)
{
$this->notImplemented();
}
/**
* Lists all of the databases available
*
* @link http://php.net/manual/en/mongoclient.listdbs.php
* @return array Returns an associative array containing three fields. The first field is databases, which in turn contains an array. Each element of the array is an associative array corresponding to a database, giving the database's name, size, and if it's empty. The other two fields are totalSize (in bytes) and ok, which is 1 if this method ran successfully.
*/
public function listDBs()
{
try {
$databaseInfoIterator = $this->client->listDatabases();
} catch (\MongoDB\Driver\Exception\Exception $e) {
throw ExceptionConverter::toLegacy($e);
}
$databases = [
'databases' => [],
'totalSize' => 0,
'ok' => 1.0,
];
foreach ($databaseInfoIterator as $databaseInfo) {
$databases['databases'][] = [
'name' => $databaseInfo->getName(),
'empty' => $databaseInfo->isEmpty(),
'sizeOnDisk' => $databaseInfo->getSizeOnDisk(),
];
$databases['totalSize'] += $databaseInfo->getSizeOnDisk();
}
return $databases;
}
/**
* Gets a database collection
*
* @link http://www.php.net/manual/en/mongoclient.selectcollection.php
* @param string $db The database name.
* @param string $collection The collection name.
* @return MongoCollection Returns a new collection object.
* @throws Exception Throws Exception if the database or collection name is invalid.
*/
public function selectCollection($db, $collection)
{
return new MongoCollection($this->selectDB($db), $collection);
}
/**
* Gets a database
*
* @link http://www.php.net/manual/en/mongo.selectdb.php
* @param string $name The database name.
* @return MongoDB Returns a new db object.
* @throws InvalidArgumentException
*/
public function selectDB($name)
{
return new MongoDB($this, $name);
}
/**
* {@inheritdoc}
*/
public function setReadPreference($readPreference, $tags = null)
{
return $this->setReadPreferenceFromParameters($readPreference, $tags);
}
/**
* {@inheritdoc}
*/
public function setWriteConcern($wstring, $wtimeout = 0)
{
return $this->setWriteConcernFromParameters($wstring, $wtimeout);
}
/**
* String representation of this connection
*
* @link http://www.php.net/manual/en/mongoclient.tostring.php
* @return string Returns hostname and port for this connection.
*/
public function __toString()
{
return $this->server;
}
/**
* Forces a connection by executing the ping command
*/
private function forceConnect()
{
$command = new \MongoDB\Driver\Command(['ping' => 1]);
$this->manager->executeCommand('db', $command);
}
private function notImplemented()
{
throw new \Exception('Not implemented');
}
/**
* @return array
*/
function __sleep()
{
return [
'connected', 'status', 'server', 'persistent'
];
}
/**
* @param $server
* @return array
*/
private function extractUrlOptions($server)
{
$queryOptions = explode('&', parse_url($server, PHP_URL_QUERY));
$options = [];
foreach ($queryOptions as $option) {
if (strpos($option, '=') === false) {
continue;
}
$keyValue = explode('=', $option);
if ($keyValue[0] === 'readPreferenceTags') {
$options[$keyValue[0]][] = $this->getReadPreferenceTags($keyValue[1]);
} else {
$options[$keyValue[0]] = $keyValue[1];
}
}
return $options;
}
/**
* @param $readPreferenceTagString
* @return array
*/
private function getReadPreferenceTags($readPreferenceTagString)
{
$tagSets = [];
foreach (explode(',', $readPreferenceTagString) as $index => $tagSet) {
$tags = explode(':', $tagSet);
$tagSets[$tags[0]] = $tags[1];
}
return $tagSets;
}
/**
* @param string $server
* @param array $options
*/
private function applyConnectionOptions($server, array $options)
{
$urlOptions = $this->extractUrlOptions($server);
if (isset($urlOptions['wTimeout'])) {
$urlOptions['wTimeoutMS'] = $urlOptions['wTimeout'];
unset($urlOptions['wTimeout']);
}
if (isset($options['wTimeout'])) {
$options['wTimeoutMS'] = $options['wTimeout'];
unset($options['wTimeout']);
}
if (isset($options['readPreferenceTags'])) {
$options['readPreferenceTags'] = [$this->getReadPreferenceTags($options['readPreferenceTags'])];
// Special handling for readPreferenceTags which are merged
if (isset($urlOptions['readPreferenceTags'])) {
$options['readPreferenceTags'] = array_merge($urlOptions['readPreferenceTags'], $options['readPreferenceTags']);
}
}
$urlOptions = array_merge($urlOptions, $options);
if (isset($urlOptions['slaveOkay'])) {
$this->setReadPreferenceFromSlaveOkay($urlOptions['slaveOkay']);
} elseif (isset($urlOptions['readPreference']) || isset($urlOptions['readPreferenceTags'])) {
$readPreference = isset($urlOptions['readPreference']) ? $urlOptions['readPreference'] : null;
$tags = isset($urlOptions['readPreferenceTags']) ? $urlOptions['readPreferenceTags'] : null;
$this->setReadPreferenceFromParameters($readPreference, $tags);
}
if (isset($urlOptions['w']) || isset($urlOptions['wTimeoutMs'])) {
$writeConcern = (isset($urlOptions['w'])) ? $urlOptions['w'] : 1;
$wTimeout = (isset($urlOptions['wTimeoutMs'])) ? $urlOptions['wTimeoutMs'] : null;
$this->setWriteConcern($writeConcern, $wTimeout);
}
}
}
Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/lib/Mongo/MongoCode.php 0000664 0001750 0001750 00000003655 12741242607 025750 0 ustar jan jan code = $code;
$this->scope = $scope;
}
/**
* Returns this code as a string
* @return string
*/
public function __toString()
{
return $this->code;
}
/**
* Converts this MongoCode to the new BSON JavaScript type
*
* @return \MongoDB\BSON\Javascript
* @internal This method is not part of the ext-mongo API
*/
public function toBSONType()
{
return new \MongoDB\BSON\Javascript($this->code, $this->scope);
}
}
Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/lib/Mongo/MongoCollection.php 0000664 0001750 0001750 00000103223 12741242607 027161 0 ustar jan jan checkCollectionName($name);
$this->db = $db;
$this->name = (string) $name;
$this->setReadPreferenceFromArray($db->getReadPreference());
$this->setWriteConcernFromArray($db->getWriteConcern());
$this->createCollectionObject();
}
/**
* Gets the underlying collection for this object
*
* @internal This part is not of the ext-mongo API and should not be used
* @return \MongoDB\Collection
*/
public function getCollection()
{
return $this->collection;
}
/**
* String representation of this collection
*
* @link http://www.php.net/manual/en/mongocollection.--tostring.php
* @return string Returns the full name of this collection.
*/
public function __toString()
{
return (string) $this->db . '.' . $this->name;
}
/**
* Gets a collection
*
* @link http://www.php.net/manual/en/mongocollection.get.php
* @param string $name The next string in the collection name.
* @return MongoCollection
*/
public function __get($name)
{
// Handle w and wtimeout properties that replicate data stored in $readPreference
if ($name === 'w' || $name === 'wtimeout') {
return $this->getWriteConcern()[$name];
}
return $this->db->selectCollection($this->name . '.' . str_replace(chr(0), '', $name));
}
/**
* @param string $name
* @param mixed $value
*/
public function __set($name, $value)
{
if ($name === 'w' || $name === 'wtimeout') {
$this->setWriteConcernFromArray([$name => $value] + $this->getWriteConcern());
$this->createCollectionObject();
}
}
/**
* Perform an aggregation using the aggregation framework
*
* @link http://www.php.net/manual/en/mongocollection.aggregate.php
* @param array $pipeline
* @param array $op
* @return array
*/
public function aggregate(array $pipeline, array $op = [])
{
if (! TypeConverter::isNumericArray($pipeline)) {
$operators = func_get_args();
$pipeline = [];
$options = [];
$i = 0;
foreach ($operators as $operator) {
$i++;
if (! is_array($operator)) {
trigger_error("Argument $i is not an array", E_WARNING);
return;
}
$pipeline[] = $operator;
}
} else {
$options = $op;
}
if (isset($options['cursor'])) {
$options['useCursor'] = true;
if (isset($options['cursor']['batchSize'])) {
$options['batchSize'] = $options['cursor']['batchSize'];
}
unset($options['cursor']);
} else {
$options['useCursor'] = false;
}
try {
$cursor = $this->collection->aggregate(TypeConverter::fromLegacy($pipeline), $options);
return [
'ok' => 1.0,
'result' => TypeConverter::toLegacy($cursor),
'waitedMS' => 0,
];
} catch (\MongoDB\Driver\Exception\Exception $e) {
throw ExceptionConverter::toLegacy($e,'MongoResultException');
}
}
/**
* Execute an aggregation pipeline command and retrieve results through a cursor
*
* @link http://php.net/manual/en/mongocollection.aggregatecursor.php
* @param array $pipeline
* @param array $options
* @return MongoCommandCursor
*/
public function aggregateCursor(array $pipeline, array $options = [])
{
// Build command manually, can't use mongo-php-library here
$command = [
'aggregate' => $this->name,
'pipeline' => $pipeline
];
// Convert cursor option
if (! isset($options['cursor'])) {
$options['cursor'] = new \stdClass();
}
$command += $options;
$cursor = new MongoCommandCursor($this->db->getConnection(), (string) $this, $command);
$cursor->setReadPreference($this->getReadPreference());
return $cursor;
}
/**
* Returns this collection's name
*
* @link http://www.php.net/manual/en/mongocollection.getname.php
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* {@inheritdoc}
*/
public function setReadPreference($readPreference, $tags = null)
{
$result = $this->setReadPreferenceFromParameters($readPreference, $tags);
$this->createCollectionObject();
return $result;
}
/**
* {@inheritdoc}
*/
public function setWriteConcern($wstring, $wtimeout = 0)
{
$result = $this->setWriteConcernFromParameters($wstring, $wtimeout);
$this->createCollectionObject();
return $result;
}
/**
* Drops this collection
*
* @link http://www.php.net/manual/en/mongocollection.drop.php
* @return array Returns the database response.
*/
public function drop()
{
return TypeConverter::toLegacy($this->collection->drop());
}
/**
* Validates this collection
*
* @link http://www.php.net/manual/en/mongocollection.validate.php
* @param bool $scan_data Only validate indices, not the base collection.
* @return array Returns the database's evaluation of this object.
*/
public function validate($scan_data = FALSE)
{
$command = [
'validate' => $this->name,
'full' => $scan_data,
];
return $this->db->command($command);
}
/**
* Inserts an array into the collection
*
* @link http://www.php.net/manual/en/mongocollection.insert.php
* @param array|object $a
* @param array $options
* @throws MongoException if the inserted document is empty or if it contains zero-length keys. Attempting to insert an object with protected and private properties will cause a zero-length key error.
* @throws MongoCursorException if the "w" option is set and the write fails.
* @throws MongoCursorTimeoutException if the "w" option is set to a value greater than one and the operation takes longer than MongoCursor::$timeout milliseconds to complete. This does not kill the operation on the server, it is a client-side timeout. The operation in MongoCollection::$wtimeout is milliseconds.
* @return bool|array Returns an array containing the status of the insertion if the "w" option is set.
*/
public function insert(&$a, array $options = [])
{
if (! $this->ensureDocumentHasMongoId($a)) {
trigger_error(sprintf('%s(): expects parameter %d to be an array or object, %s given', __METHOD__, 1, gettype($a)), E_USER_WARNING);
return;
}
if (! count((array)$a)) {
throw new \MongoException('document must be an array or object');
}
try {
$result = $this->collection->insertOne(
TypeConverter::fromLegacy($a),
$this->convertWriteConcernOptions($options)
);
} catch (\MongoDB\Driver\Exception\Exception $e) {
throw ExceptionConverter::toLegacy($e);
}
if (! $result->isAcknowledged()) {
return true;
}
return [
'ok' => 1.0,
'n' => 0,
'err' => null,
'errmsg' => null,
];
}
/**
* Inserts multiple documents into this collection
*
* @link http://www.php.net/manual/en/mongocollection.batchinsert.php
* @param array $a An array of arrays.
* @param array $options Options for the inserts.
* @throws MongoCursorException
* @return mixed If "safe" is set, returns an associative array with the status of the inserts ("ok") and any error that may have occured ("err"). Otherwise, returns TRUE if the batch insert was successfully sent, FALSE otherwise.
*/
public function batchInsert(array &$a, array $options = [])
{
if (empty($a)) {
throw new \MongoException('No write ops were included in the batch');
}
$continueOnError = isset($options['continueOnError']) && $options['continueOnError'];
foreach ($a as $key => $item) {
try {
if (! $this->ensureDocumentHasMongoId($a[$key])) {
if ($continueOnError) {
unset($a[$key]);
} else {
trigger_error(sprintf('%s expects parameter %d to be an array or object, %s given', __METHOD__, 1, gettype($a)), E_USER_WARNING);
return;
}
}
} catch (MongoException $e) {
if ( ! $continueOnError) {
throw $e;
}
}
}
try {
$result = $this->collection->insertMany(
TypeConverter::fromLegacy(array_values($a)),
$this->convertWriteConcernOptions($options)
);
} catch (\MongoDB\Driver\Exception\Exception $e) {
throw ExceptionConverter::toLegacy($e, 'MongoResultException');
}
if (! $result->isAcknowledged()) {
return true;
}
return [
'ok' => 1.0,
'connectionId' => 0,
'n' => 0,
'syncMillis' => 0,
'writtenTo' => null,
'err' => null,
];
}
/**
* Update records based on a given criteria
*
* @link http://www.php.net/manual/en/mongocollection.update.php
* @param array $criteria Description of the objects to update.
* @param array $newobj The object with which to update the matching records.
* @param array $options
* @throws MongoCursorException
* @return boolean
*/
public function update(array $criteria , array $newobj, array $options = [])
{
$multiple = isset($options['multiple']) ? $options['multiple'] : false;
$isReplace = ! \MongoDB\is_first_key_operator($newobj);
if ($isReplace && $multiple) {
throw new \MongoWriteConcernException('multi update only works with $ operators', 9);
}
unset($options['multiple']);
$method = $isReplace ? 'replace' : 'update';
$method .= $multiple ? 'Many' : 'One';
try {
/** @var \MongoDB\UpdateResult $result */
$result = $this->collection->$method(
TypeConverter::fromLegacy($criteria),
TypeConverter::fromLegacy($newobj),
$this->convertWriteConcernOptions($options)
);
} catch (\MongoDB\Driver\Exception\Exception $e) {
throw ExceptionConverter::toLegacy($e);
}
if (! $result->isAcknowledged()) {
return true;
}
return [
'ok' => 1.0,
'nModified' => $result->getModifiedCount(),
'n' => $result->getMatchedCount(),
'err' => null,
'errmsg' => null,
'updatedExisting' => $result->getUpsertedCount() == 0,
];
}
/**
* Remove records from this collection
*
* @link http://www.php.net/manual/en/mongocollection.remove.php
* @param array $criteria Query criteria for the documents to delete.
* @param array $options An array of options for the remove operation.
* @throws MongoCursorException
* @throws MongoCursorTimeoutException
* @return bool|array Returns an array containing the status of the removal
* if the "w" option is set. Otherwise, returns TRUE.
*/
public function remove(array $criteria = [], array $options = [])
{
$multiple = isset($options['justOne']) ? !$options['justOne'] : true;
$method = $multiple ? 'deleteMany' : 'deleteOne';
try {
/** @var \MongoDB\DeleteResult $result */
$result = $this->collection->$method(
TypeConverter::fromLegacy($criteria),
$this->convertWriteConcernOptions($options)
);
} catch (\MongoDB\Driver\Exception\Exception $e) {
throw ExceptionConverter::toLegacy($e);
}
if (! $result->isAcknowledged()) {
return true;
}
return [
'ok' => 1.0,
'n' => $result->getDeletedCount(),
'err' => null,
'errmsg' => null
];
}
/**
* Querys this collection
*
* @link http://www.php.net/manual/en/mongocollection.find.php
* @param array $query The fields for which to search.
* @param array $fields Fields of the results to return.
* @return MongoCursor
*/
public function find(array $query = [], array $fields = [])
{
$cursor = new MongoCursor($this->db->getConnection(), (string) $this, $query, $fields);
$cursor->setReadPreference($this->getReadPreference());
return $cursor;
}
/**
* Retrieve a list of distinct values for the given key across a collection
*
* @link http://www.php.net/manual/ru/mongocollection.distinct.php
* @param string $key The key to use.
* @param array $query An optional query parameters
* @return array|bool Returns an array of distinct values, or FALSE on failure
*/
public function distinct($key, array $query = [])
{
try {
return array_map([TypeConverter::class, 'toLegacy'], $this->collection->distinct($key, TypeConverter::fromLegacy($query)));
} catch (\MongoDB\Driver\Exception\Exception $e) {
return false;
}
}
/**
* Update a document and return it
*
* @link http://www.php.net/manual/ru/mongocollection.findandmodify.php
* @param array $query The query criteria to search for.
* @param array $update The update criteria.
* @param array $fields Optionally only return these fields.
* @param array $options An array of options to apply, such as remove the match document from the DB and return it.
* @return array Returns the original document, or the modified document when new is set.
*/
public function findAndModify(array $query, array $update = null, array $fields = null, array $options = [])
{
$query = TypeConverter::fromLegacy($query);
try {
if (isset($options['remove'])) {
unset($options['remove']);
$document = $this->collection->findOneAndDelete($query, $options);
} else {
$update = is_array($update) ? $update : [];
if (isset($options['update']) && is_array($options['update'])) {
$update = $options['update'];
unset($options['update']);
}
$update = TypeConverter::fromLegacy($update);
if (isset($options['new'])) {
$options['returnDocument'] = \MongoDB\Operation\FindOneAndUpdate::RETURN_DOCUMENT_AFTER;
unset($options['new']);
}
$options['projection'] = is_array($fields) ? TypeConverter::fromLegacy($fields) : [];
if (! \MongoDB\is_first_key_operator($update)) {
$document = $this->collection->findOneAndReplace($query, $update, $options);
} else {
$document = $this->collection->findOneAndUpdate($query, $update, $options);
}
}
} catch (\MongoDB\Driver\Exception\ConnectionException $e) {
throw new MongoResultException($e->getMessage(), $e->getCode(), $e);
} catch (\MongoDB\Driver\Exception\Exception $e) {
throw ExceptionConverter::toLegacy($e, 'MongoResultException');
}
if ($document) {
$document = TypeConverter::toLegacy($document);
}
return $document;
}
/**
* Querys this collection, returning a single element
*
* @link http://www.php.net/manual/en/mongocollection.findone.php
* @param array $query The fields for which to search.
* @param array $fields Fields of the results to return.
* @param array $options
* @return array|null
*/
public function findOne($query = [], array $fields = [], array $options = [])
{
// Can't typehint for array since MongoGridFS extends and accepts strings
if (! is_array($query)) {
trigger_error(sprintf('MongoCollection::findOne(): expects parameter 1 to be an array or object, %s given', gettype($query)), E_WARNING);
return;
}
$options = ['projection' => TypeConverter::fromLegacy($fields)] + $options;
try {
$document = $this->collection->findOne(TypeConverter::fromLegacy($query), $options);
} catch (\MongoDB\Driver\Exception\Exception $e) {
throw ExceptionConverter::toLegacy($e);
}
if ($document !== null) {
$document = TypeConverter::toLegacy($document);
}
return $document;
}
/**
* Creates an index on the given field(s), or does nothing if the index already exists
*
* @link http://www.php.net/manual/en/mongocollection.createindex.php
* @param array $keys Field or fields to use as index.
* @param array $options [optional] This parameter is an associative array of the form array("optionname" => , ...).
* @return array Returns the database response.
*/
public function createIndex($keys, array $options = [])
{
if (is_string($keys)) {
if (empty($keys)) {
throw new MongoException('empty string passed as key field');
}
$keys = [$keys => 1];
}
if (is_object($keys)) {
$keys = (array) $keys;
}
if (! is_array($keys) || ! count($keys)) {
throw new MongoException('index specification has no elements');
}
if (! isset($options['name'])) {
$options['name'] = \MongoDB\generate_index_name($keys);
}
$indexes = iterator_to_array($this->collection->listIndexes());
$indexCount = count($indexes);
$collectionExists = true;
$indexExists = false;
// listIndexes returns 0 for non-existing collections while the legacy driver returns 1
if ($indexCount === 0) {
$collectionExists = false;
$indexCount = 1;
}
foreach ($indexes as $index) {
if ($index->getKey() === $keys || $index->getName() === $options['name']) {
$indexExists = true;
break;
}
}
try {
foreach (['w', 'wTimeoutMS', 'safe', 'timeout', 'wtimeout'] as $invalidOption) {
if (isset($options[$invalidOption])) {
unset($options[$invalidOption]);
}
}
$this->collection->createIndex($keys, $options);
} catch (\MongoDB\Driver\Exception\Exception $e) {
throw ExceptionConverter::toLegacy($e, 'MongoResultException');
}
$result = [
'createdCollectionAutomatically' => !$collectionExists,
'numIndexesBefore' => $indexCount,
'numIndexesAfter' => $indexCount,
'note' => 'all indexes already exist',
'ok' => 1.0,
];
if (! $indexExists) {
$result['numIndexesAfter']++;
unset($result['note']);
}
return $result;
}
/**
* Creates an index on the given field(s), or does nothing if the index already exists
*
* @link http://www.php.net/manual/en/mongocollection.ensureindex.php
* @param array $keys Field or fields to use as index.
* @param array $options [optional] This parameter is an associative array of the form array("optionname" => , ...).
* @return array Returns the database response.
* @deprecated Use MongoCollection::createIndex() instead.
*/
public function ensureIndex(array $keys, array $options = [])
{
return $this->createIndex($keys, $options);
}
/**
* Deletes an index from this collection
*
* @link http://www.php.net/manual/en/mongocollection.deleteindex.php
* @param string|array $keys Field or fields from which to delete the index.
* @return array Returns the database response.
*/
public function deleteIndex($keys)
{
if (is_string($keys)) {
$indexName = $keys;
if (! preg_match('#_-?1$#', $indexName)) {
$indexName .= '_1';
}
} elseif (is_array($keys)) {
$indexName = \MongoDB\generate_index_name($keys);
} else {
throw new \InvalidArgumentException();
}
try {
return TypeConverter::toLegacy($this->collection->dropIndex($indexName));
} catch (\MongoDB\Driver\Exception\Exception $e) {
return ExceptionConverter::toResultArray($e) + ['nIndexesWas' => count($this->getIndexInfo())];
}
}
/**
* Delete all indexes for this collection
*
* @link http://www.php.net/manual/en/mongocollection.deleteindexes.php
* @return array Returns the database response.
*/
public function deleteIndexes()
{
try {
return TypeConverter::toLegacy($this->collection->dropIndexes());
} catch (\MongoDB\Driver\Exception\Exception $e) {
return ExceptionConverter::toResultArray($e);
}
}
/**
* Returns an array of index names for this collection
*
* @link http://www.php.net/manual/en/mongocollection.getindexinfo.php
* @return array Returns a list of index names.
*/
public function getIndexInfo()
{
$convertIndex = function(\MongoDB\Model\IndexInfo $indexInfo) {
return [
'v' => $indexInfo->getVersion(),
'key' => $indexInfo->getKey(),
'name' => $indexInfo->getName(),
'ns' => $indexInfo->getNamespace(),
];
};
return array_map($convertIndex, iterator_to_array($this->collection->listIndexes()));
}
/**
* Counts the number of documents in this collection
*
* @link http://www.php.net/manual/en/mongocollection.count.php
* @param array|stdClass $query
* @param array $options
* @return int Returns the number of documents matching the query.
*/
public function count($query = [], $options = [])
{
try {
// Handle legacy mode - limit and skip as second and third parameters, respectively
if (! is_array($options)) {
$limit = $options;
$options = [];
if ($limit !== null) {
$options['limit'] = (int) $limit;
}
if (func_num_args() > 2) {
$options['skip'] = (int) func_get_args()[2];
}
}
return $this->collection->count(TypeConverter::fromLegacy($query), $options);
} catch (\MongoDB\Driver\Exception\Exception $e) {
throw ExceptionConverter::toLegacy($e);
}
}
/**
* Saves an object to this collection
*
* @link http://www.php.net/manual/en/mongocollection.save.php
* @param array|object $a Array to save. If an object is used, it may not have protected or private properties.
* @param array $options Options for the save.
* @throws MongoException if the inserted document is empty or if it contains zero-length keys. Attempting to insert an object with protected and private properties will cause a zero-length key error.
* @throws MongoCursorException if the "w" option is set and the write fails.
* @throws MongoCursorTimeoutException if the "w" option is set to a value greater than one and the operation takes longer than MongoCursor::$timeout milliseconds to complete. This does not kill the operation on the server, it is a client-side timeout. The operation in MongoCollection::$wtimeout is milliseconds.
* @return array|boolean If w was set, returns an array containing the status of the save.
* Otherwise, returns a boolean representing if the array was not empty (an empty array will not be inserted).
*/
public function save(&$a, array $options = [])
{
$id = $this->ensureDocumentHasMongoId($a);
$document = (array) $a;
$options['upsert'] = true;
try {
/** @var \MongoDB\UpdateResult $result */
$result = $this->collection->replaceOne(
TypeConverter::fromLegacy(['_id' => $id]),
TypeConverter::fromLegacy($document),
$this->convertWriteConcernOptions($options)
);
if (! $result->isAcknowledged()) {
return true;
}
$resultArray = [
'ok' => 1.0,
'nModified' => $result->getModifiedCount(),
'n' => $result->getUpsertedCount() + $result->getModifiedCount(),
'err' => null,
'errmsg' => null,
'updatedExisting' => $result->getUpsertedCount() == 0,
];
if ($result->getUpsertedId() !== null) {
$resultArray['upserted'] = TypeConverter::toLegacy($result->getUpsertedId());
}
return $resultArray;
} catch (\MongoDB\Driver\Exception\Exception $e) {
throw ExceptionConverter::toLegacy($e);
}
}
/**
* Creates a database reference
*
* @link http://www.php.net/manual/en/mongocollection.createdbref.php
* @param array|object $document_or_id Object to which to create a reference.
* @return array Returns a database reference array.
*/
public function createDBRef($document_or_id)
{
if ($document_or_id instanceof \MongoId) {
$id = $document_or_id;
} elseif (is_object($document_or_id)) {
if (! isset($document_or_id->_id)) {
return null;
}
$id = $document_or_id->_id;
} elseif (is_array($document_or_id)) {
if (! isset($document_or_id['_id'])) {
return null;
}
$id = $document_or_id['_id'];
} else {
$id = $document_or_id;
}
return MongoDBRef::create($this->name, $id);
}
/**
* Fetches the document pointed to by a database reference
*
* @link http://www.php.net/manual/en/mongocollection.getdbref.php
* @param array $ref A database reference.
* @return array Returns the database document pointed to by the reference.
*/
public function getDBRef(array $ref)
{
return $this->db->getDBRef($ref);
}
/**
* Performs an operation similar to SQL's GROUP BY command
*
* @link http://www.php.net/manual/en/mongocollection.group.php
* @param mixed $keys Fields to group by. If an array or non-code object is passed, it will be the key used to group results.
* @param array $initial Initial value of the aggregation counter object.
* @param MongoCode|string $reduce A function that aggregates (reduces) the objects iterated.
* @param array $condition An condition that must be true for a row to be considered.
* @return array
*/
public function group($keys, array $initial, $reduce, array $condition = [])
{
if (is_string($reduce)) {
$reduce = new MongoCode($reduce);
}
$command = [
'group' => [
'ns' => $this->name,
'$reduce' => (string)$reduce,
'initial' => $initial,
'cond' => $condition,
],
];
if ($keys instanceof MongoCode) {
$command['group']['$keyf'] = (string)$keys;
} else {
$command['group']['key'] = $keys;
}
if (array_key_exists('condition', $condition)) {
$command['group']['cond'] = $condition['condition'];
}
if (array_key_exists('finalize', $condition)) {
if ($condition['finalize'] instanceof MongoCode) {
$condition['finalize'] = (string)$condition['finalize'];
}
$command['group']['finalize'] = $condition['finalize'];
}
return $this->db->command($command);
}
/**
* Returns an array of cursors to iterator over a full collection in parallel
*
* @link http://www.php.net/manual/en/mongocollection.parallelcollectionscan.php
* @param int $num_cursors The number of cursors to request from the server. Please note, that the server can return less cursors than you requested.
* @return MongoCommandCursor[]
*/
public function parallelCollectionScan($num_cursors)
{
$this->notImplemented();
}
protected function notImplemented()
{
throw new \Exception('Not implemented');
}
/**
* @return \MongoDB\Collection
*/
private function createCollectionObject()
{
$options = [
'readPreference' => $this->readPreference,
'writeConcern' => $this->writeConcern,
];
if ($this->collection === null) {
$this->collection = $this->db->getDb()->selectCollection($this->name, $options);
} else {
$this->collection = $this->collection->withOptions($options);
}
}
/**
* Converts legacy write concern options to a WriteConcern object
*
* @param array $options
* @return array
*/
private function convertWriteConcernOptions(array $options)
{
if (isset($options['safe'])) {
$options['w'] = ($options['safe']) ? 1 : 0;
}
if (isset($options['wtimeout']) && !isset($options['wTimeoutMS'])) {
$options['wTimeoutMS'] = $options['wtimeout'];
}
if (isset($options['w']) || !isset($options['wTimeoutMS'])) {
$collectionWriteConcern = $this->getWriteConcern();
$writeConcern = $this->createWriteConcernFromParameters(
isset($options['w']) ? $options['w'] : $collectionWriteConcern['w'],
isset($options['wTimeoutMS']) ? $options['wTimeoutMS'] : $collectionWriteConcern['wtimeout']
);
$options['writeConcern'] = $writeConcern;
}
unset($options['safe']);
unset($options['w']);
unset($options['wTimeout']);
unset($options['wTimeoutMS']);
return $options;
}
/**
* @param array|object $document
* @return MongoId
*/
private function ensureDocumentHasMongoId(&$document)
{
$checkKeys = function($array) {
foreach (array_keys($array) as $key) {
if (empty($key) && $key !== 0) {
throw new \MongoException('zero-length keys are not allowed, did you use $ with double quotes?');
}
}
};
if (is_array($document)) {
if (! isset($document['_id'])) {
$document['_id'] = new \MongoId();
}
$checkKeys($document);
return $document['_id'];
} elseif (is_object($document)) {
$reflectionObject = new \ReflectionObject($document);
foreach ($reflectionObject->getProperties() as $property) {
if (! $property->isPublic()) {
throw new \MongoException('zero-length keys are not allowed, did you use $ with double quotes?');
}
}
if (! isset($document->_id)) {
$document->_id = new \MongoId();
}
$checkKeys((array) $document);
return $document->_id;
}
return null;
}
private function checkCollectionName($name)
{
if (empty($name)) {
throw new Exception('Collection name cannot be empty');
} elseif (strpos($name, chr(0)) !== false) {
throw new Exception('Collection name cannot contain null bytes');
}
}
/**
* @return array
*/
public function __sleep()
{
return ['db', 'name'];
}
}
Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/lib/Mongo/MongoCommandCursor.php 0000664 0001750 0001750 00000006317 12741242607 027650 0 ustar jan jan command = $command;
}
/**
* @param MongoClient $connection
* @param string $hash
* @param array $document
* @return MongoCommandCursor
*/
public static function createFromDocument(MongoClient $connection, $hash, array $document)
{
throw new \Exception('Not implemented');
}
/**
* @return \MongoDB\Driver\Cursor
*/
protected function ensureCursor()
{
if ($this->cursor === null) {
$convertedCommand = TypeConverter::fromLegacy($this->command);
if (isset($convertedCommand->cursor)) {
if ($convertedCommand->cursor === true || $convertedCommand->cursor === []) {
$convertedCommand->cursor = new \stdClass();
}
}
$this->cursor = $this->db->command($convertedCommand, $this->getOptions());
}
return $this->cursor;
}
/**
* @return array
*/
protected function getCursorInfo()
{
return [
'ns' => $this->ns,
'limit' => 0,
'batchSize' => $this->batchSize,
'skip' => 0,
'flags' => 0,
'query' => $this->command,
'fields' => null,
];
}
/**
* @return array
*/
protected function getIterationInfo()
{
$iterationInfo = parent::getIterationInfo();
if ($iterationInfo['started_iterating']) {
$iterationInfo += [
'firstBatchAt' => $iterationInfo['at'],
'firstBatchNumReturned' => $iterationInfo['numReturned'],
];
$iterationInfo['at'] = 0;
$iterationInfo['numReturned'] = 0;
}
return $iterationInfo;
}
/**
* @return array
*/
public function __sleep()
{
return ['command'] + parent::__sleep();
}
}
Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/lib/Mongo/MongoConnectionException.php 0000664 0001750 0001750 00000001643 12741242607 031047 0 ustar jan jan query = $query;
$this->projection = $fields;
}
/**
* Adds a top-level key/value pair to a query
* @link http://www.php.net/manual/en/mongocursor.addoption.php
* @param string $key Fieldname to add.
* @param mixed $value Value to add.
* @throws MongoCursorException
* @return MongoCursor Returns this cursor
*/
public function addOption($key, $value)
{
$this->errorIfOpened();
$this->options[$key] = $value;
return $this;
}
/**
* (PECL mongo >= 1.2.11)
* Sets whether this cursor will wait for a while for a tailable cursor to return more data
* @param bool $wait [optional]
If the cursor should wait for more data to become available.
* @return MongoCursor Returns this cursor.
*/
public function awaitData($wait = true)
{
$this->errorIfOpened();
$this->awaitData = $wait;
return $this;
}
/**
* Counts the number of results for this query
* @link http://www.php.net/manual/en/mongocursor.count.php
* @param bool $foundOnly Send cursor limit and skip information to the count function, if applicable.
* @return int The number of documents returned by this cursor's query.
*/
public function count($foundOnly = false)
{
$optionNames = ['hint', 'maxTimeMS'];
if ($foundOnly) {
$optionNames = array_merge($optionNames, ['limit', 'skip']);
}
$options = $this->getOptions($optionNames) + $this->options;
try {
$count = $this->collection->count(TypeConverter::fromLegacy($this->query), $options);
} catch (\MongoDB\Driver\Exception\ExecutionTimeoutException $e) {
throw new MongoCursorTimeoutException($e->getMessage(), $e->getCode(), $e);
} catch (\MongoDB\Driver\Exception\Exception $e) {
throw ExceptionConverter::toLegacy($e);
}
return $count;
}
/**
* Execute the query
* @link http://www.php.net/manual/en/mongocursor.doquery.php
* @throws MongoConnectionException if it cannot reach the database.
* @return void
*/
protected function doQuery()
{
$options = $this->getOptions() + $this->options;
try {
$this->cursor = $this->collection->find(TypeConverter::fromLegacy($this->query), $options);
} catch (\MongoDB\Driver\Exception\ExecutionTimeoutException $e) {
throw new MongoCursorTimeoutException($e->getMessage(), $e->getCode(), $e);
} catch (\MongoDB\Driver\Exception\Exception $e) {
throw ExceptionConverter::toLegacy($e);
}
}
/**
* Return an explanation of the query, often useful for optimization and debugging
* @link http://www.php.net/manual/en/mongocursor.explain.php
* @return array Returns an explanation of the query.
*/
public function explain()
{
$this->notImplemented();
}
/**
* Sets the fields for a query
* @link http://www.php.net/manual/en/mongocursor.fields.php
* @param array $f Fields to return (or not return).
* @throws MongoCursorException
* @return MongoCursor
*/
public function fields(array $f)
{
$this->errorIfOpened();
$this->projection = $f;
return $this;
}
/**
* Advances the cursor to the next result, and returns that result
* @link http://www.php.net/manual/en/mongocursor.getnext.php
* @throws MongoConnectionException
* @throws MongoCursorTimeoutException
* @return array Returns the next object
*/
public function getNext()
{
return $this->next();
}
/**
* Checks if there are any more elements in this cursor
* @link http://www.php.net/manual/en/mongocursor.hasnext.php
* @throws MongoConnectionException
* @throws MongoCursorTimeoutException
* @return bool Returns true if there is another element
*/
public function hasNext()
{
if (! $this->startedIterating) {
$this->ensureIterator();
$this->startedIterating = true;
$this->storeIteratorState();
$this->cursorNeedsAdvancing = false;
} elseif ($this->cursorNeedsAdvancing) {
$this->ensureIterator()->next();
$this->cursorNeedsAdvancing = false;
}
return $this->ensureIterator()->valid();
}
/**
* Gives the database a hint about the query
* @link http://www.php.net/manual/en/mongocursor.hint.php
* @param array|string $keyPattern Indexes to use for the query.
* @throws MongoCursorException
* @return MongoCursor Returns this cursor
*/
public function hint($keyPattern)
{
$this->errorIfOpened();
$this->hint = $keyPattern;
return $this;
}
/**
* Sets whether this cursor will timeout
* @link http://www.php.net/manual/en/mongocursor.immortal.php
* @param bool $liveForever If the cursor should be immortal.
* @throws MongoCursorException
* @return MongoCursor Returns this cursor
*/
public function immortal($liveForever = true)
{
$this->errorIfOpened();
$this->noCursorTimeout = $liveForever;
return $this;
}
/**
* Limits the number of results returned
* @link http://www.php.net/manual/en/mongocursor.limit.php
* @param int $num The number of results to return.
* @throws MongoCursorException
* @return MongoCursor Returns this cursor
*/
public function limit($num)
{
$this->errorIfOpened();
$this->limit = $num;
return $this;
}
/**
* @param int $ms
* @return $this
* @throws MongoCursorException
*/
public function maxTimeMS($ms)
{
$this->errorIfOpened();
$this->maxTimeMS = $ms;
return $this;
}
/**
* @link http://www.php.net/manual/en/mongocursor.partial.php
* @param bool $okay [optional]
If receiving partial results is okay.
* @return MongoCursor Returns this cursor.
*/
public function partial($okay = true)
{
$this->allowPartialResults = $okay;
return $this;
}
/**
* Clears the cursor
* @link http://www.php.net/manual/en/mongocursor.reset.php
* @return void
*/
public function reset()
{
parent::reset();
}
/**
* @link http://www.php.net/manual/en/mongocursor.setflag.php
* @param int $flag
* @param bool $set
* @return MongoCursor
*/
public function setFlag($flag, $set = true)
{
$this->notImplemented();
}
/**
* Skips a number of results
* @link http://www.php.net/manual/en/mongocursor.skip.php
* @param int $num The number of results to skip.
* @throws MongoCursorException
* @return MongoCursor Returns this cursor
*/
public function skip($num)
{
$this->errorIfOpened();
$this->skip = $num;
return $this;
}
/**
* Sets whether this query can be done on a slave
* This method will override the static class variable slaveOkay.
* @link http://www.php.net/manual/en/mongocursor.slaveOkay.php
* @param boolean $okay If it is okay to query the slave.
* @throws MongoCursorException
* @return MongoCursor Returns this cursor
*/
public function slaveOkay($okay = true)
{
$this->errorIfOpened();
$this->setReadPreferenceFromSlaveOkay($okay);
return $this;
}
/**
* Use snapshot mode for the query
* @link http://www.php.net/manual/en/mongocursor.snapshot.php
* @throws MongoCursorException
* @return MongoCursor Returns this cursor
*/
public function snapshot()
{
$this->errorIfOpened();
$this->snapshot = true;
return $this;
}
/**
* Sorts the results by given fields
* @link http://www.php.net/manual/en/mongocursor.sort.php
* @param array $fields An array of fields by which to sort. Each element in the array has as key the field name, and as value either 1 for ascending sort, or -1 for descending sort
* @throws MongoCursorException
* @return MongoCursor Returns the same cursor that this method was called on
*/
public function sort(array $fields)
{
$this->errorIfOpened();
$this->sort = $fields;
return $this;
}
/**
* Sets whether this cursor will be left open after fetching the last results
* @link http://www.php.net/manual/en/mongocursor.tailable.php
* @param bool $tail If the cursor should be tailable.
* @return MongoCursor Returns this cursor
*/
public function tailable($tail = true)
{
$this->errorIfOpened();
$this->tailable = $tail;
return $this;
}
/**
* @return int|null
*/
protected function convertCursorType()
{
if (! $this->tailable) {
return null;
}
return $this->awaitData ? Find::TAILABLE_AWAIT : Find::TAILABLE;
}
/**
* @return array
*/
protected function convertModifiers()
{
$modifiers = array_key_exists('modifiers', $this->options) ? $this->options['modifiers'] : [];
foreach (['hint', 'snapshot'] as $modifier) {
if ($this->$modifier === null) {
continue;
}
$modifiers['$' . $modifier] = $this->$modifier;
}
return $modifiers;
}
/**
* @return array
*/
protected function convertProjection()
{
return TypeConverter::fromLegacy($this->projection);
}
/**
* @return Cursor
*/
protected function ensureCursor()
{
if ($this->cursor === null) {
$this->doQuery();
}
return $this->cursor;
}
/**
* @param \Traversable $traversable
* @return \Generator
*/
protected function wrapTraversable(\Traversable $traversable)
{
foreach ($traversable as $key => $value) {
if (isset($value->_id) && ($value->_id instanceof \MongoDB\BSON\ObjectID || !is_object($value->_id))) {
$key = (string) $value->_id;
}
yield $key => $value;
}
}
/**
* @return array
*/
protected function getCursorInfo()
{
return [
'ns' => $this->ns,
'limit' => $this->limit,
'batchSize' => $this->batchSize,
'skip' => $this->skip,
'flags' => $this->flags,
'query' => $this->query,
'fields' => $this->projection,
];
}
/**
* @return array
*/
public function __sleep()
{
return [
'allowPartialResults',
'awaitData',
'flags',
'hint',
'limit',
'maxTimeMS',
'noCursorTimeout',
'optionNames',
'options',
'projection',
'query',
'skip',
'snapshot',
'sort',
'tailable',
] + parent::__sleep();
}
}
Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/lib/Mongo/MongoCursorException.php 0000664 0001750 0001750 00000001633 12741242607 030224 0 ustar jan jan sec = (int) $sec;
$this->usec = (int) $this->truncateMicroSeconds($usec);
}
/**
* Returns a string representation of this date
* @return string
*/
public function __toString()
{
return (string) sprintf('%.8f', $this->truncateMicroSeconds($this->usec) / 1000000) . ' ' . $this->sec;
}
/**
* Converts this MongoDate to the new BSON UTCDateTime type
*
* @return UTCDateTime
* @internal This method is not part of the ext-mongo API
*/
public function toBSONType()
{
$milliSeconds = ($this->sec * 1000) + ($this->truncateMicroSeconds($this->usec) / 1000);
return new UTCDateTime($milliSeconds);
}
/**
* Returns a DateTime object representing this date
* @link http://php.net/manual/en/mongodate.todatetime.php
* @return DateTime
*/
public function toDateTime()
{
$datetime = new \DateTime();
$datetime->setTimestamp($this->sec);
$microSeconds = $this->truncateMicroSeconds($this->usec);
if ($microSeconds > 0) {
$datetime = \DateTime::createFromFormat('Y-m-d H:i:s.u', $datetime->format('Y-m-d H:i:s') . '.' . $microSeconds);
}
$datetime->setTimezone(new \DateTimeZone("UTC"));
return $datetime;
}
/**
* @param int $usec
* @return int
*/
private function truncateMicroSeconds($usec)
{
return (int) floor($usec / 1000) * 1000;
}
}
Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/lib/Mongo/MongoDB.php 0000664 0001750 0001750 00000041552 12741242607 025361 0 ustar jan jan checkDatabaseName($name);
$this->connection = $conn;
$this->name = (string) $name;
$this->setReadPreferenceFromArray($conn->getReadPreference());
$this->setWriteConcernFromArray($conn->getWriteConcern());
$this->createDatabaseObject();
}
/**
* @return \MongoDB\Database
* @internal This method is not part of the ext-mongo API
*/
public function getDb()
{
return $this->db;
}
/**
* The name of this database
*
* @link http://www.php.net/manual/en/mongodb.--tostring.php
* @return string Returns this database's name.
*/
public function __toString()
{
return $this->name;
}
/**
* Gets a collection
*
* @link http://www.php.net/manual/en/mongodb.get.php
* @param string $name The name of the collection.
* @return MongoCollection
*/
public function __get($name)
{
// Handle w and wtimeout properties that replicate data stored in $readPreference
if ($name === 'w' || $name === 'wtimeout') {
return $this->getWriteConcern()[$name];
}
return $this->selectCollection($name);
}
/**
* @param string $name
* @param mixed $value
*/
public function __set($name, $value)
{
if ($name === 'w' || $name === 'wtimeout') {
trigger_error("The '{$name}' property is read-only", E_DEPRECATED);
}
}
/**
* Returns information about collections in this database
*
* @link http://www.php.net/manual/en/mongodb.getcollectioninfo.php
* @param array $options An array of options for listing the collections.
* @return array
*/
public function getCollectionInfo(array $options = [])
{
$includeSystemCollections = false;
// The includeSystemCollections option is no longer supported in the command
if (isset($options['includeSystemCollections'])) {
$includeSystemCollections = $options['includeSystemCollections'];
unset($options['includeSystemCollections']);
}
try {
$collections = $this->db->listCollections($options);
} catch (\MongoDB\Driver\Exception\Exception $e) {
throw ExceptionConverter::toLegacy($e);
}
$getCollectionInfo = function (CollectionInfo $collectionInfo) {
return [
'name' => $collectionInfo->getName(),
'options' => $collectionInfo->getOptions(),
];
};
$eligibleCollections = array_filter(
iterator_to_array($collections),
$this->getSystemCollectionFilterClosure($includeSystemCollections)
);
return array_map($getCollectionInfo, $eligibleCollections);
}
/**
* Get all collections from this database
*
* @link http://www.php.net/manual/en/mongodb.getcollectionnames.php
* @param array $options An array of options for listing the collections.
* @return array Returns the names of the all the collections in the database as an array
*/
public function getCollectionNames(array $options = [])
{
$includeSystemCollections = false;
// The includeSystemCollections option is no longer supported in the command
if (isset($options['includeSystemCollections'])) {
$includeSystemCollections = $options['includeSystemCollections'];
unset($options['includeSystemCollections']);
}
try {
$collections = $this->db->listCollections($options);
} catch (\MongoDB\Driver\Exception\Exception $e) {
throw ExceptionConverter::toLegacy($e);
}
$getCollectionName = function (CollectionInfo $collectionInfo) {
return $collectionInfo->getName();
};
$eligibleCollections = array_filter(
iterator_to_array($collections),
$this->getSystemCollectionFilterClosure($includeSystemCollections)
);
return array_map($getCollectionName, $eligibleCollections);
}
/**
* @return MongoClient
* @internal This method is not part of the ext-mongo API
*/
public function getConnection()
{
return $this->connection;
}
/**
* Fetches toolkit for dealing with files stored in this database
*
* @link http://www.php.net/manual/en/mongodb.getgridfs.php
* @param string $prefix The prefix for the files and chunks collections.
* @return MongoGridFS Returns a new gridfs object for this database.
*/
public function getGridFS($prefix = "fs")
{
return new \MongoGridFS($this, $prefix);
}
/**
* Gets this database's profiling level
*
* @link http://www.php.net/manual/en/mongodb.getprofilinglevel.php
* @return int Returns the profiling level.
*/
public function getProfilingLevel()
{
$result = $this->command(['profile' => -1]);
return ($result['ok'] && isset($result['was'])) ? $result['was'] : 0;
}
/**
* Sets this database's profiling level
*
* @link http://www.php.net/manual/en/mongodb.setprofilinglevel.php
* @param int $level Profiling level.
* @return int Returns the previous profiling level.
*/
public function setProfilingLevel($level)
{
$result = $this->command(['profile' => $level]);
return ($result['ok'] && isset($result['was'])) ? $result['was'] : 0;
}
/**
* Drops this database
*
* @link http://www.php.net/manual/en/mongodb.drop.php
* @return array Returns the database response.
*/
public function drop()
{
return TypeConverter::toLegacy($this->db->drop());
}
/**
* Repairs and compacts this database
*
* @link http://www.php.net/manual/en/mongodb.repair.php
* @param bool $preserve_cloned_files [optional]
If cloned files should be kept if the repair fails.
* @param bool $backup_original_files [optional]
If original files should be backed up.
* @return array
Returns db response.
*/
public function repair($preserve_cloned_files = FALSE, $backup_original_files = FALSE)
{
$command = [
'repairDatabase' => 1,
'preserveClonedFilesOnFailure' => $preserve_cloned_files,
'backupOriginalFiles' => $backup_original_files,
];
return $this->command($command);
}
/**
* Gets a collection
*
* @link http://www.php.net/manual/en/mongodb.selectcollection.php
* @param string $name The collection name.
* @throws Exception if the collection name is invalid.
* @return MongoCollection Returns a new collection object.
*/
public function selectCollection($name)
{
return new MongoCollection($this, $name);
}
/**
* Creates a collection
*
* @link http://www.php.net/manual/en/mongodb.createcollection.php
* @param string $name The name of the collection.
* @param array $options
* @return MongoCollection Returns a collection object representing the new collection.
*/
public function createCollection($name, $options)
{
try {
if (isset($options['capped'])) {
$options['capped'] = (bool) $options['capped'];
}
$this->db->createCollection($name, $options);
} catch (\MongoDB\Driver\Exception\Exception $e) {
return false;
}
return $this->selectCollection($name);
}
/**
* Drops a collection
*
* @link http://www.php.net/manual/en/mongodb.dropcollection.php
* @param MongoCollection|string $coll MongoCollection or name of collection to drop.
* @return array Returns the database response.
*
* @deprecated Use MongoCollection::drop() instead.
*/
public function dropCollection($coll)
{
if ($coll instanceof MongoCollection) {
$coll = $coll->getName();
}
return TypeConverter::toLegacy($this->db->dropCollection((string) $coll));
}
/**
* Get a list of collections in this database
*
* @link http://www.php.net/manual/en/mongodb.listcollections.php
* @param array $options
* @return MongoCollection[] Returns a list of MongoCollections.
*/
public function listCollections(array $options = [])
{
return array_map([$this, 'selectCollection'], $this->getCollectionNames($options));
}
/**
* Creates a database reference
*
* @link http://www.php.net/manual/en/mongodb.createdbref.php
* @param string $collection The collection to which the database reference will point.
* @param mixed $document_or_id
* @return array Returns a database reference array.
*/
public function createDBRef($collection, $document_or_id)
{
if ($document_or_id instanceof \MongoId) {
$id = $document_or_id;
} elseif (is_object($document_or_id)) {
if (! isset($document_or_id->_id)) {
$id = $document_or_id;
} else {
$id = $document_or_id->_id;
}
} elseif (is_array($document_or_id)) {
if (! isset($document_or_id['_id'])) {
return null;
}
$id = $document_or_id['_id'];
} else {
$id = $document_or_id;
}
return MongoDBRef::create($collection, $id);
}
/**
* Fetches the document pointed to by a database reference
*
* @link http://www.php.net/manual/en/mongodb.getdbref.php
* @param array $ref A database reference.
* @return array Returns the document pointed to by the reference.
*/
public function getDBRef(array $ref)
{
return MongoDBRef::get($this, $ref);
}
/**
* Runs JavaScript code on the database server.
*
* @link http://www.php.net/manual/en/mongodb.execute.php
* @param MongoCode|string $code Code to execute.
* @param array $args [optional] Arguments to be passed to code.
* @return array Returns the result of the evaluation.
*/
public function execute($code, array $args = [])
{
return $this->command(['eval' => $code, 'args' => $args]);
}
/**
* Execute a database command
*
* @link http://www.php.net/manual/en/mongodb.command.php
* @param array $data The query to send.
* @param array $options
* @return array Returns database response.
*/
public function command(array $data, $options = [], &$hash = null)
{
try {
$cursor = new \MongoCommandCursor($this->connection, $this->name, $data);
$cursor->setReadPreference($this->getReadPreference());
return iterator_to_array($cursor)[0];
} catch (\MongoDB\Driver\Exception\Exception $e) {
return ExceptionConverter::toResultArray($e);
}
}
/**
* Check if there was an error on the most recent db operation performed
*
* @link http://www.php.net/manual/en/mongodb.lasterror.php
* @return array Returns the error, if there was one.
*/
public function lastError()
{
return $this->command(array('getLastError' => 1));
}
/**
* Checks for the last error thrown during a database operation
*
* @link http://www.php.net/manual/en/mongodb.preverror.php
* @return array Returns the error and the number of operations ago it occurred.
*/
public function prevError()
{
return $this->command(array('getPrevError' => 1));
}
/**
* Clears any flagged errors on the database
*
* @link http://www.php.net/manual/en/mongodb.reseterror.php
* @return array Returns the database response.
*/
public function resetError()
{
return $this->command(array('resetError' => 1));
}
/**
* Creates a database error
*
* @link http://www.php.net/manual/en/mongodb.forceerror.php
* @return boolean Returns the database response.
*/
public function forceError()
{
return $this->command(array('forceerror' => 1));
}
/**
* Log in to this database
*
* @link http://www.php.net/manual/en/mongodb.authenticate.php
* @param string $username The username.
* @param string $password The password (in plaintext).
* @return array Returns database response. If the login was successful, it will return 1.
*
* @deprecated This method is not implemented, supply authentication credentials through the connection string instead.
*/
public function authenticate($username, $password)
{
throw new \Exception('The MongoDB::authenticate method is not supported. Please supply authentication credentials through the connection string');
}
/**
* {@inheritdoc}
*/
public function setReadPreference($readPreference, $tags = null)
{
$result = $this->setReadPreferenceFromParameters($readPreference, $tags);
$this->createDatabaseObject();
return $result;
}
/**
* {@inheritdoc}
*/
public function setWriteConcern($wstring, $wtimeout = 0)
{
$result = $this->setWriteConcernFromParameters($wstring, $wtimeout);
$this->createDatabaseObject();
return $result;
}
protected function notImplemented()
{
throw new \Exception('Not implemented');
}
/**
* @return \MongoDB\Database
*/
private function createDatabaseObject()
{
$options = [
'readPreference' => $this->readPreference,
'writeConcern' => $this->writeConcern,
];
if ($this->db === null) {
$this->db = $this->connection->getClient()->selectDatabase($this->name, $options);
} else {
$this->db = $this->db->withOptions($options);
}
}
private function checkDatabaseName($name)
{
if (empty($name)) {
throw new \Exception('Database name cannot be empty');
}
if (strlen($name) >= 64) {
throw new \Exception('Database name cannot exceed 63 characters');
}
if (strpos($name, chr(0)) !== false) {
throw new \Exception('Database name cannot contain null bytes');
}
$invalidCharacters = ['.', '$', '/', ' ', '\\'];
foreach ($invalidCharacters as $char) {
if (strchr($name, $char) !== false) {
throw new \Exception('Database name contains invalid characters');
}
}
}
/**
* @param bool $includeSystemCollections
* @return Closure
*/
private function getSystemCollectionFilterClosure($includeSystemCollections = false) {
return function (CollectionInfo $collectionInfo) use ($includeSystemCollections) {
return $includeSystemCollections || ! preg_match('#^system\.#', $collectionInfo->getName());
};
}
/**
* @return array
*/
public function __sleep()
{
return ['connection', 'name'];
}
}
Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/lib/Mongo/MongoDBRef.php 0000664 0001750 0001750 00000005624 12741242607 026016 0 ustar jan jan $collection,
static::$idKey => $id
];
if ($database !== null) {
$ref['$db'] = $database;
}
return $ref;
}
/**
* This not actually follow the reference, so it does not determine if it is broken or not.
* It merely checks that $ref is in valid database reference format (in that it is an object or array with $ref and $id fields).
*
* @link http://php.net/manual/en/mongodbref.isref.php
* @static
* @param mixed $ref Array or object to check
* @return boolean Returns true if $ref is a reference
*/
public static function isRef($ref)
{
$check = (array) $ref;
return array_key_exists(static::$refKey, $check) && array_key_exists(static::$idKey, $check);
}
/**
* Fetches the object pointed to by a reference
* @link http://php.net/manual/en/mongodbref.get.php
* @static
* @param MongoDB $db Database to use
* @param array $ref Reference to fetch
* @return array|null Returns the document to which the reference refers or null if the document does not exist (the reference is broken)
*/
public static function get($db, $ref)
{
if (! static::isRef($ref)) {
return null;
}
return $db->selectCollection($ref[static::$refKey])->findOne(['_id' => $ref[static::$idKey]]);
}
}
Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/lib/Mongo/MongoDeleteBatch.php 0000664 0001750 0001750 00000002711 12741242607 027232 0 ustar jan jan (PECL mongo >= 1.5.0)
* @link http://php.net/manual/en/class.mongoduplicatekeyexception.php
*/
class MongoDuplicateKeyException extends MongoWriteConcernException {
}
Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/lib/Mongo/MongoException.php 0000664 0001750 0001750 00000001611 12741242607 027022 0 ustar jan jan (PECL mongo >= 1.5.0)
* @link http://php.net/manual/en/class.mongoexecutiontimeoutexception.php
*/
class MongoExecutionTimeoutException extends MongoException {}
Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/lib/Mongo/MongoGridFS.php 0000664 0001750 0001750 00000034673 12741242607 026220 0 ustar jan jan Optional collection name prefix.
* @param mixed $chunks [optional]
* @throws \Exception
*/
public function __construct(MongoDB $db, $prefix = "fs", $chunks = null)
{
if ($chunks) {
trigger_error("The 'chunks' argument is deprecated and ignored", E_DEPRECATED);
}
if (empty($prefix)) {
throw new \Exception('MongoGridFS::__construct(): invalid prefix');
}
$this->database = $db;
$this->prefix = (string) $prefix;
$this->filesName = $prefix . '.files';
$this->chunksName = $prefix . '.chunks';
$this->chunks = $db->selectCollection($this->chunksName);
parent::__construct($db, $this->filesName);
}
/**
* Delete a file from the database
*
* @link http://php.net/manual/en/mongogridfs.delete.php
* @param mixed $id _id of the file to remove
* @return boolean Returns true if the remove was successfully sent to the database.
*/
public function delete($id)
{
$this->createChunksIndex();
$this->chunks->remove(['files_id' => $id], ['justOne' => false]);
return parent::remove(['_id' => $id]);
}
/**
* Drops the files and chunks collections
* @link http://php.net/manual/en/mongogridfs.drop.php
* @return array The database response
*/
public function drop()
{
$this->chunks->drop();
return parent::drop();
}
/**
* @link http://php.net/manual/en/mongogridfs.find.php
* @param array $query The query
* @param array $fields Fields to return
* @param array $options Options for the find command
* @return MongoGridFSCursor A MongoGridFSCursor
*/
public function find(array $query = [], array $fields = [])
{
$cursor = new MongoGridFSCursor($this, $this->db->getConnection(), (string) $this, $query, $fields);
$cursor->setReadPreference($this->getReadPreference());
return $cursor;
}
/**
* Returns a single file matching the criteria
*
* @link http://www.php.net/manual/en/mongogridfs.findone.php
* @param mixed $query The fields for which to search or a filename to search for.
* @param array $fields Fields of the results to return.
* @param array $options Options for the find command
* @return MongoGridFSFile|null
*/
public function findOne($query = [], array $fields = [], array $options = [])
{
if (! is_array($query)) {
$query = ['filename' => (string) $query];
}
$items = iterator_to_array($this->find($query, $fields)->limit(1));
return count($items) ? current($items) : null;
}
/**
* Retrieve a file from the database
*
* @link http://www.php.net/manual/en/mongogridfs.get.php
* @param mixed $id _id of the file to find.
* @return MongoGridFSFile|null
*/
public function get($id)
{
return $this->findOne(['_id' => $id]);
}
/**
* Stores a file in the database
*
* @link http://php.net/manual/en/mongogridfs.put.php
* @param string $filename The name of the file
* @param array $extra Other metadata to add to the file saved
* @param array $options An array of options for the insert operations executed against the chunks and files collections.
* @return mixed Returns the _id of the saved object
*/
public function put($filename, array $extra = [], array $options = [])
{
return $this->storeFile($filename, $extra, $options);
}
/**
* Removes files from the collections
*
* @link http://www.php.net/manual/en/mongogridfs.remove.php
* @param array $criteria Description of records to remove.
* @param array $options Options for remove.
* @throws MongoCursorException
* @return boolean
*/
public function remove(array $criteria = [], array $options = [])
{
$this->createChunksIndex();
$matchingFiles = parent::find($criteria, ['_id' => 1]);
$ids = [];
foreach ($matchingFiles as $file) {
$ids[] = $file['_id'];
}
$this->chunks->remove(['files_id' => ['$in' => $ids]], ['justOne' => false] + $options);
return parent::remove(['_id' => ['$in' => $ids]], ['justOne' => false] + $options);
}
/**
* Chunkifies and stores bytes in the database
* @link http://php.net/manual/en/mongogridfs.storebytes.php
* @param string $bytes A string of bytes to store
* @param array $extra Other metadata to add to the file saved
* @param array $options Options for the store. "safe": Check that this store succeeded
* @return mixed The _id of the object saved
*/
public function storeBytes($bytes, array $extra = [], array $options = [])
{
$this->createChunksIndex();
$record = $extra + [
'length' => mb_strlen($bytes, '8bit'),
'md5' => md5($bytes),
];
try {
$file = $this->insertFile($record, $options);
} catch (MongoException $e) {
throw new MongoGridFSException('Could not store file: '. $e->getMessage(), 0, $e);
}
try {
$this->insertChunksFromBytes($bytes, $file);
} catch (MongoException $e) {
$this->delete($file['_id']);
throw new MongoGridFSException('Could not store file: ' . $e->getMessage(), 0, $e);
}
return $file['_id'];
}
/**
* Stores a file in the database
*
* @link http://php.net/manual/en/mongogridfs.storefile.php
* @param string $filename The name of the file
* @param array $extra Other metadata to add to the file saved
* @param array $options Options for the store. "safe": Check that this store succeeded
* @return mixed Returns the _id of the saved object
* @throws MongoGridFSException
* @throws Exception
*/
public function storeFile($filename, array $extra = [], array $options = [])
{
$this->createChunksIndex();
$record = $extra;
if (is_string($filename)) {
$record += [
'md5' => md5_file($filename),
'length' => filesize($filename),
'filename' => $filename,
];
$handle = fopen($filename, 'r');
if (! $handle) {
throw new MongoGridFSException('could not open file: ' . $filename);
}
} elseif (! is_resource($filename)) {
throw new \Exception('first argument must be a string or stream resource');
} else {
$handle = $filename;
}
$md5 = null;
try {
$file = $this->insertFile($record, $options);
} catch (MongoException $e) {
throw new MongoGridFSException('Could not store file: ' . $e->getMessage(), 0, $e);
}
try {
$length = $this->insertChunksFromFile($handle, $file, $md5);
} catch (MongoException $e) {
$this->delete($file['_id']);
throw new MongoGridFSException('Could not store file: ' . $e->getMessage(), 0, $e);
}
// Add length and MD5 if they were not present before
$update = [];
if (! isset($record['length'])) {
$update['length'] = $length;
}
if (! isset($record['md5'])) {
try {
$update['md5'] = $md5;
} catch (MongoException $e) {
throw new MongoGridFSException('Could not store file: ' . $e->getMessage(), 0, $e);
}
}
if (count($update)) {
try {
$result = $this->update(['_id' => $file['_id']], ['$set' => $update]);
if (! $this->isOKResult($result)) {
throw new MongoGridFSException('Could not store file');
}
} catch (MongoException $e) {
$this->delete($file['_id']);
throw new MongoGridFSException('Could not store file: ' . $e->getMessage(), 0, $e);
}
}
return $file['_id'];
}
/**
* Saves an uploaded file directly from a POST to the database
*
* @link http://www.php.net/manual/en/mongogridfs.storeupload.php
* @param string $name The name attribute of the uploaded file, from .
* @param array $metadata An array of extra fields for the uploaded file.
* @return mixed Returns the _id of the uploaded file.
* @throws MongoGridFSException
*/
public function storeUpload($name, array $metadata = [])
{
if (! isset($_FILES[$name]) || $_FILES[$name]['error'] !== UPLOAD_ERR_OK) {
throw new MongoGridFSException("Could not find uploaded file $name");
}
if (! isset($_FILES[$name]['tmp_name'])) {
throw new MongoGridFSException("Couldn't find tmp_name in the \$_FILES array. Are you sure the upload worked?");
}
$uploadedFile = $_FILES[$name];
$uploadedFile['tmp_name'] = (array) $uploadedFile['tmp_name'];
$uploadedFile['name'] = (array) $uploadedFile['name'];
if (count($uploadedFile['tmp_name']) > 1) {
foreach ($uploadedFile['tmp_name'] as $key => $file) {
$metadata['filename'] = $uploadedFile['name'][$key];
$this->storeFile($file, $metadata);
}
return null;
} else {
$metadata += ['filename' => array_pop($uploadedFile['name'])];
return $this->storeFile(array_pop($uploadedFile['tmp_name']), $metadata);
}
}
/**
* Creates the index on the chunks collection
*/
private function createChunksIndex()
{
try {
$this->chunks->createIndex(['files_id' => 1, 'n' => 1], ['unique' => true]);
} catch (MongoDuplicateKeyException $e) {}
}
/**
* Inserts a single chunk into the database
*
* @param mixed $fileId
* @param string $data
* @param int $chunkNumber
* @return array|bool
*/
private function insertChunk($fileId, $data, $chunkNumber)
{
$chunk = [
'files_id' => $fileId,
'n' => $chunkNumber,
'data' => new MongoBinData($data),
];
$result = $this->chunks->insert($chunk);
if (! $this->isOKResult($result)) {
throw new \MongoException('error inserting chunk');
}
return $result;
}
/**
* Splits a string into chunks and writes them to the database
*
* @param string $bytes
* @param array $record
*/
private function insertChunksFromBytes($bytes, $record)
{
$chunkSize = $record['chunkSize'];
$fileId = $record['_id'];
$i = 0;
$chunks = str_split($bytes, $chunkSize);
foreach ($chunks as $chunk) {
$this->insertChunk($fileId, $chunk, $i++);
}
}
/**
* Reads chunks from a file and writes them to the database
*
* @param resource $handle
* @param array $record
* @param string $md5
* @return int Returns the number of bytes written to the database
*/
private function insertChunksFromFile($handle, $record, &$md5)
{
$written = 0;
$offset = 0;
$i = 0;
$fileId = $record['_id'];
$chunkSize = $record['chunkSize'];
$hash = hash_init('md5');
rewind($handle);
while (! feof($handle)) {
$data = stream_get_contents($handle, $chunkSize);
hash_update($hash, $data);
$this->insertChunk($fileId, $data, $i++);
$written += strlen($data);
$offset += $chunkSize;
}
$md5 = hash_final($hash);
return $written;
}
/**
* Writes a file record to the database
*
* @param $record
* @param array $options
* @return array
*/
private function insertFile($record, array $options = [])
{
$record += [
'_id' => new MongoId(),
'uploadDate' => new MongoDate(),
'chunkSize' => $this->defaultChunkSize,
];
$result = $this->insert($record, $options);
if (! $this->isOKResult($result)) {
throw new \MongoException('error inserting file');
}
return $record;
}
private function isOKResult($result)
{
return (is_array($result) && $result['ok'] == 1.0) ||
(is_bool($result) && $result);
}
/**
* @return array
*/
public function __sleep()
{
return ['chunks', 'chunksName', 'database', 'defaultChunkSize', 'filesName', 'prefix'] + parent::__sleep();
}
}
Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/lib/Mongo/MongoGridFSCursor.php 0000664 0001750 0001750 00000004611 12741242607 027403 0 ustar jan jan gridfs = $gridfs;
parent::__construct($connection, $ns, $query, $fields);
}
/**
* Returns the current file
*
* @link http://php.net/manual/en/mongogridfscursor.current.php
* @return MongoGridFSFile The current file
*/
public function current()
{
$file = parent::current();
return ($file !== null) ? new MongoGridFSFile($this->gridfs, $file) : null;
}
/**
* Returns the current result's filename
*
* @link http://php.net/manual/en/mongogridfscursor.key.php
* @return string The current results filename
*/
public function key()
{
$file = $this->current();
return ($file !== null) ? (string)$file->file['_id'] : null;
}
}
Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/lib/Mongo/MongoGridFSException.php 0000664 0001750 0001750 00000001633 12741242607 030065 0 ustar jan jan gridfs = $gridfs;
$this->file = $file;
}
/**
* Returns this file's filename
* @link http://php.net/manual/en/mongogridfsfile.getfilename.php
* @return string Returns the filename
*/
public function getFilename()
{
return isset($this->file['filename']) ? $this->file['filename'] : null;
}
/**
* Returns this file's size
* @link http://php.net/manual/en/mongogridfsfile.getsize.php
* @return int Returns this file's size
*/
public function getSize()
{
return $this->file['length'];
}
/**
* Writes this file to the filesystem
* @link http://php.net/manual/en/mongogridfsfile.write.php
* @param string $filename The location to which to write the file (path+filename+extension). If none is given, the stored filename will be used.
* @return int Returns the number of bytes written
*/
public function write($filename = null)
{
if ($filename === null) {
$filename = $this->getFilename();
}
if (empty($filename)) {
$filename = 'file';
}
if (! $handle = fopen($filename, 'w')) {
trigger_error(E_ERROR, 'Can not open the destination file');
return 0;
}
$written = $this->copyToResource($handle);
fclose($handle);
return $written;
}
/**
* This will load the file into memory. If the file is bigger than your memory, this will cause problems!
* @link http://php.net/manual/en/mongogridfsfile.getbytes.php
* @return string Returns a string of the bytes in the file
*/
public function getBytes()
{
$result = '';
foreach ($this->getChunks() as $chunk) {
$result .= $chunk['data']->bin;
}
return $result;
}
/**
* This method returns a stream resource that can be used to read the stored file with all file functions in PHP.
* The contents of the file are pulled out of MongoDB on the fly, so that the whole file does not have to be loaded into memory first.
* At most two GridFSFile chunks will be loaded in memory.
*
* @link http://php.net/manual/en/mongogridfsfile.getresource.php
* @return resource Returns a resource that can be used to read the file with
*/
public function getResource()
{
$handle = fopen('php://temp', 'w+');
$this->copyToResource($handle);
rewind($handle);
return $handle;
}
private function copyToResource($handle)
{
$written = 0;
foreach ($this->getChunks() as $chunk) {
$written += fwrite($handle, $chunk['data']->bin);
}
return $written;
}
private function getChunks()
{
return $chunks = $this->gridfs->chunks->find(
['files_id' => $this->file['_id']],
['data' => 1],
['n' => 1]
);
}
}
Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/lib/Mongo/MongoId.php 0000664 0001750 0001750 00000013410 12741242607 025420 0 ustar jan jan createObjectID($id);
}
/**
* Check if a value is a valid ObjectId
*
* @link http://php.net/manual/en/mongoid.isvalid.php
* @param mixed $value The value to check for validity.
* @return bool
*/
public static function isValid($value)
{
if ($value instanceof ObjectID || $value instanceof MongoId) {
return true;
} elseif (! is_string($value)) {
return false;
}
return (bool) preg_match('#^[a-f0-9]{24}$#i', $value);
}
/**
* Returns a hexidecimal representation of this id
* @link http://www.php.net/manual/en/mongoid.tostring.php
* @return string
*/
public function __toString()
{
return (string) $this->objectID;
}
/**
* Converts this MongoId to the new BSON ObjectID type
*
* @return ObjectID
* @internal This method is not part of the ext-mongo API
*/
public function toBSONType()
{
return $this->objectID;
}
/**
* @param string $name
*
* @return null|string
*/
public function __get($name)
{
if ($name === '$id') {
return (string) $this->objectID;
}
return null;
}
/**
* @param string $name
* @param mixed $value
*/
public function __set($name, $value)
{
if ($name === 'id') {
trigger_error("The '\$id' property is read-only", E_DEPRECATED);
return;
}
}
/**
* @param string $name
* @return bool
*/
public function __isset($name)
{
return $name === 'id';
}
/**
* @param string $name
*/
public function __unset($name)
{
if ($name === 'id') {
trigger_error("The '\$id' property is read-only", E_DEPRECATED);
return;
}
}
/**
* @return string
*/
public function serialize()
{
return (string) $this->objectID;
}
/**
* @param string $serialized
*/
public function unserialize($serialized)
{
$this->createObjectID($serialized);
}
/**
* Gets the incremented value to create this id
* @link http://php.net/manual/en/mongoid.getinc.php
* @return int Returns the incremented value used to create this MongoId.
*/
public function getInc()
{
return hexdec(substr((string) $this->objectID, -6));
}
/**
* (PECL mongo >= 1.0.11)
* Gets the process ID
* @link http://php.net/manual/en/mongoid.getpid.php
* @return int Returns the PID of the MongoId.
*/
public function getPID()
{
$id = (string) $this->objectID;
// PID is stored as little-endian, flip it around
$pid = substr($id, 16, 2) . substr($id, 14, 2);
return hexdec($pid);
}
/**
* (PECL mongo >= 1.0.1)
* Gets the number of seconds since the epoch that this id was created
* @link http://www.php.net/manual/en/mongoid.gettimestamp.php
* @return int
*/
public function getTimestamp()
{
return hexdec(substr((string) $this->objectID, 0, 8));
}
/**
* Gets the hostname being used for this machine's ids
* @link http://www.php.net/manual/en/mongoid.gethostname.php
* @return string
*/
public static function getHostname()
{
return gethostname();
}
/**
* (PECL mongo >= 1.0.8)
* Create a dummy MongoId
* @link http://php.net/manual/en/mongoid.set-state.php
* @param array $props
Theoretically, an array of properties used to create the new id. However, as MongoId instances have no properties, this is not used.
* @return MongoId A new id with the value "000000000000000000000000".
*/
public static function __set_state(array $props)
{
}
/**
* @param $id
* @throws MongoException
*/
private function createObjectID($id)
{
try {
if (is_string($id)) {
$this->objectID = new ObjectID($id);
} elseif ($id instanceof self || $id instanceof ObjectID) {
$this->objectID = new ObjectID((string) $id);
} else {
$this->objectID = new ObjectId();
}
} catch (\Exception $e) {
throw new MongoException('Invalid object ID', 19);
}
}
}
Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/lib/Mongo/MongoInsertBatch.php 0000664 0001750 0001750 00000002711 12741242607 027274 0 ustar jan jan value = (string) $value;
}
/**
* @return string
*/
public function __toString()
{
return (string) $this->value;
}
/**
* Converts this MongoInt32 to a native integer
*
* @return int
* @internal This method is not part of the ext-mongo API
*/
public function toBSONType()
{
return (int) $this->value;
}
}
Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/lib/Mongo/MongoInt64.php 0000664 0001750 0001750 00000003263 12741242607 025775 0 ustar jan jan value = (string) $value;
}
/**
* @return string
*/
public function __toString()
{
return (string) $this->value;
}
/**
* Converts this MongoInt64 to a native integer
*
* @return int
* @internal This method is not part of the ext-mongo API
*/
public function toBSONType()
{
return (int) $this->value;
}
}
Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/lib/Mongo/MongoLog.php 0000664 0001750 0001750 00000013033 12741242607 025606 0 ustar jan jan
*
* This function will set a callback function to be called for {@link http://www.php.net/manual/en/class.mongolog.php MongoLog} events
* instead of triggering warnings.
*
One of the {@link http://www.php.net/manual/en/class.mongolog.php#mongolog.constants.module MongoLog module constants}.
*
*
* level
*
*
One of the {@link http://www.php.net/manual/en/class.mongolog.php#mongolog.constants.level MongoLog level constants}.
*
* message
*
*
The log message itself.
*
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public static function setCallback(callable $log_function )
{
self::$callback = $log_function;
return true;
}
/**
* This function can be used to set how verbose logging should be and the types of
* activities that should be logged. Use the constants described in the MongoLog
* section with bitwise operators to specify levels.
*
* @link http://php.net/manual/en/mongolog.setlevel.php
* @static
* @param int $level The levels you would like to log
* @return void
*/
public static function setLevel($level)
{
self::$level = $level;
}
/**
* This can be used to see the log level. Use the constants described in the
* MongoLog section with bitwise operators to check the level.
*
* @link http://php.net/manual/en/mongolog.getlevel.php
* @static
* @return int Returns the current level
*/
public static function getLevel()
{
return self::$level;
}
/**
* This function can be used to set which parts of the driver's functionality
* should be logged. Use the constants described in the MongoLog section with
* bitwise operators to specify modules.
*
* @link http://php.net/manual/en/mongolog.setmodule.php
* @static
* @param int $module The module(s) you would like to log
* @return void
*/
public static function setModule($module)
{
self::$module = $module;
}
/**
* This function can be used to see which parts of the driver's functionality are
* being logged. Use the constants described in the MongoLog section with bitwise
* operators to check if specific modules are being logged.
*
* @link http://php.net/manual/en/mongolog.getmodule.php
* @static
* @return int Returns the modules currently being logged
*/
public static function getModule()
{
return self::$module;
}
}
Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/lib/Mongo/MongoMaxKey.php 0000664 0001750 0001750 00000002264 12741242607 026267 0 ustar jan jan (PECL mongo >= 1.5.0)
*/
class MongoProtocolException extends MongoException {}
Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/lib/Mongo/MongoRegex.php 0000664 0001750 0001750 00000004305 12741242607 026141 0 ustar jan jan regex = $regex->getPattern();
$this->flags = $regex->getFlags();
return;
}
if (! preg_match('#^/(.*)/([imxslu]*)$#', $regex, $matches)) {
throw new MongoException('invalid regex', 9);
}
$this->regex = $matches[1];
$this->flags = $matches[2];
}
/**
* Returns a string representation of this regular expression.
* @return string This regular expression in the form "/expr/flags".
*/
public function __toString()
{
return '/' . $this->regex . '/' . $this->flags;
}
/**
* Converts this MongoRegex to the new BSON Regex type
*
* @return Regex
* @internal This method is not part of the ext-mongo API
*/
public function toBSONType()
{
return new Regex($this->regex, $this->flags);
}
}
Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/lib/Mongo/MongoResultException.php 0000664 0001750 0001750 00000002545 12741242607 030230 0 ustar jan jan (PECL mongo >= 1.3.0)
* @link http://php.net/manual/en/class.mongoresultexception.php#mongoresultexception.props.document
*
*/
class MongoResultException extends MongoException {
/**
* Retrieve the full result document
* http://php.net/manual/en/mongoresultexception.getdocument.php
* @return array
The full result document as an array, including partial data if available and additional keys.
*/
public function getDocument () {}
public $document;
}
Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/lib/Mongo/MongoTimestamp.php 0000664 0001750 0001750 00000005440 12741242607 027033 0 ustar jan jan :]
$parts = explode(':', substr((string) $sec, 1, -1));
$this->sec = (int) $parts[1];
$this->inc = (int) $parts[0];
return;
}
if (func_num_args() == 0) {
$sec = time();
}
if (func_num_args() <= 1) {
$inc = static::$globalInc;
static::$globalInc++;
}
$this->sec = (int) $sec;
$this->inc = (int) $inc;
}
/**
* @return string
*/
public function __toString()
{
return (string) $this->sec;
}
/**
* Converts this MongoTimestamp to the new BSON Timestamp type
*
* @return Timestamp
* @internal This method is not part of the ext-mongo API
*/
public function toBSONType()
{
return new Timestamp($this->inc, $this->sec);
}
}
Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/lib/Mongo/MongoUpdateBatch.php 0000664 0001750 0001750 00000002711 12741242607 027252 0 ustar jan jan collection = $collection;
$this->batchType = $batchType;
$this->writeOptions = $writeOptions;
}
/**
* Adds a write operation to a batch
*
* @see http://php.net/manual/en/mongowritebatch.add.php
* @param array|object $item
* @return boolean
*/
public function add($item)
{
if (is_object($item)) {
$item = (array)$item;
}
$this->validate($item);
$this->addItem($item);
return true;
}
/**
* Executes a batch of write operations
*
* @see http://php.net/manual/en/mongowritebatch.execute.php
* @param array $writeOptions
* @return array
*/
final public function execute(array $writeOptions = [])
{
$writeOptions += $this->writeOptions;
if (! count($this->items)) {
return ['ok' => true];
}
if (isset($writeOptions['j'])) {
trigger_error('j parameter is not supported', E_WARNING);
}
if (isset($writeOptions['fsync'])) {
trigger_error('fsync parameter is not supported', E_WARNING);
}
$options['writeConcern'] = $this->createWriteConcernFromArray($writeOptions);
if (isset($writeOptions['ordered'])) {
$options['ordered'] = $writeOptions['ordered'];
}
$collection = $this->collection->getCollection();
try {
$result = $collection->BulkWrite($this->items, $options);
$ok = true;
} catch (\MongoDB\Driver\Exception\BulkWriteException $e) {
$result = $e->getWriteResult();
$ok = false;
}
if ($ok === true) {
$this->items = [];
}
switch ($this->batchType) {
case self::COMMAND_UPDATE:
$upsertedIds = [];
foreach ($result->getUpsertedIds() as $index => $id) {
$upsertedIds[] = [
'index' => $index,
'_id' => TypeConverter::toLegacy($id)
];
}
$result = [
'nMatched' => $result->getMatchedCount(),
'nModified' => $result->getModifiedCount(),
'nUpserted' => $result->getUpsertedCount(),
'ok' => $ok,
];
if (count($upsertedIds)) {
$result['upserted'] = $upsertedIds;
}
return $result;
case self::COMMAND_DELETE:
return [
'nRemoved' => $result->getDeletedCount(),
'ok' => $ok,
];
case self::COMMAND_INSERT:
return [
'nInserted' => $result->getInsertedCount(),
'ok' => $ok,
];
}
}
private function validate(array $item)
{
switch ($this->batchType) {
case self::COMMAND_UPDATE:
if (! isset($item['q'])) {
throw new Exception("Expected \$item to contain 'q' key");
}
if (! isset($item['u'])) {
throw new Exception("Expected \$item to contain 'u' key");
}
break;
case self::COMMAND_DELETE:
if (! isset($item['q'])) {
throw new Exception("Expected \$item to contain 'q' key");
}
if (! isset($item['limit'])) {
throw new Exception("Expected \$item to contain 'limit' key");
}
break;
}
}
private function addItem(array $item)
{
switch ($this->batchType) {
case self::COMMAND_UPDATE:
$method = isset($item['multi']) ? 'updateMany' : 'updateOne';
$options = [];
if (isset($item['upsert']) && $item['upsert']) {
$options['upsert'] = true;
}
$this->items[] = [$method => [TypeConverter::fromLegacy($item['q']), TypeConverter::fromLegacy($item['u']), $options]];
break;
case self::COMMAND_INSERT:
$this->items[] = ['insertOne' => [TypeConverter::fromLegacy($item)]];
break;
case self::COMMAND_DELETE:
$method = $item['limit'] === 0 ? 'deleteMany' : 'deleteOne';
$this->items[] = [$method => [TypeConverter::fromLegacy($item['q'])]];
break;
}
}
}
Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/lib/Mongo/MongoWriteConcernException.php 0000664 0001750 0001750 00000002456 12741242607 031355 0 ustar jan jan (PECL mongo >= 1.5.0)
* @link http://php.net/manual/en/class.mongowriteconcernexception.php#class.mongowriteconcernexception
*/
class MongoWriteConcernException extends MongoCursorException {
/**
* Get the error document
* @link http://php.net/manual/en/mongowriteconcernexception.getdocument.php
* @return array
A MongoDB document, if available, as an array.
*/
public function getDocument() {}
}
Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/.gitignore 0000664 0001750 0001750 00000000045 12741242607 023516 0 ustar jan jan composer.lock
vendor/
tests/scripts/
Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/.scrutinizer.yml 0000664 0001750 0001750 00000000145 12741242607 024711 0 ustar jan jan imports:
- php
tools:
external_code_coverage:
timeout: 1200 # Timeout in seconds. Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/.travis.yml 0000664 0001750 0001750 00000001261 12741242607 023640 0 ustar jan jan sudo: false
language: php
php:
- 5.5
- 5.6
- 7.0
env:
- DRIVER_VERSION=stable
matrix:
include:
- php: 5.6
env: DRIVER_VERSION=stable LEGACY_DRIVER_VERSION=stable
addons:
apt:
sources:
- mongodb-3.2-precise
packages:
- mongodb-org-server
before_script:
- pecl install -f mongodb-${DRIVER_VERSION}
- composer install
- if [ "x$LEGACY_DRIVER_VERSION" != "x" ]; then yes '' | pecl -q install -f mongo-${LEGACY_DRIVER_VERSION}; fi
script:
- ./vendor/bin/phpunit --coverage-clover=coverage.clover
after_script:
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover
Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/CHANGELOG-1.0.md 0000664 0001750 0001750 00000011713 12741242607 023637 0 ustar jan jan CHANGELOG
=========
This changelog references the relevant changes done in minor version updates.
1.0.4 (2016-06-22)
------------------
All issues and pull requests under this release may be found under the
[1.0.4](https://github.com/alcaeus/mongo-php-adapter/issues?q=milestone%3A1.0.4)
milestone.
* [#115](https://github.com/alcaeus/mongo-php-adapter/pull/115) fixes an error
where using the alternate syntax for `MongoCollection::aggregate` would lead to
empty aggregation pipelines
* [#116](https://github.com/alcaeus/mongo-php-adapter/pull/116) fixes a bug
where read preference and write concern was not applied if it was passed in the
constructor.
1.0.3 (2016-04-13)
------------------
All issues and pull requests under this release may be found under the
[1.0.3](https://github.com/alcaeus/mongo-php-adapter/issues?q=milestone%3A1.0.3)
milestone.
* [#96](https://github.com/alcaeus/mongo-php-adapter/pull/96) fixes errors when
calling `count` on a cursor that has been iterated fully. The fix removes a
performance improvement when calling `count` on a cursor that has been opened.
`MongoCursor::count` now always re-issues a `count` command to the server.
* [#98](https://github.com/alcaeus/mongo-php-adapter/pull/98) fixes an error
where using BSON types in a query projection would result in wrong results.
* [#99](https://github.com/alcaeus/mongo-php-adapter/pull/99) ensures that the
`sec` and `usec` properties for `MongoDate` are cast to int.
1.0.2 (2016-04-08)
------------------
All issues and pull requests under this release may be found under the
[1.0.2](https://github.com/alcaeus/mongo-php-adapter/issues?q=milestone%3A1.0.2)
milestone.
* [#90](https://github.com/alcaeus/mongo-php-adapter/pull/90) ensures that database
and collection names are properly cast to string on creation.
* [#94](https://github.com/alcaeus/mongo-php-adapter/pull/94) fixes an error in
`MongoCursor::hasNext` that led to wrong data being returned.
1.0.1 (2016-04-01)
------------------
All issues and pull requests under this release may be found under the
[1.0.1](https://github.com/alcaeus/mongo-php-adapter/issues?q=milestone%3A1.0.1)
milestone.
* [#85](https://github.com/alcaeus/mongo-php-adapter/pull/85) fixes calls to
`MongoCollection::count` using the legacy syntax of providing `skip` and `limit`
arguments instead of an `options` array.
* [#88](https://github.com/alcaeus/mongo-php-adapter/pull/88) fixes an error
where a call to `MongoCollection::distinct` with a query did not convert legacy
BSON types to the new driver types.
1.0.0 (2016-03-18)
------------------
All issues and pull requests under this release may be found under the
[1.0.0](https://github.com/alcaeus/mongo-php-adapter/issues?q=milestone%3A1.0.0)
milestone.
* [#74](https://github.com/alcaeus/mongo-php-adapter/pull/74) fixes running an
aggregation command and returning a result document instead of a result cursor.
This bug was fixed in the underlying mongo-php-library.
* [#71](https://github.com/alcaeus/mongo-php-adapter/pull/71) adds checks to
all class files to prevent class declarations when `ext-mongo` is already
loaded and not using an autoloader.
* [#72](https://github.com/alcaeus/mongo-php-adapter/pull/72) fixes wrong
argument order in the constructor for the `Timestamp` type.
* [#75](https://github.com/alcaeus/mongo-php-adapter/pull/75) adds a warning to
`MongoCursor::timeout` to let people now cursor timeouts are no longer supported.
* [#77](https://github.com/alcaeus/mongo-php-adapter/pull/77) adds support for
the `update` option in `findAndModify` calls.
1.0.0-BETA1 (2016-02-17)
------------------------
All issues and pull requests under this release may be found under the
[1.0.0-BETA1](https://github.com/alcaeus/mongo-php-adapter/issues?q=milestone%3A1.0.0-BETA1)
milestone.
* [#52](https://github.com/alcaeus/mongo-php-adapter/pull/52) fixes behavior of
`MongoCollection::update` when no update operators have been given.
* [#53](https://github.com/alcaeus/mongo-php-adapter/pull/53) fixes an error
where some operations would send an invalid query to the MongoDB server,
causing command failures.
* [#54](https://github.com/alcaeus/mongo-php-adapter/pull/54) and
[#55](https://github.com/alcaeus/mongo-php-adapter/pull/55) fix the handling of
documents with numeric keys.
* [#56](https://github.com/alcaeus/mongo-php-adapter/pull/56) fixes the
behavior of `MongoGridFS::findOne` when no results are found.
* [#59](https://github.com/alcaeus/mongo-php-adapter/pull/59) adds handling for
the `includeSystemCollections` parameter in `MongoDB::getCollectionInfo` and
`MongoDB::getCollectionNames`.
* [#62](https://github.com/alcaeus/mongo-php-adapter/pull/62) removes the
manual comparison of index options to rely on the MongoDB server to decide
whether an index already exists.
* [#63](https://github.com/alcaeus/mongo-php-adapter/pull/63) prevents
serialization of driver classes which are not serializable.
0.1.0 (2016-02-06)
------------------
Initial development release.
Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/LICENSE 0000664 0001750 0001750 00000002033 12741242607 022532 0 ustar jan jan Copyright (c) 2015 alcaeus
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/phpunit.xml.dist 0000664 0001750 0001750 00000001533 12741242607 024704 0 ustar jan jan
./tests/Alcaeus/MongoDbAdapter/./lib/Alcaeus/MongoDbAdapter
Horde_Mongo-1.1.0/bundle/vendor/alcaeus/mongo-php-adapter/README.md 0000664 0001750 0001750 00000014456 12741242607 023020 0 ustar jan jan # Mongo PHP Adapter
[](https://travis-ci.org/alcaeus/mongo-php-adapter)
[](https://scrutinizer-ci.com/g/alcaeus/mongo-php-adapter/?branch=master)
[](https://scrutinizer-ci.com/g/alcaeus/mongo-php-adapter/?branch=master)
The Mongo PHP Adapter is a userland library designed to act as an adapter
between applications relying on ext-mongo and the new driver (`ext-mongodb`).
It provides the API of ext-mongo built on top of mongo-php-library, thus being
compatible with PHP 7.
# Goal
This library aims to provide a compatibility layer for applications that rely on
on libraries using ext-mongo (e.g. [Doctrine ODM](https://github.com/doctrine/mongodb-odm))
but want to migrate to PHP 7 or HHVM on which ext-mongo will not run.
You should not be using this library if you do not rely on a library using
`ext-mongo`. If you are starting a new project, please check out [mongodb/mongodb](https://github.com/mongodb/mongo-php-library).
# Installation
This library requires you to have the `mongodb` extension installed, and it
conflicts with the legacy `mongo` extension.
The preferred method of installing this library is with
[Composer](https://getcomposer.org/) by running the following from your project
root:
$ composer require alcaeus/mongo-php-adapter
This package declares that it provides `ext-mongo`; Composer only allows this
replacement to apply if `composer.json` or a dependency contain a requirement,
see [composer/composer#2690](https://github.com/composer/composer/issues/2690).
Therefore, you either need to have a dependency on a package which requires
`ext-mongo`, such as `doctrine/mongodb`, in your project:
"require": {
"php": "^7.0",
"alcaeus/mongo-php-adapter": "^1.0.0",
"doctrine/mongodb": "dev-master"
}
or you need to explicitly require `ext-mongo` yourself in `composer.json`:
"require": {
"php": "^7.0",
"alcaeus/mongo-php-adapter": "^1.0.0",
"ext-mongo": "*"
}
# Known issues
## Return values and exceptions
Some methods may not throw exceptions with the same exception messages as their
counterparts in `ext-mongo`. Do not rely on exception messages being the same.
Methods that return a result array containing a `connectionId` field will always
return `0` as connection ID.
## Serialization of objects
Serialization of any Mongo* objects (e.g. MongoGridFSFile, MongoCursor, etc.)
will not work properly. The objects can be serialized but are not usable after
unserializing them.
## Mongo
- The Mongo class is deprecated and was not implemented in this library. If you
are still using it please update your code to use the new classes.
## MongoLog
- The [MongoLog](http://php.net/manual/en/class.mongolog.php) class does not
log anything because the underlying driver does not offer a method to retrieve
this data.
## MongoClient
- The [connect](https://php.net/manual/en/mongoclient.connect.php) and
[close](https://secure.php.net/manual/en/mongoclient.close.php) methods are not
implemented because the underlying driver connects lazily and does not offer
methods for connecting disconnecting.
- The [getConnections](https://secure.php.net/manual/en/mongoclient.getconnections.php)
method is not implemented because the underlying driver does not offer a method
to retrieve this data.
- The [killCursor](https://php.net/manual/en/mongoclient.killcursor.php) method
is not yet implemented.
## MongoDB
- The [authenticate](https://secure.php.net/manual/en/mongodb.authenticate.php)
method is not supported. To connect to a database with authentication, please
supply the credentials using the connection string.
- The `$cmd` collection cannot be used due to an issue in the underlying driver.
To run commands, use the [command](https://secure.php.net/manual/en/mongodb.command.php)
method instead of querying the virtual `$cmd` collection.
## MongoCollection
- The [insert](https://php.net/manual/en/mongocollection.insert.php),
[batchInsert](https://php.net/manual/en/mongocollection.batchinsert.php),
and [save](https://php.net/manual/en/mongocollection.save.php)
methods take the first argument by reference. While the original API does not
explicitely specify by-reference arguments it does add an ID field to the
objects and documents given.
- The [parallelCollectionScan](https://php.net/manual/en/mongocollection.parallelcollectionscan.php)
method is not yet implemented.
## MongoCursor
- The [explain](https://php.net/manual/en/mongocursor.explain.php)
method is not yet implemented.
- The [info](https://php.net/manual/en/mongocursor.info.php) method does not
reliably fill all fields in the cursor information. This includes the `numReturned`
and `server` keys once the cursor has started iterating. The `numReturned` field
will always show the same value as the `at` field. The `server` field is lacking
authentication information.
- The [setFlag](https://php.net/manual/en/mongocursor.setflag.php)
method is not yet implemented.
- The [timeout](https://php.net/manual/en/mongocursor.timeout.php) method will
not change any query options. Client-side timeouts are no longer supported by
the new driver. Use the maxTimeMS setting as a replacement.
## MongoCommandCursor
- The [createFromDocument](https://php.net/manual/en/mongocommandcursor.createfromdocument.php)
method is not yet implemented.
- The [info](https://php.net/manual/en/mongocommandcursor.info.php) method does not
reliably fill all fields in the cursor information. This includes the `at`, `numReturned`,
`firstBatchAt` and `firstBatchNumReturned` fields. The `at` and `numReturned`
fields always return 0 for compatibility to MongoCursor. The `firstBatchAt` and
`firstBatchNumReturned` fields will contain the same value, which is the internal
position of the iterator.
## Types
- Return values containing objects of the [MongoDB\BSON\Javascript](https://secure.php.net/manual/en/class.mongodb-bson-javascript.php)
class cannot be converted to full [MongoCode](https://secure.php.net/manual/en/class.mongocode.php)
objects because there are no accessors for the code and scope properties.
Horde_Mongo-1.1.0/bundle/vendor/composer/autoload_classmap.php 0000664 0001750 0001750 00000000223 12741242607 022620 0 ustar jan jan $vendorDir . '/mongodb/mongodb/src/functions.php',
'06dd8487319ccd8403765f5b8c9f2d61' => $vendorDir . '/alcaeus/mongo-php-adapter/lib/Mongo/functions.php',
);
Horde_Mongo-1.1.0/bundle/vendor/composer/autoload_namespaces.php 0000664 0001750 0001750 00000000340 12741242607 023134 0 ustar jan jan array($vendorDir . '/alcaeus/mongo-php-adapter/lib/Mongo'),
);
Horde_Mongo-1.1.0/bundle/vendor/composer/autoload_psr4.php 0000664 0001750 0001750 00000000476 12741242607 021717 0 ustar jan jan array($vendorDir . '/mongodb/mongodb/src'),
'Alcaeus\\MongoDbAdapter\\' => array($vendorDir . '/alcaeus/mongo-php-adapter/lib/Alcaeus/MongoDbAdapter'),
);
Horde_Mongo-1.1.0/bundle/vendor/composer/autoload_real.php 0000664 0001750 0001750 00000004435 12741242607 021751 0 ustar jan jan = 50600 && !defined('HHVM_VERSION');
if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitd157e7b9843335f19d9ccdcdfe10d606::getInitializer($loader));
} else {
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
$loader->set($namespace, $path);
}
$map = require __DIR__ . '/autoload_psr4.php';
foreach ($map as $namespace => $path) {
$loader->setPsr4($namespace, $path);
}
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
$loader->addClassMap($classMap);
}
}
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInitd157e7b9843335f19d9ccdcdfe10d606::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequired157e7b9843335f19d9ccdcdfe10d606($fileIdentifier, $file);
}
return $loader;
}
}
function composerRequired157e7b9843335f19d9ccdcdfe10d606($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
}
}
Horde_Mongo-1.1.0/bundle/vendor/composer/autoload_static.php 0000664 0001750 0001750 00000003211 12741242607 022304 0 ustar jan jan __DIR__ . '/..' . '/mongodb/mongodb/src/functions.php',
'06dd8487319ccd8403765f5b8c9f2d61' => __DIR__ . '/..' . '/alcaeus/mongo-php-adapter/lib/Mongo/functions.php',
);
public static $prefixLengthsPsr4 = array (
'M' =>
array (
'MongoDB\\' => 8,
),
'A' =>
array (
'Alcaeus\\MongoDbAdapter\\' => 23,
),
);
public static $prefixDirsPsr4 = array (
'MongoDB\\' =>
array (
0 => __DIR__ . '/..' . '/mongodb/mongodb/src',
),
'Alcaeus\\MongoDbAdapter\\' =>
array (
0 => __DIR__ . '/..' . '/alcaeus/mongo-php-adapter/lib/Alcaeus/MongoDbAdapter',
),
);
public static $prefixesPsr0 = array (
'M' =>
array (
'Mongo' =>
array (
0 => __DIR__ . '/..' . '/alcaeus/mongo-php-adapter/lib/Mongo',
),
),
);
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitd157e7b9843335f19d9ccdcdfe10d606::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitd157e7b9843335f19d9ccdcdfe10d606::$prefixDirsPsr4;
$loader->prefixesPsr0 = ComposerStaticInitd157e7b9843335f19d9ccdcdfe10d606::$prefixesPsr0;
}, null, ClassLoader::class);
}
}
Horde_Mongo-1.1.0/bundle/vendor/composer/ClassLoader.php 0000664 0001750 0001750 00000030262 12741242607 021327 0 ustar jan jan
* Jordi Boggiano
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Autoload;
/**
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
*
* $loader = new \Composer\Autoload\ClassLoader();
*
* // register classes with namespaces
* $loader->add('Symfony\Component', __DIR__.'/component');
* $loader->add('Symfony', __DIR__.'/framework');
*
* // activate the autoloader
* $loader->register();
*
* // to enable searching the include path (eg. for PEAR packages)
* $loader->setUseIncludePath(true);
*
* In this example, if you try to use a class in the Symfony\Component
* namespace or one of its children (Symfony\Component\Console for instance),
* the autoloader will first look for the class under the component/
* directory, and it will then fallback to the framework/ directory if not
* found before giving up.
*
* This class is loosely based on the Symfony UniversalClassLoader.
*
* @author Fabien Potencier
* @author Jordi Boggiano
* @see http://www.php-fig.org/psr/psr-0/
* @see http://www.php-fig.org/psr/psr-4/
*/
class ClassLoader
{
// PSR-4
private $prefixLengthsPsr4 = array();
private $prefixDirsPsr4 = array();
private $fallbackDirsPsr4 = array();
// PSR-0
private $prefixesPsr0 = array();
private $fallbackDirsPsr0 = array();
private $useIncludePath = false;
private $classMap = array();
private $classMapAuthoritative = false;
public function getPrefixes()
{
if (!empty($this->prefixesPsr0)) {
return call_user_func_array('array_merge', $this->prefixesPsr0);
}
return array();
}
public function getPrefixesPsr4()
{
return $this->prefixDirsPsr4;
}
public function getFallbackDirs()
{
return $this->fallbackDirsPsr0;
}
public function getFallbackDirsPsr4()
{
return $this->fallbackDirsPsr4;
}
public function getClassMap()
{
return $this->classMap;
}
/**
* @param array $classMap Class to filename map
*/
public function addClassMap(array $classMap)
{
if ($this->classMap) {
$this->classMap = array_merge($this->classMap, $classMap);
} else {
$this->classMap = $classMap;
}
}
/**
* Registers a set of PSR-0 directories for a given prefix, either
* appending or prepending to the ones previously set for this prefix.
*
* @param string $prefix The prefix
* @param array|string $paths The PSR-0 root directories
* @param bool $prepend Whether to prepend the directories
*/
public function add($prefix, $paths, $prepend = false)
{
if (!$prefix) {
if ($prepend) {
$this->fallbackDirsPsr0 = array_merge(
(array) $paths,
$this->fallbackDirsPsr0
);
} else {
$this->fallbackDirsPsr0 = array_merge(
$this->fallbackDirsPsr0,
(array) $paths
);
}
return;
}
$first = $prefix[0];
if (!isset($this->prefixesPsr0[$first][$prefix])) {
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
return;
}
if ($prepend) {
$this->prefixesPsr0[$first][$prefix] = array_merge(
(array) $paths,
$this->prefixesPsr0[$first][$prefix]
);
} else {
$this->prefixesPsr0[$first][$prefix] = array_merge(
$this->prefixesPsr0[$first][$prefix],
(array) $paths
);
}
}
/**
* Registers a set of PSR-4 directories for a given namespace, either
* appending or prepending to the ones previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param array|string $paths The PSR-4 base directories
* @param bool $prepend Whether to prepend the directories
*
* @throws \InvalidArgumentException
*/
public function addPsr4($prefix, $paths, $prepend = false)
{
if (!$prefix) {
// Register directories for the root namespace.
if ($prepend) {
$this->fallbackDirsPsr4 = array_merge(
(array) $paths,
$this->fallbackDirsPsr4
);
} else {
$this->fallbackDirsPsr4 = array_merge(
$this->fallbackDirsPsr4,
(array) $paths
);
}
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
// Register directories for a new namespace.
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
} elseif ($prepend) {
// Prepend directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
(array) $paths,
$this->prefixDirsPsr4[$prefix]
);
} else {
// Append directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
$this->prefixDirsPsr4[$prefix],
(array) $paths
);
}
}
/**
* Registers a set of PSR-0 directories for a given prefix,
* replacing any others previously set for this prefix.
*
* @param string $prefix The prefix
* @param array|string $paths The PSR-0 base directories
*/
public function set($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr0 = (array) $paths;
} else {
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
}
}
/**
* Registers a set of PSR-4 directories for a given namespace,
* replacing any others previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param array|string $paths The PSR-4 base directories
*
* @throws \InvalidArgumentException
*/
public function setPsr4($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr4 = (array) $paths;
} else {
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
}
}
/**
* Turns on searching the include path for class files.
*
* @param bool $useIncludePath
*/
public function setUseIncludePath($useIncludePath)
{
$this->useIncludePath = $useIncludePath;
}
/**
* Can be used to check if the autoloader uses the include path to check
* for classes.
*
* @return bool
*/
public function getUseIncludePath()
{
return $this->useIncludePath;
}
/**
* Turns off searching the prefix and fallback directories for classes
* that have not been registered with the class map.
*
* @param bool $classMapAuthoritative
*/
public function setClassMapAuthoritative($classMapAuthoritative)
{
$this->classMapAuthoritative = $classMapAuthoritative;
}
/**
* Should class lookup fail if not found in the current class map?
*
* @return bool
*/
public function isClassMapAuthoritative()
{
return $this->classMapAuthoritative;
}
/**
* Registers this instance as an autoloader.
*
* @param bool $prepend Whether to prepend the autoloader or not
*/
public function register($prepend = false)
{
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
}
/**
* Unregisters this instance as an autoloader.
*/
public function unregister()
{
spl_autoload_unregister(array($this, 'loadClass'));
}
/**
* Loads the given class or interface.
*
* @param string $class The name of the class
* @return bool|null True if loaded, null otherwise
*/
public function loadClass($class)
{
if ($file = $this->findFile($class)) {
includeFile($file);
return true;
}
}
/**
* Finds the path to the file where the class is defined.
*
* @param string $class The name of the class
*
* @return string|false The path if found, false otherwise
*/
public function findFile($class)
{
// work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731
if ('\\' == $class[0]) {
$class = substr($class, 1);
}
// class map lookup
if (isset($this->classMap[$class])) {
return $this->classMap[$class];
}
if ($this->classMapAuthoritative) {
return false;
}
$file = $this->findFileWithExtension($class, '.php');
// Search for Hack files if we are running on HHVM
if ($file === null && defined('HHVM_VERSION')) {
$file = $this->findFileWithExtension($class, '.hh');
}
if ($file === null) {
// Remember that this class does not exist.
return $this->classMap[$class] = false;
}
return $file;
}
private function findFileWithExtension($class, $ext)
{
// PSR-4 lookup
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
$first = $class[0];
if (isset($this->prefixLengthsPsr4[$first])) {
foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) {
if (0 === strpos($class, $prefix)) {
foreach ($this->prefixDirsPsr4[$prefix] as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
return $file;
}
}
}
}
}
// PSR-4 fallback dirs
foreach ($this->fallbackDirsPsr4 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
return $file;
}
}
// PSR-0 lookup
if (false !== $pos = strrpos($class, '\\')) {
// namespaced class name
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
} else {
// PEAR-like class name
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
}
if (isset($this->prefixesPsr0[$first])) {
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
if (0 === strpos($class, $prefix)) {
foreach ($dirs as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
}
}
}
// PSR-0 fallback dirs
foreach ($this->fallbackDirsPsr0 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
// PSR-0 include paths.
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
return $file;
}
}
}
/**
* Scope isolated include.
*
* Prevents access to $this/self from included files.
*/
function includeFile($file)
{
include $file;
}
Horde_Mongo-1.1.0/bundle/vendor/composer/installed.json 0000664 0001750 0001750 00000007142 12741242607 021275 0 ustar jan jan [
{
"name": "mongodb/mongodb",
"version": "1.0.2",
"version_normalized": "1.0.2.0",
"source": {
"type": "git",
"url": "https://github.com/mongodb/mongo-php-library.git",
"reference": "faf8a1d86b5c10684ef91fa6c81475b0c7f95240"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/mongodb/mongo-php-library/zipball/faf8a1d86b5c10684ef91fa6c81475b0c7f95240",
"reference": "faf8a1d86b5c10684ef91fa6c81475b0c7f95240",
"shasum": ""
},
"require": {
"ext-mongodb": "^1.1.0",
"php": ">=5.4"
},
"time": "2016-03-30 19:10:28",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-4": {
"MongoDB\\": "src/"
},
"files": [
"src/functions.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Apache-2.0"
],
"authors": [
{
"name": "Jeremy Mikola",
"email": "jmikola@gmail.com"
},
{
"name": "Hannes Magnusson",
"email": "bjori@mongodb.com"
},
{
"name": "Derick Rethans",
"email": "github@derickrethans.nl"
}
],
"description": "MongoDB driver library",
"homepage": "https://jira.mongodb.org/browse/PHPLIB",
"keywords": [
"database",
"driver",
"mongodb",
"persistence"
]
},
{
"name": "alcaeus/mongo-php-adapter",
"version": "1.0.4",
"version_normalized": "1.0.4.0",
"source": {
"type": "git",
"url": "https://github.com/alcaeus/mongo-php-adapter.git",
"reference": "92feaf5b6e368fbfefa7f53f41dd66f3f7963bd3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/alcaeus/mongo-php-adapter/zipball/92feaf5b6e368fbfefa7f53f41dd66f3f7963bd3",
"reference": "92feaf5b6e368fbfefa7f53f41dd66f3f7963bd3",
"shasum": ""
},
"require": {
"ext-hash": "*",
"mongodb/mongodb": "^1.0.1",
"php": "^5.5 || ^7.0"
},
"provide": {
"ext-mongo": "1.6.13"
},
"require-dev": {
"phpunit/phpunit": "^4.8 || ^5.0"
},
"time": "2016-06-22 05:14:23",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-0": {
"Mongo": "lib/Mongo"
},
"psr-4": {
"Alcaeus\\MongoDbAdapter\\": "lib/Alcaeus/MongoDbAdapter"
},
"files": [
"lib/Mongo/functions.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "alcaeus",
"email": "alcaeus@alcaeus.org"
},
{
"name": "Olivier Lechevalier",
"email": "olivier.lechevalier@gmail.com"
}
],
"description": "Adapter to provide ext-mongo interface on top of mongo-php-libary",
"keywords": [
"database",
"mongodb"
]
}
]
Horde_Mongo-1.1.0/bundle/vendor/composer/LICENSE 0000664 0001750 0001750 00000002063 12741242607 017425 0 ustar jan jan
Copyright (c) 2016 Nils Adermann, Jordi Boggiano
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/src/Exception/BadMethodCallException.php 0000664 0001750 0001750 00000001362 12741242607 027404 0 ustar jan jan exchangeArray($properties);
return $array;
}
/**
* Serialize the array to BSON.
*
* The array data will be numerically reindexed to ensure that it is stored
* as a BSON array.
*
* @see http://php.net/mongodb-bson-serializable.bsonserialize
* @return array
*/
public function bsonSerialize()
{
return array_values($this->getArrayCopy());
}
/**
* Unserialize the document to BSON.
*
* @see http://php.net/mongodb-bson-unserializable.bsonunserialize
* @param array $data Array data
*/
public function bsonUnserialize(array $data)
{
self::__construct($data);
}
}
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/src/Model/BSONDocument.php 0000664 0001750 0001750 00000003241 12741242607 024442 0 ustar jan jan exchangeArray($properties);
return $document;
}
/**
* Serialize the document to BSON.
*
* @see http://php.net/mongodb-bson-serializable.bsonserialize
* @return object
*/
public function bsonSerialize()
{
return (object) $this->getArrayCopy();
}
/**
* Unserialize the document to BSON.
*
* @see http://php.net/mongodb-bson-unserializable.bsonunserialize
* @param array $data Array data
*/
public function bsonUnserialize(array $data)
{
parent::__construct($data, ArrayObject::ARRAY_AS_PROPS);
}
}
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/src/Model/CollectionInfo.php 0000664 0001750 0001750 00000003774 12741242607 025124 0 ustar jan jan info = $info;
}
/**
* Return the collection info as an array.
*
* @see http://php.net/oop5.magic#language.oop5.magic.debuginfo
* @return array
*/
public function __debugInfo()
{
return $this->info;
}
/**
* Return the maximum number of documents to keep in the capped collection.
*
* @return integer|null
*/
public function getCappedMax()
{
return isset($this->info['options']['max']) ? (integer) $this->info['options']['max'] : null;
}
/**
* Return the maximum size (in bytes) of the capped collection.
*
* @return integer|null
*/
public function getCappedSize()
{
return isset($this->info['options']['size']) ? (integer) $this->info['options']['size'] : null;
}
/**
* Return the collection name.
*
* @return string
*/
public function getName()
{
return (string) $this->info['name'];
}
/**
* Return the collection options.
*
* @return array
*/
public function getOptions()
{
return isset($this->info['options']) ? (array) $this->info['options'] : [];
}
/**
* Return whether the collection is a capped collection.
*
* @return boolean
*/
public function isCapped()
{
return ! empty($this->info['options']['capped']);
}
}
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/src/Model/CollectionInfoCommandIterator.php 0000664 0001750 0001750 00000001523 12741242607 030123 0 ustar jan jan info = $info;
}
/**
* Return the collection info as an array.
*
* @see http://php.net/oop5.magic#language.oop5.magic.debuginfo
* @return array
*/
public function __debugInfo()
{
return $this->info;
}
/**
* Return the database name.
*
* @return string
*/
public function getName()
{
return (string) $this->info['name'];
}
/**
* Return the databases size on disk (in bytes).
*
* @return integer
*/
public function getSizeOnDisk()
{
return (integer) $this->info['sizeOnDisk'];
}
/**
* Return whether the database is empty.
*
* @return boolean
*/
public function isEmpty()
{
return (boolean) $this->info['empty'];
}
}
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/src/Model/DatabaseInfoIterator.php 0000664 0001750 0001750 00000000625 12741242607 026237 0 ustar jan jan databases = $databases;
}
/**
* Return the current element as a DatabaseInfo instance.
*
* @see DatabaseInfoIterator::current()
* @see http://php.net/iterator.current
* @return DatabaseInfo
*/
public function current()
{
return new DatabaseInfo(current($this->databases));
}
/**
* Return the key of the current element.
*
* @see http://php.net/iterator.key
* @return integer
*/
public function key()
{
return key($this->databases);
}
/**
* Move forward to next element.
*
* @see http://php.net/iterator.next
*/
public function next()
{
next($this->databases);
}
/**
* Rewind the Iterator to the first element.
*
* @see http://php.net/iterator.rewind
*/
public function rewind()
{
reset($this->databases);
}
/**
* Checks if current position is valid.
*
* @see http://php.net/iterator.valid
* @return boolean
*/
public function valid()
{
return key($this->databases) !== null;
}
}
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/src/Model/IndexInfo.php 0000664 0001750 0001750 00000010007 12741242607 024063 0 ustar jan jan info = $info;
}
/**
* Return the collection info as an array.
*
* @see http://php.net/oop5.magic#language.oop5.magic.debuginfo
* @return array
*/
public function __debugInfo()
{
return $this->info;
}
/**
* Return the index key.
*
* @return array
*/
public function getKey()
{
return (array) $this->info['key'];
}
/**
* Return the index name.
*
* @return string
*/
public function getName()
{
return (string) $this->info['name'];
}
/**
* Return the index namespace (e.g. "db.collection").
*
* @return string
*/
public function getNamespace()
{
return (string) $this->info['ns'];
}
/**
* Return the index version.
*
* @return integer
*/
public function getVersion()
{
return (integer) $this->info['v'];
}
/**
* Return whether this is a sparse index.
*
* @see http://docs.mongodb.org/manual/core/index-sparse/
* @return boolean
*/
public function isSparse()
{
return ! empty($this->info['sparse']);
}
/**
* Return whether this is a TTL index.
*
* @see http://docs.mongodb.org/manual/core/index-ttl/
* @return boolean
*/
public function isTtl()
{
return array_key_exists('expireAfterSeconds', $this->info);
}
/**
* Return whether this is a unique index.
*
* @see http://docs.mongodb.org/manual/core/index-unique/
* @return boolean
*/
public function isUnique()
{
return ! empty($this->info['unique']);
}
/**
* Check whether a field exists in the index information.
*
* @see http://php.net/arrayaccess.offsetexists
* @param mixed $key
* @return boolean
*/
public function offsetExists($key)
{
return array_key_exists($key, $this->info);
}
/**
* Return the field's value from the index information.
*
* This method satisfies the Enumerating Indexes specification's requirement
* that index fields be made accessible under their original names. It may
* also be used to access fields that do not have a helper method.
*
* @see http://php.net/arrayaccess.offsetget
* @see https://github.com/mongodb/specifications/blob/master/source/enumerate-indexes.rst#getting-full-index-information
* @param mixed $key
* @return mixed
*/
public function offsetGet($key)
{
return $this->info[$key];
}
/**
* Not supported.
*
* @see http://php.net/arrayaccess.offsetset
* @throws BadMethodCallException
*/
public function offsetSet($key, $value)
{
throw BadMethodCallException::classIsImmutable(__CLASS__);
}
/**
* Not supported.
*
* @see http://php.net/arrayaccess.offsetunset
* @throws BadMethodCallException
*/
public function offsetUnset($key)
{
throw BadMethodCallException::classIsImmutable(__CLASS__);
}
}
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/src/Model/IndexInfoIterator.php 0000664 0001750 0001750 00000000615 12741242607 025601 0 ustar jan jan $order) {
if ( ! is_int($order) && ! is_float($order) && ! is_string($order)) {
throw InvalidArgumentException::invalidType(sprintf('order value for "%s" field within "key" option', $fieldName), $order, 'numeric or string');
}
}
if ( ! isset($index['ns'])) {
throw new InvalidArgumentException('Required "ns" option is missing from index specification');
}
if ( ! is_string($index['ns'])) {
throw InvalidArgumentException::invalidType('"ns" option', $index['ns'], 'string');
}
if ( ! isset($index['name'])) {
$index['name'] = \MongoDB\generate_index_name($index['key']);
}
if ( ! is_string($index['name'])) {
throw InvalidArgumentException::invalidType('"name" option', $index['name'], 'string');
}
$this->index = $index;
}
/**
* Return the index name.
*
* @param string
*/
public function __toString()
{
return $this->index['name'];
}
/**
* Serialize the index information to BSON for index creation.
*
* @see MongoDB\Collection::createIndexes()
* @see http://php.net/mongodb-bson-serializable.bsonserialize
* @return array
*/
public function bsonSerialize()
{
return $this->index;
}
}
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/src/Operation/Aggregate.php 0000664 0001750 0001750 00000021153 12741242607 024772 0 ustar jan jan = 2.6, this option allows users to turn off cursors if
* necessary to aid in mongod/mongos upgrades.
*
* @param string $databaseName Database name
* @param string $collectionName Collection name
* @param array $pipeline List of pipeline operations
* @param array $options Command options
* @throws InvalidArgumentException
*/
public function __construct($databaseName, $collectionName, array $pipeline, array $options = [])
{
if (empty($pipeline)) {
throw new InvalidArgumentException('$pipeline is empty');
}
$expectedIndex = 0;
foreach ($pipeline as $i => $operation) {
if ($i !== $expectedIndex) {
throw new InvalidArgumentException(sprintf('$pipeline is not a list (unexpected index: "%s")', $i));
}
if ( ! is_array($operation) && ! is_object($operation)) {
throw InvalidArgumentException::invalidType(sprintf('$pipeline[%d]', $i), $operation, 'array or object');
}
$expectedIndex += 1;
}
$options += [
'allowDiskUse' => false,
'useCursor' => true,
];
if ( ! is_bool($options['allowDiskUse'])) {
throw InvalidArgumentException::invalidType('"allowDiskUse" option', $options['allowDiskUse'], 'boolean');
}
if (isset($options['batchSize']) && ! is_integer($options['batchSize'])) {
throw InvalidArgumentException::invalidType('"batchSize" option', $options['batchSize'], 'integer');
}
if (isset($options['bypassDocumentValidation']) && ! is_bool($options['bypassDocumentValidation'])) {
throw InvalidArgumentException::invalidType('"bypassDocumentValidation" option', $options['bypassDocumentValidation'], 'boolean');
}
if (isset($options['maxTimeMS']) && ! is_integer($options['maxTimeMS'])) {
throw InvalidArgumentException::invalidType('"maxTimeMS" option', $options['maxTimeMS'], 'integer');
}
if (isset($options['readConcern']) && ! $options['readConcern'] instanceof ReadConcern) {
throw InvalidArgumentException::invalidType('"readConcern" option', $options['readConcern'], 'MongoDB\Driver\ReadConcern');
}
if (isset($options['readPreference']) && ! $options['readPreference'] instanceof ReadPreference) {
throw InvalidArgumentException::invalidType('"readPreference" option', $options['readPreference'], 'MongoDB\Driver\ReadPreference');
}
if (isset($options['typeMap']) && ! is_array($options['typeMap'])) {
throw InvalidArgumentException::invalidType('"typeMap" option', $options['typeMap'], 'array');
}
if ( ! is_bool($options['useCursor'])) {
throw InvalidArgumentException::invalidType('"useCursor" option', $options['useCursor'], 'boolean');
}
if (isset($options['batchSize']) && ! $options['useCursor']) {
throw new InvalidArgumentException('"batchSize" option should not be used if "useCursor" is false');
}
if (isset($options['typeMap']) && ! $options['useCursor']) {
throw new InvalidArgumentException('"typeMap" option should not be used if "useCursor" is false');
}
$this->databaseName = (string) $databaseName;
$this->collectionName = (string) $collectionName;
$this->pipeline = $pipeline;
$this->options = $options;
}
/**
* Execute the operation.
*
* @see Executable::execute()
* @param Server $server
* @return Traversable
* @throws UnexpectedValueException if the command response was malformed
*/
public function execute(Server $server)
{
$isCursorSupported = \MongoDB\server_supports_feature($server, self::$wireVersionForCursor);
$readPreference = isset($this->options['readPreference']) ? $this->options['readPreference'] : null;
$command = $this->createCommand($server, $isCursorSupported);
$cursor = $server->executeCommand($this->databaseName, $command, $readPreference);
if ($isCursorSupported && $this->options['useCursor']) {
/* The type map can only be applied to command cursors until
* https://jira.mongodb.org/browse/PHPC-314 is implemented.
*/
if (isset($this->options['typeMap'])) {
$cursor->setTypeMap($this->options['typeMap']);
}
return $cursor;
}
$result = current($cursor->toArray());
if ( ! isset($result->result) || ! is_array($result->result)) {
throw new UnexpectedValueException('aggregate command did not return a "result" array');
}
return new ArrayIterator($result->result);
}
/**
* Create the aggregate command.
*
* @param Server $server
* @param boolean $isCursorSupported
* @return Command
*/
private function createCommand(Server $server, $isCursorSupported)
{
$cmd = [
'aggregate' => $this->collectionName,
'pipeline' => $this->pipeline,
];
// Servers < 2.6 do not support any command options
if ( ! $isCursorSupported) {
return new Command($cmd);
}
$cmd['allowDiskUse'] = $this->options['allowDiskUse'];
if (isset($this->options['bypassDocumentValidation']) && \MongoDB\server_supports_feature($server, self::$wireVersionForDocumentLevelValidation)) {
$cmd['bypassDocumentValidation'] = $this->options['bypassDocumentValidation'];
}
if (isset($this->options['maxTimeMS'])) {
$cmd['maxTimeMS'] = $this->options['maxTimeMS'];
}
if (isset($this->options['readConcern']) && \MongoDB\server_supports_feature($server, self::$wireVersionForReadConcern)) {
$cmd['readConcern'] = \MongoDB\read_concern_as_document($this->options['readConcern']);
}
if ($this->options['useCursor']) {
$cmd['cursor'] = isset($this->options["batchSize"])
? ['batchSize' => $this->options["batchSize"]]
: new stdClass;
}
return new Command($cmd);
}
}
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/src/Operation/BulkWrite.php 0000664 0001750 0001750 00000023554 12741242607 025023 0 ustar jan jan [ $filter ] ],
* [ 'deleteOne' => [ $filter ] ],
* [ 'insertOne' => [ $document ] ],
* [ 'replaceOne' => [ $filter, $replacement, $options ] ],
* [ 'updateMany' => [ $filter, $update, $options ] ],
* [ 'updateOne' => [ $filter, $update, $options ] ],
* ]
*
* Arguments correspond to the respective Operation classes; however, the
* writeConcern option is specified for the top-level bulk write operation
* instead of each individual operation.
*
* Supported options for replaceOne, updateMany, and updateOne operations:
*
* * upsert (boolean): When true, a new document is created if no document
* matches the query. The default is false.
*
* Supported options for the bulk write operation:
*
* * bypassDocumentValidation (boolean): If true, allows the write to opt
* out of document level validation.
*
* * ordered (boolean): If true, when an insert fails, return without
* performing the remaining writes. If false, when a write fails,
* continue with the remaining writes, if any. The default is true.
*
* * writeConcern (MongoDB\Driver\WriteConcern): Write concern.
*
* @param string $databaseName Database name
* @param string $collectionName Collection name
* @param array[] $operations List of write operations
* @param array $options Command options
* @throws InvalidArgumentException
*/
public function __construct($databaseName, $collectionName, array $operations, array $options = [])
{
if (empty($operations)) {
throw new InvalidArgumentException('$operations is empty');
}
$expectedIndex = 0;
foreach ($operations as $i => $operation) {
if ($i !== $expectedIndex) {
throw new InvalidArgumentException(sprintf('$operations is not a list (unexpected index: "%s")', $i));
}
if ( ! is_array($operation)) {
throw InvalidArgumentException::invalidType(sprintf('$operations[%d]', $i), $operation, 'array');
}
if (count($operation) !== 1) {
throw new InvalidArgumentException(sprintf('Expected one element in $operation[%d], actually: %d', $i, count($operation)));
}
$type = key($operation);
$args = current($operation);
if ( ! isset($args[0]) && ! array_key_exists(0, $args)) {
throw new InvalidArgumentException(sprintf('Missing first argument for $operations[%d]["%s"]', $i, $type));
}
if ( ! is_array($args[0]) && ! is_object($args[0])) {
throw InvalidArgumentException::invalidType(sprintf('$operations[%d]["%s"][0]', $i, $type), $args[0], 'array or object');
}
switch ($type) {
case self::INSERT_ONE:
break;
case self::DELETE_MANY:
case self::DELETE_ONE:
$operations[$i][$type][1] = ['limit' => ($type === self::DELETE_ONE ? 1 : 0)];
break;
case self::REPLACE_ONE:
if ( ! isset($args[1]) && ! array_key_exists(1, $args)) {
throw new InvalidArgumentException(sprintf('Missing second argument for $operations[%d]["%s"]', $i, $type));
}
if ( ! is_array($args[1]) && ! is_object($args[1])) {
throw InvalidArgumentException::invalidType(sprintf('$operations[%d]["%s"][1]', $i, $type), $args[1], 'array or object');
}
if (\MongoDB\is_first_key_operator($args[1])) {
throw new InvalidArgumentException(sprintf('First key in $operations[%d]["%s"][1] is an update operator', $i, $type));
}
if ( ! isset($args[2])) {
$args[2] = [];
}
if ( ! is_array($args[2])) {
throw InvalidArgumentException::invalidType(sprintf('$operations[%d]["%s"][2]', $i, $type), $args[2], 'array');
}
$args[2]['multi'] = false;
$args[2] += ['upsert' => false];
if ( ! is_bool($args[2]['upsert'])) {
throw InvalidArgumentException::invalidType(sprintf('$operations[%d]["%s"][2]["upsert"]', $i, $type), $args[2]['upsert'], 'boolean');
}
$operations[$i][$type][2] = $args[2];
break;
case self::UPDATE_MANY:
case self::UPDATE_ONE:
if ( ! isset($args[1]) && ! array_key_exists(1, $args)) {
throw new InvalidArgumentException(sprintf('Missing second argument for $operations[%d]["%s"]', $i, $type));
}
if ( ! is_array($args[1]) && ! is_object($args[1])) {
throw InvalidArgumentException::invalidType(sprintf('$operations[%d]["%s"][1]', $i, $type), $args[1], 'array or object');
}
if ( ! \MongoDB\is_first_key_operator($args[1])) {
throw new InvalidArgumentException(sprintf('First key in $operations[%d]["%s"][1] is not an update operator', $i, $type));
}
if ( ! isset($args[2])) {
$args[2] = [];
}
if ( ! is_array($args[2])) {
throw InvalidArgumentException::invalidType(sprintf('$operations[%d]["%s"][2]', $i, $type), $args[2], 'array');
}
$args[2]['multi'] = ($type === self::UPDATE_MANY);
$args[2] += ['upsert' => false];
if ( ! is_bool($args[2]['upsert'])) {
throw InvalidArgumentException::invalidType(sprintf('$operations[%d]["%s"][2]["upsert"]', $i, $type), $args[2]['upsert'], 'boolean');
}
$operations[$i][$type][2] = $args[2];
break;
default:
throw new InvalidArgumentException(sprintf('Unknown operation type "%s" in $operations[%d]', $type, $i));
}
$expectedIndex += 1;
}
$options += ['ordered' => true];
if (isset($options['bypassDocumentValidation']) && ! is_bool($options['bypassDocumentValidation'])) {
throw InvalidArgumentException::invalidType('"bypassDocumentValidation" option', $options['bypassDocumentValidation'], 'boolean');
}
if ( ! is_bool($options['ordered'])) {
throw InvalidArgumentException::invalidType('"ordered" option', $options['ordered'], 'boolean');
}
if (isset($options['writeConcern']) && ! $options['writeConcern'] instanceof WriteConcern) {
throw InvalidArgumentException::invalidType('"writeConcern" option', $options['writeConcern'], 'MongoDB\Driver\WriteConcern');
}
$this->databaseName = (string) $databaseName;
$this->collectionName = (string) $collectionName;
$this->operations = $operations;
$this->options = $options;
}
/**
* Execute the operation.
*
* @see Executable::execute()
* @param Server $server
* @return BulkWriteResult
*/
public function execute(Server $server)
{
$options = ['ordered' => $this->options['ordered']];
if (isset($this->options['bypassDocumentValidation']) && \MongoDB\server_supports_feature($server, self::$wireVersionForDocumentLevelValidation)) {
$options['bypassDocumentValidation'] = $this->options['bypassDocumentValidation'];
}
$bulk = new Bulk($options);
$insertedIds = [];
foreach ($this->operations as $i => $operation) {
$type = key($operation);
$args = current($operation);
switch ($type) {
case self::DELETE_MANY:
case self::DELETE_ONE:
$bulk->delete($args[0], $args[1]);
break;
case self::INSERT_ONE:
$insertedId = $bulk->insert($args[0]);
if ($insertedId !== null) {
$insertedIds[$i] = $insertedId;
} else {
$insertedIds[$i] = \MongoDB\extract_id_from_inserted_document($args[0]);
}
break;
case self::REPLACE_ONE:
case self::UPDATE_MANY:
case self::UPDATE_ONE:
$bulk->update($args[0], $args[1], $args[2]);
}
}
$writeConcern = isset($this->options['writeConcern']) ? $this->options['writeConcern'] : null;
$writeResult = $server->executeBulkWrite($this->databaseName . '.' . $this->collectionName, $bulk, $writeConcern);
return new BulkWriteResult($writeResult, $insertedIds);
}
}
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/src/Operation/Count.php 0000664 0001750 0001750 00000012257 12741242607 024201 0 ustar jan jan databaseName = (string) $databaseName;
$this->collectionName = (string) $collectionName;
$this->filter = $filter;
$this->options = $options;
}
/**
* Execute the operation.
*
* @see Executable::execute()
* @param Server $server
* @return integer
* @throws UnexpectedValueException if the command response was malformed
*/
public function execute(Server $server)
{
$readPreference = isset($this->options['readPreference']) ? $this->options['readPreference'] : null;
$cursor = $server->executeCommand($this->databaseName, $this->createCommand($server), $readPreference);
$result = current($cursor->toArray());
// Older server versions may return a float
if ( ! isset($result->n) || ! (is_integer($result->n) || is_float($result->n))) {
throw new UnexpectedValueException('count command did not return a numeric "n" value');
}
return (integer) $result->n;
}
/**
* Create the count command.
*
* @param Server $server
* @return Command
*/
private function createCommand(Server $server)
{
$cmd = ['count' => $this->collectionName];
if ( ! empty($this->filter)) {
$cmd['query'] = (object) $this->filter;
}
foreach (['hint', 'limit', 'maxTimeMS', 'skip'] as $option) {
if (isset($this->options[$option])) {
$cmd[$option] = $this->options[$option];
}
}
if (isset($this->options['readConcern']) && \MongoDB\server_supports_feature($server, self::$wireVersionForReadConcern)) {
$cmd['readConcern'] = \MongoDB\read_concern_as_document($this->options['readConcern']);
}
return new Command($cmd);
}
}
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/src/Operation/CreateCollection.php 0000664 0001750 0001750 00000015164 12741242607 026330 0 ustar jan jan databaseName = (string) $databaseName;
$this->collectionName = (string) $collectionName;
$this->options = $options;
}
/**
* Execute the operation.
*
* @see Executable::execute()
* @param Server $server
* @return array|object Command result document
*/
public function execute(Server $server)
{
$cursor = $server->executeCommand($this->databaseName, $this->createCommand());
if (isset($this->options['typeMap'])) {
$cursor->setTypeMap($this->options['typeMap']);
}
return current($cursor->toArray());
}
/**
* Create the create command.
*
* @return Command
*/
private function createCommand()
{
$cmd = ['create' => $this->collectionName];
foreach (['autoIndexId', 'capped', 'flags', 'max', 'maxTimeMS', 'size', 'validationAction', 'validationLevel'] as $option) {
if (isset($this->options[$option])) {
$cmd[$option] = $this->options[$option];
}
}
if (isset($this->options['indexOptionDefaults'])) {
$cmd['indexOptionDefaults'] = (object) $this->options['indexOptionDefaults'];
}
if (isset($this->options['storageEngine'])) {
$cmd['storageEngine'] = (object) $this->options['storageEngine'];
}
if (isset($this->options['validator'])) {
$cmd['validator'] = (object) $this->options['validator'];
}
return new Command($cmd);
}
}
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/src/Operation/CreateIndexes.php 0000664 0001750 0001750 00000006637 12741242607 025641 0 ustar jan jan $index) {
if ($i !== $expectedIndex) {
throw new InvalidArgumentException(sprintf('$indexes is not a list (unexpected index: "%s")', $i));
}
if ( ! is_array($index)) {
throw InvalidArgumentException::invalidType(sprintf('$index[%d]', $i), $index, 'array');
}
if ( ! isset($index['ns'])) {
$index['ns'] = $databaseName . '.' . $collectionName;
}
$this->indexes[] = new IndexInput($index);
$expectedIndex += 1;
}
$this->databaseName = (string) $databaseName;
$this->collectionName = (string) $collectionName;
}
/**
* Execute the operation.
*
* For servers < 2.6, this will actually perform an insert operation on the
* database's "system.indexes" collection.
*
* @see Executable::execute()
* @param Server $server
* @return string[] The names of the created indexes
*/
public function execute(Server $server)
{
if (\MongoDB\server_supports_feature($server, self::$wireVersionForCommand)) {
$this->executeCommand($server);
} else {
$this->executeLegacy($server);
}
return array_map(function(IndexInput $index) { return (string) $index; }, $this->indexes);
}
/**
* Create one or more indexes for the collection using the createIndexes
* command.
*
* @param Server $server
*/
private function executeCommand(Server $server)
{
$command = new Command([
'createIndexes' => $this->collectionName,
'indexes' => $this->indexes,
]);
$cursor = $server->executeCommand($this->databaseName, $command);
return current($cursor->toArray());
}
/**
* Create one or more indexes for the collection by inserting into the
* "system.indexes" collection (MongoDB <2.6).
*
* @param Server $server
*/
private function executeLegacy(Server $server)
{
$bulk = new Bulk(['ordered' => true]);
foreach ($this->indexes as $index) {
$bulk->insert($index);
}
$server->executeBulkWrite($this->databaseName . '.system.indexes', $bulk, new WriteConcern(1));
}
}
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/src/Operation/DatabaseCommand.php 0000664 0001750 0001750 00000005164 12741242607 026113 0 ustar jan jan databaseName = (string) $databaseName;
$this->command = ($command instanceof Command) ? $command : new Command($command);
$this->options = $options;
}
/**
* Execute the operation.
*
* @see Executable::execute()
* @param Server $server
* @return integer
*/
public function execute(Server $server)
{
$readPreference = isset($this->options['readPreference']) ? $this->options['readPreference'] : null;
$cursor = $server->executeCommand($this->databaseName, $this->command, $readPreference);
if (isset($this->options['typeMap'])) {
$cursor->setTypeMap($this->options['typeMap']);
}
return $cursor;
}
}
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/src/Operation/Delete.php 0000664 0001750 0001750 00000005237 12741242607 024313 0 ustar jan jan databaseName = (string) $databaseName;
$this->collectionName = (string) $collectionName;
$this->filter = $filter;
$this->limit = $limit;
$this->options = $options;
}
/**
* Execute the operation.
*
* @see Executable::execute()
* @param Server $server
* @return DeleteResult
*/
public function execute(Server $server)
{
$bulk = new Bulk();
$bulk->delete($this->filter, ['limit' => $this->limit]);
$writeConcern = isset($this->options['writeConcern']) ? $this->options['writeConcern'] : null;
$writeResult = $server->executeBulkWrite($this->databaseName . '.' . $this->collectionName, $bulk, $writeConcern);
return new DeleteResult($writeResult);
}
}
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/src/Operation/DeleteMany.php 0000664 0001750 0001750 00000002427 12741242607 025136 0 ustar jan jan delete = new Delete($databaseName, $collectionName, $filter, 0, $options);
}
/**
* Execute the operation.
*
* @see Executable::execute()
* @param Server $server
* @return DeleteResult
*/
public function execute(Server $server)
{
return $this->delete->execute($server);
}
}
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/src/Operation/DeleteOne.php 0000664 0001750 0001750 00000002426 12741242607 024752 0 ustar jan jan delete = new Delete($databaseName, $collectionName, $filter, 1, $options);
}
/**
* Execute the operation.
*
* @see Executable::execute()
* @param Server $server
* @return DeleteResult
*/
public function execute(Server $server)
{
return $this->delete->execute($server);
}
}
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/src/Operation/Distinct.php 0000664 0001750 0001750 00000010235 12741242607 024664 0 ustar jan jan databaseName = (string) $databaseName;
$this->collectionName = (string) $collectionName;
$this->fieldName = (string) $fieldName;
$this->filter = $filter;
$this->options = $options;
}
/**
* Execute the operation.
*
* @see Executable::execute()
* @param Server $server
* @return mixed[]
* @throws UnexpectedValueException if the command response was malformed
*/
public function execute(Server $server)
{
$readPreference = isset($this->options['readPreference']) ? $this->options['readPreference'] : null;
$cursor = $server->executeCommand($this->databaseName, $this->createCommand($server), $readPreference);
$result = current($cursor->toArray());
if ( ! isset($result->values) || ! is_array($result->values)) {
throw new UnexpectedValueException('distinct command did not return a "values" array');
}
return $result->values;
}
/**
* Create the distinct command.
*
* @param Server $server
* @return Command
*/
private function createCommand(Server $server)
{
$cmd = [
'distinct' => $this->collectionName,
'key' => $this->fieldName,
];
if ( ! empty($this->filter)) {
$cmd['query'] = (object) $this->filter;
}
if (isset($this->options['maxTimeMS'])) {
$cmd['maxTimeMS'] = $this->options['maxTimeMS'];
}
if (isset($this->options['readConcern']) && \MongoDB\server_supports_feature($server, self::$wireVersionForReadConcern)) {
$cmd['readConcern'] = \MongoDB\read_concern_as_document($this->options['readConcern']);
}
return new Command($cmd);
}
}
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/src/Operation/DropCollection.php 0000664 0001750 0001750 00000004537 12741242607 026033 0 ustar jan jan databaseName = (string) $databaseName;
$this->collectionName = (string) $collectionName;
$this->options = $options;
}
/**
* Execute the operation.
*
* @see Executable::execute()
* @param Server $server
* @return array|object Command result document
*/
public function execute(Server $server)
{
try {
$cursor = $server->executeCommand($this->databaseName, new Command(['drop' => $this->collectionName]));
} catch (RuntimeException $e) {
/* The server may return an error if the collection does not exist.
* Check for an error message (unfortunately, there isn't a code)
* and NOP instead of throwing.
*/
if ($e->getMessage() === self::$errorMessageNamespaceNotFound) {
return (object) ['ok' => 0, 'errmsg' => self::$errorMessageNamespaceNotFound];
}
throw $e;
}
if (isset($this->options['typeMap'])) {
$cursor->setTypeMap($this->options['typeMap']);
}
return current($cursor->toArray());
}
}
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/src/Operation/DropDatabase.php 0000664 0001750 0001750 00000003137 12741242607 025437 0 ustar jan jan databaseName = (string) $databaseName;
$this->options = $options;
}
/**
* Execute the operation.
*
* @see Executable::execute()
* @param Server $server
* @return array|object Command result document
*/
public function execute(Server $server)
{
$cursor = $server->executeCommand($this->databaseName, new Command(['dropDatabase' => 1]));
if (isset($this->options['typeMap'])) {
$cursor->setTypeMap($this->options['typeMap']);
}
return current($cursor->toArray());
}
}
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/src/Operation/DropIndexes.php 0000664 0001750 0001750 00000004255 12741242607 025334 0 ustar jan jan databaseName = (string) $databaseName;
$this->collectionName = (string) $collectionName;
$this->indexName = $indexName;
$this->options = $options;
}
/**
* Execute the operation.
*
* @see Executable::execute()
* @param Server $server
* @return array|object Command result document
*/
public function execute(Server $server)
{
$cmd = [
'dropIndexes' => $this->collectionName,
'index' => $this->indexName,
];
$cursor = $server->executeCommand($this->databaseName, new Command($cmd));
if (isset($this->options['typeMap'])) {
$cursor->setTypeMap($this->options['typeMap']);
}
return current($cursor->toArray());
}
}
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/src/Operation/Executable.php 0000664 0001750 0001750 00000000716 12741242607 025167 0 ustar jan jan databaseName = (string) $databaseName;
$this->collectionName = (string) $collectionName;
$this->filter = $filter;
$this->options = $options;
}
/**
* Execute the operation.
*
* @see Executable::execute()
* @param Server $server
* @return Cursor
*/
public function execute(Server $server)
{
$readPreference = isset($this->options['readPreference']) ? $this->options['readPreference'] : null;
$cursor = $server->executeQuery($this->databaseName . '.' . $this->collectionName, $this->createQuery(), $readPreference);
if (isset($this->options['typeMap'])) {
$cursor->setTypeMap($this->options['typeMap']);
}
return $cursor;
}
/**
* Create the find query.
*
* @return Query
*/
private function createQuery()
{
$options = [];
if ( ! empty($this->options['allowPartialResults'])) {
$options['partial'] = true;
}
if (isset($this->options['cursorType'])) {
if ($this->options['cursorType'] === self::TAILABLE) {
$options['tailable'] = true;
}
if ($this->options['cursorType'] === self::TAILABLE_AWAIT) {
$options['tailable'] = true;
$options['awaitData'] = true;
}
}
foreach (['batchSize', 'limit', 'skip', 'sort', 'noCursorTimeout', 'oplogReplay', 'projection', 'readConcern'] as $option) {
if (isset($this->options[$option])) {
$options[$option] = $this->options[$option];
}
}
$modifiers = empty($this->options['modifiers']) ? [] : (array) $this->options['modifiers'];
if (isset($this->options['comment'])) {
$modifiers['$comment'] = $this->options['comment'];
}
if (isset($this->options['maxTimeMS'])) {
$modifiers['$maxTimeMS'] = $this->options['maxTimeMS'];
}
if ( ! empty($modifiers)) {
$options['modifiers'] = $modifiers;
}
return new Query($this->filter, $options);
}
}
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/src/Operation/FindAndModify.php 0000664 0001750 0001750 00000016533 12741242607 025565 0 ustar jan jan = 3.2.
*
* @param string $databaseName Database name
* @param string $collectionName Collection name
* @param array $options Command options
* @throws InvalidArgumentException
*/
public function __construct($databaseName, $collectionName, array $options)
{
$options += [
'new' => false,
'remove' => false,
'upsert' => false,
];
if (isset($options['bypassDocumentValidation']) && ! is_bool($options['bypassDocumentValidation'])) {
throw InvalidArgumentException::invalidType('"bypassDocumentValidation" option', $options['bypassDocumentValidation'], 'boolean');
}
if (isset($options['fields']) && ! is_array($options['fields']) && ! is_object($options['fields'])) {
throw InvalidArgumentException::invalidType('"fields" option', $options['fields'], 'array or object');
}
if (isset($options['maxTimeMS']) && ! is_integer($options['maxTimeMS'])) {
throw InvalidArgumentException::invalidType('"maxTimeMS" option', $options['maxTimeMS'], 'integer');
}
if ( ! is_bool($options['new'])) {
throw InvalidArgumentException::invalidType('"new" option', $options['new'], 'boolean');
}
if (isset($options['query']) && ! is_array($options['query']) && ! is_object($options['query'])) {
throw InvalidArgumentException::invalidType('"query" option', $options['query'], 'array or object');
}
if ( ! is_bool($options['remove'])) {
throw InvalidArgumentException::invalidType('"remove" option', $options['remove'], 'boolean');
}
if (isset($options['sort']) && ! is_array($options['sort']) && ! is_object($options['sort'])) {
throw InvalidArgumentException::invalidType('"sort" option', $options['sort'], 'array or object');
}
if (isset($options['update']) && ! is_array($options['update']) && ! is_object($options['update'])) {
throw InvalidArgumentException::invalidType('"update" option', $options['update'], 'array or object');
}
if (isset($options['writeConcern']) && ! $options['writeConcern'] instanceof WriteConcern) {
throw InvalidArgumentException::invalidType('"writeConcern" option', $options['writeConcern'], 'MongoDB\Driver\WriteConcern');
}
if ( ! is_bool($options['upsert'])) {
throw InvalidArgumentException::invalidType('"upsert" option', $options['upsert'], 'boolean');
}
if ( ! (isset($options['update']) xor $options['remove'])) {
throw new InvalidArgumentException('The "remove" option must be true or an "update" document must be specified, but not both');
}
$this->databaseName = (string) $databaseName;
$this->collectionName = (string) $collectionName;
$this->options = $options;
}
/**
* Execute the operation.
*
* @see Executable::execute()
* @param Server $server
* @return object|null
* @throws UnexpectedValueException if the command response was malformed
*/
public function execute(Server $server)
{
$cursor = $server->executeCommand($this->databaseName, $this->createCommand($server));
$result = current($cursor->toArray());
if ( ! isset($result->value)) {
return null;
}
/* Prior to 3.0, findAndModify returns an empty document instead of null
* when an upsert is performed and the pre-modified document was
* requested.
*/
if ($this->options['upsert'] && ! $this->options['new'] &&
isset($result->lastErrorObject->updatedExisting) &&
! $result->lastErrorObject->updatedExisting) {
return null;
}
if ( ! is_object($result->value)) {
throw new UnexpectedValueException('findAndModify command did not return a "value" document');
}
return $result->value;
}
/**
* Create the findAndModify command.
*
* @param Server $server
* @return Command
*/
private function createCommand(Server $server)
{
$cmd = ['findAndModify' => $this->collectionName];
if ($this->options['remove']) {
$cmd['remove'] = true;
} else {
$cmd['new'] = $this->options['new'];
$cmd['upsert'] = $this->options['upsert'];
}
foreach (['fields', 'query', 'sort', 'update'] as $option) {
if (isset($this->options[$option])) {
$cmd[$option] = (object) $this->options[$option];
}
}
if (isset($this->options['maxTimeMS'])) {
$cmd['maxTimeMS'] = $this->options['maxTimeMS'];
}
if (isset($this->options['bypassDocumentValidation']) && \MongoDB\server_supports_feature($server, self::$wireVersionForDocumentLevelValidation)) {
$cmd['bypassDocumentValidation'] = $this->options['bypassDocumentValidation'];
}
if (isset($this->options['writeConcern']) && \MongoDB\server_supports_feature($server, self::$wireVersionForWriteConcern)) {
$cmd['writeConcern'] = $this->options['writeConcern'];
}
return new Command($cmd);
}
}
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/src/Operation/FindOne.php 0000664 0001750 0001750 00000005230 12741242607 024424 0 ustar jan jan find = new Find(
$databaseName,
$collectionName,
$filter,
['limit' => 1] + $options
);
$this->options = $options;
}
/**
* Execute the operation.
*
* @see Executable::execute()
* @param Server $server
* @return array|object|null
*/
public function execute(Server $server)
{
$cursor = $this->find->execute($server);
$document = current($cursor->toArray());
return ($document === false) ? null : $document;
}
}
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/src/Operation/FindOneAndDelete.php 0000664 0001750 0001750 00000004613 12741242607 026176 0 ustar jan jan = 3.2.
*
* @param string $databaseName Database name
* @param string $collectionName Collection name
* @param array|object $filter Query by which to filter documents
* @param array $options Command options
* @throws InvalidArgumentException
*/
public function __construct($databaseName, $collectionName, $filter, array $options = [])
{
if ( ! is_array($filter) && ! is_object($filter)) {
throw InvalidArgumentException::invalidType('$filter', $filter, 'array or object');
}
if (isset($options['projection']) && ! is_array($options['projection']) && ! is_object($options['projection'])) {
throw InvalidArgumentException::invalidType('"projection" option', $options['projection'], 'array or object');
}
if (isset($options['projection'])) {
$options['fields'] = $options['projection'];
}
unset($options['projection']);
$this->findAndModify = new FindAndModify(
$databaseName,
$collectionName,
['query' => $filter, 'remove' => true] + $options
);
}
/**
* Execute the operation.
*
* @see Executable::execute()
* @param Server $server
* @return object|null
*/
public function execute(Server $server)
{
return $this->findAndModify->execute($server);
}
}
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/src/Operation/FindOneAndReplace.php 0000664 0001750 0001750 00000010256 12741242607 026347 0 ustar jan jan = 3.2.
*
* @param string $databaseName Database name
* @param string $collectionName Collection name
* @param array|object $filter Query by which to filter documents
* @param array|object $replacement Replacement document
* @param array $options Command options
* @throws InvalidArgumentException
*/
public function __construct($databaseName, $collectionName, $filter, $replacement, array $options = [])
{
if ( ! is_array($filter) && ! is_object($filter)) {
throw InvalidArgumentException::invalidType('$filter', $filter, 'array or object');
}
if ( ! is_array($replacement) && ! is_object($replacement)) {
throw InvalidArgumentException::invalidType('$replacement', $replacement, 'array or object');
}
if (\MongoDB\is_first_key_operator($replacement)) {
throw new InvalidArgumentException('First key in $replacement argument is an update operator');
}
$options += [
'returnDocument' => self::RETURN_DOCUMENT_BEFORE,
'upsert' => false,
];
if (isset($options['projection']) && ! is_array($options['projection']) && ! is_object($options['projection'])) {
throw InvalidArgumentException::invalidType('"projection" option', $options['projection'], 'array or object');
}
if ( ! is_integer($options['returnDocument'])) {
throw InvalidArgumentException::invalidType('"returnDocument" option', $options['returnDocument'], 'integer');
}
if ($options['returnDocument'] !== self::RETURN_DOCUMENT_AFTER &&
$options['returnDocument'] !== self::RETURN_DOCUMENT_BEFORE) {
throw new InvalidArgumentException('Invalid value for "returnDocument" option: ' . $options['returnDocument']);
}
if (isset($options['projection'])) {
$options['fields'] = $options['projection'];
}
$options['new'] = $options['returnDocument'] === self::RETURN_DOCUMENT_AFTER;
unset($options['projection'], $options['returnDocument']);
$this->findAndModify = new FindAndModify(
$databaseName,
$collectionName,
['query' => $filter, 'update' => $replacement] + $options
);
}
/**
* Execute the operation.
*
* @see Executable::execute()
* @param Server $server
* @return object|null
*/
public function execute(Server $server)
{
return $this->findAndModify->execute($server);
}
}
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/src/Operation/FindOneAndUpdate.php 0000664 0001750 0001750 00000010231 12741242607 026207 0 ustar jan jan = 3.2.
*
* @param string $databaseName Database name
* @param string $collectionName Collection name
* @param array|object $filter Query by which to filter documents
* @param array|object $update Update to apply to the matched document
* @param array $options Command options
* @throws InvalidArgumentException
*/
public function __construct($databaseName, $collectionName, $filter, $update, array $options = [])
{
if ( ! is_array($filter) && ! is_object($filter)) {
throw InvalidArgumentException::invalidType('$filter', $filter, 'array or object');
}
if ( ! is_array($update) && ! is_object($update)) {
throw InvalidArgumentException::invalidType('$update', $update, 'array or object');
}
if ( ! \MongoDB\is_first_key_operator($update)) {
throw new InvalidArgumentException('First key in $update argument is not an update operator');
}
$options += [
'returnDocument' => self::RETURN_DOCUMENT_BEFORE,
'upsert' => false,
];
if (isset($options['projection']) && ! is_array($options['projection']) && ! is_object($options['projection'])) {
throw InvalidArgumentException::invalidType('"projection" option', $options['projection'], 'array or object');
}
if ( ! is_integer($options['returnDocument'])) {
throw InvalidArgumentException::invalidType('"returnDocument" option', $options['returnDocument'], 'integer');
}
if ($options['returnDocument'] !== self::RETURN_DOCUMENT_AFTER &&
$options['returnDocument'] !== self::RETURN_DOCUMENT_BEFORE) {
throw new InvalidArgumentException('Invalid value for "returnDocument" option: ' . $options['returnDocument']);
}
if (isset($options['projection'])) {
$options['fields'] = $options['projection'];
}
$options['new'] = $options['returnDocument'] === self::RETURN_DOCUMENT_AFTER;
unset($options['projection'], $options['returnDocument']);
$this->findAndModify = new FindAndModify(
$databaseName,
$collectionName,
['query' => $filter, 'update' => $update] + $options
);
}
/**
* Execute the operation.
*
* @see Executable::execute()
* @param Server $server
* @return object|null
*/
public function execute(Server $server)
{
return $this->findAndModify->execute($server);
}
}
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/src/Operation/InsertMany.php 0000664 0001750 0001750 00000010327 12741242607 025176 0 ustar jan jan $document) {
if ($i !== $expectedIndex) {
throw new InvalidArgumentException(sprintf('$documents is not a list (unexpected index: "%s")', $i));
}
if ( ! is_array($document) && ! is_object($document)) {
throw InvalidArgumentException::invalidType(sprintf('$documents[%d]', $i), $document, 'array or object');
}
$expectedIndex += 1;
}
$options += ['ordered' => true];
if (isset($options['bypassDocumentValidation']) && ! is_bool($options['bypassDocumentValidation'])) {
throw InvalidArgumentException::invalidType('"bypassDocumentValidation" option', $options['bypassDocumentValidation'], 'boolean');
}
if ( ! is_bool($options['ordered'])) {
throw InvalidArgumentException::invalidType('"ordered" option', $options['ordered'], 'boolean');
}
if (isset($options['writeConcern']) && ! $options['writeConcern'] instanceof WriteConcern) {
throw InvalidArgumentException::invalidType('"writeConcern" option', $options['writeConcern'], 'MongoDB\Driver\WriteConcern');
}
$this->databaseName = (string) $databaseName;
$this->collectionName = (string) $collectionName;
$this->documents = $documents;
$this->options = $options;
}
/**
* Execute the operation.
*
* @see Executable::execute()
* @param Server $server
* @return InsertManyResult
*/
public function execute(Server $server)
{
$options = ['ordered' => $this->options['ordered']];
if (isset($this->options['bypassDocumentValidation']) && \MongoDB\server_supports_feature($server, self::$wireVersionForDocumentLevelValidation)) {
$options['bypassDocumentValidation'] = $this->options['bypassDocumentValidation'];
}
$bulk = new Bulk($options);
$insertedIds = [];
foreach ($this->documents as $i => $document) {
$insertedId = $bulk->insert($document);
if ($insertedId !== null) {
$insertedIds[$i] = $insertedId;
} else {
$insertedIds[$i] = \MongoDB\extract_id_from_inserted_document($document);
}
}
$writeConcern = isset($this->options['writeConcern']) ? $this->options['writeConcern'] : null;
$writeResult = $server->executeBulkWrite($this->databaseName . '.' . $this->collectionName, $bulk, $writeConcern);
return new InsertManyResult($writeResult, $insertedIds);
}
}
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/src/Operation/InsertOne.php 0000664 0001750 0001750 00000006152 12741242607 025014 0 ustar jan jan databaseName = (string) $databaseName;
$this->collectionName = (string) $collectionName;
$this->document = $document;
$this->options = $options;
}
/**
* Execute the operation.
*
* @see Executable::execute()
* @param Server $server
* @return InsertOneResult
*/
public function execute(Server $server)
{
$options = [];
if (isset($this->options['bypassDocumentValidation']) && \MongoDB\server_supports_feature($server, self::$wireVersionForDocumentLevelValidation)) {
$options['bypassDocumentValidation'] = $this->options['bypassDocumentValidation'];
}
$bulk = new Bulk($options);
$insertedId = $bulk->insert($this->document);
if ($insertedId === null) {
$insertedId = \MongoDB\extract_id_from_inserted_document($this->document);
}
$writeConcern = isset($this->options['writeConcern']) ? $this->options['writeConcern'] : null;
$writeResult = $server->executeBulkWrite($this->databaseName . '.' . $this->collectionName, $bulk, $writeConcern);
return new InsertOneResult($writeResult, $insertedId);
}
}
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/src/Operation/ListCollections.php 0000664 0001750 0001750 00000007637 12741242607 026231 0 ustar jan jan databaseName = (string) $databaseName;
$this->options = $options;
}
/**
* Execute the operation.
*
* @see Executable::execute()
* @param Server $server
* @return CollectionInfoIterator
*/
public function execute(Server $server)
{
return \MongoDB\server_supports_feature($server, self::$wireVersionForCommand)
? $this->executeCommand($server)
: $this->executeLegacy($server);
}
/**
* Returns information for all collections in this database using the
* listCollections command.
*
* @param Server $server
* @return CollectionInfoCommandIterator
*/
private function executeCommand(Server $server)
{
$cmd = ['listCollections' => 1];
if ( ! empty($this->options['filter'])) {
$cmd['filter'] = (object) $this->options['filter'];
}
if (isset($this->options['maxTimeMS'])) {
$cmd['maxTimeMS'] = $this->options['maxTimeMS'];
}
$cursor = $server->executeCommand($this->databaseName, new Command($cmd));
$cursor->setTypeMap(['root' => 'array', 'document' => 'array']);
return new CollectionInfoCommandIterator($cursor);
}
/**
* Returns information for all collections in this database by querying the
* "system.namespaces" collection (MongoDB <3.0).
*
* @param Server $server
* @return CollectionInfoLegacyIterator
* @throws InvalidArgumentException if filter.name is not a string.
*/
private function executeLegacy(Server $server)
{
$filter = empty($this->options['filter']) ? [] : (array) $this->options['filter'];
if (array_key_exists('name', $filter)) {
if ( ! is_string($filter['name'])) {
throw InvalidArgumentException::invalidType('filter name for MongoDB <3.0', $filter['name'], 'string');
}
$filter['name'] = $this->databaseName . '.' . $filter['name'];
}
$options = isset($this->options['maxTimeMS'])
? ['modifiers' => ['$maxTimeMS' => $this->options['maxTimeMS']]]
: [];
$cursor = $server->executeQuery($this->databaseName . '.system.namespaces', new Query($filter, $options));
$cursor->setTypeMap(['root' => 'array', 'document' => 'array']);
return new CollectionInfoLegacyIterator($cursor);
}
}
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/src/Operation/ListDatabases.php 0000664 0001750 0001750 00000004507 12741242607 025633 0 ustar jan jan options = $options;
}
/**
* Execute the operation.
*
* @see Executable::execute()
* @param Server $server
* @return DatabaseInfoIterator
* @throws UnexpectedValueException if the command response was malformed
*/
public function execute(Server $server)
{
$cmd = ['listDatabases' => 1];
if (isset($this->options['maxTimeMS'])) {
$cmd['maxTimeMS'] = $this->options['maxTimeMS'];
}
$cursor = $server->executeCommand('admin', new Command($cmd));
$cursor->setTypeMap(['root' => 'array', 'document' => 'array']);
$result = current($cursor->toArray());
if ( ! isset($result['databases']) || ! is_array($result['databases'])) {
throw new UnexpectedValueException('listDatabases command did not return a "databases" array');
}
/* Return an Iterator instead of an array in case listDatabases is
* eventually changed to return a command cursor, like the collection
* and index enumeration commands. This makes the "totalSize" command
* field inaccessible, but users can manually invoke the command if they
* need that value.
*/
return new DatabaseInfoLegacyIterator($result['databases']);
}
}
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/src/Operation/ListIndexes.php 0000664 0001750 0001750 00000007536 12741242607 025350 0 ustar jan jan databaseName = (string) $databaseName;
$this->collectionName = (string) $collectionName;
$this->options = $options;
}
/**
* Execute the operation.
*
* @see Executable::execute()
* @param Server $server
* @return IndexInfoIterator
*/
public function execute(Server $server)
{
return \MongoDB\server_supports_feature($server, self::$wireVersionForCommand)
? $this->executeCommand($server)
: $this->executeLegacy($server);
}
/**
* Returns information for all indexes for this collection using the
* listIndexes command.
*
* @param Server $server
* @return IndexInfoIteratorIterator
*/
private function executeCommand(Server $server)
{
$cmd = ['listIndexes' => $this->collectionName];
if (isset($this->options['maxTimeMS'])) {
$cmd['maxTimeMS'] = $this->options['maxTimeMS'];
}
try {
$cursor = $server->executeCommand($this->databaseName, new Command($cmd));
} catch (RuntimeException $e) {
/* The server may return an error if the collection does not exist.
* Check for possible error codes (see: SERVER-20463) and return an
* empty iterator instead of throwing.
*/
if ($e->getCode() === self::$errorCodeNamespaceNotFound || $e->getCode() === self::$errorCodeDatabaseNotFound) {
return new IndexInfoIteratorIterator(new EmptyIterator);
}
throw $e;
}
$cursor->setTypeMap(['root' => 'array', 'document' => 'array']);
return new IndexInfoIteratorIterator($cursor);
}
/**
* Returns information for all indexes for this collection by querying the
* "system.indexes" collection (MongoDB <3.0).
*
* @param Server $server
* @return IndexInfoIteratorIterator
*/
private function executeLegacy(Server $server)
{
$filter = ['ns' => $this->databaseName . '.' . $this->collectionName];
$options = isset($this->options['maxTimeMS'])
? ['modifiers' => ['$maxTimeMS' => $this->options['maxTimeMS']]]
: [];
$cursor = $server->executeQuery($this->databaseName . '.system.indexes', new Query($filter, $options));
$cursor->setTypeMap(['root' => 'array', 'document' => 'array']);
return new IndexInfoIteratorIterator($cursor);
}
}
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/src/Operation/ReplaceOne.php 0000664 0001750 0001750 00000004110 12741242607 025113 0 ustar jan jan update = new Update(
$databaseName,
$collectionName,
$filter,
$replacement,
['multi' => false] + $options
);
}
/**
* Execute the operation.
*
* @see Executable::execute()
* @param Server $server
* @return UpdateResult
*/
public function execute(Server $server)
{
return $this->update->execute($server);
}
}
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/src/Operation/Update.php 0000664 0001750 0001750 00000011002 12741242607 024316 0 ustar jan jan false,
'upsert' => false,
];
if (isset($options['bypassDocumentValidation']) && ! is_bool($options['bypassDocumentValidation'])) {
throw InvalidArgumentException::invalidType('"bypassDocumentValidation" option', $options['bypassDocumentValidation'], 'boolean');
}
if ( ! is_bool($options['multi'])) {
throw InvalidArgumentException::invalidType('"multi" option', $options['multi'], 'boolean');
}
if ($options['multi'] && ! \MongoDB\is_first_key_operator($update)) {
throw new InvalidArgumentException('"multi" option cannot be true if $update is a replacement document');
}
if ( ! is_bool($options['upsert'])) {
throw InvalidArgumentException::invalidType('"upsert" option', $options['upsert'], 'boolean');
}
if (isset($options['writeConcern']) && ! $options['writeConcern'] instanceof WriteConcern) {
throw InvalidArgumentException::invalidType('"writeConcern" option', $options['writeConcern'], 'MongoDB\Driver\WriteConcern');
}
$this->databaseName = (string) $databaseName;
$this->collectionName = (string) $collectionName;
$this->filter = $filter;
$this->update = $update;
$this->options = $options;
}
/**
* Execute the operation.
*
* @see Executable::execute()
* @param Server $server
* @return UpdateResult
*/
public function execute(Server $server)
{
$updateOptions = [
'multi' => $this->options['multi'],
'upsert' => $this->options['upsert'],
];
$bulkOptions = [];
if (isset($this->options['bypassDocumentValidation']) && \MongoDB\server_supports_feature($server, self::$wireVersionForDocumentLevelValidation)) {
$bulkOptions['bypassDocumentValidation'] = $this->options['bypassDocumentValidation'];
}
$bulk = new Bulk($bulkOptions);
$bulk->update($this->filter, $this->update, $updateOptions);
$writeConcern = isset($this->options['writeConcern']) ? $this->options['writeConcern'] : null;
$writeResult = $server->executeBulkWrite($this->databaseName . '.' . $this->collectionName, $bulk, $writeConcern);
return new UpdateResult($writeResult);
}
}
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/src/Operation/UpdateMany.php 0000664 0001750 0001750 00000004072 12741242607 025154 0 ustar jan jan update = new Update(
$databaseName,
$collectionName,
$filter,
$update,
['multi' => true] + $options
);
}
/**
* Execute the operation.
*
* @see Executable::execute()
* @param Server $server
* @return UpdateResult
*/
public function execute(Server $server)
{
return $this->update->execute($server);
}
}
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/src/Operation/UpdateOne.php 0000664 0001750 0001750 00000004067 12741242607 024775 0 ustar jan jan update = new Update(
$databaseName,
$collectionName,
$filter,
$update,
['multi' => false] + $options
);
}
/**
* Execute the operation.
*
* @see Executable::execute()
* @param Server $server
* @return UpdateResult
*/
public function execute(Server $server)
{
return $this->update->execute($server);
}
}
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/src/BulkWriteResult.php 0000664 0001750 0001750 00000012115 12741242607 024251 0 ustar jan jan writeResult = $writeResult;
$this->insertedIds = $insertedIds;
$this->isAcknowledged = $writeResult->isAcknowledged();
}
/**
* Return the number of documents that were deleted.
*
* This method should only be called if the write was acknowledged.
*
* @see BulkWriteResult::isAcknowledged()
* @return integer
* @throws BadMethodCallException is the write result is unacknowledged
*/
public function getDeletedCount()
{
if ($this->isAcknowledged) {
return $this->writeResult->getDeletedCount();
}
throw BadMethodCallException::unacknowledgedWriteResultAccess(__METHOD__);
}
/**
* Return the number of documents that were inserted.
*
* This method should only be called if the write was acknowledged.
*
* @see BulkWriteResult::isAcknowledged()
* @return integer
* @throws BadMethodCallException is the write result is unacknowledged
*/
public function getInsertedCount()
{
if ($this->isAcknowledged) {
return $this->writeResult->getInsertedCount();
}
throw BadMethodCallException::unacknowledgedWriteResultAccess(__METHOD__);
}
/**
* Return a map of the inserted documents' IDs.
*
* The index of each ID in the map corresponds to the document's position in
* the bulk operation. If the document had an ID prior to insertion (i.e.
* the driver did not generate an ID), this will contain its "_id" field
* value. Any driver-generated ID will be an MongoDB\Driver\ObjectID
* instance.
*
* @return mixed[]
*/
public function getInsertedIds()
{
return $this->insertedIds;
}
/**
* Return the number of documents that were matched by the filter.
*
* This method should only be called if the write was acknowledged.
*
* @see BulkWriteResult::isAcknowledged()
* @return integer
* @throws BadMethodCallException is the write result is unacknowledged
*/
public function getMatchedCount()
{
if ($this->isAcknowledged) {
return $this->writeResult->getMatchedCount();
}
throw BadMethodCallException::unacknowledgedWriteResultAccess(__METHOD__);
}
/**
* Return the number of documents that were modified.
*
* This value is undefined (i.e. null) if the write executed as a legacy
* operation instead of command.
*
* This method should only be called if the write was acknowledged.
*
* @see BulkWriteResult::isAcknowledged()
* @return integer|null
* @throws BadMethodCallException is the write result is unacknowledged
*/
public function getModifiedCount()
{
if ($this->isAcknowledged) {
return $this->writeResult->getModifiedCount();
}
throw BadMethodCallException::unacknowledgedWriteResultAccess(__METHOD__);
}
/**
* Return the number of documents that were upserted.
*
* This method should only be called if the write was acknowledged.
*
* @see BulkWriteResult::isAcknowledged()
* @return integer
* @throws BadMethodCallException is the write result is unacknowledged
*/
public function getUpsertedCount()
{
if ($this->isAcknowledged) {
return $this->writeResult->getUpsertedCount();
}
throw BadMethodCallException::unacknowledgedWriteResultAccess(__METHOD__);
}
/**
* Return a map of the upserted documents' IDs.
*
* The index of each ID in the map corresponds to the document's position
* in bulk operation. If the document had an ID prior to upserting (i.e. the
* server did not need to generate an ID), this will contain its "_id". Any
* server-generated ID will be an MongoDB\Driver\ObjectID instance.
*
* This method should only be called if the write was acknowledged.
*
* @see BulkWriteResult::isAcknowledged()
* @return mixed[]
* @throws BadMethodCallException is the write result is unacknowledged
*/
public function getUpsertedIds()
{
if ($this->isAcknowledged) {
return $this->writeResult->getUpsertedIds();
}
throw BadMethodCallException::unacknowledgedWriteResultAccess(__METHOD__);
}
/**
* Return whether this update was acknowledged by the server.
*
* If the update was not acknowledged, other fields from the WriteResult
* (e.g. matchedCount) will be undefined.
*
* @return boolean
*/
public function isAcknowledged()
{
return $this->isAcknowledged;
}
}
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/src/Client.php 0000664 0001750 0001750 00000012461 12741242607 022364 0 ustar jan jan 'MongoDB\Model\BSONArray',
'document' => 'MongoDB\Model\BSONDocument',
'root' => 'MongoDB\Model\BSONDocument',
];
private $manager;
private $uri;
private $typeMap;
/**
* Constructs a new Client instance.
*
* This is the preferred class for connecting to a MongoDB server or
* cluster of servers. It serves as a gateway for accessing individual
* databases and collections.
*
* Supported driver-specific options:
*
* * typeMap (array): Default type map for cursors and BSON documents.
*
* Other options are documented in MongoDB\Driver\Manager::__construct().
*
* @see http://docs.mongodb.org/manual/reference/connection-string/
* @see http://php.net/manual/en/mongodb-driver-manager.construct.php
* @see http://php.net/manual/en/mongodb.persistence.php#mongodb.persistence.typemaps
* @param string $uri MongoDB connection string
* @param array $uriOptions Additional connection string options
* @param array $driverOptions Driver-specific options
* @throws InvalidArgumentException
*/
public function __construct($uri = 'mongodb://localhost:27017', array $uriOptions = [], array $driverOptions = [])
{
$driverOptions += ['typeMap' => self::$defaultTypeMap];
if (isset($driverOptions['typeMap']) && ! is_array($driverOptions['typeMap'])) {
throw InvalidArgumentException::invalidType('"typeMap" driver option', $driverOptions['typeMap'], 'array');
}
$this->manager = new Manager($uri, $uriOptions, $driverOptions);
$this->uri = (string) $uri;
$this->typeMap = isset($driverOptions['typeMap']) ? $driverOptions['typeMap'] : null;
}
/**
* Return internal properties for debugging purposes.
*
* @see http://php.net/manual/en/language.oop5.magic.php#language.oop5.magic.debuginfo
* @param array
*/
public function __debugInfo()
{
return [
'manager' => $this->manager,
'uri' => $this->uri,
'typeMap' => $this->typeMap,
];
}
/**
* Select a database.
*
* Note: databases whose names contain special characters (e.g. "-") may
* be selected with complex syntax (e.g. $client->{"that-database"}) or
* {@link selectDatabase()}.
*
* @see http://php.net/oop5.overloading#object.get
* @see http://php.net/types.string#language.types.string.parsing.complex
* @param string $databaseName Name of the database to select
* @return Database
*/
public function __get($databaseName)
{
return $this->selectDatabase($databaseName);
}
/**
* Return the connection string (i.e. URI).
*
* @param string
*/
public function __toString()
{
return $this->uri;
}
/**
* Drop a database.
*
* @see DropDatabase::__construct() for supported options
* @param string $databaseName Database name
* @param array $options Additional options
* @return array|object Command result document
*/
public function dropDatabase($databaseName, array $options = [])
{
if ( ! isset($options['typeMap'])) {
$options['typeMap'] = $this->typeMap;
}
$operation = new DropDatabase($databaseName, $options);
$server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
return $operation->execute($server);
}
/**
* List databases.
*
* @see ListDatabases::__construct() for supported options
* @return DatabaseInfoIterator
*/
public function listDatabases(array $options = [])
{
$operation = new ListDatabases($options);
$server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
return $operation->execute($server);
}
/**
* Select a collection.
*
* @see Collection::__construct() for supported options
* @param string $databaseName Name of the database containing the collection
* @param string $collectionName Name of the collection to select
* @param array $options Collection constructor options
* @return Collection
*/
public function selectCollection($databaseName, $collectionName, array $options = [])
{
$options += ['typeMap' => $this->typeMap];
return new Collection($this->manager, $databaseName, $collectionName, $options);
}
/**
* Select a database.
*
* @see Database::__construct() for supported options
* @param string $databaseName Name of the database to select
* @param array $options Database constructor options
* @return Database
*/
public function selectDatabase($databaseName, array $options = [])
{
$options += ['typeMap' => $this->typeMap];
return new Database($this->manager, $databaseName, $options);
}
}
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/src/Collection.php 0000664 0001750 0001750 00000066243 12741242607 023250 0 ustar jan jan 'MongoDB\Model\BSONArray',
'document' => 'MongoDB\Model\BSONDocument',
'root' => 'MongoDB\Model\BSONDocument',
];
private static $wireVersionForFindAndModifyWriteConcern = 4;
private $collectionName;
private $databaseName;
private $manager;
private $readConcern;
private $readPreference;
private $typeMap;
private $writeConcern;
/**
* Constructs new Collection instance.
*
* This class provides methods for collection-specific operations, such as
* CRUD (i.e. create, read, update, and delete) and index management.
*
* Supported options:
*
* * readConcern (MongoDB\Driver\ReadConcern): The default read concern to
* use for collection operations. Defaults to the Manager's read concern.
*
* * readPreference (MongoDB\Driver\ReadPreference): The default read
* preference to use for collection operations. Defaults to the Manager's
* read preference.
*
* * typeMap (array): Default type map for cursors and BSON documents.
*
* * writeConcern (MongoDB\Driver\WriteConcern): The default write concern
* to use for collection operations. Defaults to the Manager's write
* concern.
*
* @param Manager $manager Manager instance from the driver
* @param string $databaseName Database name
* @param string $collectionName Collection name
* @param array $options Collection options
* @throws InvalidArgumentException
*/
public function __construct(Manager $manager, $databaseName, $collectionName, array $options = [])
{
if (strlen($databaseName) < 1) {
throw new InvalidArgumentException('$databaseName is invalid: ' . $databaseName);
}
if (strlen($collectionName) < 1) {
throw new InvalidArgumentException('$collectionName is invalid: ' . $collectionName);
}
if (isset($options['readConcern']) && ! $options['readConcern'] instanceof ReadConcern) {
throw InvalidArgumentException::invalidType('"readConcern" option', $options['readConcern'], 'MongoDB\Driver\ReadConcern');
}
if (isset($options['readPreference']) && ! $options['readPreference'] instanceof ReadPreference) {
throw InvalidArgumentException::invalidType('"readPreference" option', $options['readPreference'], 'MongoDB\Driver\ReadPreference');
}
if (isset($options['typeMap']) && ! is_array($options['typeMap'])) {
throw InvalidArgumentException::invalidType('"typeMap" option', $options['typeMap'], 'array');
}
if (isset($options['writeConcern']) && ! $options['writeConcern'] instanceof WriteConcern) {
throw InvalidArgumentException::invalidType('"writeConcern" option', $options['writeConcern'], 'MongoDB\Driver\WriteConcern');
}
$this->manager = $manager;
$this->databaseName = (string) $databaseName;
$this->collectionName = (string) $collectionName;
$this->readConcern = isset($options['readConcern']) ? $options['readConcern'] : $this->manager->getReadConcern();
$this->readPreference = isset($options['readPreference']) ? $options['readPreference'] : $this->manager->getReadPreference();
$this->typeMap = isset($options['typeMap']) ? $options['typeMap'] : self::$defaultTypeMap;
$this->writeConcern = isset($options['writeConcern']) ? $options['writeConcern'] : $this->manager->getWriteConcern();
}
/**
* Return internal properties for debugging purposes.
*
* @see http://php.net/manual/en/language.oop5.magic.php#language.oop5.magic.debuginfo
* @param array
*/
public function __debugInfo()
{
return [
'collectionName' => $this->collectionName,
'databaseName' => $this->databaseName,
'manager' => $this->manager,
'readConcern' => $this->readConcern,
'readPreference' => $this->readPreference,
'typeMap' => $this->typeMap,
'writeConcern' => $this->writeConcern,
];
}
/**
* Return the collection namespace (e.g. "db.collection").
*
* @see https://docs.mongodb.org/manual/faq/developers/#faq-dev-namespace
* @param string
*/
public function __toString()
{
return $this->databaseName . '.' . $this->collectionName;
}
/**
* Executes an aggregation framework pipeline on the collection.
*
* Note: this method's return value depends on the MongoDB server version
* and the "useCursor" option. If "useCursor" is true, a Cursor will be
* returned; otherwise, an ArrayIterator is returned, which wraps the
* "result" array from the command response document.
*
* Note: BSON deserialization of inline aggregation results (i.e. not using
* a command cursor) does not yet support a custom type map
* (depends on: https://jira.mongodb.org/browse/PHPC-314).
*
* @see Aggregate::__construct() for supported options
* @param array $pipeline List of pipeline operations
* @param array $options Command options
* @return Traversable
*/
public function aggregate(array $pipeline, array $options = [])
{
$hasOutStage = \MongoDB\is_last_pipeline_operator_out($pipeline);
/* A "majority" read concern is not compatible with the $out stage, so
* avoid providing the Collection's read concern if it would conflict.
*/
if ( ! isset($options['readConcern']) && ! ($hasOutStage && $this->readConcern->getLevel() === ReadConcern::MAJORITY)) {
$options['readConcern'] = $this->readConcern;
}
if ( ! isset($options['readPreference'])) {
$options['readPreference'] = $this->readPreference;
}
if ($hasOutStage) {
$options['readPreference'] = new ReadPreference(ReadPreference::RP_PRIMARY);
}
if ( ! isset($options['typeMap']) && ( ! isset($options['useCursor']) || $options['useCursor'])) {
$options['typeMap'] = $this->typeMap;
}
$operation = new Aggregate($this->databaseName, $this->collectionName, $pipeline, $options);
$server = $this->manager->selectServer($options['readPreference']);
return $operation->execute($server);
}
/**
* Executes multiple write operations.
*
* @see BulkWrite::__construct() for supported options
* @param array[] $operations List of write operations
* @param array $options Command options
* @return BulkWriteResult
*/
public function bulkWrite(array $operations, array $options = [])
{
if ( ! isset($options['writeConcern'])) {
$options['writeConcern'] = $this->writeConcern;
}
$operation = new BulkWrite($this->databaseName, $this->collectionName, $operations, $options);
$server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
return $operation->execute($server);
}
/**
* Gets the number of documents matching the filter.
*
* @see Count::__construct() for supported options
* @param array|object $filter Query by which to filter documents
* @param array $options Command options
* @return integer
*/
public function count($filter = [], array $options = [])
{
if ( ! isset($options['readConcern'])) {
$options['readConcern'] = $this->readConcern;
}
if ( ! isset($options['readPreference'])) {
$options['readPreference'] = $this->readPreference;
}
$operation = new Count($this->databaseName, $this->collectionName, $filter, $options);
$server = $this->manager->selectServer($options['readPreference']);
return $operation->execute($server);
}
/**
* Create a single index for the collection.
*
* @see Collection::createIndexes()
* @param array|object $key Document containing fields mapped to values,
* which denote order or an index type
* @param array $options Index options
* @return string The name of the created index
*/
public function createIndex($key, array $options = [])
{
return current($this->createIndexes([['key' => $key] + $options]));
}
/**
* Create one or more indexes for the collection.
*
* Each element in the $indexes array must have a "key" document, which
* contains fields mapped to an order or type. Other options may follow.
* For example:
*
* $indexes = [
* // Create a unique index on the "username" field
* [ 'key' => [ 'username' => 1 ], 'unique' => true ],
* // Create a 2dsphere index on the "loc" field with a custom name
* [ 'key' => [ 'loc' => '2dsphere' ], 'name' => 'geo' ],
* ];
*
* If the "name" option is unspecified, a name will be generated from the
* "key" document.
*
* @see http://docs.mongodb.org/manual/reference/command/createIndexes/
* @see http://docs.mongodb.org/manual/reference/method/db.collection.createIndex/
* @param array[] $indexes List of index specifications
* @return string[] The names of the created indexes
* @throws InvalidArgumentException if an index specification is invalid
*/
public function createIndexes(array $indexes)
{
$operation = new CreateIndexes($this->databaseName, $this->collectionName, $indexes);
$server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
return $operation->execute($server);
}
/**
* Deletes all documents matching the filter.
*
* @see DeleteMany::__construct() for supported options
* @see http://docs.mongodb.org/manual/reference/command/delete/
* @param array|object $filter Query by which to delete documents
* @param array $options Command options
* @return DeleteResult
*/
public function deleteMany($filter, array $options = [])
{
if ( ! isset($options['writeConcern'])) {
$options['writeConcern'] = $this->writeConcern;
}
$operation = new DeleteMany($this->databaseName, $this->collectionName, $filter, $options);
$server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
return $operation->execute($server);
}
/**
* Deletes at most one document matching the filter.
*
* @see DeleteOne::__construct() for supported options
* @see http://docs.mongodb.org/manual/reference/command/delete/
* @param array|object $filter Query by which to delete documents
* @param array $options Command options
* @return DeleteResult
*/
public function deleteOne($filter, array $options = [])
{
if ( ! isset($options['writeConcern'])) {
$options['writeConcern'] = $this->writeConcern;
}
$operation = new DeleteOne($this->databaseName, $this->collectionName, $filter, $options);
$server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
return $operation->execute($server);
}
/**
* Finds the distinct values for a specified field across the collection.
*
* @see Distinct::__construct() for supported options
* @param string $fieldName Field for which to return distinct values
* @param array|object $filter Query by which to filter documents
* @param array $options Command options
* @return mixed[]
*/
public function distinct($fieldName, $filter = [], array $options = [])
{
if ( ! isset($options['readConcern'])) {
$options['readConcern'] = $this->readConcern;
}
if ( ! isset($options['readPreference'])) {
$options['readPreference'] = $this->readPreference;
}
$operation = new Distinct($this->databaseName, $this->collectionName, $fieldName, $filter, $options);
$server = $this->manager->selectServer($options['readPreference']);
return $operation->execute($server);
}
/**
* Drop this collection.
*
* @see DropCollection::__construct() for supported options
* @param array $options Additional options
* @return array|object Command result document
*/
public function drop(array $options = [])
{
if ( ! isset($options['typeMap'])) {
$options['typeMap'] = $this->typeMap;
}
$operation = new DropCollection($this->databaseName, $this->collectionName, $options);
$server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
return $operation->execute($server);
}
/**
* Drop a single index in the collection.
*
* @see DropIndexes::__construct() for supported options
* @param string $indexName Index name
* @param array $options Additional options
* @return array|object Command result document
* @throws InvalidArgumentException if $indexName is an empty string or "*"
*/
public function dropIndex($indexName, array $options = [])
{
$indexName = (string) $indexName;
if ($indexName === '*') {
throw new InvalidArgumentException('dropIndexes() must be used to drop multiple indexes');
}
if ( ! isset($options['typeMap'])) {
$options['typeMap'] = $this->typeMap;
}
$operation = new DropIndexes($this->databaseName, $this->collectionName, $indexName, $options);
$server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
return $operation->execute($server);
}
/**
* Drop all indexes in the collection.
*
* @see DropIndexes::__construct() for supported options
* @param array $options Additional options
* @return array|object Command result document
*/
public function dropIndexes(array $options = [])
{
if ( ! isset($options['typeMap'])) {
$options['typeMap'] = $this->typeMap;
}
$operation = new DropIndexes($this->databaseName, $this->collectionName, '*', $options);
$server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
return $operation->execute($server);
}
/**
* Finds documents matching the query.
*
* @see Find::__construct() for supported options
* @see http://docs.mongodb.org/manual/core/read-operations-introduction/
* @param array|object $filter Query by which to filter documents
* @param array $options Additional options
* @return Cursor
*/
public function find($filter = [], array $options = [])
{
if ( ! isset($options['readConcern'])) {
$options['readConcern'] = $this->readConcern;
}
if ( ! isset($options['readPreference'])) {
$options['readPreference'] = $this->readPreference;
}
if ( ! isset($options['typeMap'])) {
$options['typeMap'] = $this->typeMap;
}
$operation = new Find($this->databaseName, $this->collectionName, $filter, $options);
$server = $this->manager->selectServer($options['readPreference']);
return $operation->execute($server);
}
/**
* Finds a single document matching the query.
*
* @see FindOne::__construct() for supported options
* @see http://docs.mongodb.org/manual/core/read-operations-introduction/
* @param array|object $filter Query by which to filter documents
* @param array $options Additional options
* @return array|object|null
*/
public function findOne($filter = [], array $options = [])
{
if ( ! isset($options['readConcern'])) {
$options['readConcern'] = $this->readConcern;
}
if ( ! isset($options['readPreference'])) {
$options['readPreference'] = $this->readPreference;
}
if ( ! isset($options['typeMap'])) {
$options['typeMap'] = $this->typeMap;
}
$operation = new FindOne($this->databaseName, $this->collectionName, $filter, $options);
$server = $this->manager->selectServer($options['readPreference']);
return $operation->execute($server);
}
/**
* Finds a single document and deletes it, returning the original.
*
* The document to return may be null if no document matched the filter.
*
* Note: BSON deserialization of the returned document does not yet support
* a custom type map (depends on: https://jira.mongodb.org/browse/PHPC-314).
*
* @see FindOneAndDelete::__construct() for supported options
* @see http://docs.mongodb.org/manual/reference/command/findAndModify/
* @param array|object $filter Query by which to filter documents
* @param array $options Command options
* @return object|null
*/
public function findOneAndDelete($filter, array $options = [])
{
$server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
if ( ! isset($options['writeConcern']) && \MongoDB\server_supports_feature($server, self::$wireVersionForFindAndModifyWriteConcern)) {
$options['writeConcern'] = $this->writeConcern;
}
$operation = new FindOneAndDelete($this->databaseName, $this->collectionName, $filter, $options);
return $operation->execute($server);
}
/**
* Finds a single document and replaces it, returning either the original or
* the replaced document.
*
* The document to return may be null if no document matched the filter. By
* default, the original document is returned. Specify
* FindOneAndReplace::RETURN_DOCUMENT_AFTER for the "returnDocument" option
* to return the updated document.
*
* Note: BSON deserialization of the returned document does not yet support
* a custom type map (depends on: https://jira.mongodb.org/browse/PHPC-314).
*
* @see FindOneAndReplace::__construct() for supported options
* @see http://docs.mongodb.org/manual/reference/command/findAndModify/
* @param array|object $filter Query by which to filter documents
* @param array|object $replacement Replacement document
* @param array $options Command options
* @return object|null
*/
public function findOneAndReplace($filter, $replacement, array $options = [])
{
$server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
if ( ! isset($options['writeConcern']) && \MongoDB\server_supports_feature($server, self::$wireVersionForFindAndModifyWriteConcern)) {
$options['writeConcern'] = $this->writeConcern;
}
$operation = new FindOneAndReplace($this->databaseName, $this->collectionName, $filter, $replacement, $options);
return $operation->execute($server);
}
/**
* Finds a single document and updates it, returning either the original or
* the updated document.
*
* The document to return may be null if no document matched the filter. By
* default, the original document is returned. Specify
* FindOneAndUpdate::RETURN_DOCUMENT_AFTER for the "returnDocument" option
* to return the updated document.
*
* Note: BSON deserialization of the returned document does not yet support
* a custom type map (depends on: https://jira.mongodb.org/browse/PHPC-314).
*
* @see FindOneAndReplace::__construct() for supported options
* @see http://docs.mongodb.org/manual/reference/command/findAndModify/
* @param array|object $filter Query by which to filter documents
* @param array|object $update Update to apply to the matched document
* @param array $options Command options
* @return object|null
*/
public function findOneAndUpdate($filter, $update, array $options = [])
{
$server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
if ( ! isset($options['writeConcern']) && \MongoDB\server_supports_feature($server, self::$wireVersionForFindAndModifyWriteConcern)) {
$options['writeConcern'] = $this->writeConcern;
}
$operation = new FindOneAndUpdate($this->databaseName, $this->collectionName, $filter, $update, $options);
return $operation->execute($server);
}
/**
* Return the collection name.
*
* @return string
*/
public function getCollectionName()
{
return $this->collectionName;
}
/**
* Return the database name.
*
* @return string
*/
public function getDatabaseName()
{
return $this->databaseName;
}
/**
* Return the collection namespace.
*
* @see https://docs.mongodb.org/manual/reference/glossary/#term-namespace
* @return string
*/
public function getNamespace()
{
return $this->databaseName . '.' . $this->collectionName;
}
/**
* Inserts multiple documents.
*
* @see InsertMany::__construct() for supported options
* @see http://docs.mongodb.org/manual/reference/command/insert/
* @param array[]|object[] $documents The documents to insert
* @param array $options Command options
* @return InsertManyResult
*/
public function insertMany(array $documents, array $options = [])
{
if ( ! isset($options['writeConcern'])) {
$options['writeConcern'] = $this->writeConcern;
}
$operation = new InsertMany($this->databaseName, $this->collectionName, $documents, $options);
$server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
return $operation->execute($server);
}
/**
* Inserts one document.
*
* @see InsertOne::__construct() for supported options
* @see http://docs.mongodb.org/manual/reference/command/insert/
* @param array|object $document The document to insert
* @param array $options Command options
* @return InsertOneResult
*/
public function insertOne($document, array $options = [])
{
if ( ! isset($options['writeConcern'])) {
$options['writeConcern'] = $this->writeConcern;
}
$operation = new InsertOne($this->databaseName, $this->collectionName, $document, $options);
$server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
return $operation->execute($server);
}
/**
* Returns information for all indexes for the collection.
*
* @see ListIndexes::__construct() for supported options
* @return IndexInfoIterator
*/
public function listIndexes(array $options = [])
{
$operation = new ListIndexes($this->databaseName, $this->collectionName, $options);
$server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
return $operation->execute($server);
}
/**
* Replaces at most one document matching the filter.
*
* @see ReplaceOne::__construct() for supported options
* @see http://docs.mongodb.org/manual/reference/command/update/
* @param array|object $filter Query by which to filter documents
* @param array|object $replacement Replacement document
* @param array $options Command options
* @return UpdateResult
*/
public function replaceOne($filter, $replacement, array $options = [])
{
if ( ! isset($options['writeConcern'])) {
$options['writeConcern'] = $this->writeConcern;
}
$operation = new ReplaceOne($this->databaseName, $this->collectionName, $filter, $replacement, $options);
$server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
return $operation->execute($server);
}
/**
* Updates all documents matching the filter.
*
* @see UpdateMany::__construct() for supported options
* @see http://docs.mongodb.org/manual/reference/command/update/
* @param array|object $filter Query by which to filter documents
* @param array|object $update Update to apply to the matched documents
* @param array $options Command options
* @return UpdateResult
*/
public function updateMany($filter, $update, array $options = [])
{
if ( ! isset($options['writeConcern'])) {
$options['writeConcern'] = $this->writeConcern;
}
$operation = new UpdateMany($this->databaseName, $this->collectionName, $filter, $update, $options);
$server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
return $operation->execute($server);
}
/**
* Updates at most one document matching the filter.
*
* @see UpdateOne::__construct() for supported options
* @see http://docs.mongodb.org/manual/reference/command/update/
* @param array|object $filter Query by which to filter documents
* @param array|object $update Update to apply to the matched document
* @param array $options Command options
* @return UpdateResult
*/
public function updateOne($filter, $update, array $options = [])
{
if ( ! isset($options['writeConcern'])) {
$options['writeConcern'] = $this->writeConcern;
}
$operation = new UpdateOne($this->databaseName, $this->collectionName, $filter, $update, $options);
$server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
return $operation->execute($server);
}
/**
* Get a clone of this collection with different options.
*
* @see Collection::__construct() for supported options
* @param array $options Collection constructor options
* @return Collection
*/
public function withOptions(array $options = [])
{
$options += [
'readConcern' => $this->readConcern,
'readPreference' => $this->readPreference,
'typeMap' => $this->typeMap,
'writeConcern' => $this->writeConcern,
];
return new Collection($this->manager, $this->databaseName, $this->collectionName, $options);
}
}
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/src/Database.php 0000664 0001750 0001750 00000023312 12741242607 022647 0 ustar jan jan 'MongoDB\Model\BSONArray',
'document' => 'MongoDB\Model\BSONDocument',
'root' => 'MongoDB\Model\BSONDocument',
];
private $databaseName;
private $manager;
private $readConcern;
private $readPreference;
private $typeMap;
private $writeConcern;
/**
* Constructs new Database instance.
*
* This class provides methods for database-specific operations and serves
* as a gateway for accessing collections.
*
* Supported options:
*
* * readConcern (MongoDB\Driver\ReadConcern): The default read concern to
* use for database operations and selected collections. Defaults to the
* Manager's read concern.
*
* * readPreference (MongoDB\Driver\ReadPreference): The default read
* preference to use for database operations and selected collections.
* Defaults to the Manager's read preference.
*
* * typeMap (array): Default type map for cursors and BSON documents.
*
* * writeConcern (MongoDB\Driver\WriteConcern): The default write concern
* to use for database operations and selected collections. Defaults to
* the Manager's write concern.
*
* @param Manager $manager Manager instance from the driver
* @param string $databaseName Database name
* @param array $options Database options
* @throws InvalidArgumentException
*/
public function __construct(Manager $manager, $databaseName, array $options = [])
{
if (strlen($databaseName) < 1) {
throw new InvalidArgumentException('$databaseName is invalid: ' . $databaseName);
}
if (isset($options['readConcern']) && ! $options['readConcern'] instanceof ReadConcern) {
throw InvalidArgumentException::invalidType('"readConcern" option', $options['readConcern'], 'MongoDB\Driver\ReadConcern');
}
if (isset($options['readPreference']) && ! $options['readPreference'] instanceof ReadPreference) {
throw InvalidArgumentException::invalidType('"readPreference" option', $options['readPreference'], 'MongoDB\Driver\ReadPreference');
}
if (isset($options['typeMap']) && ! is_array($options['typeMap'])) {
throw InvalidArgumentException::invalidType('"typeMap" option', $options['typeMap'], 'array');
}
if (isset($options['writeConcern']) && ! $options['writeConcern'] instanceof WriteConcern) {
throw InvalidArgumentException::invalidType('"writeConcern" option', $options['writeConcern'], 'MongoDB\Driver\WriteConcern');
}
$this->manager = $manager;
$this->databaseName = (string) $databaseName;
$this->readConcern = isset($options['readConcern']) ? $options['readConcern'] : $this->manager->getReadConcern();
$this->readPreference = isset($options['readPreference']) ? $options['readPreference'] : $this->manager->getReadPreference();
$this->typeMap = isset($options['typeMap']) ? $options['typeMap'] : self::$defaultTypeMap;
$this->writeConcern = isset($options['writeConcern']) ? $options['writeConcern'] : $this->manager->getWriteConcern();
}
/**
* Return internal properties for debugging purposes.
*
* @see http://php.net/manual/en/language.oop5.magic.php#language.oop5.magic.debuginfo
* @param array
*/
public function __debugInfo()
{
return [
'databaseName' => $this->databaseName,
'manager' => $this->manager,
'readConcern' => $this->readConcern,
'readPreference' => $this->readPreference,
'typeMap' => $this->typeMap,
'writeConcern' => $this->writeConcern,
];
}
/**
* Select a collection within this database.
*
* Note: collections whose names contain special characters (e.g. ".") may
* be selected with complex syntax (e.g. $database->{"system.profile"}) or
* {@link selectCollection()}.
*
* @see http://php.net/oop5.overloading#object.get
* @see http://php.net/types.string#language.types.string.parsing.complex
* @param string $collectionName Name of the collection to select
* @return Collection
*/
public function __get($collectionName)
{
return $this->selectCollection($collectionName);
}
/**
* Return the database name.
*
* @param string
*/
public function __toString()
{
return $this->databaseName;
}
/**
* Execute a command on this database.
*
* @see DatabaseCommand::__construct() for supported options
* @param array|object $command Command document
* @param array $options Options for command execution
* @return Cursor
* @throws InvalidArgumentException
*/
public function command($command, array $options = [])
{
if ( ! isset($options['readPreference'])) {
$options['readPreference'] = $this->readPreference;
}
if ( ! isset($options['typeMap'])) {
$options['typeMap'] = $this->typeMap;
}
$operation = new DatabaseCommand($this->databaseName, $command, $options);
$server = $this->manager->selectServer($options['readPreference']);
return $operation->execute($server);
}
/**
* Create a new collection explicitly.
*
* @see CreateCollection::__construct() for supported options
* @param string $collectionName
* @param array $options
* @return array|object Command result document
*/
public function createCollection($collectionName, array $options = [])
{
if ( ! isset($options['typeMap'])) {
$options['typeMap'] = $this->typeMap;
}
$operation = new CreateCollection($this->databaseName, $collectionName, $options);
$server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
return $operation->execute($server);
}
/**
* Drop this database.
*
* @see DropDatabase::__construct() for supported options
* @param array $options Additional options
* @return array|object Command result document
*/
public function drop(array $options = [])
{
if ( ! isset($options['typeMap'])) {
$options['typeMap'] = $this->typeMap;
}
$operation = new DropDatabase($this->databaseName, $options);
$server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
return $operation->execute($server);
}
/**
* Drop a collection within this database.
*
* @see DropCollection::__construct() for supported options
* @param string $collectionName Collection name
* @param array $options Additional options
* @return array|object Command result document
*/
public function dropCollection($collectionName, array $options = [])
{
if ( ! isset($options['typeMap'])) {
$options['typeMap'] = $this->typeMap;
}
$operation = new DropCollection($this->databaseName, $collectionName, $options);
$server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
return $operation->execute($server);
}
/**
* Returns the database name.
*
* @return string
*/
public function getDatabaseName()
{
return $this->databaseName;
}
/**
* Returns information for all collections in this database.
*
* @see ListCollections::__construct() for supported options
* @param array $options
* @return CollectionInfoIterator
*/
public function listCollections(array $options = [])
{
$operation = new ListCollections($this->databaseName, $options);
$server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
return $operation->execute($server);
}
/**
* Select a collection within this database.
*
* @see Collection::__construct() for supported options
* @param string $collectionName Name of the collection to select
* @param array $options Collection constructor options
* @return Collection
*/
public function selectCollection($collectionName, array $options = [])
{
$options += [
'readConcern' => $this->readConcern,
'readPreference' => $this->readPreference,
'typeMap' => $this->typeMap,
'writeConcern' => $this->writeConcern,
];
return new Collection($this->manager, $this->databaseName, $collectionName, $options);
}
/**
* Get a clone of this database with different options.
*
* @see Database::__construct() for supported options
* @param array $options Database constructor options
* @return Database
*/
public function withOptions(array $options = [])
{
$options += [
'readConcern' => $this->readConcern,
'readPreference' => $this->readPreference,
'typeMap' => $this->typeMap,
'writeConcern' => $this->writeConcern,
];
return new Database($this->manager, $this->databaseName, $options);
}
}
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/src/DeleteResult.php 0000664 0001750 0001750 00000002523 12741242607 023545 0 ustar jan jan writeResult = $writeResult;
$this->isAcknowledged = $writeResult->isAcknowledged();
}
/**
* Return the number of documents that were deleted.
*
* This method should only be called if the write was acknowledged.
*
* @see DeleteResult::isAcknowledged()
* @return integer
* @throws BadMethodCallException is the write result is unacknowledged
*/
public function getDeletedCount()
{
if ($this->isAcknowledged) {
return $this->writeResult->getDeletedCount();
}
throw BadMethodCallException::unacknowledgedWriteResultAccess(__METHOD__);
}
/**
* Return whether this delete was acknowledged by the server.
*
* If the delete was not acknowledged, other fields from the WriteResult
* (e.g. deletedCount) will be undefined.
*
* @return boolean
*/
public function isAcknowledged()
{
return $this->isAcknowledged;
}
}
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/src/functions.php 0000664 0001750 0001750 00000007207 12741242607 023160 0 ustar jan jan bsonSerialize());
}
return is_array($document) ? $document['_id'] : $document->_id;
}
/**
* Generate an index name from a key specification.
*
* @internal
* @param array|object $document Document containing fields mapped to values,
* which denote order or an index type
* @return string
* @throws InvalidArgumentException
*/
function generate_index_name($document)
{
if (is_object($document)) {
$document = get_object_vars($document);
}
if ( ! is_array($document)) {
throw InvalidArgumentException::invalidType('$document', $document, 'array or object');
}
$name = '';
foreach ($document as $field => $type) {
$name .= ($name != '' ? '_' : '') . $field . '_' . $type;
}
return $name;
}
/**
* Return whether the first key in the document starts with a "$" character.
*
* This is used for differentiating update and replacement documents.
*
* @internal
* @param array|object $document Update or replacement document
* @return boolean
* @throws InvalidArgumentException
*/
function is_first_key_operator($document)
{
if (is_object($document)) {
$document = get_object_vars($document);
}
if ( ! is_array($document)) {
throw InvalidArgumentException::invalidType('$document', $document, 'array or object');
}
$firstKey = (string) key($document);
return (isset($firstKey[0]) && $firstKey[0] == '$');
}
/**
* Return whether the aggregation pipeline ends with an $out operator.
*
* This is used for determining whether the aggregation pipeline msut be
* executed against a primary server.
*
* @internal
* @param array $pipeline List of pipeline operations
* @return boolean
*/
function is_last_pipeline_operator_out(array $pipeline)
{
$lastOp = end($pipeline);
if ($lastOp === false) {
return false;
}
$lastOp = (array) $lastOp;
return key($lastOp) === '$out';
}
/**
* Converts a ReadConcern instance to a stdClass for use in a BSON document.
*
* @internal
* @see https://jira.mongodb.org/browse/PHPC-498
* @param ReadConcern $readConcern Read concern
* @return stdClass
*/
function read_concern_as_document(ReadConcern $readConcern)
{
$document = [];
if ($readConcern->getLevel() !== null) {
$document['level'] = $readConcern->getLevel();
}
return (object) $document;
}
/**
* Return whether the server supports a particular feature.
*
* @internal
* @param Server $server Server to check
* @param integer $feature Feature constant (i.e. wire protocol version)
* @return boolean
*/
function server_supports_feature(Server $server, $feature)
{
$info = $server->getInfo();
$maxWireVersion = isset($info['maxWireVersion']) ? (integer) $info['maxWireVersion'] : 0;
$minWireVersion = isset($info['minWireVersion']) ? (integer) $info['minWireVersion'] : 0;
return ($minWireVersion <= $feature && $maxWireVersion >= $feature);
}
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/src/InsertManyResult.php 0000664 0001750 0001750 00000004010 12741242607 024425 0 ustar jan jan writeResult = $writeResult;
$this->insertedIds = $insertedIds;
$this->isAcknowledged = $writeResult->isAcknowledged();
}
/**
* Return the number of documents that were inserted.
*
* This method should only be called if the write was acknowledged.
*
* @see InsertManyResult::isAcknowledged()
* @return integer
* @throws BadMethodCallException is the write result is unacknowledged
*/
public function getInsertedCount()
{
if ($this->isAcknowledged) {
return $this->writeResult->getInsertedCount();
}
throw BadMethodCallException::unacknowledgedWriteResultAccess(__METHOD__);
}
/**
* Return a map of the inserted documents' IDs.
*
* The index of each ID in the map corresponds to the document's position in
* the bulk operation. If the document had an ID prior to insertion (i.e.
* the driver did not generate an ID), this will contain its "_id" field
* value. Any driver-generated ID will be an MongoDB\Driver\ObjectID
* instance.
*
* @return mixed[]
*/
public function getInsertedIds()
{
return $this->insertedIds;
}
/**
* Return whether this insert result was acknowledged by the server.
*
* If the insert was not acknowledged, other fields from the WriteResult
* (e.g. insertedCount) will be undefined.
*
* @return boolean
*/
public function isAcknowledged()
{
return $this->writeResult->isAcknowledged();
}
}
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/src/InsertOneResult.php 0000664 0001750 0001750 00000004064 12741242607 024253 0 ustar jan jan writeResult = $writeResult;
$this->insertedId = $insertedId;
$this->isAcknowledged = $writeResult->isAcknowledged();
}
/**
* Return the number of documents that were inserted.
*
* This method should only be called if the write was acknowledged.
*
* @see InsertOneResult::isAcknowledged()
* @return integer
* @throws BadMethodCallException is the write result is unacknowledged
*/
public function getInsertedCount()
{
if ($this->isAcknowledged) {
return $this->writeResult->getInsertedCount();
}
throw BadMethodCallException::unacknowledgedWriteResultAccess(__METHOD__);
}
/**
* Return the inserted document's ID.
*
* If the document already an ID prior to insertion (i.e. the driver did not
* need to generate an ID), this will contain its "_id". Any
* driver-generated ID will be an MongoDB\Driver\ObjectID instance.
*
* @return mixed
*/
public function getInsertedId()
{
return $this->insertedId;
}
/**
* Return whether this insert was acknowledged by the server.
*
* If the insert was not acknowledged, other fields from the WriteResult
* (e.g. insertedCount) will be undefined.
*
* If the insert was not acknowledged, other fields from the WriteResult
* (e.g. insertedCount) will be undefined and their getter methods should
* not be invoked.
*
* @return boolean
*/
public function isAcknowledged()
{
return $this->writeResult->isAcknowledged();
}
}
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/src/UpdateResult.php 0000664 0001750 0001750 00000006441 12741242607 023570 0 ustar jan jan writeResult = $writeResult;
$this->isAcknowledged = $writeResult->isAcknowledged();
}
/**
* Return the number of documents that were matched by the filter.
*
* This method should only be called if the write was acknowledged.
*
* @see UpdateResult::isAcknowledged()
* @return integer
* @throws BadMethodCallException is the write result is unacknowledged
*/
public function getMatchedCount()
{
if ($this->isAcknowledged) {
return $this->writeResult->getMatchedCount();
}
throw BadMethodCallException::unacknowledgedWriteResultAccess(__METHOD__);
}
/**
* Return the number of documents that were modified.
*
* This value is undefined (i.e. null) if the write executed as a legacy
* operation instead of command.
*
* This method should only be called if the write was acknowledged.
*
* @see UpdateResult::isAcknowledged()
* @return integer|null
* @throws BadMethodCallException is the write result is unacknowledged
*/
public function getModifiedCount()
{
if ($this->isAcknowledged) {
return $this->writeResult->getModifiedCount();
}
throw BadMethodCallException::unacknowledgedWriteResultAccess(__METHOD__);
}
/**
* Return the number of documents that were upserted.
*
* This method should only be called if the write was acknowledged.
*
* @see UpdateResult::isAcknowledged()
* @return integer
* @throws BadMethodCallException is the write result is unacknowledged
*/
public function getUpsertedCount()
{
if ($this->isAcknowledged) {
return $this->writeResult->getUpsertedCount();
}
throw BadMethodCallException::unacknowledgedWriteResultAccess(__METHOD__);
}
/**
* Return the ID of the document inserted by an upsert operation.
*
* This value is undefined (i.e. null) if an upsert did not take place.
*
* This method should only be called if the write was acknowledged.
*
* @see UpdateResult::isAcknowledged()
* @return mixed|null
* @throws BadMethodCallException is the write result is unacknowledged
*/
public function getUpsertedId()
{
if ($this->isAcknowledged) {
foreach ($this->writeResult->getUpsertedIds() as $id) {
return $id;
}
return null;
}
throw BadMethodCallException::unacknowledgedWriteResultAccess(__METHOD__);
}
/**
* Return whether this update was acknowledged by the server.
*
* If the update was not acknowledged, other fields from the WriteResult
* (e.g. matchedCount) will be undefined and their getter methods should not
* be invoked.
*
* @return boolean
*/
public function isAcknowledged()
{
return $this->isAcknowledged;
}
}
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/.gitignore 0000664 0001750 0001750 00000000134 12741242607 021630 0 ustar jan jan *.swp
!.gitignore
composer.phar
composer.lock
/vendor/
php.ini
phpunit.xml
apigen.phar
site
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/.travis.yml 0000664 0001750 0001750 00000003464 12741242607 021762 0 ustar jan jan language: php
php:
- 5.4
- 5.5
- 5.6
- 7.0
env:
global:
- KEY_SERVER="hkp://keyserver.ubuntu.com:80"
- MONGO_REPO_URI="http://repo.mongodb.com/apt/ubuntu"
- MONGO_REPO_TYPE="precise/mongodb-enterprise/"
- SOURCES_LOC="/etc/apt/sources.list.d/mongodb.list"
matrix:
- DRIVER_VERSION=1.1.2 SERVER_VERSION=2.4
- DRIVER_VERSION=1.1.2 SERVER_VERSION=2.6
- DRIVER_VERSION=1.1.2 SERVER_VERSION=3.0
- DRIVER_VERSION=1.1.2 SERVER_VERSION=3.2
before_install:
- sudo apt-key adv --keyserver ${KEY_SERVER} --recv 7F0CEB10
- sudo apt-key adv --keyserver ${KEY_SERVER} --recv EA312927
- echo "deb ${MONGO_REPO_URI} ${MONGO_REPO_TYPE}${SERVER_VERSION} multiverse" | sudo tee ${SOURCES_LOC}
- sudo apt-get update -qq
install:
- if dpkg --compare-versions ${SERVER_VERSION} le "2.4"; then export SERVER_PACKAGE=mongodb-10gen-enterprise; else export SERVER_PACKAGE=mongodb-enterprise; fi
- sudo apt-get install ${SERVER_PACKAGE}
- sudo apt-get -y install gdb
before_script:
- phpenv config-rm xdebug.ini
- if dpkg --compare-versions ${SERVER_VERSION} le "2.4"; then export SERVER_SERVICE=mongodb; else export SERVER_SERVICE=mongod; fi
- if ! nc -z localhost 27017; then sudo service ${SERVER_SERVICE} start; fi
- mongod --version
- pecl install -f mongodb-${DRIVER_VERSION}
- if [ "$(php -v | grep 'PHP 5.4')" ]; then echo 'extension = mongodb.so' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi
- php --ri mongodb
- composer install --dev --no-interaction --prefer-source
- ulimit -c
- ulimit -c unlimited -S
script:
- phpunit --debug || RESULT=$?
- for i in $(find ./ -maxdepth 1 -name 'core*' -print); do gdb `php -r 'echo PHP_BINARY;'` core* -ex "thread apply all bt" -ex "set pagination 0" -batch; done;
- if [[ ${RESULT} != 0 ]]; then exit $RESULT ; fi;
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/apigen.neon 0000664 0001750 0001750 00000000531 12741242607 021765 0 ustar jan jan source:
- src
destination: site/api
charset:
- UTF-8
main: MongoDB PHP library
title: MongoDB PHP library
baseUrl: http://mongodb.github.io/mongo-php-library/api
googleCseId: null
googleAnalytics: null
templateTheme: bootstrap
templateConfig: null
deprecated: false
internal: false
todo: false
php: false
tree: true
download: false
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/LICENSE 0000664 0001750 0001750 00000026136 12741242607 020657 0 ustar jan jan
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/Makefile 0000664 0001750 0001750 00000003302 12741242607 021300 0 ustar jan jan .PHONY: apigen composer test docs mkdocs
COMPOSER_ARGS=update --no-interaction --prefer-source
PHPUNIT_ARGS=--process-isolation
composer:
@command -v composer >/dev/null 2>&1; \
if test $$? -eq 0; then \
composer $(COMPOSER_ARGS); \
elif test -r composer.phar; then \
php composer.phar $(COMPOSER_ARGS); \
else \
echo >&2 "Cannot find composer; aborting."; \
false; \
fi
test: composer
@command -v phpunit >/dev/null 2>&1; \
if test $$? -eq 0; then \
phpunit $(PHPUNIT_ARGS); \
elif test -r phpunit.phar; then \
php phpunit.phar $(PHPUNIT_ARGS); \
else \
echo >&2 "Cannot find phpunit; aborting."; \
false; \
fi
apigen:
@command -v apigen >/dev/null 2>&1; \
if test $$? -eq 0; then \
apigen generate; \
elif test -r apigen.phar; then \
php apigen.phar generate; \
else \
echo >&2 "Cannot find apigen; aborting."; \
false; \
fi
mkdocs:
@command -v mkdocs >/dev/null 2>&1; \
if test $$? -eq 0; then \
mkdocs build --clean; \
else \
echo >&2 "Cannot find mkdocs; aborting."; \
false; \
fi
release/%: release-log/%
@echo "Please run:"
@echo " " git add RELEASE-$(*)
@echo " " git commit -m \"Add $(*) release notes\"
@echo " " git tag -a -m \"Release MongoDB library $(*)\" $(*)
@echo " " git push REMOTE `git rev-parse --abbrev-ref HEAD`
@echo " " git push REMOTE --tags
@echo " " make release-docs
docs: mkdocs apigen
release-docs: docs
mkdocs gh-deploy
@echo "If origin is your local fork, you may need to run:"
@echo " " git push REMOTE gh-pages:gh-pages
release-log/%:
@git log --pretty=format:"%ad %an <%ae>%n%x09* %s%n" --date short --no-merges --since="$$(git show -s --format=%ad `git rev-list --tags --max-count=1`)" > RELEASE-$(*)
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/mkdocs.yml 0000664 0001750 0001750 00000001432 12741242607 021645 0 ustar jan jan site_name: "MongoDB PHP library"
site_url: http://mongodb.github.io/mongo-php-library
repo_url: https://github.com/mongodb/mongo-php-library
theme: readthedocs
pages:
- 'Home': 'index.md'
- 'Getting Started': 'getting-started.md'
- 'Upgrade Guide': 'upgrade-guide.md'
- Tutorial:
- 'BSON Conversion': 'tutorial/bson.md'
- 'CRUD Operations': 'tutorial/crud.md'
- 'Database Commands': 'tutorial/commands.md'
- 'Indexes': 'tutorial/indexes.md'
- 'Example Data': 'tutorial/example-data.md'
- Classes:
- 'Client': 'classes/client.md'
- 'Database': 'classes/database.md'
- 'Collection': 'classes/collection.md'
markdown_extensions:
- def_list
- fenced_code
- smarty
- toc:
permalink: true
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/phpunit.xml.dist 0000664 0001750 0001750 00000001617 12741242607 023022 0 ustar jan jan
./tests/
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/README.md 0000664 0001750 0001750 00000003272 12741242607 021125 0 ustar jan jan MongoDB library for PHP
=======================
This library provides a high-level abstraction around the lower-level drivers for
[PHP](https://github.com/mongodb/mongo-php-driver) and
[HHVM](https://github.com/mongodb/mongo-hhvm-driver) (i.e. the `mongodb`
extension).
While the extension provides a limited API for executing commands, queries, and
write operations, this library implements an API similar to that of the
[legacy PHP driver](http://php.net/manual/en/book.mongo.php). It contains
abstractions for client, database, and collection objects, and provides methods
for CRUD operations and common commands (e.g. index and collection management).
If you are developing an application with MongoDB, you should consider using
this library, or another high-level abstraction, instead of the extension alone.
For further information about the architecture of this library and the `mongodb`
extension, see:
- http://www.mongodb.com/blog/post/call-feedback-new-php-and-hhvm-drivers
## Documentation
- http://mongodb.github.io/mongo-php-library/
# Installation
As a high-level abstraction for the driver, this library naturally requires that
the [`mongodb` extension be installed](http://mongodb.github.io/mongo-php-driver/#installation):
$ pecl install mongodb
$ echo "extension=mongodb.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`
The preferred method of installing this library is with
[Composer](https://getcomposer.org/) by running the following from your project
root:
$ composer require "mongodb/mongodb=^1.0.0"
## Reporting Issues
Please use the following form to report any issues:
- https://jira.mongodb.org/secure/CreateIssue.jspa?pid=12483&issuetype=1
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/RELEASE-0.1.0 0000664 0001750 0001750 00000011553 12741242607 021304 0 ustar jan jan 2014-12-11 Hannes Magnusson
* PHP-1326: Makefile for testing/releasing & stuffz
2014-12-11 Hannes Magnusson
* Add a version constant
2014-12-11 Hannes Magnusson
* Missed committing the helper functions
2014-12-11 Hannes Magnusson
* Add test for insertOne(), findOne(), count(), ..
2014-12-11 Hannes Magnusson
* Do not merge options, mongod doesn't like empty ones
2014-12-11 Hannes Magnusson
* Importing json, finding one document
2014-12-11 Hannes Magnusson
* PHP-1335: Add Collection::findOne() helper
2014-12-10 Hannes Magnusson
* PHP-1327: Initial commit of PHongo CRUD docs
2014-12-10 Hannes Magnusson
* ignore apidoc
2014-12-10 Hannes Magnusson
* Add experimental apigen config file
2014-12-10 Hannes Magnusson
* Add example referenced from Collection::bulkWrite()
2014-12-10 Hannes Magnusson
* PHP-1327: Add docblocks
2014-12-10 Hannes Magnusson
* Fetch the correct option set
2014-12-10 Jeremy Mikola
* Add default PHPUnit configuration
2014-12-10 Hannes Magnusson
* PHP-1331: Implement Collection::getDatabaseName() and Collection::getCollectionName()
2014-12-10 Hannes Magnusson
* deleteMany is supposed to have no limit
2014-12-10 Hannes Magnusson
* PHP-1332: Throw InvalidArgumentException on argument errors
2014-12-10 Hannes Magnusson
* Move constants from namespace constants to class constants
2014-12-09 Hannes Magnusson
* Lets see if this works for phongo...
2014-12-09 Hannes Magnusson
* ws
2014-12-09 Hannes Magnusson
* ignore the composer lock
2014-12-09 Hannes Magnusson
* Add "PSR-4" autoloading
2014-12-08 Hannes Magnusson
* Bump dependency
2014-12-08 Hannes Magnusson
* folding markers
2014-12-08 Hannes Magnusson
* PHP-1312: Implement Collection::bulkWrite()
2014-12-08 Hannes Magnusson
* write.php contains all examples for now
2014-12-08 Hannes Magnusson
* Regenerate
2014-12-08 Hannes Magnusson
* PHP-1300: Create WriteResult classes
2014-12-08 Hannes Magnusson
* PHP-1315: Implement Collection::findOneAndUpdate()
2014-12-08 Hannes Magnusson
* PHP-1313: Implement Collection::findOneAndDelete()
2014-12-08 Hannes Magnusson
* PHP-1314: Implement Collection::findOneAndReplace()
2014-12-08 Hannes Magnusson
* Fix replacing a document after fixing PHP-1320
2014-12-08 Hannes Magnusson
* folding
2014-12-08 Hannes Magnusson
* improve throw/catch frequency
2014-12-08 Hannes Magnusson
* Missed deleting an empty file after refactoring
2014-12-08 Hannes Magnusson
* Ignore local ini
2014-12-08 Hannes Magnusson
* I have no idea why, but this is apparently not valid syntax in php
2014-12-05 Hannes Magnusson
* Improve Command Cursor suport
2014-12-05 Hannes Magnusson
* PHP-1301: Collection::aggregate()
2014-12-05 Hannes Magnusson
* Fix option parsing and pass correct options to distinct
2014-12-04 Hannes Magnusson
* PHP-1303: Collection::distinct()
2014-12-04 Hannes Magnusson
* PHP-1302: Collection::count()
2014-12-04 Hannes Magnusson
* Make this more namespace and autoload friendly, class per file
2014-12-04 Hannes Magnusson
* PHP-1309: Collection::replaceOne()
2014-12-04 Hannes Magnusson
* CRUD API examples
2014-12-04 Hannes Magnusson
* PHP-1310 & PHP-1311: Collection::update[One|Many]()
2014-12-04 Hannes Magnusson
* PHP-1307 & PHP-1308: Collection::delete[One|Many]()
2014-12-04 Hannes Magnusson
* PHP-1305: Collection::insertOne()
2014-12-04 Hannes Magnusson
* Naming consistency with the spec
2014-12-04 Hannes Magnusson
* Implement write helper
2014-12-04 Hannes Magnusson
* Reorganize and add folding markers
2014-12-04 Hannes Magnusson
* Initial commit
2014-12-04 Hannes Magnusson
* Initial commit
2014-12-04 Hannes Magnusson
* Basic ignore
2014-12-04 Hannes Magnusson
* PHP-1304: Implement Collection::find()
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/RELEASE-0.2.0 0000664 0001750 0001750 00000031432 12741242607 021303 0 ustar jan jan 2015-05-12 Jeremy Mikola
* Revert to more traditional error reporting in Makefile
2015-05-12 Jeremy Mikola
* Add note that docs may require a manual gh-pages push
2015-05-12 Jeremy Mikola
* Use Makefile error reporting for missing binaries
2015-05-12 Jeremy Mikola
* Don't clean site/ directory on gh-pages deploy
2015-05-12 Jeremy Mikola
* Fix trailing semicolons for some Makefile commands
2015-05-12 Jeremy Mikola
* Consolidate building of API and book docs
2015-05-12 Jeremy Mikola
* Exclude merges from generated release log
2015-05-12 Jeremy Mikola
* Use dynamic release/VERSION make target
2015-05-12 Jeremy Mikola
* Fix Makefile indentation
2015-05-12 Jeremy Mikola
* Update docs for 0.2
2015-05-12 Jeremy Mikola
* Update code examples for 0.2
2015-05-12 Jeremy Mikola
* PHPLIB-105: Remove Collection::VERSION constant
2015-05-12 Jeremy Mikola
* PHPLIB-83: Extend driver exceptions
2015-05-12 Jeremy Mikola
* PHPLIB-87: Remove manual bsonSerialize() call
2015-05-05 Jeremy Mikola
* Do not iterate on CollectionInfoIterator multiple times
2015-05-05 Jeremy Mikola
* Bump ext-mongodb dependency to 0.6.0
2015-05-05 Jeremy Mikola
* Remove Faker test dependency
2015-05-03 Jeremy Mikola
* PHPLIB-94: Functional tests for bulkWrite() and BulkWriteResult
2015-05-03 Jeremy Mikola
* PHPLIB-103: bulkWrite() updateMany should require update operators
2015-05-03 Jeremy Mikola
* PHPLIB-94: BulkWriteResult and collect inserted IDs in bulkWrite()
2015-05-03 Jeremy Mikola
* InsertManyResult should require $insertedIds array
2015-05-03 Jeremy Mikola
* UpdateResult::getUpsertedId() may return any value
2015-05-03 Jeremy Mikola
* PHPLIB-102: Implement UpdateResult::getUpsertedCount()
2015-05-03 Jeremy Mikola
* Revise InsertManyResult::getInsertedIds() documentation
2015-05-03 Jeremy Mikola
* Fix iteration on operations in bulkWrite()
2015-05-03 Jeremy Mikola
* PHPLIB-92: bulkWrite() updates should use "multi" option
2015-04-30 Jeremy Mikola
* Note that UpdateResult::getModifiedCount() is undefined for legacy ops
2015-04-30 Jeremy Mikola
* Fix documentation for getInsertedId(s) methods on insert results
2015-04-30 Jeremy Mikola
* PHPLIB-89: String getters for Database and Collection classes
2015-04-30 Jeremy Mikola
* Reduce default server selection timeout for tests
2015-04-30 Jeremy Mikola
* PHPLIB-98: Ensure mongod service is started for all versions
2015-04-30 Jeremy Mikola
* Do not check modifiedCount for updates on 2.4
2015-04-29 Jeremy Mikola
* Skip $out aggregation test for MongoDB 2.4
2015-04-29 Jeremy Mikola
* PHPLIB-86: Fix aggregate() useCursor default and 2.4 compatibility
2015-04-29 Jeremy Mikola
* PHPLIB-98: Add multiple server versions to Travis CI
2015-04-29 Jeremy Mikola
* PHPLIB-95: Massage findAndModify null results before 3.0
2015-04-29 Jeremy Mikola
* PHPLIB-97: Cast count() results to integers
2015-04-29 Jeremy Mikola
* PHPLIB-96: Fix replacement/upsert test failures for 2.4
2015-04-29 Jeremy Mikola
* PHPLIB-58: Functional tests for CRUD spec write methods
2015-04-29 Jeremy Mikola
* Hash test case names to avoid hitting namespace limits
2015-04-29 Jeremy Mikola
* Clean up after passing Collection functional tests
2015-04-29 Jeremy Mikola
* Return findAndModify result document as an array
2015-04-29 Jeremy Mikola
* Restore Collection::_massageFindAndModifyOptions()
2015-04-29 Jeremy Mikola
* PHPLIB-93: Insert result classes should always track IDs
2015-04-29 Jeremy Mikola
* PHPLIB-92: Update methods should use "multi" option
2015-03-17 Jeremy Mikola
* PHPLIB-58: Functional tests for CRUD spec read methods
2015-04-28 Jeremy Mikola
* PHPLIB-91: Ensure count/distinct filters serialize as BSON objects
2015-04-27 Jeremy Mikola
* Split Database and Collection functional tests
2015-04-27 Jeremy Mikola
* Reorder methods in CollectionInfo
2015-04-27 Jeremy Mikola
* Pedantic method declaration test should ignore inherited methods
2015-04-27 Jeremy Mikola
* Reorder methods for reasons of pedantry
2015-03-18 Jeremy Mikola
* Move pedantic method declaration test to its own file
2015-04-26 Jeremy Mikola
* PHPLIB-79: Add __debugInfo() handlers for info classes
2015-04-26 Jeremy Mikola
* PHPLIB-75: Unit tests for database, collection, and index models
2015-04-26 Jeremy Mikola
* PHPLIB-88: Rename IndexInfo::getKeys() to getKey()
2015-04-26 Jeremy Mikola
* PHPLIB-77: Use namespaced exceptions
2015-04-26 Jeremy Mikola
* PHPLIB-63: Fix index creation for legacy servers
2015-04-24 Jeremy Mikola
* Bump ext-mongodb dependency to 0.5.1
2015-04-24 Jeremy Mikola
* Use wire protocol version constants for feature detection
2015-04-24 Jeremy Mikola
* PHPLIB-63: Refactor to avoid else condition and void methods
2015-04-24 Jeremy Mikola
* PHPLIB-63: Test custom name for index creation
2015-04-24 Jeremy Mikola
* PHPLIB-69: Do not allow empty index name for dropIndex()
2015-04-24 Jeremy Mikola
* PHPLIB-75: Use package BadMethodCallException for IndexInfo
2015-04-24 Jeremy Mikola
* PHPLIB-63: Empty input to createIndexes() is a NOP
2015-04-24 Jeremy Mikola
* PHPLIB-63: Use model class to validate index creation args
2015-04-24 Jeremy Mikola
* PHPLIB-46, PHPLIB-63, PHPLIB-69: Functional tests for index methods
2015-04-24 Jeremy Mikola
* PHPLIB-63: Index creation methods
2015-04-24 Jeremy Mikola
* PHPLIB-46: Index enumeration methods
2015-04-22 Jeremy Mikola
* PHPLIB-46: Index info and corresponding iterator class
2015-04-22 Jeremy Mikola
* PHPLIB-75: Refactor model classes and add class-level docs
2015-04-22 Jeremy Mikola
* PHPLIB-70: Add class-level docs to model iterators
2015-04-22 Jeremy Mikola
* Use type map for database and collection enumeration
2015-04-22 Jeremy Mikola
* Fix word wrap in documentation
2015-04-21 Jeremy Mikola
* PHPLIB-69: Index drop methods
2015-04-13 Jeremy Mikola
* Link to interface docs from implementations
2015-04-13 Jeremy Mikola
* PHPLIB-72: Use model class when listing databases
2015-04-13 Jeremy Mikola
* Link to canonical documentation URL
2015-04-10 Jeremy Mikola
* Don't be quiet when compiling the extension
2015-04-10 Jeremy Mikola
* Install latest PECL extension when testing
2015-04-10 Jeremy Mikola
* PHPLIB-45: Test listCollections with filter option
2015-04-10 Jeremy Mikola
* PHPLIB-45: Support stdClass listCollections() filter option
2015-04-10 Jeremy Mikola
* PHPLIB-45: List collections according to wire protocol version
2015-04-10 Jeremy Mikola
* PHPLIB-45: Construct CollectionInfoLegacyIterator from Traversable
2015-04-06 Jeremy Mikola
* Allow any extension version for development
2015-04-06 Jeremy Mikola
* PHPLIB-64: Collection creation method
2015-04-06 Jeremy Mikola
* Handle new Cursor and toArray() API in extension
2015-03-27 Jeremy Mikola
* PHPLIB-45: Collection enumeration methods
2015-03-27 Jeremy Mikola
* Setup Database object in DatabaseFunctionalTest
2015-03-26 Jeremy Mikola
* PHPLIB-71: Collection drop methods
2015-03-26 Jeremy Mikola
* PHPLIB-72: Database enumeration method
2015-03-25 Jeremy Mikola
* Restructure CollectionTest and fixture generation functions
2015-03-25 Jeremy Mikola
* Use 127.0.0.1 instead of localhost for default URI
2015-03-25 Jeremy Mikola
* Dump server buildInfo before running tests on Travis CI
2015-03-23 Jeremy Mikola
* Cast expected string arguments
2015-03-23 Jeremy Mikola
* PHPLIB-65: Database drop methods
2015-03-23 Jeremy Mikola
* PHPLIB-73: Inherit default write concern and read preferences
2015-03-17 Jeremy Mikola
* Create base classes for unit and functional tests
2015-03-17 Jeremy Mikola
* Create test bootstrap for autoloading
2015-04-10 Jeremy Mikola
* Link to the HHVM driver alongside PHP
2015-03-23 Jeremy Mikola
* Remove unsupported options in ApiGen config
2015-03-23 Jeremy Mikola
* Rename version variable in Makefile
2015-03-23 Jeremy Mikola
* Fix typos in Makefile
2015-03-23 Jeremy Mikola
* Fix database name in example docs
2015-03-23 Jeremy Mikola
* Update documentation for PECL mongodb-0.2.0
2015-03-23 Jeremy Mikola
* Fix function array dereferencing syntax for PHP 5.3
2015-03-23 Jeremy Mikola
* PHPLIB-56: Travis CI configuration
2015-03-23 Jeremy Mikola
* Update readme and composer.json for PECL mongodb-0.2.0
2015-03-17 Jeremy Mikola
* PHPLIB-45: Prototype for collection enumeration method
2015-03-17 Jeremy Mikola
* PHPLIB-46: Prototypes for index enumeration method
2015-03-17 Jeremy Mikola
* Declare Collection methods alphabetically by visibility
2015-03-17 Jeremy Mikola
* PHPLIB-71: Prototypes for collection drop methods
2015-03-17 Jeremy Mikola
* PHPLIB-65: Prototypes for database drop methods
2015-03-17 Jeremy Mikola
* PHPLIB-64: Prototype for collection create method
2015-03-17 Jeremy Mikola
* PHPLIB-63: Prototypes for index creation methods
2015-03-17 Jeremy Mikola
* PHPLIB-69: Prototypes for index drop methods
2015-03-16 Jeremy Mikola
* PHPLIB-59: Implement insertMany() and InsertManyResult
2015-03-16 Jeremy Mikola
* PHPLIB-60: Create result classes for CRUD methods
2015-03-16 Hannes Magnusson
* Bump phongo version and link to jira
2015-03-12 Hannes Magnusson
* Add MongoClient and Database objects
2015-03-12 Hannes Magnusson
* missing argument doc
2015-03-12 Hannes Magnusson
* PHPLIB-62: Its called BulkWrite now
2015-02-19 Jeremy Mikola
* PHPLIB-54: Update references to driver classes
2015-02-19 Jeremy Mikola
* PHPLIB-44: php-cs-fixer fix src/ --level=psr2
2014-12-19 Jeremy Mikola
* Rename package to mongodb/mongodb and update metadata
2014-12-19 Jeremy Mikola
* Add @jmikola and @derickr to Composer author list
2014-12-19 Jeremy Mikola
* Add @jmikola to author list
2014-12-19 Jeremy Mikola
* Specify Apache 2 license
2014-12-12 Jeremy Mikola
* Reformat composer.json
2014-12-12 Jeremy Mikola
* Fix package name in composer.json
2014-12-12 Hannes Magnusson
* Update links after moving the repo from bjori to 10gen-labs
2014-12-12 Hannes Magnusson
* README updates
2014-12-11 Hannes Magnusson
* Improve steps needed
2014-12-11 Hannes Magnusson
* Add 0.1.0 release notes
Horde_Mongo-1.1.0/bundle/vendor/mongodb/mongodb/RELEASE-1.0 0000664 0001750 0001750 00000045143 12741242607 021150 0 ustar jan jan RELEASE 1.0.2
-------------
2016-03-30 Jeremy Mikola
* Discuss how inserted IDs may be accessed in Upgrade Guide
2016-03-30 Jeremy Mikola
* Use reference-style links in Upgrade Guide
2016-03-29 Nick Dresselhaus
* PHPLIB-189: Fix merging of comment and maxTimeMS options
2016-03-29 Jeremy Mikola
* Use listCollections for command cursor example, move aggregate to CRUD
2016-03-28 Jeremy Mikola
* Add query examples and create BSON tutorial page
2016-03-28 Jeremy Mikola
* Clarify that Persistable is supported in methods without "typeMap" option
2016-03-24 Jeremy Mikola
* Add Client API documentation
2016-03-24 Jeremy Mikola
* Fix typo in Client::__get() documentation
2016-03-24 Jeremy Mikola
* Split Database docs into API and tutorial
2016-03-24 Jeremy Mikola
* CreateCollection::execute() may return an array
2016-03-23 Jeremy Mikola
* Split Collection docs into API, tutorial, and upgrade guide
2016-03-23 Jeremy Mikola
* Specify when findAndModify operations may return null
2016-03-23 Jeremy Mikola
* Misc doc block updates for Collection operations
2016-03-23 Jeremy Mikola
* Document typeMap option for DropDatabase and DropIndexes
2016-03-23 Jeremy Mikola
* Specify classes for returnDocument option constants
2016-03-23 Jeremy Mikola
* FindOne::execute() may return an array
2016-03-14 Jeremy Mikola
* Remove branch alias for 1.0.x
2016-03-04 Jeremy Mikola
* Add 1.0.1 release notes
RELEASE 1.0.1
-------------
2016-02-16 minenok
* PHPLIB-180: Fix option merging for Find operation
2016-01-30 Andreas Braun
* PHPLIB-179: Don't apply typeMap if useCursor is false
2016-01-21 Jeremy Mikola
* Update README install instructions for 1.0.0
2016-01-21 Jeremy Mikola
* Allow ext-mongodb 1.1.0
RELEASE 1.0.0
-------------
2016-01-21 Jeremy Mikola
* Rewrite documentation for 1.0.0
2016-01-21 Jeremy Mikola
* PHPLIB-164: CreateCollection should use type map
2016-01-20 Jeremy Mikola
* PHPLIB-165: Take explicit db/coll name args in Collection ctor
2016-01-20 Jeremy Mikola
* PHPLIB-74: Use Client's default type map for Database and Collection
2016-01-20 Jeremy Mikola
* PHPLIB-164: Drop operations should use type map
2016-01-19 Jeremy Mikola
* PHPLIB-164: Database::command() should use type map
2016-01-18 Jeremy Mikola
* PHPLIB-162: Support database and collection selection via __get()
2016-01-18 Jeremy Mikola
* PHPLIB-163: __set_state() for BSON array and document models
2016-01-14 Jeremy Mikola
* BSONDocument should allow property access by default
2016-01-14 Jeremy Mikola
* Tests for BSON array and document serialize methods
2016-01-12 Jeremy Mikola
* Executable interface is internal
2016-01-11 Jeremy Mikola
* Unit tests for ListDatabases and ListIndexes options
2016-01-11 Jeremy Mikola
* Test for invalid typeMap options
2016-01-11 Jeremy Mikola
* Test for invalid ReadConcern options
2016-01-10 Jeremy Mikola
* Clean up exception docs and use statements
2016-01-10 Jeremy Mikola
* PHPLIB-141: Replace InvalidArgumentTypeException with a factory method
2016-01-07 Jeremy Mikola
* Remove unused exception classes
2016-01-07 Jeremy Mikola
* Unit test for IndexInfo's ArrayAccess implementation
2016-01-07 Jeremy Mikola
* PHPLIB-141: Static method for immutable BadMethodCallException
2016-01-07 Jeremy Mikola
* Add missing doc block info
2016-01-07 Jeremy Mikola
* PHPLIB-157: Improve _id extraction for Serializable objects
2016-01-07 Jeremy Mikola
* Re-order functions.php alphabetically
2016-01-07 Jeremy Mikola
* Test with mongodb-1.1.2 on Travis CI
2016-01-05 Jeremy Mikola
* PHPLIB-74: Use array and document classes in default type map
2015-12-28 Jeremy Mikola
* PHPLIB-74: Model classes for BSON array and document
2015-12-28 Jeremy Mikola
* Update IndexInput::bsonSerialize() doc block
2015-12-28 Jeremy Mikola
* Add 1.0.0-beta2 release notes
RELEASE 1.0.0-beta2
-------------------
2015-12-25 Jeremy Mikola
* PHPLIB-135: Support validator options for CreateCollection
2015-12-25 Jeremy Mikola
* Don't use empty() to check for empty documents
2015-12-24 Jeremy Mikola
* Clean up some doc block typos
2015-12-23 Jeremy Mikola
* PHPLIB-138: Support typeMap option for aggregate and find operations
2015-12-23 Jeremy Mikola
* PHPLIB-138: Support typeMap option for Database::command()
2015-12-23 Jeremy Mikola
* PHPLIB-138: Support typeMap option for core classes
2015-12-23 Jeremy Mikola
* Refactor option handling for Client, Database, and Collection
2015-12-23 Jeremy Mikola
* PHPLIB-132: Add MongoDB 3.2 to Travis CI build matrix
2015-12-23 Jeremy Mikola