Skip to content

Commit d9a90ec

Browse files
authored
PHPC-2348 Remove WriteException and move getWriteResult to BulkWriteException (#1685)
1 parent c78ee57 commit d9a90ec

10 files changed

+35
-99
lines changed

config.m4

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ if test "$PHP_MONGODB" != "no"; then
197197
src/MongoDB/Exception/ServerException.c \
198198
src/MongoDB/Exception/SSLConnectionException.c \
199199
src/MongoDB/Exception/UnexpectedValueException.c \
200-
src/MongoDB/Exception/WriteException.c \
201200
src/MongoDB/Monitoring/CommandFailedEvent.c \
202201
src/MongoDB/Monitoring/CommandStartedEvent.c \
203202
src/MongoDB/Monitoring/CommandSubscriber.c \

config.w32

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ if (PHP_MONGODB != "no") {
117117
MONGODB_ADD_SOURCES("/src", "phongo_apm.c phongo_bson.c phongo_bson_encode.c phongo_client.c phongo_compat.c phongo_error.c phongo_execute.c phongo_ini.c phongo_log.c phongo_util.c");
118118
MONGODB_ADD_SOURCES("/src/BSON", "Binary.c BinaryInterface.c Document.c Iterator.c DBPointer.c Decimal128.c Decimal128Interface.c Int64.c Javascript.c JavascriptInterface.c MaxKey.c MaxKeyInterface.c MinKey.c MinKeyInterface.c ObjectId.c ObjectIdInterface.c PackedArray.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");
119119
MONGODB_ADD_SOURCES("/src/MongoDB", "BulkWrite.c ClientEncryption.c Command.c Cursor.c CursorInterface.c Manager.c Query.c ReadConcern.c ReadPreference.c Server.c ServerApi.c ServerDescription.c Session.c TopologyDescription.c WriteConcern.c WriteConcernError.c WriteError.c WriteResult.c");
120-
MONGODB_ADD_SOURCES("/src/MongoDB/Exception", "AuthenticationException.c BulkWriteException.c CommandException.c ConnectionException.c ConnectionTimeoutException.c EncryptionException.c Exception.c ExecutionTimeoutException.c InvalidArgumentException.c LogicException.c RuntimeException.c ServerException.c SSLConnectionException.c UnexpectedValueException.c WriteException.c");
120+
MONGODB_ADD_SOURCES("/src/MongoDB/Exception", "AuthenticationException.c BulkWriteException.c CommandException.c ConnectionException.c ConnectionTimeoutException.c EncryptionException.c Exception.c ExecutionTimeoutException.c InvalidArgumentException.c LogicException.c RuntimeException.c ServerException.c SSLConnectionException.c UnexpectedValueException.c");
121121
MONGODB_ADD_SOURCES("/src/MongoDB/Monitoring", "CommandFailedEvent.c CommandStartedEvent.c CommandSubscriber.c CommandSucceededEvent.c LogSubscriber.c SDAMSubscriber.c Subscriber.c ServerChangedEvent.c ServerClosedEvent.c ServerHeartbeatFailedEvent.c ServerHeartbeatStartedEvent.c ServerHeartbeatSucceededEvent.c ServerOpeningEvent.c TopologyChangedEvent.c TopologyClosedEvent.c TopologyOpeningEvent.c functions.c");
122122
MONGODB_ADD_SOURCES("/src/libmongoc/src/common", PHP_MONGODB_COMMON_SOURCES);
123123
MONGODB_ADD_SOURCES("/src/libmongoc/src/libbson/src/bson", PHP_MONGODB_BSON_SOURCES);

php_phongo.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,6 @@ PHP_MINIT_FUNCTION(mongodb) /* {{{ */
273273
php_phongo_runtimeexception_init_ce(INIT_FUNC_ARGS_PASSTHRU);
274274
php_phongo_serverexception_init_ce(INIT_FUNC_ARGS_PASSTHRU);
275275
php_phongo_connectionexception_init_ce(INIT_FUNC_ARGS_PASSTHRU);
276-
php_phongo_writeexception_init_ce(INIT_FUNC_ARGS_PASSTHRU);
277276

278277
php_phongo_authenticationexception_init_ce(INIT_FUNC_ARGS_PASSTHRU);
279278
php_phongo_bulkwriteexception_init_ce(INIT_FUNC_ARGS_PASSTHRU);

src/MongoDB/Exception/BulkWriteException.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,25 @@
1717
#include <php.h>
1818

1919
#include "php_phongo.h"
20+
#include "phongo_error.h"
2021
#include "BulkWriteException_arginfo.h"
2122

2223
zend_class_entry* php_phongo_bulkwriteexception_ce;
2324

25+
/* Returns the WriteResult from the failed write operation. */
26+
static PHP_METHOD(MongoDB_Driver_Exception_BulkWriteException, getWriteResult)
27+
{
28+
zval* writeresult;
29+
zval rv;
30+
31+
PHONGO_PARSE_PARAMETERS_NONE();
32+
33+
writeresult = zend_read_property(php_phongo_bulkwriteexception_ce, Z_OBJ_P(getThis()), ZEND_STRL("writeResult"), 0, &rv);
34+
35+
RETURN_ZVAL(writeresult, 1, 0);
36+
}
37+
2438
void php_phongo_bulkwriteexception_init_ce(INIT_FUNC_ARGS)
2539
{
26-
php_phongo_bulkwriteexception_ce = register_class_MongoDB_Driver_Exception_BulkWriteException(php_phongo_writeexception_ce);
40+
php_phongo_bulkwriteexception_ce = register_class_MongoDB_Driver_Exception_BulkWriteException(php_phongo_serverexception_ce);
2741
}

src/MongoDB/Exception/BulkWriteException.stub.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77

88
namespace MongoDB\Driver\Exception;
99

10-
class BulkWriteException extends WriteException
10+
class BulkWriteException extends RuntimeException
1111
{
12+
/** @var \MongoDB\Driver\WriteResult */
13+
protected $writeResult;
14+
15+
final public function getWriteResult(): \MongoDB\Driver\WriteResult {}
1216
}

src/MongoDB/Exception/BulkWriteException_arginfo.h

Lines changed: 14 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/MongoDB/Exception/WriteException.c

Lines changed: 0 additions & 41 deletions
This file was deleted.

src/MongoDB/Exception/WriteException.stub.php

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/MongoDB/Exception/WriteException_arginfo.h

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/phongo_classes.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,6 @@ extern zend_class_entry* php_phongo_sslconnectionexception_ce;
328328
extern zend_class_entry* php_phongo_encryptionexception_ce;
329329
extern zend_class_entry* php_phongo_executiontimeoutexception_ce;
330330
extern zend_class_entry* php_phongo_connectiontimeoutexception_ce;
331-
extern zend_class_entry* php_phongo_writeexception_ce;
332331
extern zend_class_entry* php_phongo_bulkwriteexception_ce;
333332

334333
extern zend_class_entry* php_phongo_type_ce;
@@ -444,7 +443,6 @@ extern void php_phongo_runtimeexception_init_ce(INIT_FUNC_ARGS);
444443
extern void php_phongo_serverexception_init_ce(INIT_FUNC_ARGS);
445444
extern void php_phongo_sslconnectionexception_init_ce(INIT_FUNC_ARGS);
446445
extern void php_phongo_unexpectedvalueexception_init_ce(INIT_FUNC_ARGS);
447-
extern void php_phongo_writeexception_init_ce(INIT_FUNC_ARGS);
448446

449447
extern void php_phongo_commandfailedevent_init_ce(INIT_FUNC_ARGS);
450448
extern void php_phongo_commandstartedevent_init_ce(INIT_FUNC_ARGS);

0 commit comments

Comments
 (0)