Skip to content

Commit c84f9e9

Browse files
committed
Add separate php_properties attr
1 parent 6e8575c commit c84f9e9

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

php_phongo.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,17 @@ zend_object_handlers* phongo_get_std_object_handlers(void);
6262

6363
#define PHONGO_GET_PROPERTY_HASH_INIT_PROPS(is_temp, intern, props, size) \
6464
do { \
65-
if (is_temp) { \
65+
if (!(intern)->php_properties) { \
6666
ALLOC_HASHTABLE(props); \
6767
zend_hash_init((props), (size), NULL, ZVAL_PTR_DTOR, 0); \
68-
} else if ((intern)->properties) { \
69-
(props) = (intern)->properties; \
68+
} \
69+
if (is_temp) { \
70+
(props) = zend_array_dup((intern)->php_properties); \
7071
} else { \
71-
ALLOC_HASHTABLE(props); \
72-
zend_hash_init((props), (size), NULL, ZVAL_PTR_DTOR, 0); \
72+
if ((intern)->properties) { \
73+
zend_hash_release(intern->properties); \
74+
} \
75+
(props) = zend_array_dup((intern)->php_properties); \
7376
(intern)->properties = (props); \
7477
} \
7578
} while (0)

src/phongo_structs.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,14 @@ typedef struct {
122122
typedef struct {
123123
mongoc_read_concern_t* read_concern;
124124
HashTable* properties;
125+
HashTable* php_properties;
125126
zend_object std;
126127
} php_phongo_readconcern_t;
127128

128129
typedef struct {
129130
mongoc_read_prefs_t* read_preference;
130131
HashTable* properties;
132+
HashTable* php_properties;
131133
zend_object std;
132134
} php_phongo_readpreference_t;
133135

@@ -141,12 +143,14 @@ typedef struct {
141143
typedef struct {
142144
mongoc_server_api_t* server_api;
143145
HashTable* properties;
146+
HashTable* php_properties;
144147
zend_object std;
145148
} php_phongo_serverapi_t;
146149

147150
typedef struct {
148151
mongoc_server_description_t* server_description;
149152
HashTable* properties;
153+
HashTable* php_properties;
150154
zend_object std;
151155
} php_phongo_serverdescription_t;
152156

@@ -160,11 +164,13 @@ typedef struct {
160164
typedef struct {
161165
mongoc_topology_description_t* topology_description;
162166
HashTable* properties;
167+
HashTable* php_properties;
163168
zend_object std;
164169
} php_phongo_topologydescription_t;
165170

166171
typedef struct {
167172
HashTable* properties;
173+
HashTable* php_properties;
168174
mongoc_write_concern_t* write_concern;
169175
zend_object std;
170176
} php_phongo_writeconcern_t;
@@ -197,18 +203,21 @@ typedef struct {
197203
int data_len;
198204
uint8_t type;
199205
HashTable* properties;
206+
HashTable* php_properties;
200207
zend_object std;
201208
} php_phongo_binary_t;
202209

203210
typedef struct {
204211
bson_t* bson;
205212
HashTable* properties;
213+
HashTable* php_properties;
206214
zend_object std;
207215
} php_phongo_packedarray_t;
208216

209217
typedef struct {
210218
bson_t* bson;
211219
HashTable* properties;
220+
HashTable* php_properties;
212221
zend_object std;
213222
} php_phongo_document_t;
214223

@@ -220,6 +229,7 @@ typedef struct {
220229
size_t key;
221230
zval current;
222231
HashTable* properties;
232+
HashTable* php_properties;
223233
zend_object std;
224234
} php_phongo_iterator_t;
225235

@@ -228,20 +238,23 @@ typedef struct {
228238
size_t ref_len;
229239
char id[25];
230240
HashTable* properties;
241+
HashTable* php_properties;
231242
zend_object std;
232243
} php_phongo_dbpointer_t;
233244

234245
typedef struct {
235246
bool initialized;
236247
bson_decimal128_t decimal;
237248
HashTable* properties;
249+
HashTable* php_properties;
238250
zend_object std;
239251
} php_phongo_decimal128_t;
240252

241253
typedef struct {
242254
bool initialized;
243255
int64_t integer;
244256
HashTable* properties;
257+
HashTable* php_properties;
245258
zend_object std;
246259
} php_phongo_int64_t;
247260

@@ -250,6 +263,7 @@ typedef struct {
250263
size_t code_len;
251264
bson_t* scope;
252265
HashTable* properties;
266+
HashTable* php_properties;
253267
zend_object std;
254268
} php_phongo_javascript_t;
255269

@@ -265,6 +279,7 @@ typedef struct {
265279
bool initialized;
266280
char oid[25];
267281
HashTable* properties;
282+
HashTable* php_properties;
268283
zend_object std;
269284
} php_phongo_objectid_t;
270285

@@ -274,13 +289,15 @@ typedef struct {
274289
char* flags;
275290
int flags_len;
276291
HashTable* properties;
292+
HashTable* php_properties;
277293
zend_object std;
278294
} php_phongo_regex_t;
279295

280296
typedef struct {
281297
char* symbol;
282298
size_t symbol_len;
283299
HashTable* properties;
300+
HashTable* php_properties;
284301
zend_object std;
285302
} php_phongo_symbol_t;
286303

@@ -289,6 +306,7 @@ typedef struct {
289306
uint32_t increment;
290307
uint32_t timestamp;
291308
HashTable* properties;
309+
HashTable* php_properties;
292310
zend_object std;
293311
} php_phongo_timestamp_t;
294312

@@ -300,6 +318,7 @@ typedef struct {
300318
bool initialized;
301319
int64_t milliseconds;
302320
HashTable* properties;
321+
HashTable* php_properties;
303322
zend_object std;
304323
} php_phongo_utcdatetime_t;
305324

0 commit comments

Comments
 (0)