Skip to content

Commit

Permalink
PHPC-2348 Remove WriteException and move getWriteResult to `BulkW…
Browse files Browse the repository at this point in the history
…riteException` (#1685)
  • Loading branch information
GromNaN authored Sep 24, 2024
1 parent c78ee57 commit d9a90ec
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 99 deletions.
1 change: 0 additions & 1 deletion config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ if test "$PHP_MONGODB" != "no"; then
src/MongoDB/Exception/ServerException.c \
src/MongoDB/Exception/SSLConnectionException.c \
src/MongoDB/Exception/UnexpectedValueException.c \
src/MongoDB/Exception/WriteException.c \
src/MongoDB/Monitoring/CommandFailedEvent.c \
src/MongoDB/Monitoring/CommandStartedEvent.c \
src/MongoDB/Monitoring/CommandSubscriber.c \
Expand Down
2 changes: 1 addition & 1 deletion config.w32
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ if (PHP_MONGODB != "no") {
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");
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");
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");
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");
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");
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");
MONGODB_ADD_SOURCES("/src/libmongoc/src/common", PHP_MONGODB_COMMON_SOURCES);
MONGODB_ADD_SOURCES("/src/libmongoc/src/libbson/src/bson", PHP_MONGODB_BSON_SOURCES);
Expand Down
1 change: 0 additions & 1 deletion php_phongo.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ PHP_MINIT_FUNCTION(mongodb) /* {{{ */
php_phongo_runtimeexception_init_ce(INIT_FUNC_ARGS_PASSTHRU);
php_phongo_serverexception_init_ce(INIT_FUNC_ARGS_PASSTHRU);
php_phongo_connectionexception_init_ce(INIT_FUNC_ARGS_PASSTHRU);
php_phongo_writeexception_init_ce(INIT_FUNC_ARGS_PASSTHRU);

php_phongo_authenticationexception_init_ce(INIT_FUNC_ARGS_PASSTHRU);
php_phongo_bulkwriteexception_init_ce(INIT_FUNC_ARGS_PASSTHRU);
Expand Down
16 changes: 15 additions & 1 deletion src/MongoDB/Exception/BulkWriteException.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,25 @@
#include <php.h>

#include "php_phongo.h"
#include "phongo_error.h"
#include "BulkWriteException_arginfo.h"

zend_class_entry* php_phongo_bulkwriteexception_ce;

/* Returns the WriteResult from the failed write operation. */
static PHP_METHOD(MongoDB_Driver_Exception_BulkWriteException, getWriteResult)
{
zval* writeresult;
zval rv;

PHONGO_PARSE_PARAMETERS_NONE();

writeresult = zend_read_property(php_phongo_bulkwriteexception_ce, Z_OBJ_P(getThis()), ZEND_STRL("writeResult"), 0, &rv);

RETURN_ZVAL(writeresult, 1, 0);
}

void php_phongo_bulkwriteexception_init_ce(INIT_FUNC_ARGS)
{
php_phongo_bulkwriteexception_ce = register_class_MongoDB_Driver_Exception_BulkWriteException(php_phongo_writeexception_ce);
php_phongo_bulkwriteexception_ce = register_class_MongoDB_Driver_Exception_BulkWriteException(php_phongo_serverexception_ce);
}
6 changes: 5 additions & 1 deletion src/MongoDB/Exception/BulkWriteException.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@

namespace MongoDB\Driver\Exception;

class BulkWriteException extends WriteException
class BulkWriteException extends RuntimeException
{
/** @var \MongoDB\Driver\WriteResult */
protected $writeResult;

final public function getWriteResult(): \MongoDB\Driver\WriteResult {}
}
17 changes: 14 additions & 3 deletions src/MongoDB/Exception/BulkWriteException_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 0 additions & 41 deletions src/MongoDB/Exception/WriteException.c

This file was deleted.

17 changes: 0 additions & 17 deletions src/MongoDB/Exception/WriteException.stub.php

This file was deleted.

31 changes: 0 additions & 31 deletions src/MongoDB/Exception/WriteException_arginfo.h

This file was deleted.

2 changes: 0 additions & 2 deletions src/phongo_classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,6 @@ extern zend_class_entry* php_phongo_sslconnectionexception_ce;
extern zend_class_entry* php_phongo_encryptionexception_ce;
extern zend_class_entry* php_phongo_executiontimeoutexception_ce;
extern zend_class_entry* php_phongo_connectiontimeoutexception_ce;
extern zend_class_entry* php_phongo_writeexception_ce;
extern zend_class_entry* php_phongo_bulkwriteexception_ce;

extern zend_class_entry* php_phongo_type_ce;
Expand Down Expand Up @@ -444,7 +443,6 @@ extern void php_phongo_runtimeexception_init_ce(INIT_FUNC_ARGS);
extern void php_phongo_serverexception_init_ce(INIT_FUNC_ARGS);
extern void php_phongo_sslconnectionexception_init_ce(INIT_FUNC_ARGS);
extern void php_phongo_unexpectedvalueexception_init_ce(INIT_FUNC_ARGS);
extern void php_phongo_writeexception_init_ce(INIT_FUNC_ARGS);

extern void php_phongo_commandfailedevent_init_ce(INIT_FUNC_ARGS);
extern void php_phongo_commandstartedevent_init_ce(INIT_FUNC_ARGS);
Expand Down

0 comments on commit d9a90ec

Please sign in to comment.