|
| 1 | +Fix build on PHP 7.4 |
| 2 | +https://github.com/php/pecl-search_engine-solr/pull/18 |
| 3 | +diff --git pecl-compat/src/zend_hash.h pecl-compat/src/zend_hash.h |
| 4 | +index ccec116e16c..2331aa5bfa1 100644 |
| 5 | +--- pecl-compat/src/zend_hash.h |
| 6 | ++++ pecl-compat/src/zend_hash.h |
| 7 | +@@ -289,8 +289,8 @@ static zend_always_inline int compat_zend_hash_get_current_key_ex(const HashTabl |
| 8 | + { |
| 9 | + int status; |
| 10 | + char *str; |
| 11 | +- uint str_length; |
| 12 | +- ulong num; |
| 13 | ++ uint32_t str_length; |
| 14 | ++ zend_ulong num; |
| 15 | + |
| 16 | + status = zend_hash_get_current_key_ex(ht, &str, &str_length, &num, 0, pos); |
| 17 | + if (status == HASH_KEY_IS_STRING) { |
| 18 | +@@ -311,8 +311,8 @@ static zend_always_inline int compat_zend_hash_str_get_current_key_ex(const Hash |
| 19 | + , zend_bool duplicate, HashPosition *pos) |
| 20 | + { |
| 21 | + int status; |
| 22 | +- uint length; |
| 23 | +- ulong num; |
| 24 | ++ uint32_t length; |
| 25 | ++ zend_ulong num; |
| 26 | + |
| 27 | + status = zend_hash_get_current_key_ex(ht, str_index, &length, &num, duplicate, pos); |
| 28 | + if (status == HASH_KEY_IS_STRING) { |
| 29 | +diff --git src/php7/php_solr.c src/php7/php_solr.c |
| 30 | +index b99b650d404..c0febc1306d 100644 |
| 31 | +--- src/php7/php_solr.c |
| 32 | ++++ src/php7/php_solr.c |
| 33 | +@@ -1296,7 +1296,7 @@ PHP_RINIT_FUNCTION(solr) |
| 34 | + zend_bool persistent = SOLR_HASHTABLE_PERSISTENT; |
| 35 | + |
| 36 | + /* Initial size of the HashTable */ |
| 37 | +- uint nSize = SOLR_INITIAL_HASH_TABLE_SIZE; |
| 38 | ++ uint32_t nSize = SOLR_INITIAL_HASH_TABLE_SIZE; |
| 39 | + |
| 40 | + ALLOC_HASHTABLE(SOLR_GLOBAL(documents)); |
| 41 | + ALLOC_HASHTABLE(SOLR_GLOBAL(clients)); |
| 42 | +diff --git src/php7/php_solr_collapse_function.c src/php7/php_solr_collapse_function.c |
| 43 | +index 5bcf6436d49..44d34f182bd 100644 |
| 44 | +--- src/php7/php_solr_collapse_function.c |
| 45 | ++++ src/php7/php_solr_collapse_function.c |
| 46 | +@@ -24,7 +24,7 @@ |
| 47 | + PHP_METHOD(SolrCollapseFunction, __construct) |
| 48 | + { |
| 49 | + long int index = SOLR_UNIQUE_FUNCTION_INDEX(); |
| 50 | +- uint nSize = SOLR_INITIAL_HASH_TABLE_SIZE; |
| 51 | ++ uint32_t nSize = SOLR_INITIAL_HASH_TABLE_SIZE; |
| 52 | + solr_function_t *solr_function_dest = NULL; |
| 53 | + zval *objptr = getThis(); |
| 54 | + #ifdef PHP_7 |
| 55 | +diff --git src/php7/php_solr_document.c src/php7/php_solr_document.c |
| 56 | +index be4748ee55e..158130ba233 100644 |
| 57 | +--- src/php7/php_solr_document.c |
| 58 | ++++ src/php7/php_solr_document.c |
| 59 | +@@ -475,7 +475,7 @@ static int solr_unserialize_document_object(solr_document_t *doc_entry, char *se |
| 60 | + PHP_METHOD(SolrDocument, __construct) |
| 61 | + { |
| 62 | + zval *objptr = getThis(); |
| 63 | +- ulong document_index = SOLR_UNIQUE_DOCUMENT_INDEX(); |
| 64 | ++ zend_ulong document_index = SOLR_UNIQUE_DOCUMENT_INDEX(); |
| 65 | + |
| 66 | + if (solr_init_document(document_index) == NULL) |
| 67 | + { |
| 68 | +@@ -742,7 +742,7 @@ PHP_METHOD(SolrDocument, current) |
| 69 | + PHP_METHOD(SolrDocument, key) |
| 70 | + { |
| 71 | + solr_document_t *doc_entry = NULL; |
| 72 | +- ulong num_index = 0L; |
| 73 | ++ zend_ulong num_index = 0L; |
| 74 | + HashTable *doc_fields = NULL; |
| 75 | + zend_string *field_name_str; |
| 76 | + |
| 77 | +@@ -838,7 +838,7 @@ PHP_METHOD(SolrDocument, unserialize) |
| 78 | + solr_char_t *serialized = NULL; |
| 79 | + COMPAT_ARG_SIZE_T serialized_length = 0; |
| 80 | + zval *objptr = getThis(); |
| 81 | +- ulong document_index = SOLR_UNIQUE_DOCUMENT_INDEX(); |
| 82 | ++ zend_ulong document_index = SOLR_UNIQUE_DOCUMENT_INDEX(); |
| 83 | + solr_document_t *doc_entry = NULL; |
| 84 | + |
| 85 | + /* Process the parameters passed to the default constructor */ |
| 86 | +@@ -1184,7 +1184,7 @@ PHP_METHOD(SolrDocument, merge) |
| 87 | + zend_hash_merge(destination_document->fields, source_document->fields, p_copy_ctor, (int) overwrite); |
| 88 | + |
| 89 | + /* Update the field count */ |
| 90 | +- destination_document->field_count = (uint) zend_hash_num_elements(destination_document->fields); |
| 91 | ++ destination_document->field_count = (uint32_t) zend_hash_num_elements(destination_document->fields); |
| 92 | + |
| 93 | + RETURN_TRUE; |
| 94 | + } |
| 95 | +diff --git src/php7/php_solr_extract.c src/php7/php_solr_extract.c |
| 96 | +index 180e91072bb..e117b438e72 100644 |
| 97 | +--- src/php7/php_solr_extract.c |
| 98 | ++++ src/php7/php_solr_extract.c |
| 99 | +@@ -35,7 +35,7 @@ extern HashTable *ustreams; |
| 100 | + |
| 101 | + PHP_SOLR_API int solr_init_ustream(zval *obj) |
| 102 | + { |
| 103 | +- ulong index = SOLR_UNIQUE_USTREAM_INDEX(); |
| 104 | ++ zend_ulong index = SOLR_UNIQUE_USTREAM_INDEX(); |
| 105 | + solr_ustream_t *ustream_entry = NULL; |
| 106 | + |
| 107 | + ustream_entry = pemalloc(sizeof(solr_ustream_t), 0); |
| 108 | +diff --git src/php7/php_solr_input_document.c src/php7/php_solr_input_document.c |
| 109 | +index a85bd69bc5c..1722a8396e3 100644 |
| 110 | +--- src/php7/php_solr_input_document.c |
| 111 | ++++ src/php7/php_solr_input_document.c |
| 112 | +@@ -708,7 +708,7 @@ PHP_METHOD(SolrInputDocument, merge) |
| 113 | + zend_hash_merge(destination_document->fields, source_document->fields, p_copy_ctor, overwrite); |
| 114 | + |
| 115 | + /* Update the field count */ |
| 116 | +- destination_document->field_count = (uint) zend_hash_num_elements(destination_document->fields); |
| 117 | ++ destination_document->field_count = (uint32_t) zend_hash_num_elements(destination_document->fields); |
| 118 | + |
| 119 | + RETURN_TRUE; |
| 120 | + } |
| 121 | +diff --git src/php7/php_solr_params.c src/php7/php_solr_params.c |
| 122 | +index 3a33e1e0261..3b8234f9a97 100644 |
| 123 | +--- src/php7/php_solr_params.c |
| 124 | ++++ src/php7/php_solr_params.c |
| 125 | +@@ -424,7 +424,7 @@ static int solr_unserialize_solr_params_object(const char *serialized, int size, |
| 126 | + solr_params_t *solr_params = NULL; |
| 127 | + long int params_index = SOLR_UNIQUE_PARAMS_INDEX(); |
| 128 | + solr_params_t tmp_solr_params; |
| 129 | +- uint nSize = SOLR_INITIAL_HASH_TABLE_SIZE; |
| 130 | ++ uint32_t nSize = SOLR_INITIAL_HASH_TABLE_SIZE; |
| 131 | + HashTable *params_ht = NULL; |
| 132 | + xmlDoc *doc = NULL; |
| 133 | + xmlXPathContext *xpathctxt; |
| 134 | +diff --git src/php7/solr_functions_document.c src/php7/solr_functions_document.c |
| 135 | +index e89ef917760..7e001f0aca2 100644 |
| 136 | +--- src/php7/solr_functions_document.c |
| 137 | ++++ src/php7/solr_functions_document.c |
| 138 | +@@ -150,7 +150,7 @@ PHP_SOLR_API int solr_document_insert_field_value_ex(solr_field_list_t *queue, c |
| 139 | + */ |
| 140 | + PHP_SOLR_API solr_document_t *solr_init_document(long int document_index) |
| 141 | + { |
| 142 | +- uint nSize = SOLR_INITIAL_HASH_TABLE_SIZE; |
| 143 | ++ uint32_t nSize = SOLR_INITIAL_HASH_TABLE_SIZE; |
| 144 | + solr_document_t *doc_ptr = NULL; |
| 145 | + solr_document_t *doc_entry; |
| 146 | + |
| 147 | +@@ -194,7 +194,7 @@ PHP_SOLR_API solr_document_t *solr_init_document(long int document_index) |
| 148 | + */ |
| 149 | + PHP_SOLR_API solr_document_t *solr_input_doc_ctor(zval *objptr) |
| 150 | + { |
| 151 | +- ulong document_index = SOLR_UNIQUE_DOCUMENT_INDEX(); |
| 152 | ++ zend_ulong document_index = SOLR_UNIQUE_DOCUMENT_INDEX(); |
| 153 | + solr_document_t *solr_doc = NULL; |
| 154 | + |
| 155 | + if ((solr_doc = solr_init_document(document_index)) == NULL) |
| 156 | +diff --git src/php7/solr_functions_helpers.c src/php7/solr_functions_helpers.c |
| 157 | +index eb32808f491..616032f9cca 100644 |
| 158 | +--- src/php7/solr_functions_helpers.c |
| 159 | ++++ src/php7/solr_functions_helpers.c |
| 160 | +@@ -1547,7 +1547,7 @@ PHP_SOLR_API void solr_solrfunc_to_string(solr_function_t *function, solr_string |
| 161 | + |
| 162 | + solr_string_t *value; |
| 163 | + zend_string *key; |
| 164 | +- ulong num_idx; |
| 165 | ++ zend_ulong num_idx; |
| 166 | + ZEND_HASH_FOREACH_KEY_PTR(function->params, num_idx, key, value) |
| 167 | + { |
| 168 | + (void)num_idx; /* silent -Wunused-but-set-variable */ |
| 169 | +@@ -1590,7 +1590,7 @@ PHP_SOLR_API void solr_destroy_ustream_zv(zval *obj) |
| 170 | + PHP_SOLR_API int solr_fetch_ustream_entry(zval *objptr, solr_ustream_t **stream_entry TSRMLS_DC) |
| 171 | + { |
| 172 | + zval rv, *index_zv; |
| 173 | +- ulong index = 0; |
| 174 | ++ zend_ulong index = 0; |
| 175 | + index_zv = zend_read_property(Z_OBJCE_P(objptr), objptr, SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME)-1, 1, &rv); |
| 176 | + |
| 177 | + index = Z_LVAL_P(index_zv); |
| 178 | +diff --git src/php7/solr_functions_params.c src/php7/solr_functions_params.c |
| 179 | +index 584577f48a9..3b3e3ed999f 100644 |
| 180 | +--- src/php7/solr_functions_params.c |
| 181 | ++++ src/php7/solr_functions_params.c |
| 182 | +@@ -22,7 +22,7 @@ |
| 183 | + |
| 184 | + PHP_SOLR_API int solr_init_params(solr_params_t *solr_params, long int index) |
| 185 | + { |
| 186 | +- uint nSize = SOLR_INITIAL_HASH_TABLE_SIZE; |
| 187 | ++ uint32_t nSize = SOLR_INITIAL_HASH_TABLE_SIZE; |
| 188 | + solr_params = (solr_params_t *)pemalloc( sizeof(solr_params_t), SOLR_PARAMS_PERSISTENT); |
| 189 | + |
| 190 | + memset(solr_params, 0, sizeof(solr_params_t)); |
| 191 | +@@ -605,7 +605,7 @@ PHP_SOLR_API void solr_normal_param_value_fetch(solr_param_t *solr_param, solr_s |
| 192 | + |
| 193 | + } else { |
| 194 | + |
| 195 | +- ulong n_loops = solr_param->count - 1; |
| 196 | ++ zend_ulong n_loops = solr_param->count - 1; |
| 197 | + |
| 198 | + while(n_loops) |
| 199 | + { |
| 200 | +@@ -646,7 +646,7 @@ PHP_SOLR_API void solr_simple_list_param_value_fetch(solr_param_t *solr_param, s |
| 201 | + { |
| 202 | + solr_param_value_t *current_ptr = solr_param->head; |
| 203 | + solr_char_t list_delimiter = ','; /* Comma 0x2C */ |
| 204 | +- ulong n_loops = solr_param->count - 1; |
| 205 | ++ zend_ulong n_loops = solr_param->count - 1; |
| 206 | + auto solr_string_t tmp_buffer; |
| 207 | + zend_string *url_encoded_list = NULL; |
| 208 | + |
| 209 | +@@ -686,7 +686,7 @@ PHP_SOLR_API void solr_arg_list_param_value_fetch(solr_param_t *solr_param, solr |
| 210 | + solr_param_value_t *current_ptr = solr_param->head; |
| 211 | + solr_char_t list_delimiter = solr_param->delimiter; |
| 212 | + solr_char_t separator = solr_param->arg_separator; |
| 213 | +- ulong n_loops = solr_param->count - 1; |
| 214 | ++ zend_ulong n_loops = solr_param->count - 1; |
| 215 | + solr_string_t tmp_buffer; |
| 216 | + zend_string *url_encoded_list = NULL; |
| 217 | + |
| 218 | +@@ -883,7 +883,7 @@ PHP_SOLR_API void solr_normal_param_value_tostring(solr_param_t *solr_param, sol |
| 219 | + |
| 220 | + } else { |
| 221 | + |
| 222 | +- ulong n_loops = solr_param->count - 1; |
| 223 | ++ zend_ulong n_loops = solr_param->count - 1; |
| 224 | + zend_string *url_encoded_param_value = NULL; |
| 225 | + |
| 226 | + while(n_loops) |
| 227 | +@@ -936,7 +936,7 @@ PHP_SOLR_API void solr_simple_list_param_value_tostring(solr_param_t *solr_param |
| 228 | + { |
| 229 | + solr_param_value_t *current_ptr = solr_param->head; |
| 230 | + solr_char_t list_delimiter = solr_param->delimiter; /* Comma 0x2C */ |
| 231 | +- ulong n_loops = solr_param->count - 1; |
| 232 | ++ zend_ulong n_loops = solr_param->count - 1; |
| 233 | + auto solr_string_t tmp_buffer; |
| 234 | + zend_string *url_encoded_list = NULL; |
| 235 | + |
| 236 | +@@ -981,7 +981,7 @@ PHP_SOLR_API void solr_arg_list_param_value_tostring(solr_param_t *solr_param, s |
| 237 | + solr_param_value_t *current_ptr = solr_param->head; |
| 238 | + solr_char_t list_delimiter = solr_param->delimiter; |
| 239 | + solr_char_t separator = solr_param->arg_separator; |
| 240 | +- ulong n_loops = solr_param->count - 1; |
| 241 | ++ zend_ulong n_loops = solr_param->count - 1; |
| 242 | + solr_string_t tmp_buffer; |
| 243 | + zend_string *url_encoded_list = NULL; |
| 244 | + |
| 245 | +diff --git src/php7/solr_types.h src/php7/solr_types.h |
| 246 | +index a177a7aacc4..fa6236e4ae9 100644 |
| 247 | +--- src/php7/solr_types.h |
| 248 | ++++ src/php7/solr_types.h |
| 249 | +@@ -163,7 +163,7 @@ typedef struct { |
| 250 | + |
| 251 | + char str[CURL_ERROR_SIZE + 1]; /* Stores the error message */ |
| 252 | + |
| 253 | +- uint number; /* Stores the error number */ |
| 254 | ++ uint32_t number; /* Stores the error number */ |
| 255 | + |
| 256 | + } solr_curl_error_t; |
| 257 | + |
| 258 | +@@ -265,9 +265,9 @@ typedef struct { |
| 259 | + |
| 260 | + typedef struct { |
| 261 | + |
| 262 | +- ulong client_index; /* Unique for the SolrClient instance. Used as index in HashTables */ |
| 263 | ++ zend_ulong client_index; /* Unique for the SolrClient instance. Used as index in HashTables */ |
| 264 | + |
| 265 | +- uint request_count; /* The number of requests made from this client */ |
| 266 | ++ uint32_t request_count; /* The number of requests made from this client */ |
| 267 | + |
| 268 | + solr_client_options_t options; /* The connection options for this client */ |
| 269 | + |
| 270 | +@@ -305,9 +305,9 @@ typedef struct { |
| 271 | + |
| 272 | + double field_boost; /* The boost value for this field */ |
| 273 | + |
| 274 | +- uint count; /* The number of values in this field */ |
| 275 | ++ uint32_t count; /* The number of values in this field */ |
| 276 | + |
| 277 | +- uint modified; /* marks field as getting modified */ |
| 278 | ++ uint32_t modified; /* marks field as getting modified */ |
| 279 | + |
| 280 | + solr_char_t *field_name; /* The name of the field */ |
| 281 | + |
| 282 | +@@ -321,9 +321,9 @@ typedef struct { |
| 283 | + /* {{{ Types for Documents and Document Collections */ |
| 284 | + typedef struct { |
| 285 | + |
| 286 | +- ulong document_index; /* Unique for the SolrInputDocument instance. Used as index in HashTables */ |
| 287 | ++ zend_ulong document_index; /* Unique for the SolrInputDocument instance. Used as index in HashTables */ |
| 288 | + |
| 289 | +- uint field_count; /* Number of fields in this document */ |
| 290 | ++ uint32_t field_count; /* Number of fields in this document */ |
| 291 | + |
| 292 | + double document_boost; /* The boost value for this document */ |
| 293 | + |
| 294 | +@@ -382,7 +382,7 @@ typedef struct { |
| 295 | + |
| 296 | + solr_param_type_t type; /* What type of query parameter this is */ |
| 297 | + |
| 298 | +- uint count; /* The number of values for this parameter */ |
| 299 | ++ uint32_t count; /* The number of values for this parameter */ |
| 300 | + |
| 301 | + solr_char_t *param_name; /* The name of the parameter */ |
| 302 | + |
| 303 | +@@ -415,9 +415,9 @@ typedef void (*solr_param_tostring_func_t)(solr_param_t *solr_param, solr_string |
| 304 | + |
| 305 | + typedef struct { |
| 306 | + |
| 307 | +- ulong params_index; /* The index for this object in the HashTable */ |
| 308 | ++ zend_ulong params_index; /* The index for this object in the HashTable */ |
| 309 | + |
| 310 | +- uint params_count; /* The number of parameters for the query object */ |
| 311 | ++ uint32_t params_count; /* The number of parameters for the query object */ |
| 312 | + |
| 313 | + HashTable *params; /* The HashTable for storing query parameters */ |
| 314 | + |
| 315 | +@@ -428,7 +428,7 @@ typedef struct { |
| 316 | + /* {{{ solr function/localparams type */ |
| 317 | + typedef struct { |
| 318 | + |
| 319 | +- ulong function_index; /* The index for this object in the HashTable */ |
| 320 | ++ zend_ulong function_index; /* The index for this object in the HashTable */ |
| 321 | + |
| 322 | + solr_char_t *name; |
| 323 | + size_t name_length; |
| 324 | +@@ -469,13 +469,13 @@ typedef struct { |
| 325 | + /* {{{ Extension Global : This should be the last data type declared. More members may be added later. */ |
| 326 | + ZEND_BEGIN_MODULE_GLOBALS(solr) |
| 327 | + |
| 328 | +- uint request_count; /* The number of times PHP_RINIT has been called */ |
| 329 | ++ uint32_t request_count; /* The number of times PHP_RINIT has been called */ |
| 330 | + |
| 331 | +- uint document_count; /* The number of active SolrDocuments in this request */ |
| 332 | ++ uint32_t document_count; /* The number of active SolrDocuments in this request */ |
| 333 | + |
| 334 | +- uint client_count; /* The number of active SolrClients in this request */ |
| 335 | ++ uint32_t client_count; /* The number of active SolrClients in this request */ |
| 336 | + |
| 337 | +- uint functions_count; /* The number of active Functions in this request */ |
| 338 | ++ uint32_t functions_count; /* The number of active Functions in this request */ |
| 339 | + |
| 340 | + HashTable *documents; /* HashTable for storing solr_document_t documents */ |
| 341 | + |
0 commit comments