Skip to content

Commit 9cc427b

Browse files
committed
Merge branch 'devel' of https://github.com/arangodb/arangodb-php into frankmayer-devel
2 parents fc84fd5 + ebe79b0 commit 9cc427b

File tree

6 files changed

+32
-9
lines changed

6 files changed

+32
-9
lines changed

lib/triagens/ArangoDb/Batch.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,6 @@ public function append($method, $request)
369369

370370
$result = 'HTTP/1.1 202 Accepted' . $eol;
371371
$result .= 'location: /_db/_system/_api/document/0/0' . $eol;
372-
$result .= 'server: triagens GmbH High-Performance HTTP Server' . $eol;
373372
$result .= 'content-type: application/json; charset=utf-8' . $eol;
374373
$result .= 'etag: "0"' . $eol;
375374
$result .= 'connection: Close' . $eol . $eol;

lib/triagens/ArangoDb/CollectionHandler.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -659,18 +659,24 @@ public function truncate($collection)
659659
* @throws Exception
660660
*
661661
* @param mixed $collection - collection id as string or number or collection object
662+
* @param array $options - an array of options for the drop operation
662663
*
663664
* @return bool - always true, will throw if there is an error
664665
*/
665-
public function drop($collection)
666+
public function drop($collection, $options = array())
666667
{
667668
$collectionName = $this->getCollectionName($collection);
668669

669670
if ($this->isValidCollectionId($collectionName)) {
670671
throw new ClientException('Cannot alter a collection without a collection id');
671672
}
672673

673-
$this->getConnection()->delete(UrlHelper::buildUrl(Urls::URL_COLLECTION, [$collectionName]));
674+
$appendix = '';
675+
if (is_array($options) && isset($options['isSystem'])) {
676+
$appendix = '?isSystem=' . UrlHelper::getBoolString($options['isSystem']);
677+
}
678+
679+
$this->getConnection()->delete(UrlHelper::buildUrl(Urls::URL_COLLECTION, [$collectionName]) . $appendix);
674680

675681
return true;
676682
}

lib/triagens/ArangoDb/Document.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -729,8 +729,8 @@ public function getCollectionId()
729729
*
730730
* Revision ids are generated on the server only.
731731
*
732-
* Document ids are numeric but might be bigger than PHP_INT_MAX.
733-
* To reliably store a document id elsewhere, a PHP string should be used
732+
* Document ids are strings, even if they look "numeric"
733+
* To reliably store a document id elsewhere, a PHP string must be used
734734
*
735735
* @param mixed $rev - revision id
736736
*

tests/CollectionBasicTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ public function testCreateAndDeleteSystemCollectionWithoutCreatingObject()
428428
$name = '_ArangoDB_PHP_TestSuite_TestCollection_02';
429429

430430
try {
431-
$collectionHandler->drop($name);
431+
$collectionHandler->drop($name, [ 'isSystem' => true ]);
432432
} catch (Exception $e) {
433433
//Silence the exception
434434
}
@@ -447,7 +447,7 @@ public function testCreateAndDeleteSystemCollectionWithoutCreatingObject()
447447
static::assertTrue($resultingCollectionProperties->getWaitForSync());
448448

449449

450-
$collectionHandler->delete($name);
450+
$collectionHandler->drop($name, [ 'isSystem' => true ]);
451451
}
452452

453453

tests/CollectionExtendedTest.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function setUp()
3333
$this->documentHandler = new DocumentHandler($this->connection);
3434

3535
try {
36-
$this->collectionHandler->delete('ArangoDB_PHP_TestSuite_TestCollection_01');
36+
$this->collectionHandler->drop('ArangoDB_PHP_TestSuite_TestCollection_01');
3737
} catch (\Exception $e) {
3838
// don't bother us, if it's already deleted.
3939
}
@@ -112,6 +112,11 @@ public function testCreateGetAndDeleteSystemCollection()
112112
$collection->setName($name);
113113
$collection->setIsSystem(true);
114114

115+
try {
116+
$collectionHandler->drop($name, [ 'isSystem' => true ]);
117+
} catch (Exception $e) {
118+
//Silence the exception
119+
}
115120

116121
$response = $collectionHandler->add($collection);
117122

@@ -122,7 +127,7 @@ public function testCreateGetAndDeleteSystemCollection()
122127
$properties = $collectionHandler->getProperties($name);
123128
static::assertTrue($properties->getIsSystem(), '"isSystem" should be true!');
124129

125-
$response = $collectionHandler->delete($collection);
130+
$response = $collectionHandler->drop($collection, [ 'isSystem' => true ]);
126131
static::assertTrue($response, 'Delete should return true!');
127132
}
128133

tests/EdgeExtendedTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,19 @@ public function setUp()
3131
$this->collection = new Collection();
3232
$this->collection->setName('ArangoDB_PHP_TestSuite_TestEdgeCollection_01');
3333
$this->collectionHandler->add($this->collection);
34+
35+
try {
36+
$this->collectionHandler->drop('ArangoDB_PHP_TestSuite_EdgeCollection_01');
37+
} catch (Exception $e) {
38+
//Silence the exception
39+
}
40+
41+
try {
42+
$this->collectionHandler->drop('ArangoDB_PHP_TestSuite_Collection_01');
43+
} catch (Exception $e) {
44+
//Silence the exception
45+
}
46+
3447
$this->edgeHandler = new EdgeHandler($this->connection);
3548
$this->edgeCollection = new Collection();
3649
$this->edgeCollection->setName('ArangoDBPHPTestSuiteTestEdgeCollection01');

0 commit comments

Comments
 (0)