Skip to content

Commit 291996b

Browse files
committed
Merge pull request #765
2 parents 0778a4a + 1196609 commit 291996b

File tree

7 files changed

+68
-8
lines changed

7 files changed

+68
-8
lines changed

config.m4

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ if test "$PHP_MONGODB" != "no"; then
215215
src/MongoDB/Exception/InvalidArgumentException.c \
216216
src/MongoDB/Exception/LogicException.c \
217217
src/MongoDB/Exception/RuntimeException.c \
218+
src/MongoDB/Exception/ServerException.c \
218219
src/MongoDB/Exception/SSLConnectionException.c \
219220
src/MongoDB/Exception/UnexpectedValueException.c \
220221
src/MongoDB/Exception/WriteException.c \

config.w32

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ if (PHP_MONGODB != "no") {
8686
ADD_SOURCES(configure_module_dirname + "/src", "bson.c bson-encode.c", "mongodb");
8787
ADD_SOURCES(configure_module_dirname + "/src/BSON", "Binary.c BinaryInterface.c DBPointer.c Decimal128.c Decimal128Interface.c Javascript.c JavascriptInterface.c MaxKey.c MaxKeyInterface.c MinKey.c MinKeyInterface.c ObjectId.c ObjectIdInterface.c Persistable.c Regex.c RegexInterface.c Serializable.c Symbol.c Timestamp.c TimestampInterface.c Type.c Undefined.c Unserializable.c UTCDateTime.c UTCDateTimeInterface.c functions.c", "mongodb");
8888
ADD_SOURCES(configure_module_dirname + "/src/MongoDB", "BulkWrite.c Command.c Cursor.c CursorId.c Manager.c Query.c ReadConcern.c ReadPreference.c Server.c Session.c WriteConcern.c WriteConcernError.c WriteError.c WriteResult.c", "mongodb");
89-
ADD_SOURCES(configure_module_dirname + "/src/MongoDB/Exception", "AuthenticationException.c BulkWriteException.c ConnectionException.c ConnectionTimeoutException.c Exception.c ExecutionTimeoutException.c InvalidArgumentException.c LogicException.c RuntimeException.c SSLConnectionException.c UnexpectedValueException.c WriteException.c", "mongodb");
89+
ADD_SOURCES(configure_module_dirname + "/src/MongoDB/Exception", "AuthenticationException.c BulkWriteException.c ConnectionException.c ConnectionTimeoutException.c Exception.c ExecutionTimeoutException.c InvalidArgumentException.c LogicException.c RuntimeException.c ServerException.c SSLConnectionException.c UnexpectedValueException.c WriteException.c", "mongodb");
9090
ADD_SOURCES(configure_module_dirname + "/src/MongoDB/Monitoring", "CommandFailedEvent.c CommandStartedEvent.c CommandSubscriber.c CommandSucceededEvent.c Subscriber.c functions.c", "mongodb");
9191
ADD_SOURCES(configure_module_dirname + "/src/libbson/src/bson", PHP_MONGODB_BSON_SOURCES, "mongodb");
9292
ADD_SOURCES(configure_module_dirname + "/src/libbson/src/jsonsl", PHP_MONGODB_JSONSL_SOURCES, "mongodb");

php_phongo.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,18 +163,21 @@ zend_class_entry* phongo_exception_from_mongoc_domain(uint32_t /* mongoc_error_d
163163
case MONGOC_ERROR_PROTOCOL_INVALID_REPLY:
164164
case MONGOC_ERROR_PROTOCOL_BAD_WIRE_VERSION:
165165
case MONGOC_ERROR_CURSOR_INVALID_CURSOR:
166-
case MONGOC_ERROR_QUERY_FAILURE:
167166
/*case MONGOC_ERROR_PROTOCOL_ERROR:*/
168167
case MONGOC_ERROR_BSON_INVALID:
169168
case MONGOC_ERROR_MATCHER_INVALID:
170169
case MONGOC_ERROR_NAMESPACE_INVALID:
171-
case MONGOC_ERROR_COLLECTION_INSERT_FAILED:
172170
case MONGOC_ERROR_GRIDFS_INVALID_FILENAME:
171+
return php_phongo_runtimeexception_ce;
172+
case MONGOC_ERROR_QUERY_FAILURE:
173173
case MONGOC_ERROR_QUERY_COMMAND_NOT_FOUND:
174174
case MONGOC_ERROR_QUERY_NOT_TAILABLE:
175-
return php_phongo_runtimeexception_ce;
175+
case MONGOC_ERROR_COLLECTION_INSERT_FAILED:
176+
return php_phongo_serverexception_ce;
176177
}
177178
switch (domain) {
179+
case MONGOC_ERROR_SERVER:
180+
return php_phongo_serverexception_ce;
178181
case MONGOC_ERROR_CLIENT:
179182
case MONGOC_ERROR_STREAM:
180183
case MONGOC_ERROR_PROTOCOL:
@@ -2800,6 +2803,7 @@ PHP_MINIT_FUNCTION(mongodb)
28002803
/* Register base exception classes first */
28012804
php_phongo_exception_init_ce(INIT_FUNC_ARGS_PASSTHRU);
28022805
php_phongo_runtimeexception_init_ce(INIT_FUNC_ARGS_PASSTHRU);
2806+
php_phongo_serverexception_init_ce(INIT_FUNC_ARGS_PASSTHRU);
28032807
php_phongo_connectionexception_init_ce(INIT_FUNC_ARGS_PASSTHRU);
28042808
php_phongo_writeexception_init_ce(INIT_FUNC_ARGS_PASSTHRU);
28052809

php_phongo_classes.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ extern zend_class_entry* php_phongo_writeresult_ce;
289289
extern zend_class_entry* php_phongo_exception_ce;
290290
extern zend_class_entry* php_phongo_logicexception_ce;
291291
extern zend_class_entry* php_phongo_runtimeexception_ce;
292+
extern zend_class_entry* php_phongo_serverexception_ce;
292293
extern zend_class_entry* php_phongo_unexpectedvalueexception_ce;
293294
extern zend_class_entry* php_phongo_invalidargumentexception_ce;
294295
extern zend_class_entry* php_phongo_connectionexception_ce;
@@ -383,6 +384,7 @@ extern void php_phongo_executiontimeoutexception_init_ce(INIT_FUNC_ARGS);
383384
extern void php_phongo_invalidargumentexception_init_ce(INIT_FUNC_ARGS);
384385
extern void php_phongo_logicexception_init_ce(INIT_FUNC_ARGS);
385386
extern void php_phongo_runtimeexception_init_ce(INIT_FUNC_ARGS);
387+
extern void php_phongo_serverexception_init_ce(INIT_FUNC_ARGS);
386388
extern void php_phongo_sslconnectionexception_init_ce(INIT_FUNC_ARGS);
387389
extern void php_phongo_unexpectedvalueexception_init_ce(INIT_FUNC_ARGS);
388390
extern void php_phongo_writeexception_init_ce(INIT_FUNC_ARGS);

src/MongoDB/Exception/ExecutionTimeoutException.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ void php_phongo_executiontimeoutexception_init_ce(INIT_FUNC_ARGS) /* {{{ */
3737

3838
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "ExecutionTimeoutException", php_phongo_executiontimeoutexception_me);
3939
#if PHP_VERSION_ID >= 70000
40-
php_phongo_executiontimeoutexception_ce = zend_register_internal_class_ex(&ce, php_phongo_runtimeexception_ce);
40+
php_phongo_executiontimeoutexception_ce = zend_register_internal_class_ex(&ce, php_phongo_serverexception_ce);
4141
#else
42-
php_phongo_executiontimeoutexception_ce = zend_register_internal_class_ex(&ce, php_phongo_runtimeexception_ce, NULL TSRMLS_CC);
42+
php_phongo_executiontimeoutexception_ce = zend_register_internal_class_ex(&ce, php_phongo_serverexception_ce, NULL TSRMLS_CC);
4343
#endif
4444
PHONGO_CE_FINAL(php_phongo_executiontimeoutexception_ce);
4545
} /* }}} */
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright 2018 MongoDB, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#ifdef HAVE_CONFIG_H
18+
#include "config.h"
19+
#endif
20+
21+
#include <php.h>
22+
23+
#include "phongo_compat.h"
24+
#include "php_phongo.h"
25+
26+
zend_class_entry* php_phongo_serverexception_ce;
27+
28+
/* {{{ MongoDB\Driver\Exception\ServerException function entries */
29+
static zend_function_entry php_phongo_serverexception_me[] = {
30+
PHP_FE_END
31+
};
32+
/* }}} */
33+
34+
void php_phongo_serverexception_init_ce(INIT_FUNC_ARGS) /* {{{ */
35+
{
36+
zend_class_entry ce;
37+
38+
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "ServerException", php_phongo_serverexception_me);
39+
#if PHP_VERSION_ID >= 70000
40+
php_phongo_serverexception_ce = zend_register_internal_class_ex(&ce, php_phongo_runtimeexception_ce);
41+
#else
42+
php_phongo_serverexception_ce = zend_register_internal_class_ex(&ce, php_phongo_runtimeexception_ce, NULL TSRMLS_CC);
43+
#endif
44+
} /* }}} */
45+
46+
/*
47+
* Local variables:
48+
* tab-width: 4
49+
* c-basic-offset: 4
50+
* End:
51+
* vim600: noet sw=4 ts=4 fdm=marker
52+
* vim<600: noet sw=4 ts=4
53+
*/

src/MongoDB/Exception/WriteException.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ void php_phongo_writeexception_init_ce(INIT_FUNC_ARGS) /* {{{ */
6363

6464
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "WriteException", php_phongo_writeexception_me);
6565
#if PHP_VERSION_ID >= 70000
66-
php_phongo_writeexception_ce = zend_register_internal_class_ex(&ce, php_phongo_runtimeexception_ce);
66+
php_phongo_writeexception_ce = zend_register_internal_class_ex(&ce, php_phongo_serverexception_ce);
6767
#else
68-
php_phongo_writeexception_ce = zend_register_internal_class_ex(&ce, php_phongo_runtimeexception_ce, NULL TSRMLS_CC);
68+
php_phongo_writeexception_ce = zend_register_internal_class_ex(&ce, php_phongo_serverexception_ce, NULL TSRMLS_CC);
6969
#endif
7070
php_phongo_writeexception_ce->ce_flags |= ZEND_ACC_EXPLICIT_ABSTRACT_CLASS;
7171

0 commit comments

Comments
 (0)