diff -Nru php-amqp-1.7.1/amqp-1.7.1/amqp.c php-amqp-1.9.3/amqp-1.7.1/amqp.c --- php-amqp-1.7.1/amqp-1.7.1/amqp.c 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/amqp.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,498 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2007 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 | - | Lead: | - | - Pieter de Zwart | - | Maintainers: | - | - Brad Rodriguez | - | - Jonathan Tansavatdi | - +----------------------------------------------------------------------+ -*/ - -/* $Id: amqp.c 327551 2012-09-09 03:49:34Z pdezwart $ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#include "php_ini.h" -#include "ext/standard/info.h" -#include "zend_ini.h" -#include "zend_exceptions.h" - -#ifdef PHP_WIN32 -# include "win32/php_stdint.h" -# include "win32/signal.h" -#else -# include -# include -#endif -#include -#include - -#include "php_amqp.h" -#include "amqp_connection.h" -#include "amqp_channel.h" -#include "amqp_queue.h" -#include "amqp_exchange.h" -#include "amqp_envelope.h" -#include "amqp_connection_resource.h" - - -#ifdef PHP_WIN32 -# include "win32/unistd.h" -#else -# include -#endif - -#include "amqp_connection.h" -#include "amqp_connection_resource.h" -#include "amqp_channel.h" -#include "amqp_envelope.h" -#include "amqp_exchange.h" -#include "amqp_queue.h" - -/* True global resources - no need for thread safety here */ - -zend_class_entry *amqp_exception_class_entry, - *amqp_connection_exception_class_entry, - *amqp_channel_exception_class_entry, - *amqp_queue_exception_class_entry, - *amqp_exchange_exception_class_entry; - -/* {{{ amqp_functions[] -* -*Every user visible function must have an entry in amqp_functions[]. -*/ -zend_function_entry amqp_functions[] = { - {NULL, NULL, NULL} /* Must be the last line in amqp_functions[] */ -}; -/* }}} */ - -/* {{{ amqp_module_entry -*/ -zend_module_entry amqp_module_entry = { - STANDARD_MODULE_HEADER, - "amqp", - amqp_functions, - PHP_MINIT(amqp), - PHP_MSHUTDOWN(amqp), - NULL, - NULL, - PHP_MINFO(amqp), - PHP_AMQP_VERSION, - STANDARD_MODULE_PROPERTIES -}; -/* }}} */ - -#ifdef COMPILE_DL_AMQP - ZEND_GET_MODULE(amqp) -#endif - -void php_amqp_error(amqp_rpc_reply_t reply, char **message, amqp_connection_resource *connection_resource, amqp_channel_resource *channel_resource TSRMLS_DC) -{ - assert(connection_resource != NULL); - - switch (php_amqp_connection_resource_error(reply, message, connection_resource, (amqp_channel_t)(channel_resource ? channel_resource->channel_id : 0) TSRMLS_CC)) { - case PHP_AMQP_RESOURCE_RESPONSE_OK: - break; - case PHP_AMQP_RESOURCE_RESPONSE_ERROR: - /* Library or other non-protocol or even protocol related errors may be here. */ - /* In most cases it designate some underlying hard errors. Fail fast. */ - case PHP_AMQP_RESOURCE_RESPONSE_ERROR_CONNECTION_CLOSED: - /* Mark connection resource as closed to prevent sending any further requests */ - connection_resource->is_connected = '\0'; - - /* Close connection with all its channels */ - php_amqp_disconnect_force(connection_resource TSRMLS_CC); - - break; - case PHP_AMQP_RESOURCE_RESPONSE_ERROR_CHANNEL_CLOSED: - /* Mark channel as closed to prevent sending channel.close request */ - assert(channel_resource != NULL); - if (channel_resource) { - channel_resource->is_connected = '\0'; - - /* Close channel */ - php_amqp_close_channel(channel_resource TSRMLS_CC); - } - /* No more error handling necessary, returning. */ - break; - default: - spprintf(message, 0, "Unknown server error, method id 0x%08X (not handled by extension)", reply.reply.id); - break; - } -} - -void php_amqp_zend_throw_exception(amqp_rpc_reply_t reply, zend_class_entry *exception_ce, const char *message, PHP5to7_param_long_type_t code TSRMLS_DC) -{ - switch (reply.reply_type) { - case AMQP_RESPONSE_NORMAL: - break; - case AMQP_RESPONSE_NONE: - exception_ce = amqp_exception_class_entry; - break; - case AMQP_RESPONSE_LIBRARY_EXCEPTION: - exception_ce = amqp_exception_class_entry; - break; - case AMQP_RESPONSE_SERVER_EXCEPTION: - switch (reply.reply.id) { - case AMQP_CONNECTION_CLOSE_METHOD: - /* Fatal errors - pass them to connection level */ - exception_ce = amqp_connection_exception_class_entry; - break; - case AMQP_CHANNEL_CLOSE_METHOD: - /* Most channel-level errors occurs due to previously known action and thus their kind can be predicted. */ - /* exception_ce = amqp_channel_exception_class_entry; */ - break; - } - break; - /* Default for the above switch should be handled by the below default. */ - default: - exception_ce = amqp_exception_class_entry; - break; - } - - zend_throw_exception(exception_ce, message, code TSRMLS_CC); -} - - -void php_amqp_maybe_release_buffers_on_channel(amqp_connection_resource *connection_resource, amqp_channel_resource *channel_resource) -{ - assert(channel_resource != NULL); - assert(channel_resource->channel_id > 0); - - if (connection_resource) { - amqp_maybe_release_buffers_on_channel(connection_resource->connection_state, channel_resource->channel_id); - } -} - -amqp_bytes_t php_amqp_long_string(char const *cstr, PHP5to7_param_str_len_type_t len) -{ - if (len < 1) { - return amqp_empty_bytes; - } - - amqp_bytes_t result; - result.len = (size_t)len; - result.bytes = (void *) cstr; - - return result; -} - -char *stringify_bytes(amqp_bytes_t bytes) -{ -/* We will need up to 4 chars per byte, plus the terminating 0 */ - char *res = emalloc(bytes.len * 4 + 1); - uint8_t *data = bytes.bytes; - char *p = res; - size_t i; - - for (i = 0; i < bytes.len; i++) { - if (data[i] >= 32 && data[i] != 127) { - *p++ = data[i]; - } else { - *p++ = '\\'; - *p++ = '0' + (data[i] >> 6); - *p++ = '0' + (data[i] >> 3 & 0x7); - *p++ = '0' + (data[i] & 0x7); - } - } - - *p = 0; - return res; -} - -void internal_convert_zval_to_amqp_table(zval *zvalArguments, amqp_table_t *arguments, char allow_int_keys TSRMLS_DC) -{ - HashTable *ht; - HashPosition pos; - - zval *value; - zval **data; - - PHP5to7_ZEND_REAL_HASH_KEY_T *real_key; - - char *key; - uint key_len; - - ulong index; - - char type[16]; - amqp_table_t *inner_table; - - ht = Z_ARRVAL_P(zvalArguments); - - /* Allocate all the memory necessary for storing the arguments */ - arguments->entries = (amqp_table_entry_t *)ecalloc((size_t)zend_hash_num_elements(ht), sizeof(amqp_table_entry_t)); - arguments->num_entries = 0; - - PHP5to7_ZEND_HASH_FOREACH_KEY_VAL(ht, index, real_key, key, key_len, data, value, pos) { - char *strKey; - char *strValue; - amqp_table_entry_t *table; - amqp_field_value_t *field; - - - /* Now pull the key */ - - if (!PHP5to7_ZEND_HASH_KEY_IS_STRING(ht, real_key, key, key_len, index, pos)) { - if (allow_int_keys) { - /* Convert to strings non-string keys */ - char str[32]; - - key_len = sprintf(str, "%lu", index); - key = str; - } else { - /* Skip things that are not strings */ - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Ignoring non-string header field '%lu'", index); - - - - PHP5to7_ZEND_HASH_FOREACH_CONTINUE; - } - } else { - PHP5to7_ZEND_HASH_KEY_MAYBE_UNPACK(real_key, key, key_len); - } - - /* Build the value */ - table = &arguments->entries[arguments->num_entries++]; - field = &table->value; - - switch (Z_TYPE_P(value)) { - PHP5to7_CASE_IS_BOOL: - field->kind = AMQP_FIELD_KIND_BOOLEAN; - field->value.boolean = (amqp_boolean_t)Z_LVAL_P(value); - break; - case IS_DOUBLE: - field->kind = AMQP_FIELD_KIND_F64; - field->value.f64 = Z_DVAL_P(value); - break; - case IS_LONG: - field->kind = AMQP_FIELD_KIND_I64; - field->value.i64 = Z_LVAL_P(value); - break; - case IS_STRING: - field->kind = AMQP_FIELD_KIND_UTF8; - - if (Z_STRLEN_P(value)) { - amqp_bytes_t bytes; - bytes.len = (size_t) Z_STRLEN_P(value); - bytes.bytes = estrndup(Z_STRVAL_P(value), (uint)Z_STRLEN_P(value)); - - field->value.bytes = bytes; - } else { - field->value.bytes = amqp_empty_bytes; - } - - break; - case IS_ARRAY: - field->kind = AMQP_FIELD_KIND_TABLE; - internal_convert_zval_to_amqp_table(value, &field->value.table, 1 TSRMLS_CC); - - break; - default: - switch(Z_TYPE_P(value)) { - case IS_NULL: strcpy(type, "null"); break; - case IS_OBJECT: strcpy(type, "object"); break; - case IS_RESOURCE: strcpy(type, "resource"); break; - default: strcpy(type, "unknown"); - } - - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Ignoring field '%s' due to unsupported value type (%s)", key, type); - - /* Reset entries counter back */ - arguments->num_entries --; - - PHP5to7_ZEND_HASH_FOREACH_CONTINUE; - } - - strKey = estrndup(key, key_len); - table->key = amqp_cstring_bytes(strKey); - - } PHP5to7_ZEND_HASH_FOREACH_END(); -}; - -amqp_table_t *convert_zval_to_amqp_table(zval *zvalArguments TSRMLS_DC) -{ - amqp_table_t *arguments; - /* In setArguments, we are overwriting all the existing values */ - arguments = (amqp_table_t *)emalloc(sizeof(amqp_table_t)); - - internal_convert_zval_to_amqp_table(zvalArguments, arguments, 0 TSRMLS_CC); - - return arguments; -} - - - - -void internal_php_amqp_free_amqp_table(amqp_table_t *object, char clear_root) -{ - if (!object) { - return; - } - - if (object->entries) { - int macroEntryCounter; - for (macroEntryCounter = 0; macroEntryCounter < object->num_entries; macroEntryCounter++) { - - amqp_table_entry_t *entry = &object->entries[macroEntryCounter]; - efree(entry->key.bytes); - - switch (entry->value.kind) { - case AMQP_FIELD_KIND_TABLE: - internal_php_amqp_free_amqp_table(&entry->value.value.table, 0); - break; - case AMQP_FIELD_KIND_UTF8: - if (entry->value.value.bytes.bytes) { - efree(entry->value.value.bytes.bytes); - } - break; - default: - break; - } - } - efree(object->entries); - } - - if (clear_root) { - efree(object); - } -} - -void php_amqp_free_amqp_table(amqp_table_t *object) -{ - internal_php_amqp_free_amqp_table(object, 1); -} - - -PHP_INI_BEGIN() - PHP_INI_ENTRY("amqp.host", DEFAULT_HOST, PHP_INI_ALL, NULL) - PHP_INI_ENTRY("amqp.vhost", DEFAULT_VHOST, PHP_INI_ALL, NULL) - PHP_INI_ENTRY("amqp.port", DEFAULT_PORT, PHP_INI_ALL, NULL) - PHP_INI_ENTRY("amqp.timeout", DEFAULT_TIMEOUT, PHP_INI_ALL, NULL) - PHP_INI_ENTRY("amqp.read_timeout", DEFAULT_READ_TIMEOUT, PHP_INI_ALL, NULL) - PHP_INI_ENTRY("amqp.write_timeout", DEFAULT_WRITE_TIMEOUT, PHP_INI_ALL, NULL) - PHP_INI_ENTRY("amqp.connect_timeout", DEFAULT_CONNECT_TIMEOUT, PHP_INI_ALL, NULL) - PHP_INI_ENTRY("amqp.login", DEFAULT_LOGIN, PHP_INI_ALL, NULL) - PHP_INI_ENTRY("amqp.password", DEFAULT_PASSWORD, PHP_INI_ALL, NULL) - PHP_INI_ENTRY("amqp.auto_ack", DEFAULT_AUTOACK, PHP_INI_ALL, NULL) - PHP_INI_ENTRY("amqp.prefetch_count", DEFAULT_PREFETCH_COUNT, PHP_INI_ALL, NULL) - PHP_INI_ENTRY("amqp.channel_max", DEFAULT_CHANNEL_MAX, PHP_INI_ALL, NULL) - PHP_INI_ENTRY("amqp.frame_max", DEFAULT_FRAME_MAX, PHP_INI_ALL, NULL) - PHP_INI_ENTRY("amqp.heartbeat", DEFAULT_HEARTBEAT, PHP_INI_ALL, NULL) -PHP_INI_END() - -/* {{{ PHP_MINIT_FUNCTION -*/ -PHP_MINIT_FUNCTION(amqp) -{ - zend_class_entry ce; - - /* Set up the connection resource */ - le_amqp_connection_resource = zend_register_list_destructors_ex(amqp_connection_resource_dtor, NULL, PHP_AMQP_CONNECTION_RES_NAME, module_number); - le_amqp_connection_resource_persistent = zend_register_list_destructors_ex(NULL, amqp_connection_resource_dtor_persistent, PHP_AMQP_CONNECTION_RES_NAME, module_number); - - PHP_MINIT(amqp_connection)(INIT_FUNC_ARGS_PASSTHRU); - PHP_MINIT(amqp_channel)(INIT_FUNC_ARGS_PASSTHRU); - PHP_MINIT(amqp_queue)(INIT_FUNC_ARGS_PASSTHRU); - PHP_MINIT(amqp_exchange)(INIT_FUNC_ARGS_PASSTHRU); - PHP_MINIT(amqp_envelope)(INIT_FUNC_ARGS_PASSTHRU); - - /* Class Exceptions */ - INIT_CLASS_ENTRY(ce, "AMQPException", NULL); - amqp_exception_class_entry = PHP5to7_zend_register_internal_class_ex(&ce, zend_exception_get_default(TSRMLS_C)); - - INIT_CLASS_ENTRY(ce, "AMQPConnectionException", NULL); - amqp_connection_exception_class_entry = PHP5to7_zend_register_internal_class_ex(&ce, amqp_exception_class_entry); - - INIT_CLASS_ENTRY(ce, "AMQPChannelException", NULL); - amqp_channel_exception_class_entry = PHP5to7_zend_register_internal_class_ex(&ce, amqp_exception_class_entry); - - INIT_CLASS_ENTRY(ce, "AMQPQueueException", NULL); - amqp_queue_exception_class_entry = PHP5to7_zend_register_internal_class_ex(&ce, amqp_exception_class_entry); - - INIT_CLASS_ENTRY(ce, "AMQPExchangeException", NULL); - amqp_exchange_exception_class_entry = PHP5to7_zend_register_internal_class_ex(&ce, amqp_exception_class_entry); - - REGISTER_INI_ENTRIES(); - - REGISTER_LONG_CONSTANT("AMQP_NOPARAM", AMQP_NOPARAM, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("AMQP_JUST_CONSUME", AMQP_JUST_CONSUME, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("AMQP_DURABLE", AMQP_DURABLE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("AMQP_PASSIVE", AMQP_PASSIVE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("AMQP_EXCLUSIVE", AMQP_EXCLUSIVE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("AMQP_AUTODELETE", AMQP_AUTODELETE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("AMQP_INTERNAL", AMQP_INTERNAL, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("AMQP_NOLOCAL", AMQP_NOLOCAL, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("AMQP_AUTOACK", AMQP_AUTOACK, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("AMQP_IFEMPTY", AMQP_IFEMPTY, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("AMQP_IFUNUSED", AMQP_IFUNUSED, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("AMQP_MANDATORY", AMQP_MANDATORY, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("AMQP_IMMEDIATE", AMQP_IMMEDIATE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("AMQP_MULTIPLE", AMQP_MULTIPLE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("AMQP_NOWAIT", AMQP_NOWAIT, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("AMQP_REQUEUE", AMQP_REQUEUE, CONST_CS | CONST_PERSISTENT); - - REGISTER_STRING_CONSTANT("AMQP_EX_TYPE_DIRECT", AMQP_EX_TYPE_DIRECT, CONST_CS | CONST_PERSISTENT); - REGISTER_STRING_CONSTANT("AMQP_EX_TYPE_FANOUT", AMQP_EX_TYPE_FANOUT, CONST_CS | CONST_PERSISTENT); - REGISTER_STRING_CONSTANT("AMQP_EX_TYPE_TOPIC", AMQP_EX_TYPE_TOPIC, CONST_CS | CONST_PERSISTENT); - REGISTER_STRING_CONSTANT("AMQP_EX_TYPE_HEADERS",AMQP_EX_TYPE_HEADERS, CONST_CS | CONST_PERSISTENT); - - REGISTER_LONG_CONSTANT("AMQP_OS_SOCKET_TIMEOUT_ERRNO", AMQP_OS_SOCKET_TIMEOUT_ERRNO, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PHP_AMQP_MAX_CHANNELS", PHP_AMQP_MAX_CHANNELS, CONST_CS | CONST_PERSISTENT); - - return SUCCESS; -} -/* }}} */ - -/* {{{ PHP_MSHUTDOWN_FUNCTION -*/ -PHP_MSHUTDOWN_FUNCTION(amqp) -{ - UNREGISTER_INI_ENTRIES(); - - return SUCCESS; -} -/* }}} */ - - -/* {{{ PHP_MINFO_FUNCTION -*/ -PHP_MINFO_FUNCTION(amqp) -{ - php_info_print_table_start(); - php_info_print_table_header(2, "Version", PHP_AMQP_VERSION); - php_info_print_table_header(2, "Revision", PHP_AMQP_REVISION); - php_info_print_table_header(2, "Compiled", __DATE__ " @ " __TIME__); - php_info_print_table_header(2, "AMQP protocol version", "0-9-1"); - php_info_print_table_header(2, "librabbitmq version", amqp_version()); - php_info_print_table_header(2, "Default max channels per connection", DEFAULT_CHANNEL_MAX); - php_info_print_table_header(2, "Default max frame size", DEFAULT_FRAME_MAX); - php_info_print_table_header(2, "Default heartbeats interval", DEFAULT_HEARTBEAT); - DISPLAY_INI_ENTRIES(); -} -/* }}} */ - -/* -*Local variables: -*tab-width: 4 -*c-basic-offset: 4 -*End: -*vim600: noet sw=4 ts=4 fdm=marker -*vim<600: noet sw=4 ts=4 -*/ diff -Nru php-amqp-1.7.1/amqp-1.7.1/amqp_channel.c php-amqp-1.9.3/amqp-1.7.1/amqp_channel.c --- php-amqp-1.7.1/amqp-1.7.1/amqp_channel.c 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/amqp_channel.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,760 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2007 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 | - | Lead: | - | - Pieter de Zwart | - | Maintainers: | - | - Brad Rodriguez | - | - Jonathan Tansavatdi | - +----------------------------------------------------------------------+ -*/ - -/* $Id: amqp_channel.c 318036 2011-10-11 20:30:46Z pdezwart $ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#include "php_ini.h" -#include "ext/standard/info.h" -#include "zend_exceptions.h" - -#ifdef PHP_WIN32 -# include "win32/php_stdint.h" -# include "win32/signal.h" -#else -# include -# include -#endif -#include -#include - -#ifdef PHP_WIN32 -# include "win32/unistd.h" -#else -# include -#endif - -#include "php_amqp.h" -#include "amqp_connection.h" -#include "amqp_connection_resource.h" -#include "amqp_channel.h" - -zend_class_entry *amqp_channel_class_entry; -#define this_ce amqp_channel_class_entry - -zend_object_handlers amqp_channel_object_handlers; - -void php_amqp_close_channel(amqp_channel_resource *channel_resource TSRMLS_DC) -{ - assert(channel_resource != NULL); - - amqp_connection_resource *connection_resource = channel_resource->connection_resource; - - if (connection_resource != NULL) { - /* First, remove it from active channels table to prevent recursion in case of connection error */ - php_amqp_connection_resource_unregister_channel(connection_resource, channel_resource->channel_id); - } else { - channel_resource->is_connected = '\0'; - } - - assert(channel_resource->connection_resource == NULL); - - if (!channel_resource->is_connected) { - /* Nothing to do more - channel was previously marked as closed, possibly, due to channel-level error */ - return; - } - - channel_resource->is_connected = '\0'; - - if (connection_resource && connection_resource->is_connected && channel_resource->channel_id > 0) { - assert(connection_resource != NULL); - - amqp_channel_close(connection_resource->connection_state, channel_resource->channel_id, AMQP_REPLY_SUCCESS); - - amqp_rpc_reply_t res = amqp_get_rpc_reply(connection_resource->connection_state); - - if (res.reply_type != AMQP_RESPONSE_NORMAL) { - PHP_AMQP_INIT_ERROR_MESSAGE(); - - php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, connection_resource, channel_resource TSRMLS_CC); - - php_amqp_zend_throw_exception(res, amqp_channel_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC); - php_amqp_maybe_release_buffers_on_channel(connection_resource, channel_resource); - - PHP_AMQP_DESTROY_ERROR_MESSAGE(); - return; - } - - php_amqp_maybe_release_buffers_on_channel(connection_resource, channel_resource); - } -} - - -void amqp_channel_free(PHP5to7_obj_free_zend_object *object TSRMLS_DC) -{ - amqp_channel_object *channel = PHP_AMQP_FETCH_CHANNEL(object); - - if (channel->channel_resource != NULL) { - php_amqp_close_channel(channel->channel_resource TSRMLS_CC); - - efree(channel->channel_resource); - channel->channel_resource = NULL; - } - - zend_object_std_dtor(&channel->zo TSRMLS_CC); - -#if PHP_MAJOR_VERSION < 7 - efree(object); -#endif -} - - -PHP5to7_zend_object_value amqp_channel_ctor(zend_class_entry *ce TSRMLS_DC) -{ - amqp_channel_object *channel = PHP5to7_ECALLOC_CHANNEL_OBJECT(ce); - - zend_object_std_init(&channel->zo, ce TSRMLS_CC); - AMQP_OBJECT_PROPERTIES_INIT(channel->zo, ce); - -#if PHP_MAJOR_VERSION >=7 - channel->zo.handlers = &amqp_channel_object_handlers; - - return &channel->zo; -#else - PHP5to7_zend_object_value new_value; - - new_value.handle = zend_objects_store_put( - channel, - NULL, - (zend_objects_free_object_storage_t) amqp_channel_free, - NULL TSRMLS_CC - ); - - new_value.handlers = zend_get_std_object_handlers(); - - return new_value; -#endif -} - - -/* {{{ proto AMQPChannel::__construct(AMQPConnection obj) - */ -PHP_METHOD(amqp_channel_class, __construct) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - - zval *connection_object = NULL; - - amqp_channel_resource *channel_resource; - amqp_channel_object *channel; - amqp_connection_object *connection; - - /* Parse out the method parameters */ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &connection_object) == FAILURE) { - zend_throw_exception(amqp_channel_exception_class_entry, "Parameter must be an instance of AMQPConnection.", 0 TSRMLS_CC); - RETURN_NULL(); - } - - channel = PHP_AMQP_GET_CHANNEL(getThis()); - - /* Set the prefetch count */ - zend_update_property_long(this_ce, getThis(), ZEND_STRL("prefetch_count"), INI_INT("amqp.prefetch_count") TSRMLS_CC); - - /* Pull out and verify the connection */ - connection = PHP_AMQP_GET_CONNECTION(connection_object); - PHP_AMQP_VERIFY_CONNECTION(connection, "Could not create channel."); - - if (!connection->connection_resource) { - zend_throw_exception(amqp_channel_exception_class_entry, "Could not create channel. No connection resource.", 0 TSRMLS_CC); - return; - } - - if (!connection->connection_resource->is_connected) { - zend_throw_exception(amqp_channel_exception_class_entry, "Could not create channel. Connection resource is not connected.", 0 TSRMLS_CC); - return; - } - - zend_update_property(this_ce, getThis(), ZEND_STRL("connection"), connection_object TSRMLS_CC); - - channel_resource = (amqp_channel_resource*)ecalloc(1, sizeof(amqp_channel_resource)); - channel->channel_resource = channel_resource; - - /* Figure out what the next available channel is on this connection */ - channel_resource->channel_id = php_amqp_connection_resource_get_available_channel_id(connection->connection_resource); - - /* Check that we got a valid channel */ - if (!channel_resource->channel_id) { - zend_throw_exception(amqp_channel_exception_class_entry, "Could not create channel. Connection has no open channel slots remaining.", 0 TSRMLS_CC); - return; - } - - if (php_amqp_connection_resource_register_channel(connection->connection_resource, channel_resource, channel_resource->channel_id) == FAILURE) { - zend_throw_exception(amqp_channel_exception_class_entry, "Could not create channel. Failed to add channel to connection slot.", 0 TSRMLS_CC); - } - - /* Open up the channel for use */ - amqp_channel_open_ok_t *r = amqp_channel_open(channel_resource->connection_resource->connection_state, channel_resource->channel_id); - - - if (!r) { - amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state); - - PHP_AMQP_INIT_ERROR_MESSAGE(); - - php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, channel_resource->connection_resource, channel_resource TSRMLS_CC); - - php_amqp_zend_throw_exception(res, amqp_channel_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC); - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - - PHP_AMQP_DESTROY_ERROR_MESSAGE(); - - /* Prevent double free, it may happens in case case channel resource was already freed due to some hard error. */ - if (channel_resource->connection_resource) { - php_amqp_connection_resource_unregister_channel(channel_resource->connection_resource, channel_resource->channel_id); - channel_resource->channel_id = 0; - } - - return; - } - - /* r->channel_id is a 16-bit channel number insibe amqp_bytes_t, assertion below will without converting to uint16_t*/ - /* assert (r->channel_id == channel_resource->channel_id);*/ - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - - channel_resource->is_connected = '\1'; - - /* Set the prefetch count: */ - amqp_basic_qos( - channel_resource->connection_resource->connection_state, - channel_resource->channel_id, - 0, /* prefetch window size */ - (uint16_t)PHP_AMQP_READ_THIS_PROP_LONG("prefetch_count"), /* prefetch message count */ - /* NOTE that RabbitMQ has reinterpreted global flag field. See https://www.rabbitmq.com/amqp-0-9-1-reference.html#basic.qos.global for details */ - 0 /* global flag */ - ); - - amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state); - - if (res.reply_type != AMQP_RESPONSE_NORMAL) { - PHP_AMQP_INIT_ERROR_MESSAGE(); - - php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, channel_resource->connection_resource, channel_resource TSRMLS_CC); - - php_amqp_zend_throw_exception(res, amqp_channel_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC); - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - - PHP_AMQP_DESTROY_ERROR_MESSAGE(); - return; - } - - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); -} -/* }}} */ - - -/* {{{ proto bool amqp::isConnected() -check amqp channel */ -PHP_METHOD(amqp_channel_class, isConnected) -{ - amqp_channel_resource *channel_resource; - - PHP_AMQP_NOPARAMS(); - - channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(getThis()); - - RETURN_BOOL(channel_resource && channel_resource->is_connected); -} -/* }}} */ - -/* {{{ proto bool amqp::getChannelId() -get amqp channel ID */ -PHP_METHOD(amqp_channel_class, getChannelId) -{ - amqp_channel_resource *channel_resource; - - PHP_AMQP_NOPARAMS(); - - channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(getThis()); - - if (!channel_resource) { - RETURN_NULL(); - } - - RETURN_LONG(channel_resource->channel_id); -} -/* }}} */ - -/* {{{ proto bool amqp::setPrefetchCount(long count) -set the number of prefetches */ -PHP_METHOD(amqp_channel_class, setPrefetchCount) -{ - amqp_channel_resource *channel_resource; - PHP5to7_param_long_type_t prefetch_count; - - /* Get the vhost from the method params */ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &prefetch_count) == FAILURE) { - return; - } - - channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(getThis()); - PHP_AMQP_VERIFY_CHANNEL_CONNECTION_RESOURCE(channel_resource, "Could not set prefetch count."); - // TODO: verify that connection is active and resource exists. that is enough - - /* If we are already connected, set the new prefetch count */ - if (channel_resource->is_connected) { - amqp_basic_qos( - channel_resource->connection_resource->connection_state, - channel_resource->channel_id, - 0, - (uint16_t)prefetch_count, - 0 - ); - - amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state); - - if (res.reply_type != AMQP_RESPONSE_NORMAL) { - PHP_AMQP_INIT_ERROR_MESSAGE(); - - php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, channel_resource->connection_resource, channel_resource TSRMLS_CC); - - php_amqp_zend_throw_exception(res, amqp_channel_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC); - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - - PHP_AMQP_DESTROY_ERROR_MESSAGE(); - return; - } - - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - } - - /* Set the prefetch count - the implication is to disable the size */ - zend_update_property_long(this_ce, getThis(), ZEND_STRL("prefetch_count"), prefetch_count TSRMLS_CC); - zend_update_property_long(this_ce, getThis(), ZEND_STRL("prefetch_size"), 0 TSRMLS_CC); - - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto long amqp::setPrefetchCount() -get the number of prefetches */ -PHP_METHOD(amqp_channel_class, getPrefetchCount) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - PHP_AMQP_NOPARAMS(); - PHP_AMQP_RETURN_THIS_PROP("prefetch_count") -} -/* }}} */ - - -/* {{{ proto bool amqp::setPrefetchSize(long size) -set the number of prefetches */ -PHP_METHOD(amqp_channel_class, setPrefetchSize) -{ - amqp_channel_resource *channel_resource; - PHP5to7_param_long_type_t prefetch_size; - - /* Get the vhost from the method params */ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &prefetch_size) == FAILURE) { - return; - } - - channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(getThis()); - PHP_AMQP_VERIFY_CHANNEL_CONNECTION_RESOURCE(channel_resource, "Could not set prefetch size."); - - /* If we are already connected, set the new prefetch count */ - if (channel_resource->is_connected) { - amqp_basic_qos( - channel_resource->connection_resource->connection_state, - channel_resource->channel_id, - (uint16_t)prefetch_size, - 0, - 0 - ); - - amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state); - - if (res.reply_type != AMQP_RESPONSE_NORMAL) { - PHP_AMQP_INIT_ERROR_MESSAGE(); - - php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, channel_resource->connection_resource, channel_resource TSRMLS_CC); - - php_amqp_zend_throw_exception(res, amqp_channel_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC); - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - - PHP_AMQP_DESTROY_ERROR_MESSAGE(); - return; - } - - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - } - - /* Set the prefetch size - the implication is to disable the count */ - zend_update_property_long(this_ce, getThis(), ZEND_STRL("prefetch_count"), 0 TSRMLS_CC); - zend_update_property_long(this_ce, getThis(), ZEND_STRL("prefetch_size"), prefetch_size TSRMLS_CC); - - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto long amqp::getPrefetchSize() -get the number of prefetches */ -PHP_METHOD(amqp_channel_class, getPrefetchSize) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - PHP_AMQP_NOPARAMS(); - PHP_AMQP_RETURN_THIS_PROP("prefetch_size") -} -/* }}} */ - - - -/* {{{ proto amqp::qos(long size, long count) -set the number of prefetches */ -PHP_METHOD(amqp_channel_class, qos) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - - amqp_channel_resource *channel_resource; - PHP5to7_param_long_type_t prefetch_size; - PHP5to7_param_long_type_t prefetch_count; - - /* Get the vhost from the method params */ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &prefetch_size, &prefetch_count) == FAILURE) { - return; - } - - channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(getThis()); - PHP_AMQP_VERIFY_CHANNEL_CONNECTION_RESOURCE(channel_resource, "Could not set qos parameters."); - - /* Set the prefetch size - the implication is to disable the count */ - zend_update_property_long(this_ce, getThis(), ZEND_STRL("prefetch_size"), prefetch_size TSRMLS_CC); - zend_update_property_long(this_ce, getThis(), ZEND_STRL("prefetch_count"), prefetch_count TSRMLS_CC); - - /* If we are already connected, set the new prefetch count */ - if (channel_resource->is_connected) { - amqp_basic_qos( - channel_resource->connection_resource->connection_state, - channel_resource->channel_id, - (uint16_t)PHP_AMQP_READ_THIS_PROP_LONG("prefetch_size"), - (uint16_t)PHP_AMQP_READ_THIS_PROP_LONG("prefetch_count"), - /* NOTE that RabbitMQ has reinterpreted global flag field. See https://www.rabbitmq.com/amqp-0-9-1-reference.html#basic.qos.global for details */ - 0 /* Global flag - whether this change should affect every channel_resource */ - ); - - amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state); - - if (res.reply_type != AMQP_RESPONSE_NORMAL) { - PHP_AMQP_INIT_ERROR_MESSAGE(); - - php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, channel_resource->connection_resource, channel_resource TSRMLS_CC); - - php_amqp_zend_throw_exception(res, amqp_channel_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC); - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - - PHP_AMQP_DESTROY_ERROR_MESSAGE(); - return; - } - - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - } - - RETURN_TRUE; -} -/* }}} */ - - -/* {{{ proto amqp::startTransaction() -start a transaction on the given channel */ -PHP_METHOD(amqp_channel_class, startTransaction) -{ - amqp_channel_resource *channel_resource; - - amqp_rpc_reply_t res; - - /* Get the vhost from the method params */ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { - return; - } - - channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(getThis()); - PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not start the transaction."); - - amqp_tx_select( - channel_resource->connection_resource->connection_state, - channel_resource->channel_id - ); - - res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state); - - if (res.reply_type != AMQP_RESPONSE_NORMAL) { - PHP_AMQP_INIT_ERROR_MESSAGE(); - - php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, channel_resource->connection_resource, channel_resource TSRMLS_CC); - - php_amqp_zend_throw_exception(res, amqp_channel_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC); - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - - PHP_AMQP_DESTROY_ERROR_MESSAGE(); - return; - } - - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - - RETURN_TRUE; -} -/* }}} */ - - -/* {{{ proto amqp::startTransaction() -start a transaction on the given channel */ -PHP_METHOD(amqp_channel_class, commitTransaction) -{ - amqp_channel_resource *channel_resource; - - amqp_rpc_reply_t res; - - /* Get the vhost from the method params */ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { - return; - } - - channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(getThis()); - PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not start the transaction."); - - amqp_tx_commit( - channel_resource->connection_resource->connection_state, - channel_resource->channel_id - ); - - res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state); - - if (res.reply_type != AMQP_RESPONSE_NORMAL) { - PHP_AMQP_INIT_ERROR_MESSAGE(); - - php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, channel_resource->connection_resource, channel_resource TSRMLS_CC); - - php_amqp_zend_throw_exception(res, amqp_channel_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC); - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - - PHP_AMQP_DESTROY_ERROR_MESSAGE(); - return; - } - - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto amqp::startTransaction() -start a transaction on the given channel */ -PHP_METHOD(amqp_channel_class, rollbackTransaction) -{ - amqp_channel_resource *channel_resource; - - amqp_rpc_reply_t res; - - /* Get the vhost from the method params */ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { - return; - } - - - channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(getThis()); - PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not rollback the transaction."); - - amqp_tx_rollback( - channel_resource->connection_resource->connection_state, - channel_resource->channel_id - ); - - res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state); - - if (res.reply_type != AMQP_RESPONSE_NORMAL) { - PHP_AMQP_INIT_ERROR_MESSAGE(); - - php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, channel_resource->connection_resource, channel_resource TSRMLS_CC); - - php_amqp_zend_throw_exception(res, amqp_channel_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC); - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - - PHP_AMQP_DESTROY_ERROR_MESSAGE(); - return; - } - - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto AMQPChannel::getConnection() -Get the AMQPConnection object in use */ -PHP_METHOD(amqp_channel_class, getConnection) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - PHP_AMQP_NOPARAMS(); - PHP_AMQP_RETURN_THIS_PROP("connection") -} -/* }}} */ - -/* {{{ proto bool amqp::basicRecover([bool requeue=TRUE]) -Redeliver unacknowledged messages */ -PHP_METHOD(amqp_channel_class, basicRecover) -{ - amqp_channel_resource *channel_resource; - - amqp_rpc_reply_t res; - - zend_bool requeue = 1; - - /* Get the vhost from the method params */ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &requeue) == FAILURE) { - return; - } - - channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(getThis()); - PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not redeliver unacknowledged messages."); - - amqp_basic_recover( - channel_resource->connection_resource->connection_state, - channel_resource->channel_id, - (amqp_boolean_t) requeue - ); - - res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state); - - if (res.reply_type != AMQP_RESPONSE_NORMAL) { - PHP_AMQP_INIT_ERROR_MESSAGE(); - - php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, channel_resource->connection_resource, channel_resource TSRMLS_CC); - - php_amqp_zend_throw_exception(res, amqp_channel_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC); - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - - PHP_AMQP_DESTROY_ERROR_MESSAGE(); - return; - } - - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - - RETURN_TRUE; - -} -/* }}} */ - - -/* amqp_channel_class ARG_INFO definition */ -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class__construct, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) - ZEND_ARG_OBJ_INFO(0, amqp_connection, AMQPConnection, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_isConnected, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_getChannelId, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_setPrefetchSize, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) - ZEND_ARG_INFO(0, size) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_getPrefetchSize, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_setPrefetchCount, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) - ZEND_ARG_INFO(0, count) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_getPrefetchCount, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_qos, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 2) - ZEND_ARG_INFO(0, size) - ZEND_ARG_INFO(0, count) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_startTransaction, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_commitTransaction, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_rollbackTransaction, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_getConnection, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_basicRecover, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) - ZEND_ARG_INFO(0, requeue) -ZEND_END_ARG_INFO() - - -zend_function_entry amqp_channel_class_functions[] = { - PHP_ME(amqp_channel_class, __construct, arginfo_amqp_channel_class__construct, ZEND_ACC_PUBLIC) - PHP_ME(amqp_channel_class, isConnected, arginfo_amqp_channel_class_isConnected, ZEND_ACC_PUBLIC) - - PHP_ME(amqp_channel_class, getChannelId, arginfo_amqp_channel_class_getChannelId, ZEND_ACC_PUBLIC) - - PHP_ME(amqp_channel_class, setPrefetchSize, arginfo_amqp_channel_class_setPrefetchSize, ZEND_ACC_PUBLIC) - PHP_ME(amqp_channel_class, getPrefetchSize, arginfo_amqp_channel_class_getPrefetchSize, ZEND_ACC_PUBLIC) - PHP_ME(amqp_channel_class, setPrefetchCount,arginfo_amqp_channel_class_setPrefetchCount,ZEND_ACC_PUBLIC) - PHP_ME(amqp_channel_class, getPrefetchCount,arginfo_amqp_channel_class_getPrefetchCount,ZEND_ACC_PUBLIC) - PHP_ME(amqp_channel_class, qos, arginfo_amqp_channel_class_qos, ZEND_ACC_PUBLIC) - - PHP_ME(amqp_channel_class, startTransaction, arginfo_amqp_channel_class_startTransaction, ZEND_ACC_PUBLIC) - PHP_ME(amqp_channel_class, commitTransaction, arginfo_amqp_channel_class_commitTransaction, ZEND_ACC_PUBLIC) - PHP_ME(amqp_channel_class, rollbackTransaction, arginfo_amqp_channel_class_rollbackTransaction, ZEND_ACC_PUBLIC) - - PHP_ME(amqp_channel_class, getConnection, arginfo_amqp_channel_class_getConnection, ZEND_ACC_PUBLIC) - - PHP_ME(amqp_channel_class, basicRecover, arginfo_amqp_channel_class_basicRecover, ZEND_ACC_PUBLIC) - - {NULL, NULL, NULL} /* Must be the last line in amqp_functions[] */ -}; - -PHP_MINIT_FUNCTION(amqp_channel) -{ - zend_class_entry ce; - - INIT_CLASS_ENTRY(ce, "AMQPChannel", amqp_channel_class_functions); - ce.create_object = amqp_channel_ctor; - amqp_channel_class_entry = zend_register_internal_class(&ce TSRMLS_CC); - - zend_declare_property_null(this_ce, ZEND_STRL("connection"), ZEND_ACC_PRIVATE TSRMLS_CC); - - zend_declare_property_null(this_ce, ZEND_STRL("prefetch_count"), ZEND_ACC_PRIVATE TSRMLS_CC); - zend_declare_property_long(this_ce, ZEND_STRL("prefetch_size"), 0, ZEND_ACC_PRIVATE TSRMLS_CC); - -#if PHP_MAJOR_VERSION >=7 - memcpy(&amqp_channel_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); - - amqp_channel_object_handlers.offset = XtOffsetOf(amqp_connection_object, zo); - amqp_channel_object_handlers.free_obj = amqp_channel_free; -#endif - - return SUCCESS; -} -/* -*Local variables: -*tab-width: 4 -*c-basic-offset: 4 -*End: -*vim600: noet sw=4 ts=4 fdm=marker -*vim<600: noet sw=4 ts=4 -*/ diff -Nru php-amqp-1.7.1/amqp-1.7.1/amqp_channel.h php-amqp-1.9.3/amqp-1.7.1/amqp_channel.h --- php-amqp-1.7.1/amqp-1.7.1/amqp_channel.h 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/amqp_channel.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2007 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 | - | Lead: | - | - Pieter de Zwart | - | Maintainers: | - | - Brad Rodriguez | - | - Jonathan Tansavatdi | - +----------------------------------------------------------------------+ -*/ - -/* $Id: amqp_channel.h 305865 2010-12-01 01:30:56Z pdezwart $ */ - -extern zend_class_entry *amqp_channel_class_entry; - -void php_amqp_close_channel(amqp_channel_resource *channel_resource TSRMLS_DC); - -PHP_METHOD(amqp_channel_class, __construct); -PHP_METHOD(amqp_channel_class, isConnected); -PHP_METHOD(amqp_channel_class, getChannelId); -PHP_METHOD(amqp_channel_class, setPrefetchSize); -PHP_METHOD(amqp_channel_class, getPrefetchSize); -PHP_METHOD(amqp_channel_class, setPrefetchCount); -PHP_METHOD(amqp_channel_class, getPrefetchCount); -PHP_METHOD(amqp_channel_class, qos); - -PHP_METHOD(amqp_channel_class, startTransaction); -PHP_METHOD(amqp_channel_class, commitTransaction); -PHP_METHOD(amqp_channel_class, rollbackTransaction); - -PHP_METHOD(amqp_channel_class, getConnection); - -PHP_METHOD(amqp_channel_class, basicRecover); - -PHP_MINIT_FUNCTION(amqp_channel); - -/* -*Local variables: -*tab-width: 4 -*c-basic-offset: 4 -*End: -*vim600: noet sw=4 ts=4 fdm=marker -*vim<600: noet sw=4 ts=4 -*/ diff -Nru php-amqp-1.7.1/amqp-1.7.1/amqp_connection.c php-amqp-1.9.3/amqp-1.7.1/amqp_connection.c --- php-amqp-1.7.1/amqp-1.7.1/amqp_connection.c 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/amqp_connection.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,1298 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2007 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 | - | Lead: | - | - Pieter de Zwart | - | Maintainers: | - | - Brad Rodriguez | - | - Jonathan Tansavatdi | - +----------------------------------------------------------------------+ -*/ - - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#include "php_ini.h" -#include "zend_exceptions.h" - -#ifdef PHP_WIN32 -# include "win32/php_stdint.h" -# include "win32/signal.h" -#else -# include -# include -#endif -#include -#include -#include - -#ifdef PHP_WIN32 -# include "win32/unistd.h" -#else -# include -#endif - -#include "php_amqp.h" -#include "amqp_channel.h" -#include "amqp_connection_resource.h" -#include "amqp_connection.h" - -#ifndef E_DEPRECATED -#define E_DEPRECATED E_WARNING -#endif - -zend_class_entry *amqp_connection_class_entry; -#define this_ce amqp_connection_class_entry - -zend_object_handlers amqp_connection_object_handlers; - - -static int php_amqp_connection_resource_deleter(PHP5to7_zend_resource_le_t *el, amqp_connection_resource *connection_resource TSRMLS_DC) -{ - if (Z_RES_P(el)->ptr == connection_resource) { - return ZEND_HASH_APPLY_REMOVE | ZEND_HASH_APPLY_STOP; - } - - return ZEND_HASH_APPLY_KEEP; -} - -static PHP5to7_param_str_len_type_t php_amqp_get_connection_hash(amqp_connection_params *params, char **hash) { - return spprintf(hash, - 0, - "amqp_conn_res_h:%s_p:%d_v:%s_l:%s_p:%s_f:%d_c:%d_h:%d", - params->host, - params->port, - params->vhost, - params->login, - params->password, - params->frame_max, - params->channel_max, - params->heartbeat - ); -} - -static void php_amqp_cleanup_connection_resource(amqp_connection_resource *connection_resource TSRMLS_DC) -{ - if (!connection_resource) { - return; - } - - PHP5to7_zend_resource_t resource = connection_resource->resource; - - connection_resource->parent->connection_resource = NULL; - connection_resource->parent = NULL; - - if (connection_resource->is_dirty) { - if (connection_resource->is_persistent) { - zend_hash_apply_with_argument(&EG(persistent_list), (apply_func_arg_t)php_amqp_connection_resource_deleter, (void*)connection_resource TSRMLS_CC); - } - - zend_list_delete(resource); - } else { - if (connection_resource->is_persistent) { - connection_resource->resource = PHP5to7_ZEND_RESOURCE_EMPTY; - } - - if (connection_resource->resource != PHP5to7_ZEND_RESOURCE_EMPTY) { - zend_list_delete(resource); - } - } -} - -static void php_amqp_disconnect(amqp_connection_resource *resource TSRMLS_DC) -{ - php_amqp_prepare_for_disconnect(resource TSRMLS_CC); - php_amqp_cleanup_connection_resource(resource TSRMLS_CC); -} - - -void php_amqp_disconnect_force(amqp_connection_resource *resource TSRMLS_DC) -{ - php_amqp_prepare_for_disconnect(resource TSRMLS_CC); - resource->is_dirty = '\1'; - php_amqp_cleanup_connection_resource(resource TSRMLS_CC); -} - -/** - * php_amqp_connect - * handles connecting to amqp - * called by connect(), pconnect(), reconnect(), preconnect() - */ -int php_amqp_connect(amqp_connection_object *connection, zend_bool persistent, INTERNAL_FUNCTION_PARAMETERS) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - - char *key = NULL; - PHP5to7_param_str_len_type_t key_len = 0; - - if (connection->connection_resource) { - /* Clean up old memory allocations which are now invalid (new connection) */ - php_amqp_cleanup_connection_resource(connection->connection_resource TSRMLS_CC); - } - - assert(connection->connection_resource == NULL); - - amqp_connection_params connection_params; - - connection_params.host = PHP_AMQP_READ_THIS_PROP_STR("host"); - connection_params.port = (int)PHP_AMQP_READ_THIS_PROP_LONG("port"); - connection_params.vhost = PHP_AMQP_READ_THIS_PROP_STR("vhost"); - connection_params.login = PHP_AMQP_READ_THIS_PROP_STR("login"); - connection_params.password = PHP_AMQP_READ_THIS_PROP_STR("password"); - connection_params.frame_max = (int) PHP_AMQP_READ_THIS_PROP_LONG("frame_max"); - connection_params.channel_max = (int) PHP_AMQP_READ_THIS_PROP_LONG("channel_max"); - connection_params.heartbeat = (int) PHP_AMQP_READ_THIS_PROP_LONG("heartbeat"); - connection_params.read_timeout = PHP_AMQP_READ_THIS_PROP_DOUBLE("read_timeout"); - connection_params.write_timeout = PHP_AMQP_READ_THIS_PROP_DOUBLE("write_timeout"); - connection_params.connect_timeout = PHP_AMQP_READ_THIS_PROP_DOUBLE("connect_timeout"); - - - if (persistent) { - PHP5to7_zend_resource_store_t *le = PHP5to7_ZEND_RESOURCE_EMPTY; - - /* Look for an established resource */ - key_len = php_amqp_get_connection_hash(&connection_params, &key); - - if (PHP5to7_ZEND_HASH_STR_FIND_PTR(&EG(persistent_list), key, key_len, le)) { - efree(key); - - if (le->type != le_amqp_connection_resource_persistent) { - /* hash conflict, given name associate with non-amqp persistent connection resource */ - return 0; - } - - /* An entry for this connection resource already exists */ - /* Stash the connection resource in the connection */ - connection->connection_resource = le->ptr; - - if (connection->connection_resource->resource != PHP5to7_ZEND_RESOURCE_EMPTY) { - /* resource in use! */ - connection->connection_resource = NULL; - - zend_throw_exception(amqp_connection_exception_class_entry, "There are already established persistent connection to the same resource.", 0 TSRMLS_CC); - return 0; - } - - connection->connection_resource->resource = PHP5to7_ZEND_REGISTER_RESOURCE(connection->connection_resource, persistent ? le_amqp_connection_resource_persistent : le_amqp_connection_resource); - connection->connection_resource->parent = connection; - - /* Set desired timeouts */ - if (php_amqp_set_resource_read_timeout(connection->connection_resource, PHP_AMQP_READ_THIS_PROP_DOUBLE("read_timeout") TSRMLS_CC) == 0 - || php_amqp_set_resource_write_timeout(connection->connection_resource, PHP_AMQP_READ_THIS_PROP_DOUBLE("write_timeout") TSRMLS_CC) == 0) { - - php_amqp_disconnect_force(connection->connection_resource TSRMLS_CC); - return 0; - } - - /* Set connection status to connected */ - connection->connection_resource->is_connected = '\1'; - connection->connection_resource->is_persistent = persistent; - - return 1; - } - - efree(key); - } - - connection->connection_resource = connection_resource_constructor(&connection_params, persistent TSRMLS_CC); - - if (connection->connection_resource == NULL) { - return 0; - } - - connection->connection_resource->resource = PHP5to7_ZEND_REGISTER_RESOURCE(connection->connection_resource, persistent ? le_amqp_connection_resource_persistent : le_amqp_connection_resource); - connection->connection_resource->parent = connection; - - /* Set connection status to connected */ - connection->connection_resource->is_connected = '\1'; - - if (persistent) { - connection->connection_resource->is_persistent = persistent; - - key_len = php_amqp_get_connection_hash(&connection_params, &key); - - PHP5to7_zend_resource_store_t new_le; - - /* Store a reference in the persistence list */ - new_le.ptr = connection->connection_resource; - new_le.type = persistent ? le_amqp_connection_resource_persistent : le_amqp_connection_resource; - - if (!PHP5to7_ZEND_HASH_STR_UPD_MEM(&EG(persistent_list), key, key_len, new_le, sizeof(PHP5to7_zend_resource_store_t))) { - efree(key); - php_amqp_disconnect_force(connection->connection_resource TSRMLS_CC); - return 0; - } - efree(key); - } - - return 1; -} - -void amqp_connection_free(PHP5to7_obj_free_zend_object *object TSRMLS_DC) -{ - amqp_connection_object *connection = PHP_AMQP_FETCH_CONNECTION(object); - - if (connection->connection_resource) { - php_amqp_disconnect(connection->connection_resource TSRMLS_CC); - } - - zend_object_std_dtor(&connection->zo TSRMLS_CC); - -#if PHP_MAJOR_VERSION < 7 - efree(object); -#endif -} - -PHP5to7_zend_object_value amqp_connection_ctor(zend_class_entry *ce TSRMLS_DC) -{ - amqp_connection_object* connection = PHP5to7_ECALLOC_CONNECTION_OBJECT(ce); - - zend_object_std_init(&connection->zo, ce TSRMLS_CC); - AMQP_OBJECT_PROPERTIES_INIT(connection->zo, ce); - -#if PHP_MAJOR_VERSION >=7 - connection->zo.handlers = &amqp_connection_object_handlers; - - return &connection->zo; -#else - PHP5to7_zend_object_value new_value; - - new_value.handle = zend_objects_store_put( - connection, - NULL, - (zend_objects_free_object_storage_t) amqp_connection_free, - NULL TSRMLS_CC - ); - - new_value.handlers = zend_get_std_object_handlers(); - - return new_value; -#endif -} - - -/* {{{ proto AMQPConnection::__construct([array optional]) - * The array can contain 'host', 'port', 'login', 'password', 'vhost', 'read_timeout', 'write_timeout', 'connect_timeout' and 'timeout' (deprecated) indexes - */ -PHP_METHOD(amqp_connection_class, __construct) -{ - zval* ini_arr = NULL; - - PHP5to7_zval_t *zdata = NULL; - - /* Parse out the method parameters */ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a", &ini_arr) == FAILURE) { - return; - } - - /* Pull the login out of the $params array */ - zdata = NULL; - if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "login", sizeof("login"), zdata)) { - // TODO: check whether we need separate zval - convert_to_string(PHP5to7_MAYBE_DEREF(zdata)); - } - /* Validate the given login */ - if (zdata && Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) > 0) { - if (Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) < 128) { - zend_update_property(this_ce, getThis(), ZEND_STRL("login"), PHP5to7_MAYBE_DEREF(zdata)TSRMLS_CC); - } else { - zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'login' exceeds 128 character limit.", 0 TSRMLS_CC); - return; - } - } else { - zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("login"), INI_STR("amqp.login"), (PHP5to7_param_str_len_type_t) (strlen(INI_STR("amqp.login")) > 128 ? 128 : strlen(INI_STR("amqp.login"))) TSRMLS_CC); - } - - /* Pull the password out of the $params array */ - zdata = NULL; - if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "password", sizeof("password"), zdata)) { - convert_to_string(PHP5to7_MAYBE_DEREF(zdata)); - } - /* Validate the given password */ - if (zdata && Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) > 0) { - if (Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) < 128) { - zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("password"), Z_STRVAL_P(PHP5to7_MAYBE_DEREF(zdata)), Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC); - } else { - zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'password' exceeds 128 character limit.", 0 TSRMLS_CC); - return; - } - } else { - zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("password"), INI_STR("amqp.password"), (PHP5to7_param_str_len_type_t) (strlen(INI_STR("amqp.password")) > 128 ? 128 : strlen(INI_STR("amqp.password"))) TSRMLS_CC); - } - - /* Pull the host out of the $params array */ - zdata = NULL; - if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "host", sizeof("host"), zdata)) { - convert_to_string(PHP5to7_MAYBE_DEREF(zdata)); - } - /* Validate the given host */ - if (zdata && Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) > 0) { - if (Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) < 128) { - zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("host"), Z_STRVAL_P(PHP5to7_MAYBE_DEREF(zdata)), Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC); - } else { - zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'host' exceeds 128 character limit.", 0 TSRMLS_CC); - return; - } - } else { - zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("host"), INI_STR("amqp.host"), (PHP5to7_param_str_len_type_t) (strlen(INI_STR("amqp.host")) > 128 ? 128 : strlen(INI_STR("amqp.host"))) TSRMLS_CC); - } - - /* Pull the vhost out of the $params array */ - zdata = NULL; - if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "vhost", sizeof("vhost"), zdata)) { - convert_to_string(PHP5to7_MAYBE_DEREF(zdata)); - } - /* Validate the given vhost */ - if (zdata && Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) > 0) { - if (Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) < 128) { - zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("vhost"), Z_STRVAL_P(PHP5to7_MAYBE_DEREF(zdata)), Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC); - } else { - zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'vhost' exceeds 128 character limit.", 0 TSRMLS_CC); - return; - } - } else { - zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("vhost"), INI_STR("amqp.vhost"), (PHP5to7_param_str_len_type_t) (strlen(INI_STR("amqp.vhost")) > 128 ? 128 : strlen(INI_STR("amqp.vhost"))) TSRMLS_CC); - - } - - zend_update_property_long(this_ce, getThis(), ZEND_STRL("port"), INI_INT("amqp.port") TSRMLS_CC); - - if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "port", sizeof("port"), zdata)) { - convert_to_long(PHP5to7_MAYBE_DEREF(zdata)); - zend_update_property_long(this_ce, getThis(), ZEND_STRL("port"), Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC); - } - - zend_update_property_double(this_ce, getThis(), ZEND_STRL("read_timeout"), INI_FLT("amqp.read_timeout") TSRMLS_CC); - - if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "read_timeout", sizeof("read_timeout"), zdata)) { - convert_to_double(PHP5to7_MAYBE_DEREF(zdata)); - if (Z_DVAL_P(PHP5to7_MAYBE_DEREF(zdata)) < 0) { - zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'read_timeout' must be greater than or equal to zero.", 0 TSRMLS_CC); - } else { - zend_update_property_double(this_ce, getThis(), ZEND_STRL("read_timeout"), Z_DVAL_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC); - } - - if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "timeout", sizeof("timeout"), zdata)) { - /* 'read_timeout' takes precedence on 'timeout' but users have to know this */ - php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Parameter 'timeout' is deprecated, 'read_timeout' used instead"); - } - - } else if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "timeout", sizeof("timeout"), zdata)) { - - php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "Parameter 'timeout' is deprecated; use 'read_timeout' instead"); - - convert_to_double(PHP5to7_MAYBE_DEREF(zdata)); - if (Z_DVAL_P(PHP5to7_MAYBE_DEREF(zdata)) < 0) { - zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'timeout' must be greater than or equal to zero.", 0 TSRMLS_CC); - } else { - zend_update_property_double(this_ce, getThis(), ZEND_STRL("read_timeout"), Z_DVAL_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC); - } - } else { - - assert(DEFAULT_TIMEOUT != NULL); - if (strcmp(DEFAULT_TIMEOUT, INI_STR("amqp.timeout")) != 0) { - php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "INI setting 'amqp.timeout' is deprecated; use 'amqp.read_timeout' instead"); - - if (strcmp(DEFAULT_READ_TIMEOUT, INI_STR("amqp.read_timeout")) == 0) { - zend_update_property_double(this_ce, getThis(), ZEND_STRL("read_timeout"), INI_FLT("amqp.timeout") TSRMLS_CC); - } else { - php_error_docref(NULL TSRMLS_CC, E_NOTICE, "INI setting 'amqp.read_timeout' will be used instead of 'amqp.timeout'"); - zend_update_property_double(this_ce, getThis(), ZEND_STRL("read_timeout"), INI_FLT("amqp.read_timeout") TSRMLS_CC); - } - } else { - zend_update_property_double(this_ce, getThis(), ZEND_STRL("read_timeout"), INI_FLT("amqp.read_timeout") TSRMLS_CC); - } - } - - zend_update_property_double(this_ce, getThis(), ZEND_STRL("write_timeout"), INI_FLT("amqp.write_timeout") TSRMLS_CC); - - if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "write_timeout", sizeof("write_timeout"), zdata)) { - convert_to_double(PHP5to7_MAYBE_DEREF(zdata)); - if (Z_DVAL_P(PHP5to7_MAYBE_DEREF(zdata)) < 0) { - zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'write_timeout' must be greater than or equal to zero.", 0 TSRMLS_CC); - } else { - zend_update_property_double(this_ce, getThis(), ZEND_STRL("write_timeout"), Z_DVAL_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC); - } - } - - zend_update_property_double(this_ce, getThis(), ZEND_STRL("connect_timeout"), INI_FLT("amqp.connect_timeout") TSRMLS_CC); - - if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "connect_timeout", sizeof("connect_timeout"), zdata)) { - convert_to_double(PHP5to7_MAYBE_DEREF(zdata)); - if (Z_DVAL_P(PHP5to7_MAYBE_DEREF(zdata)) < 0) { - zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'connect_timeout' must be greater than or equal to zero.", 0 TSRMLS_CC); - } else { - zend_update_property_double(this_ce, getThis(), ZEND_STRL("connect_timeout"), Z_DVAL_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC); - - } - } - - zend_update_property_long(this_ce, getThis(), ZEND_STRL("channel_max"), INI_INT("amqp.channel_max") TSRMLS_CC); - - if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "channel_max", sizeof("channel_max"), zdata)) { - convert_to_long(PHP5to7_MAYBE_DEREF(zdata)); - if (Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) < 0 || Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) > PHP_AMQP_MAX_CHANNELS) { - zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'channel_max' is out of range.", 0 TSRMLS_CC); - } else { - if(Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) == 0) { - zend_update_property_long(this_ce, getThis(), ZEND_STRL("channel_max"), PHP_AMQP_DEFAULT_CHANNEL_MAX TSRMLS_CC); - } else { - zend_update_property_long(this_ce, getThis(), ZEND_STRL("channel_max"), Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC); - } - } - } - - zend_update_property_long(this_ce, getThis(), ZEND_STRL("frame_max"), INI_INT("amqp.frame_max") TSRMLS_CC); - - if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "frame_max", sizeof("frame_max"), zdata)) { - convert_to_long(PHP5to7_MAYBE_DEREF(zdata)); - if (Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) < 0 || Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) > PHP_AMQP_MAX_FRAME) { - zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'frame_max' is out of range.", 0 TSRMLS_CC); - } else { - if(Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) == 0) { - zend_update_property_long(this_ce, getThis(), ZEND_STRL("frame_max"), PHP_AMQP_DEFAULT_FRAME_MAX TSRMLS_CC); - } else { - zend_update_property_long(this_ce, getThis(), ZEND_STRL("frame_max"), Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC); - } - } - } - - zend_update_property_long(this_ce, getThis(), ZEND_STRL("heartbeat"), INI_INT("amqp.heartbeat") TSRMLS_CC); - - if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "heartbeat", sizeof("heartbeat"), zdata)) { - convert_to_long(PHP5to7_MAYBE_DEREF(zdata)); - if (Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) < 0 || Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) > PHP_AMQP_MAX_HEARTBEAT) { - zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'heartbeat' is out of range.", 0 TSRMLS_CC); - } else { - zend_update_property_long(this_ce, getThis(), ZEND_STRL("heartbeat"), Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC); - } - } - -} -/* }}} */ - - -/* {{{ proto amqp::isConnected() -check amqp connection */ -PHP_METHOD(amqp_connection_class, isConnected) -{ - amqp_connection_object *connection; - - PHP_AMQP_NOPARAMS(); - - /* Get the connection object out of the store */ - connection = PHP_AMQP_GET_CONNECTION(getThis()); - - /* If the channel_connect is 1, we have a connection */ - if (connection->connection_resource != NULL && connection->connection_resource->is_connected) { - RETURN_TRUE; - } - - /* We have no connection */ - RETURN_FALSE; -} -/* }}} */ - - -/* {{{ proto amqp::connect() -create amqp connection */ -PHP_METHOD(amqp_connection_class, connect) -{ - amqp_connection_object *connection; - - PHP_AMQP_NOPARAMS(); - - /* Get the connection object out of the store */ - connection = PHP_AMQP_GET_CONNECTION(getThis()); - - if (connection->connection_resource && connection->connection_resource->is_connected) { - if (connection->connection_resource->is_persistent) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempt to start transient connection while persistent transient one already established. Continue."); - } - - RETURN_TRUE; - } - - /* Actually connect this resource to the broker */ - RETURN_BOOL(php_amqp_connect(connection, 0, INTERNAL_FUNCTION_PARAM_PASSTHRU)); -} -/* }}} */ - - -/* {{{ proto amqp::connect() -create amqp connection */ -PHP_METHOD(amqp_connection_class, pconnect) -{ - amqp_connection_object *connection; - - PHP_AMQP_NOPARAMS(); - - /* Get the connection object out of the store */ - connection = PHP_AMQP_GET_CONNECTION(getThis()); - - if (connection->connection_resource && connection->connection_resource->is_connected) { - - assert(connection->connection_resource != NULL); - if (!connection->connection_resource->is_persistent) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempt to start persistent connection while transient one already established. Continue."); - } - - RETURN_TRUE; - } - - /* Actually connect this resource to the broker or use stored connection */ - RETURN_BOOL(php_amqp_connect(connection, 1, INTERNAL_FUNCTION_PARAM_PASSTHRU)); -} -/* }}} */ - - -/* {{{ proto amqp:pdisconnect() -destroy amqp persistent connection */ -PHP_METHOD(amqp_connection_class, pdisconnect) -{ - amqp_connection_object *connection; - - PHP_AMQP_NOPARAMS(); - - /* Get the connection object out of the store */ - connection = PHP_AMQP_GET_CONNECTION(getThis()); - - if (!connection->connection_resource || !connection->connection_resource->is_connected) { - RETURN_TRUE; - } - - assert(connection->connection_resource != NULL); - - if (!connection->connection_resource->is_persistent) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempt to close persistent connection while transient one already established. Abort."); - - RETURN_FALSE; - } - - php_amqp_disconnect_force(connection->connection_resource TSRMLS_CC); - - RETURN_TRUE; -} -/* }}} */ - - -/* {{{ proto amqp::disconnect() -destroy amqp connection */ -PHP_METHOD(amqp_connection_class, disconnect) -{ - amqp_connection_object *connection; - - PHP_AMQP_NOPARAMS(); - - /* Get the connection object out of the store */ - connection = PHP_AMQP_GET_CONNECTION(getThis()); - - if (!connection->connection_resource || !connection->connection_resource->is_connected) { - RETURN_TRUE; - } - - if (connection->connection_resource->is_persistent) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempt to close transient connection while persistent one already established. Abort."); - - RETURN_FALSE; - } - - assert(connection->connection_resource != NULL); - - php_amqp_disconnect(connection->connection_resource TSRMLS_CC); - - RETURN_TRUE; -} - -/* }}} */ - -/* {{{ proto amqp::reconnect() -recreate amqp connection */ -PHP_METHOD(amqp_connection_class, reconnect) -{ - amqp_connection_object *connection; - - PHP_AMQP_NOPARAMS(); - - /* Get the connection object out of the store */ - connection = PHP_AMQP_GET_CONNECTION(getThis()); - - if (connection->connection_resource && connection->connection_resource->is_connected) { - - assert(connection->connection_resource != NULL); - - if (connection->connection_resource->is_persistent) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempt to reconnect persistent connection while transient one already established. Abort."); - - RETURN_FALSE; - } - - php_amqp_disconnect(connection->connection_resource TSRMLS_CC); - } - - RETURN_BOOL(php_amqp_connect(connection, 0, INTERNAL_FUNCTION_PARAM_PASSTHRU)); -} -/* }}} */ - -/* {{{ proto amqp::preconnect() -recreate amqp connection */ -PHP_METHOD(amqp_connection_class, preconnect) -{ - amqp_connection_object *connection; - - PHP_AMQP_NOPARAMS(); - - /* Get the connection object out of the store */ - connection = PHP_AMQP_GET_CONNECTION(getThis()); - - - if (connection->connection_resource && connection->connection_resource->is_connected) { - - assert(connection->connection_resource != NULL); - - if (!connection->connection_resource->is_persistent) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempt to reconnect transient connection while persistent one already established. Abort."); - - RETURN_FALSE; - } - - php_amqp_disconnect_force(connection->connection_resource TSRMLS_CC); - } - - RETURN_BOOL(php_amqp_connect(connection, 1, INTERNAL_FUNCTION_PARAM_PASSTHRU)); -} -/* }}} */ - - -/* {{{ proto amqp::getLogin() -get the login */ -PHP_METHOD(amqp_connection_class, getLogin) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - PHP_AMQP_NOPARAMS(); - PHP_AMQP_RETURN_THIS_PROP("login"); -} -/* }}} */ - - -/* {{{ proto amqp::setLogin(string login) -set the login */ -PHP_METHOD(amqp_connection_class, setLogin) -{ - char *login = NULL; PHP5to7_param_str_len_type_t login_len = 0; - - /* Get the login from the method params */ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &login, &login_len) == FAILURE) { - return; - } - - /* Validate login length */ - if (login_len > 128) { - zend_throw_exception(amqp_connection_exception_class_entry, "Invalid 'login' given, exceeds 128 characters limit.", 0 TSRMLS_CC); - return; - } - - zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("login"), login, login_len TSRMLS_CC); - - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto amqp::getPassword() -get the password */ -PHP_METHOD(amqp_connection_class, getPassword) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - PHP_AMQP_NOPARAMS(); - PHP_AMQP_RETURN_THIS_PROP("password"); -} -/* }}} */ - - -/* {{{ proto amqp::setPassword(string password) -set the password */ -PHP_METHOD(amqp_connection_class, setPassword) -{ - char *password = NULL; PHP5to7_param_str_len_type_t password_len = 0; - - /* Get the password from the method params */ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &password, &password_len) == FAILURE) { - return; - } - - /* Validate password length */ - if (password_len > 128) { - zend_throw_exception(amqp_connection_exception_class_entry, "Invalid 'password' given, exceeds 128 characters limit.", 0 TSRMLS_CC); - return; - } - - zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("password"), password, password_len TSRMLS_CC); - - RETURN_TRUE; -} -/* }}} */ - - -/* {{{ proto amqp::getHost() -get the host */ -PHP_METHOD(amqp_connection_class, getHost) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - PHP_AMQP_NOPARAMS(); - PHP_AMQP_RETURN_THIS_PROP("host"); -} -/* }}} */ - - -/* {{{ proto amqp::setHost(string host) -set the host */ -PHP_METHOD(amqp_connection_class, setHost) -{ - char *host = NULL; PHP5to7_param_str_len_type_t host_len = 0; - - /* Get the host from the method params */ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &host, &host_len) == FAILURE) { - return; - } - - /* Validate host length */ - if (host_len > 1024) { - zend_throw_exception(amqp_connection_exception_class_entry, "Invalid 'host' given, exceeds 1024 character limit.", 0 TSRMLS_CC); - return; - } - - zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("host"), host, host_len TSRMLS_CC); - - RETURN_TRUE; -} -/* }}} */ - - -/* {{{ proto amqp::getPort() -get the port */ -PHP_METHOD(amqp_connection_class, getPort) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - PHP_AMQP_NOPARAMS(); - PHP_AMQP_RETURN_THIS_PROP("port"); -} -/* }}} */ - - -/* {{{ proto amqp::setPort(mixed port) -set the port */ -PHP_METHOD(amqp_connection_class, setPort) -{ - zval *zvalPort; - int port; - - /* Get the port from the method params */ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &zvalPort) == FAILURE) { - return; - } - - /* Parse out the port*/ - switch (Z_TYPE_P(zvalPort)) { - case IS_DOUBLE: - port = (int)Z_DVAL_P(zvalPort); - break; - case IS_LONG: - port = (int)Z_LVAL_P(zvalPort); - break; - case IS_STRING: - convert_to_long(zvalPort); - port = (int)Z_LVAL_P(zvalPort); - break; - default: - port = 0; - } - - /* Check the port value */ - if (port <= 0 || port > 65535) { - zend_throw_exception(amqp_connection_exception_class_entry, "Invalid port given. Value must be between 1 and 65535.", 0 TSRMLS_CC); - return; - } - - zend_update_property_long(this_ce, getThis(), ZEND_STRL("port"), port TSRMLS_CC); - - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto amqp::getVhost() -get the vhost */ -PHP_METHOD(amqp_connection_class, getVhost) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - PHP_AMQP_NOPARAMS(); - PHP_AMQP_RETURN_THIS_PROP("vhost"); -} -/* }}} */ - - -/* {{{ proto amqp::setVhost(string vhost) -set the vhost */ -PHP_METHOD(amqp_connection_class, setVhost) -{ - char *vhost = NULL; PHP5to7_param_str_len_type_t vhost_len = 0; - - /* Get the vhost from the method params */ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &vhost, &vhost_len) == FAILURE) { - return; - } - - /* Validate vhost length */ - if (vhost_len > 128) { - zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'vhost' exceeds 128 characters limit.", 0 TSRMLS_CC); - return; - } - - zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("vhost"), vhost, vhost_len TSRMLS_CC); - - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto amqp::getTimeout() -@deprecated -get the timeout */ -PHP_METHOD(amqp_connection_class, getTimeout) -{ - php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "AMQPConnection::getTimeout() method is deprecated; use AMQPConnection::getReadTimeout() instead"); - - PHP5to7_READ_PROP_RV_PARAM_DECL; - PHP_AMQP_NOPARAMS(); - PHP_AMQP_RETURN_THIS_PROP("read_timeout"); -} -/* }}} */ - -/* {{{ proto amqp::setTimeout(double timeout) -@deprecated -set the timeout */ -PHP_METHOD(amqp_connection_class, setTimeout) -{ - amqp_connection_object *connection; - double read_timeout; - - php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "AMQPConnection::setTimeout($timeout) method is deprecated; use AMQPConnection::setReadTimeout($timeout) instead"); - - /* Get the timeout from the method params */ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &read_timeout) == FAILURE) { - return; - } - - /* Validate timeout */ - if (read_timeout < 0) { - zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'timeout' must be greater than or equal to zero.", 0 TSRMLS_CC); - return; - } - - /* Get the connection object out of the store */ - connection = PHP_AMQP_GET_CONNECTION(getThis()); - - zend_update_property_double(this_ce, getThis(), ZEND_STRL("read_timeout"), read_timeout TSRMLS_CC); - - if (connection->connection_resource && connection->connection_resource->is_connected) { - if (php_amqp_set_resource_read_timeout(connection->connection_resource, read_timeout TSRMLS_CC) == 0) { - - php_amqp_disconnect_force(connection->connection_resource TSRMLS_CC); - - RETURN_FALSE; - } - } - - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto amqp::getReadTimeout() -get the read timeout */ -PHP_METHOD(amqp_connection_class, getReadTimeout) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - PHP_AMQP_NOPARAMS(); - PHP_AMQP_RETURN_THIS_PROP("read_timeout"); -} -/* }}} */ - -/* {{{ proto amqp::setReadTimeout(double timeout) -set read timeout */ -PHP_METHOD(amqp_connection_class, setReadTimeout) -{ - amqp_connection_object *connection; - double read_timeout; - - /* Get the timeout from the method params */ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &read_timeout) == FAILURE) { - return; - } - - /* Validate timeout */ - if (read_timeout < 0) { - zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'read_timeout' must be greater than or equal to zero.", 0 TSRMLS_CC); - return; - } - - /* Get the connection object out of the store */ - connection = PHP_AMQP_GET_CONNECTION(getThis()); - - zend_update_property_double(this_ce, getThis(), ZEND_STRL("read_timeout"), read_timeout TSRMLS_CC); - - if (connection->connection_resource && connection->connection_resource->is_connected) { - if (php_amqp_set_resource_read_timeout(connection->connection_resource, read_timeout TSRMLS_CC) == 0) { - - php_amqp_disconnect_force(connection->connection_resource TSRMLS_CC); - - RETURN_FALSE; - } - } - - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto amqp::getWriteTimeout() -get write timeout */ -PHP_METHOD(amqp_connection_class, getWriteTimeout) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - PHP_AMQP_NOPARAMS(); - PHP_AMQP_RETURN_THIS_PROP("write_timeout"); -} -/* }}} */ - -/* {{{ proto amqp::setWriteTimeout(double timeout) -set write timeout */ -PHP_METHOD(amqp_connection_class, setWriteTimeout) -{ - amqp_connection_object *connection; - double write_timeout; - - /* Get the timeout from the method params */ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &write_timeout) == FAILURE) { - return; - } - - /* Validate timeout */ - if (write_timeout < 0) { - zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'write_timeout' must be greater than or equal to zero.", 0 TSRMLS_CC); - return; - } - - /* Get the connection object out of the store */ - connection = PHP_AMQP_GET_CONNECTION(getThis()); - - zend_update_property_double(this_ce, getThis(), ZEND_STRL("write_timeout"), write_timeout TSRMLS_CC); - - if (connection->connection_resource && connection->connection_resource->is_connected) { - if (php_amqp_set_resource_write_timeout(connection->connection_resource, write_timeout TSRMLS_CC) == 0) { - - php_amqp_disconnect_force(connection->connection_resource TSRMLS_CC); - - RETURN_FALSE; - } - } - - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto amqp::getUsedChannels() -Get max used channels number */ -PHP_METHOD(amqp_connection_class, getUsedChannels) -{ - amqp_connection_object *connection; - - /* Get the timeout from the method params */ - PHP_AMQP_NOPARAMS(); - - /* Get the connection object out of the store */ - connection = PHP_AMQP_GET_CONNECTION(getThis()); - - if (!connection->connection_resource || !connection->connection_resource->is_connected) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Connection is not connected."); - - RETURN_LONG(0); - } - - RETURN_LONG(connection->connection_resource->used_slots); -} -/* }}} */ - -/* {{{ proto amqp::getMaxChannels() -Get max supported channels number per connection */ -PHP_METHOD(amqp_connection_class, getMaxChannels) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - amqp_connection_object *connection; - - PHP_AMQP_NOPARAMS(); - - /* Get the connection object out of the store */ - connection = PHP_AMQP_GET_CONNECTION(getThis()); - - if (connection->connection_resource && connection->connection_resource->is_connected) { - RETURN_LONG(connection->connection_resource->max_slots); - } - - PHP_AMQP_RETURN_THIS_PROP("channel_max"); -} -/* }}} */ - -/* {{{ proto amqp::getMaxFrameSize() -Get max supported frame size per connection in bytes */ -PHP_METHOD(amqp_connection_class, getMaxFrameSize) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - amqp_connection_object *connection; - - PHP_AMQP_NOPARAMS(); - - /* Get the connection object out of the store */ - connection = PHP_AMQP_GET_CONNECTION(getThis()); - -#if AMQP_VERSION_MAJOR * 100 + AMQP_VERSION_MINOR * 10 + AMQP_VERSION_PATCH > 52 - if (connection->connection_resource && connection->connection_resource->is_connected) { - RETURN_LONG(amqp_get_frame_max(connection->connection_resource->connection_state)); - } -#endif - - PHP_AMQP_RETURN_THIS_PROP("frame_max"); -} -/* }}} */ - -/* {{{ proto amqp::getHeartbeatInterval() -Get number of seconds between heartbeats of the connection in seconds */ -PHP_METHOD(amqp_connection_class, getHeartbeatInterval) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - amqp_connection_object *connection; - - PHP_AMQP_NOPARAMS(); - - /* Get the connection object out of the store */ - connection = PHP_AMQP_GET_CONNECTION(getThis()); - -#if AMQP_VERSION_MAJOR * 100 + AMQP_VERSION_MINOR * 10 + AMQP_VERSION_PATCH > 52 - if (connection->connection_resource != NULL - && connection->connection_resource->is_connected != '\0') { - RETURN_LONG(amqp_get_heartbeat(connection->connection_resource->connection_state)); - } -#endif - - PHP_AMQP_RETURN_THIS_PROP("heartbeat"); -} -/* }}} */ - -/* {{{ proto amqp::isPersistent() -check whether amqp connection is persistent */ -PHP_METHOD(amqp_connection_class, isPersistent) -{ - amqp_connection_object *connection; - - PHP_AMQP_NOPARAMS(); - - connection = PHP_AMQP_GET_CONNECTION(getThis()); - - RETURN_BOOL(connection->connection_resource && connection->connection_resource->is_persistent); -} -/* }}} */ - - -/* amqp_connection_class ARG_INFO definition */ -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class__construct, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) - ZEND_ARG_ARRAY_INFO(0, credentials, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_isConnected, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_connect, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_pconnect, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_pdisconnect, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_disconnect, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_reconnect, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_preconnect, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getLogin, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_setLogin, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) - ZEND_ARG_INFO(0, login) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getPassword, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_setPassword, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) - ZEND_ARG_INFO(0, password) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getHost, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_setHost, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) - ZEND_ARG_INFO(0, host) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getPort, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_setPort, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) - ZEND_ARG_INFO(0, port) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getVhost, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_setVhost, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) - ZEND_ARG_INFO(0, vhost) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getTimeout, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_setTimeout, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) - ZEND_ARG_INFO(0, timeout) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getReadTimeout, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_setReadTimeout, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) - ZEND_ARG_INFO(0, timeout) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getWriteTimeout, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_setWriteTimeout, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) - ZEND_ARG_INFO(0, timeout) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getUsedChannels, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getMaxChannels, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getMaxFrameSize, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getHeartbeatInterval, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_isPersistent, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - - -zend_function_entry amqp_connection_class_functions[] = { - PHP_ME(amqp_connection_class, __construct, arginfo_amqp_connection_class__construct, ZEND_ACC_PUBLIC) - PHP_ME(amqp_connection_class, isConnected, arginfo_amqp_connection_class_isConnected, ZEND_ACC_PUBLIC) - PHP_ME(amqp_connection_class, connect, arginfo_amqp_connection_class_connect, ZEND_ACC_PUBLIC) - PHP_ME(amqp_connection_class, pconnect, arginfo_amqp_connection_class_pconnect, ZEND_ACC_PUBLIC) - PHP_ME(amqp_connection_class, pdisconnect, arginfo_amqp_connection_class_pdisconnect, ZEND_ACC_PUBLIC) - PHP_ME(amqp_connection_class, disconnect, arginfo_amqp_connection_class_disconnect, ZEND_ACC_PUBLIC) - PHP_ME(amqp_connection_class, reconnect, arginfo_amqp_connection_class_reconnect, ZEND_ACC_PUBLIC) - PHP_ME(amqp_connection_class, preconnect, arginfo_amqp_connection_class_preconnect, ZEND_ACC_PUBLIC) - - PHP_ME(amqp_connection_class, getLogin, arginfo_amqp_connection_class_getLogin, ZEND_ACC_PUBLIC) - PHP_ME(amqp_connection_class, setLogin, arginfo_amqp_connection_class_setLogin, ZEND_ACC_PUBLIC) - - PHP_ME(amqp_connection_class, getPassword, arginfo_amqp_connection_class_getPassword, ZEND_ACC_PUBLIC) - PHP_ME(amqp_connection_class, setPassword, arginfo_amqp_connection_class_setPassword, ZEND_ACC_PUBLIC) - - PHP_ME(amqp_connection_class, getHost, arginfo_amqp_connection_class_getHost, ZEND_ACC_PUBLIC) - PHP_ME(amqp_connection_class, setHost, arginfo_amqp_connection_class_setHost, ZEND_ACC_PUBLIC) - - PHP_ME(amqp_connection_class, getPort, arginfo_amqp_connection_class_getPort, ZEND_ACC_PUBLIC) - PHP_ME(amqp_connection_class, setPort, arginfo_amqp_connection_class_setPort, ZEND_ACC_PUBLIC) - - PHP_ME(amqp_connection_class, getVhost, arginfo_amqp_connection_class_getVhost, ZEND_ACC_PUBLIC) - PHP_ME(amqp_connection_class, setVhost, arginfo_amqp_connection_class_setVhost, ZEND_ACC_PUBLIC) - - PHP_ME(amqp_connection_class, getTimeout, arginfo_amqp_connection_class_getTimeout, ZEND_ACC_PUBLIC) - PHP_ME(amqp_connection_class, setTimeout, arginfo_amqp_connection_class_setTimeout, ZEND_ACC_PUBLIC) - - PHP_ME(amqp_connection_class, getReadTimeout, arginfo_amqp_connection_class_getReadTimeout, ZEND_ACC_PUBLIC) - PHP_ME(amqp_connection_class, setReadTimeout, arginfo_amqp_connection_class_setReadTimeout, ZEND_ACC_PUBLIC) - - PHP_ME(amqp_connection_class, getWriteTimeout, arginfo_amqp_connection_class_getWriteTimeout, ZEND_ACC_PUBLIC) - PHP_ME(amqp_connection_class, setWriteTimeout, arginfo_amqp_connection_class_setWriteTimeout, ZEND_ACC_PUBLIC) - - PHP_ME(amqp_connection_class, getUsedChannels, arginfo_amqp_connection_class_getUsedChannels, ZEND_ACC_PUBLIC) - PHP_ME(amqp_connection_class, getMaxChannels, arginfo_amqp_connection_class_getMaxChannels, ZEND_ACC_PUBLIC) - PHP_ME(amqp_connection_class, isPersistent, arginfo_amqp_connection_class_isPersistent, ZEND_ACC_PUBLIC) - PHP_ME(amqp_connection_class, getHeartbeatInterval, arginfo_amqp_connection_class_getHeartbeatInterval, ZEND_ACC_PUBLIC) - PHP_ME(amqp_connection_class, getMaxFrameSize, arginfo_amqp_connection_class_getMaxFrameSize, ZEND_ACC_PUBLIC) - - {NULL, NULL, NULL} /* Must be the last line in amqp_functions[] */ -}; - - -PHP_MINIT_FUNCTION(amqp_connection) -{ - zend_class_entry ce; - - INIT_CLASS_ENTRY(ce, "AMQPConnection", amqp_connection_class_functions); - ce.create_object = amqp_connection_ctor; - this_ce = zend_register_internal_class(&ce TSRMLS_CC); - - zend_declare_property_null(this_ce, ZEND_STRL("login"), ZEND_ACC_PRIVATE TSRMLS_CC); - zend_declare_property_null(this_ce, ZEND_STRL("password"), ZEND_ACC_PRIVATE TSRMLS_CC); - zend_declare_property_null(this_ce, ZEND_STRL("host"), ZEND_ACC_PRIVATE TSRMLS_CC); - zend_declare_property_null(this_ce, ZEND_STRL("vhost"), ZEND_ACC_PRIVATE TSRMLS_CC); - zend_declare_property_null(this_ce, ZEND_STRL("port"), ZEND_ACC_PRIVATE TSRMLS_CC); - - zend_declare_property_null(this_ce, ZEND_STRL("read_timeout"), ZEND_ACC_PRIVATE TSRMLS_CC); - zend_declare_property_null(this_ce, ZEND_STRL("write_timeout"), ZEND_ACC_PRIVATE TSRMLS_CC); - zend_declare_property_null(this_ce, ZEND_STRL("connect_timeout"), ZEND_ACC_PRIVATE TSRMLS_CC); - - zend_declare_property_null(this_ce, ZEND_STRL("channel_max"), ZEND_ACC_PRIVATE TSRMLS_CC); - zend_declare_property_null(this_ce, ZEND_STRL("frame_max"), ZEND_ACC_PRIVATE TSRMLS_CC); - zend_declare_property_null(this_ce, ZEND_STRL("heartbeat"), ZEND_ACC_PRIVATE TSRMLS_CC); - -#if PHP_MAJOR_VERSION >=7 - memcpy(&amqp_connection_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); - - amqp_connection_object_handlers.offset = XtOffsetOf(amqp_connection_object, zo); - amqp_connection_object_handlers.free_obj = amqp_connection_free; -#endif - - return SUCCESS; -} - -/* -*Local variables: -*tab-width: 4 -*c-basic-offset: 4 -*End: -*vim600: noet sw=4 ts=4 fdm=marker -*vim<6 -*/ diff -Nru php-amqp-1.7.1/amqp-1.7.1/amqp_connection.h php-amqp-1.9.3/amqp-1.7.1/amqp_connection.h --- php-amqp-1.7.1/amqp-1.7.1/amqp_connection.h 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/amqp_connection.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2007 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 | - | Lead: | - | - Pieter de Zwart | - | Maintainers: | - | - Brad Rodriguez | - | - Jonathan Tansavatdi | - +----------------------------------------------------------------------+ -*/ - -/* $Id: amqp_connection.h 326660 2012-07-17 05:32:34Z pdezwart $ */ - -extern zend_class_entry *amqp_connection_class_entry; - -int php_amqp_connect(amqp_connection_object *amqp_connection, zend_bool persistent, INTERNAL_FUNCTION_PARAMETERS); -void php_amqp_disconnect_force(amqp_connection_resource *resource TSRMLS_DC); - -PHP_METHOD(amqp_connection_class, __construct); -PHP_METHOD(amqp_connection_class, isConnected); -PHP_METHOD(amqp_connection_class, connect); -PHP_METHOD(amqp_connection_class, pconnect); -PHP_METHOD(amqp_connection_class, pdisconnect); -PHP_METHOD(amqp_connection_class, disconnect); -PHP_METHOD(amqp_connection_class, reconnect); -PHP_METHOD(amqp_connection_class, preconnect); - -PHP_METHOD(amqp_connection_class, getLogin); -PHP_METHOD(amqp_connection_class, setLogin); - -PHP_METHOD(amqp_connection_class, getPassword); -PHP_METHOD(amqp_connection_class, setPassword); - -PHP_METHOD(amqp_connection_class, getHost); -PHP_METHOD(amqp_connection_class, setHost); - -PHP_METHOD(amqp_connection_class, getPort); -PHP_METHOD(amqp_connection_class, setPort); - -PHP_METHOD(amqp_connection_class, getVhost); -PHP_METHOD(amqp_connection_class, setVhost); - -PHP_METHOD(amqp_connection_class, getTimeout); -PHP_METHOD(amqp_connection_class, setTimeout); - -PHP_METHOD(amqp_connection_class, getReadTimeout); -PHP_METHOD(amqp_connection_class, setReadTimeout); - -PHP_METHOD(amqp_connection_class, getWriteTimeout); -PHP_METHOD(amqp_connection_class, setWriteTimeout); - -PHP_METHOD(amqp_connection_class, getUsedChannels); -PHP_METHOD(amqp_connection_class, getMaxChannels); -PHP_METHOD(amqp_connection_class, getHeartbeatInterval); -PHP_METHOD(amqp_connection_class, getMaxFrameSize); -PHP_METHOD(amqp_connection_class, isPersistent); - -PHP_MINIT_FUNCTION(amqp_connection); - -/* -*Local variables: -*tab-width: 4 -*c-basic-offset: 4 -*End: -*vim600: noet sw=4 ts=4 fdm=marker -*vim<600: noet sw=4 ts=4 -*/ diff -Nru php-amqp-1.7.1/amqp-1.7.1/amqp_connection_resource.c php-amqp-1.9.3/amqp-1.7.1/amqp_connection_resource.c --- php-amqp-1.7.1/amqp-1.7.1/amqp_connection_resource.c 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/amqp_connection_resource.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,500 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2007 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 | - | Lead: | - | - Pieter de Zwart | - | Maintainers: | - | - Brad Rodriguez | - | - Jonathan Tansavatdi | - +----------------------------------------------------------------------+ -*/ - -/* $Id: amqp_connection.c 327551 2012-09-09 03:49:34Z pdezwart $ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#include "php_ini.h" -#include "ext/standard/info.h" -#include "ext/standard/datetime.h" -#include "zend_exceptions.h" - -#ifdef PHP_WIN32 -# include "win32/php_stdint.h" -# include "win32/signal.h" -#else -# include -# include -#endif -#include -#include -#include - -#ifdef PHP_WIN32 -# include "win32/unistd.h" -#else -# include -#endif - -#include "php_amqp.h" -#include "amqp_channel.h" -#include "amqp_connection_resource.h" - -#ifndef E_DEPRECATED -#define E_DEPRECATED E_WARNING -#endif - -int le_amqp_connection_resource; -int le_amqp_connection_resource_persistent; - -static void connection_resource_destructor(amqp_connection_resource *resource, int persistent TSRMLS_DC); - - -/* Figure out what's going on connection and handle protocol exceptions, if any */ - -int php_amqp_connection_resource_error(amqp_rpc_reply_t reply, char **message, amqp_connection_resource *resource, amqp_channel_t channel_id TSRMLS_DC) -{ - assert (resource != NULL); - - switch (reply.reply_type) { - case AMQP_RESPONSE_NORMAL: - return PHP_AMQP_RESOURCE_RESPONSE_OK; - - case AMQP_RESPONSE_NONE: - spprintf(message, 0, "Missing RPC reply type."); - return PHP_AMQP_RESOURCE_RESPONSE_ERROR; - - case AMQP_RESPONSE_LIBRARY_EXCEPTION: - spprintf(message, 0, "Library error: %s", amqp_error_string2(reply.library_error)); - return PHP_AMQP_RESOURCE_RESPONSE_ERROR; - - case AMQP_RESPONSE_SERVER_EXCEPTION: - switch (reply.reply.id) { - case AMQP_CONNECTION_CLOSE_METHOD: { - amqp_connection_close_t *m = (amqp_connection_close_t *)reply.reply.decoded; - - spprintf(message, 0, "Server connection error: %d, message: %.*s", - m->reply_code, - (PHP5to7_param_str_len_type_t) m->reply_text.len, - (char *) m->reply_text.bytes - ); - - /* - * - If r.reply.id == AMQP_CONNECTION_CLOSE_METHOD a connection exception - * occurred, cast r.reply.decoded to amqp_connection_close_t* to see - * details of the exception. The client amqp_send_method() a - * amqp_connection_close_ok_t and disconnect from the broker. - */ - - amqp_connection_close_ok_t *decoded = (amqp_connection_close_ok_t *) NULL; - - amqp_send_method( - resource->connection_state, - 0, /* NOTE: 0-channel is reserved for things like this */ - AMQP_CONNECTION_CLOSE_OK_METHOD, - &decoded - ); - - /* Prevent finishing AMQP connection in connection resource destructor */ - resource->is_connected = '\0'; - - return PHP_AMQP_RESOURCE_RESPONSE_ERROR_CONNECTION_CLOSED; - } - case AMQP_CHANNEL_CLOSE_METHOD: { - assert(channel_id > 0 && channel_id <= resource->max_slots); - - amqp_channel_close_t *m = (amqp_channel_close_t *) reply.reply.decoded; - - spprintf(message, 0, "Server channel error: %d, message: %.*s", - m->reply_code, - (PHP5to7_param_str_len_type_t) m->reply_text.len, - (char *)m->reply_text.bytes - ); - - /* - * - If r.reply.id == AMQP_CHANNEL_CLOSE_METHOD a channel exception - * occurred, cast r.reply.decoded to amqp_channel_close_t* to see details - * of the exception. The client should amqp_send_method() a - * amqp_channel_close_ok_t. The channel must be re-opened before it - * can be used again. Any resources associated with the channel - * (auto-delete exchanges, auto-delete queues, consumers) are invalid - * and must be recreated before attempting to use them again. - */ - - amqp_channel_close_ok_t *decoded = (amqp_channel_close_ok_t *) NULL; - - amqp_send_method( - resource->connection_state, - channel_id, - AMQP_CHANNEL_CLOSE_OK_METHOD, - &decoded - ); - - return PHP_AMQP_RESOURCE_RESPONSE_ERROR_CHANNEL_CLOSED; - } - } - /* Default for the above switch should be handled by the below default. */ - default: - spprintf(message, 0, "Unknown server error, method id 0x%08X", reply.reply.id); - return PHP_AMQP_RESOURCE_RESPONSE_ERROR; - } - - /* Should not never get here*/ -} - - -/* Socket-related functions */ -int php_amqp_set_resource_read_timeout(amqp_connection_resource *resource, double timeout TSRMLS_DC) -{ - assert(timeout >= 0.0); - -#ifdef PHP_WIN32 - DWORD read_timeout; - /* - In Windows, setsockopt with SO_RCVTIMEO sets actual timeout - to a value that's 500ms greater than specified value. - Also, it's not possible to set timeout to any value below 500ms. - Zero timeout works like it should, however. - */ - if (timeout == 0.) { - read_timeout = 0; - } else { - read_timeout = (int) (max(timeout * 1.e+3 - .5e+3, 1.)); - } -#else - struct timeval read_timeout; - read_timeout.tv_sec = (int) floor(timeout); - read_timeout.tv_usec = (int) ((timeout - floor(timeout)) * 1.e+6); -#endif - - if (0 != setsockopt(amqp_get_sockfd(resource->connection_state), SOL_SOCKET, SO_RCVTIMEO, (char *)&read_timeout, sizeof(read_timeout))) { - zend_throw_exception(amqp_connection_exception_class_entry, "Socket error: cannot setsockopt SO_RCVTIMEO", 0 TSRMLS_CC); - return 0; - } - - return 1; -} - -int php_amqp_set_resource_write_timeout(amqp_connection_resource *resource, double timeout TSRMLS_DC) -{ - assert(timeout >= 0.0); - -#ifdef PHP_WIN32 - DWORD write_timeout; - - if (timeout == 0.) { - write_timeout = 0; - } else { - write_timeout = (int) (max(timeout * 1.e+3 - .5e+3, 1.)); - } -#else - struct timeval write_timeout; - write_timeout.tv_sec = (int) floor(timeout); - write_timeout.tv_usec = (int) ((timeout - floor(timeout)) * 1.e+6); -#endif - - if (0 != setsockopt(amqp_get_sockfd(resource->connection_state), SOL_SOCKET, SO_SNDTIMEO, (char *)&write_timeout, sizeof(write_timeout))) { - zend_throw_exception(amqp_connection_exception_class_entry, "Socket error: cannot setsockopt SO_SNDTIMEO", 0 TSRMLS_CC); - return 0; - } - - return 1; -} - - -/* Channel-related functions */ - -amqp_channel_t php_amqp_connection_resource_get_available_channel_id(amqp_connection_resource *resource) -{ - assert(resource != NULL); - assert(resource->slots != NULL); - - /* Check if there are any open slots */ - if (resource->used_slots >= resource->max_slots) { - return 0; - } - - amqp_channel_t slot; - - for (slot = 0; slot < resource->max_slots; slot++) { - if (resource->slots[slot] == 0) { - return (amqp_channel_t) (slot + 1); - } - } - - return 0; -} - -int php_amqp_connection_resource_register_channel(amqp_connection_resource *resource, amqp_channel_resource *channel_resource, amqp_channel_t channel_id) -{ - assert(resource != NULL); - assert(resource->slots != NULL); - assert(channel_id > 0 && channel_id <= resource->max_slots); - - if (resource->slots[channel_id - 1] != 0) { - return FAILURE; - } - - resource->slots[channel_id - 1] = channel_resource; - channel_resource->connection_resource = resource; - resource->used_slots++; - - return SUCCESS; -} - -int php_amqp_connection_resource_unregister_channel(amqp_connection_resource *resource, amqp_channel_t channel_id) -{ - assert(resource != NULL); - assert(resource->slots != NULL); - assert(channel_id > 0 && channel_id <= resource->max_slots); - - if (resource->slots[channel_id - 1] != 0) { - resource->slots[channel_id - 1]->connection_resource = NULL; - - resource->slots[channel_id - 1] = 0; - resource->used_slots--; - } - - return SUCCESS; -} - - -/* Creating and destroying resource */ - -amqp_connection_resource *connection_resource_constructor(amqp_connection_params *params, zend_bool persistent TSRMLS_DC) -{ - struct timeval tv = {0}; - struct timeval *tv_ptr = &tv; - - char *std_datetime; - amqp_table_entry_t client_properties_entries[5]; - amqp_table_t client_properties_table; - - amqp_table_entry_t custom_properties_entries[1]; - amqp_table_t custom_properties_table; - - amqp_connection_resource *resource; - - /* Allocate space for the connection resource */ - resource = (amqp_connection_resource *)pecalloc(1, sizeof(amqp_connection_resource), persistent); - - /* Create the connection */ - resource->connection_state = amqp_new_connection(); - - /* Create socket object */ - resource->socket = amqp_tcp_socket_new(resource->connection_state); - - if (params->connect_timeout > 0) { - tv.tv_sec = (long int) params->connect_timeout; - tv.tv_usec = (long int) ((params->connect_timeout - tv.tv_sec) * 1000000); - } else { - tv_ptr = NULL; - } - - /* Try to connect and verify that no error occurred */ - if (amqp_socket_open_noblock(resource->socket, params->host, params->port, tv_ptr)) { - - zend_throw_exception(amqp_connection_exception_class_entry, "Socket error: could not connect to host.", 0 TSRMLS_CC); - - connection_resource_destructor(resource, persistent TSRMLS_CC); - - return NULL; - } - - if (!php_amqp_set_resource_read_timeout(resource, params->read_timeout TSRMLS_CC)) { - connection_resource_destructor(resource, persistent TSRMLS_CC); - return NULL; - } - - if (!php_amqp_set_resource_write_timeout(resource, params->write_timeout TSRMLS_CC)) { - connection_resource_destructor(resource, persistent TSRMLS_CC); - return NULL; - } - - std_datetime = php_std_date(time(NULL) TSRMLS_CC); - - client_properties_entries[0].key = amqp_cstring_bytes("type"); - client_properties_entries[0].value.kind = AMQP_FIELD_KIND_UTF8; - client_properties_entries[0].value.value.bytes = amqp_cstring_bytes("php-amqp extension"); - - client_properties_entries[1].key = amqp_cstring_bytes("version"); - client_properties_entries[1].value.kind = AMQP_FIELD_KIND_UTF8; - client_properties_entries[1].value.value.bytes = amqp_cstring_bytes(PHP_AMQP_VERSION); - - client_properties_entries[2].key = amqp_cstring_bytes("revision"); - client_properties_entries[2].value.kind = AMQP_FIELD_KIND_UTF8; - client_properties_entries[2].value.value.bytes = amqp_cstring_bytes(PHP_AMQP_REVISION); - - client_properties_entries[3].key = amqp_cstring_bytes("connection type"); - client_properties_entries[3].value.kind = AMQP_FIELD_KIND_UTF8; - client_properties_entries[3].value.value.bytes = amqp_cstring_bytes(persistent ? "persistent" : "transient"); - - client_properties_entries[4].key = amqp_cstring_bytes("connection started"); - client_properties_entries[4].value.kind = AMQP_FIELD_KIND_UTF8; - client_properties_entries[4].value.value.bytes = amqp_cstring_bytes(std_datetime); - - client_properties_table.entries = client_properties_entries; - client_properties_table.num_entries = sizeof(client_properties_entries) / sizeof(amqp_table_entry_t); - - custom_properties_entries[0].key = amqp_cstring_bytes("client"); - custom_properties_entries[0].value.kind = AMQP_FIELD_KIND_TABLE; - custom_properties_entries[0].value.value.table = client_properties_table; - - custom_properties_table.entries = custom_properties_entries; - custom_properties_table.num_entries = sizeof(custom_properties_entries) / sizeof(amqp_table_entry_t); - - /* We can assume that connection established here but it is not true, real handshake goes during login */ - - assert(params->frame_max > 0); - - amqp_rpc_reply_t res = amqp_login_with_properties( - resource->connection_state, - params->vhost, - params->channel_max, - params->frame_max, - params->heartbeat, - &custom_properties_table, - AMQP_SASL_METHOD_PLAIN, - params->login, - params->password - ); - - efree(std_datetime); - - if (res.reply_type != AMQP_RESPONSE_NORMAL) { - char *message, *long_message; - - php_amqp_connection_resource_error(res, &message, resource, 0 TSRMLS_CC); - - spprintf(&long_message, 0, "%s - Potential login failure.", message); - zend_throw_exception(amqp_connection_exception_class_entry, long_message, 0 TSRMLS_CC); - - efree(message); - efree(long_message); - - /* https://www.rabbitmq.com/resources/specs/amqp0-9-1.pdf - * - * 2.2.4 The Connection Class: - * ... a peer that detects an error MUST close the socket without sending any further data. - * - * 4.10.2 Denial of Service Attacks: - * ... The general response to any exceptional condition in the connection negotiation is to pause that connection - * (presumably a thread) for a period of several seconds and then to close the network connection. This - * includes syntax errors, over-sized data, and failed attempts to authenticate. - */ - connection_resource_destructor(resource, persistent TSRMLS_CC); - return NULL; - } - - /* Allocate space for the channel slots in the ring buffer */ - resource->max_slots = (amqp_channel_t) amqp_get_channel_max(resource->connection_state); - assert(resource->max_slots > 0); - - resource->slots = (amqp_channel_resource **)pecalloc(resource->max_slots + 1, sizeof(amqp_channel_object*), persistent); - - resource->is_connected = '\1'; - - return resource; -} - -ZEND_RSRC_DTOR_FUNC(amqp_connection_resource_dtor_persistent) -{ - amqp_connection_resource *resource = (amqp_connection_resource *)PHP5to7_ZEND_RESOURCE_DTOR_ARG->ptr; - - connection_resource_destructor(resource, 1 TSRMLS_CC); -} - -ZEND_RSRC_DTOR_FUNC(amqp_connection_resource_dtor) -{ - amqp_connection_resource *resource = (amqp_connection_resource *)PHP5to7_ZEND_RESOURCE_DTOR_ARG->ptr; - - connection_resource_destructor(resource, 0 TSRMLS_CC); -} - -static void connection_resource_destructor(amqp_connection_resource *resource, int persistent TSRMLS_DC) -{ - assert(resource != NULL); - -#ifndef PHP_WIN32 - void * old_handler; - - /* - If we are trying to close the connection and the connection already closed, it will throw - SIGPIPE, which is fine, so ignore all SIGPIPES - */ - - /* Start ignoring SIGPIPE */ - old_handler = signal(SIGPIPE, SIG_IGN); -#endif - - if (resource->parent) { - resource->parent->connection_resource = NULL; - } - - if (resource->slots) { - php_amqp_prepare_for_disconnect(resource TSRMLS_CC); - - pefree(resource->slots, persistent); - resource->slots = NULL; - } - - /* connection may be closed in case of previous failure */ - if (resource->is_connected) { - amqp_connection_close(resource->connection_state, AMQP_REPLY_SUCCESS); - } - - amqp_destroy_connection(resource->connection_state); - -#ifndef PHP_WIN32 - /* End ignoring of SIGPIPEs */ - signal(SIGPIPE, old_handler); -#endif - - pefree(resource, persistent); -} - -void php_amqp_prepare_for_disconnect(amqp_connection_resource *resource TSRMLS_DC) -{ - if (resource == NULL) { - return; - } - - if(resource->slots != NULL) { - /* NOTE: when we have persistent connection we do not move channels between php requests - * due to current php-amqp extension limitation in AMQPChannel where __construct == channel.open AMQP method call - * and __destruct = channel.close AMQP method call - */ - - /* Clean up old memory allocations which are now invalid (new connection) */ - amqp_channel_t slot; - - for (slot = 0; slot < resource->max_slots; slot++) { - if (resource->slots[slot] != 0) { - php_amqp_close_channel(resource->slots[slot] TSRMLS_CC); - } - } - } - - /* If it's persistent connection do not destroy connection resource (this keep connection alive) */ - if (resource->is_persistent) { - /* Cleanup buffers to reduce memory usage in idle mode */ - amqp_maybe_release_buffers(resource->connection_state); - } - - return; -} - diff -Nru php-amqp-1.7.1/amqp-1.7.1/amqp_connection_resource.h php-amqp-1.9.3/amqp-1.7.1/amqp_connection_resource.h --- php-amqp-1.7.1/amqp-1.7.1/amqp_connection_resource.h 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/amqp_connection_resource.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,75 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2007 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 | - | Lead: | - | - Pieter de Zwart | - | Maintainers: | - | - Brad Rodriguez | - | - Jonathan Tansavatdi | - +----------------------------------------------------------------------+ -*/ -#ifndef PHP_AMQP_CONNECTION_RESOURCE_H -#define PHP_AMQP_CONNECTION_RESOURCE_H - -#define PHP_AMQP_RESOURCE_RESPONSE_OK 0 -#define PHP_AMQP_RESOURCE_RESPONSE_ERROR -1 -#define PHP_AMQP_RESOURCE_RESPONSE_ERROR_CHANNEL_CLOSED -2 -#define PHP_AMQP_RESOURCE_RESPONSE_ERROR_CONNECTION_CLOSED -3 - -extern int le_amqp_connection_resource; -extern int le_amqp_connection_resource_persistent; - -void php_amqp_prepare_for_disconnect(amqp_connection_resource *resource TSRMLS_DC); - -typedef struct _amqp_connection_params { - char *login; - char *password; - char *host; - char *vhost; - int port; - int channel_max; - int frame_max; - int heartbeat; - double read_timeout; - double write_timeout; - double connect_timeout; -} amqp_connection_params; - -/* Figure out what's going on connection and handle protocol exceptions, if any */ -int php_amqp_connection_resource_error(amqp_rpc_reply_t reply, char **message, amqp_connection_resource *resource, amqp_channel_t channel_id TSRMLS_DC); - -/* Socket-related functions */ -int php_amqp_set_resource_read_timeout(amqp_connection_resource *resource, double read_timeout TSRMLS_DC); -int php_amqp_set_resource_write_timeout(amqp_connection_resource *resource, double write_timeout TSRMLS_DC); - -/* Channel-related functions */ -amqp_channel_t php_amqp_connection_resource_get_available_channel_id(amqp_connection_resource *resource); -int php_amqp_connection_resource_unregister_channel(amqp_connection_resource *resource, amqp_channel_t channel_id); -int php_amqp_connection_resource_register_channel(amqp_connection_resource *resource, amqp_channel_resource *channel_resource, amqp_channel_t channel_id); - -/* Creating and destroying resource */ -amqp_connection_resource *connection_resource_constructor(amqp_connection_params *params, zend_bool persistent TSRMLS_DC); -ZEND_RSRC_DTOR_FUNC(amqp_connection_resource_dtor_persistent); -ZEND_RSRC_DTOR_FUNC(amqp_connection_resource_dtor); - -#endif -/* -*Local variables: -*tab-width: 4 -*c-basic-offset: 4 -*End: -*vim600: noet sw=4 ts=4 fdm=marker -*vim<600: noet sw=4 ts=4 -*/ diff -Nru php-amqp-1.7.1/amqp-1.7.1/amqp_envelope.c php-amqp-1.9.3/amqp-1.7.1/amqp_envelope.c --- php-amqp-1.7.1/amqp-1.7.1/amqp_envelope.c 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/amqp_envelope.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,668 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2007 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 | - | Lead: | - | - Pieter de Zwart | - | Maintainers: | - | - Brad Rodriguez | - | - Jonathan Tansavatdi | - +----------------------------------------------------------------------+ -*/ - -/* $Id: amqp_envelope.c 327551 2012-09-09 03:49:34Z pdezwart $ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#include "php_ini.h" -#include "ext/standard/info.h" -#include "zend_exceptions.h" - -#ifdef PHP_WIN32 -# include "win32/php_stdint.h" -# include "win32/signal.h" -#else - -# include -# include - -#endif - -#include -#include - -#ifdef PHP_WIN32 -# include "win32/unistd.h" -#else - -# include - -#endif - -#include "php_amqp.h" -#include "amqp_envelope.h" - -zend_class_entry *amqp_envelope_class_entry; -#define this_ce amqp_envelope_class_entry - -void parse_amqp_table(amqp_table_t *table, zval *result); - -void convert_amqp_envelope_to_zval(amqp_envelope_t *amqp_envelope, zval *envelope TSRMLS_DC) -{ - PHP5to7_zval_t headers PHP5to7_MAYBE_SET_TO_NULL; - - /* Build the envelope */ - object_init_ex(envelope, this_ce); - - PHP5to7_MAYBE_INIT(headers); - PHP5to7_ARRAY_INIT(headers); - - amqp_basic_properties_t *p = &amqp_envelope->message.properties; - amqp_message_t *message = &amqp_envelope->message; - - zend_update_property_stringl(this_ce, envelope, ZEND_STRL("body"), (const char *) message->body.bytes, (PHP5to7_param_str_len_type_t) message->body.len TSRMLS_CC); - - zend_update_property_long(this_ce, envelope, ZEND_STRL("delivery_tag"), (PHP5to7_param_long_type_t) amqp_envelope->delivery_tag TSRMLS_CC); - zend_update_property_bool(this_ce, envelope, ZEND_STRL("is_redelivery"), (PHP5to7_param_long_type_t) amqp_envelope->redelivered TSRMLS_CC); - zend_update_property_stringl(this_ce, envelope, ZEND_STRL("exchange_name"), (const char *) amqp_envelope->exchange.bytes, (PHP5to7_param_str_len_type_t) amqp_envelope->exchange.len TSRMLS_CC); - zend_update_property_stringl(this_ce, envelope, ZEND_STRL("routing_key"), (const char *) amqp_envelope->routing_key.bytes, (PHP5to7_param_str_len_type_t) amqp_envelope->routing_key.len TSRMLS_CC); - - - - if (p->_flags & AMQP_BASIC_CONTENT_TYPE_FLAG) { - zend_update_property_stringl(this_ce, envelope, ZEND_STRL("content_type"), (const char *) p->content_type.bytes, (PHP5to7_param_str_len_type_t) p->content_type.len TSRMLS_CC); - } else { - /* BC */ - zend_update_property_stringl(this_ce, envelope, ZEND_STRL("content_type"), "", 0 TSRMLS_CC); - } - - if (p->_flags & AMQP_BASIC_CONTENT_ENCODING_FLAG) { - zend_update_property_stringl(this_ce, envelope, ZEND_STRL("content_encoding"), (const char *) p->content_encoding.bytes, (PHP5to7_param_str_len_type_t) p->content_encoding.len TSRMLS_CC); - } else { - /* BC */ - zend_update_property_stringl(this_ce, envelope, ZEND_STRL("content_encoding"), "", 0 TSRMLS_CC); - } - - if (p->_flags & AMQP_BASIC_HEADERS_FLAG) { - parse_amqp_table(&(p->headers), PHP5to7_MAYBE_PTR(headers)); - } - - zend_update_property(this_ce, envelope, ZEND_STRL("headers"), PHP5to7_MAYBE_PTR(headers) TSRMLS_CC); - - if (p->_flags & AMQP_BASIC_DELIVERY_MODE_FLAG) { - zend_update_property_long(this_ce, envelope, ZEND_STRL("delivery_mode"), (PHP5to7_param_long_type_t) p->delivery_mode TSRMLS_CC); - } else { - /* BC */ - zend_update_property_long(this_ce, envelope, ZEND_STRL("delivery_mode"), AMQP_DELIVERY_NONPERSISTENT TSRMLS_CC); - } - - if (p->_flags & AMQP_BASIC_PRIORITY_FLAG) { - zend_update_property_long(this_ce, envelope, ZEND_STRL("priority"), (PHP5to7_param_long_type_t) p->priority TSRMLS_CC); - } else { - /* BC */ - zend_update_property_long(this_ce, envelope, ZEND_STRL("priority"), 0 TSRMLS_CC); - } - - - if (p->_flags & AMQP_BASIC_CORRELATION_ID_FLAG) { - zend_update_property_stringl(this_ce, envelope, ZEND_STRL("correlation_id"), (const char *) p->correlation_id.bytes, (PHP5to7_param_str_len_type_t) p->correlation_id.len TSRMLS_CC); - } else { - /* BC */ - zend_update_property_stringl(this_ce, envelope, ZEND_STRL("correlation_id"), "", 0 TSRMLS_CC); - } - - if (p->_flags & AMQP_BASIC_REPLY_TO_FLAG) { - zend_update_property_stringl(this_ce, envelope, ZEND_STRL("reply_to"), (const char *) p->reply_to.bytes, (PHP5to7_param_str_len_type_t) p->reply_to.len TSRMLS_CC); - } else { - /* BC */ - zend_update_property_stringl(this_ce, envelope, ZEND_STRL("reply_to"), "", 0 TSRMLS_CC); - } - - if (p->_flags & AMQP_BASIC_EXPIRATION_FLAG) { - zend_update_property_stringl(this_ce, envelope, ZEND_STRL("expiration"), (const char *) p->expiration.bytes, (PHP5to7_param_str_len_type_t) p->expiration.len TSRMLS_CC); - } else { - /* BC */ - zend_update_property_stringl(this_ce, envelope, ZEND_STRL("expiration"), "", 0 TSRMLS_CC); - } - - if (p->_flags & AMQP_BASIC_MESSAGE_ID_FLAG) { - zend_update_property_stringl(this_ce, envelope, ZEND_STRL("message_id"), (const char *) p->message_id.bytes, (PHP5to7_param_str_len_type_t) p->message_id.len TSRMLS_CC); - } else { - /* BC */ - zend_update_property_stringl(this_ce, envelope, ZEND_STRL("message_id"), "", 0 TSRMLS_CC); - } - - if (p->_flags & AMQP_BASIC_TIMESTAMP_FLAG) { - zend_update_property_long(this_ce, envelope, ZEND_STRL("timestamp"), (PHP5to7_param_long_type_t) p->timestamp TSRMLS_CC); - } else { - /* BC */ - zend_update_property_long(this_ce, envelope, ZEND_STRL("timestamp"), 0 TSRMLS_CC); - } - - if (p->_flags & AMQP_BASIC_TYPE_FLAG) { - zend_update_property_stringl(this_ce, envelope, ZEND_STRL("type"), (const char *) p->type.bytes, (PHP5to7_param_str_len_type_t) p->type.len TSRMLS_CC); - } else { - /* BC */ - zend_update_property_stringl(this_ce, envelope, ZEND_STRL("type"), "", 0 TSRMLS_CC); - } - - if (p->_flags & AMQP_BASIC_USER_ID_FLAG) { - zend_update_property_stringl(this_ce, envelope, ZEND_STRL("user_id"), (const char *) p->user_id.bytes, (PHP5to7_param_str_len_type_t) p->user_id.len TSRMLS_CC); - } else { - /* BC */ - zend_update_property_stringl(this_ce, envelope, ZEND_STRL("user_id"), "", 0 TSRMLS_CC); - } - - if (p->_flags & AMQP_BASIC_APP_ID_FLAG) { - zend_update_property_stringl(this_ce, envelope, ZEND_STRL("app_id"), (const char *) p->app_id.bytes, (PHP5to7_param_str_len_type_t) p->app_id.len TSRMLS_CC); - } else { - /* BC */ - zend_update_property_stringl(this_ce, envelope, ZEND_STRL("app_id"), "", 0 TSRMLS_CC); - } - - PHP5to7_MAYBE_DESTROY(headers); -} - - -/* {{{ proto AMQPEnvelope::__construct() */ -PHP_METHOD (amqp_envelope_class, __construct) { - PHP_AMQP_NOPARAMS(); - - /* BC */ - PHP5to7_zval_t headers PHP5to7_MAYBE_SET_TO_NULL; - PHP5to7_MAYBE_INIT(headers); - PHP5to7_ARRAY_INIT(headers); - - zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("body"), "", 0 TSRMLS_CC); - - zend_update_property_long(this_ce, getThis(), ZEND_STRL("delivery_tag"), 0 TSRMLS_CC); - zend_update_property_bool(this_ce, getThis(), ZEND_STRL("is_redelivery"), 0 TSRMLS_CC); - zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("exchange_name"), "", 0 TSRMLS_CC); - zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("routing_key"), "", 0 TSRMLS_CC); - - zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("content_type"), "", 0 TSRMLS_CC); - zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("content_encoding"), "", 0 TSRMLS_CC); - zend_update_property(this_ce, getThis(), ZEND_STRL("headers"), PHP5to7_MAYBE_PTR(headers) TSRMLS_CC); - zend_update_property_long(this_ce, getThis(), ZEND_STRL("delivery_mode"), AMQP_DELIVERY_NONPERSISTENT TSRMLS_CC); - zend_update_property_long(this_ce, getThis(), ZEND_STRL("priority"), 0 TSRMLS_CC); - zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("correlation_id"), "", 0 TSRMLS_CC); - zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("reply_to"), "", 0 TSRMLS_CC); - zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("expiration"), "", 0 TSRMLS_CC); - zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("message_id"), "", 0 TSRMLS_CC); - zend_update_property_long(this_ce, getThis(), ZEND_STRL("timestamp"), 0 TSRMLS_CC); - zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("type"), "", 0 TSRMLS_CC); - zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("user_id"), "", 0 TSRMLS_CC); - zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("app_id"), "", 0 TSRMLS_CC); - - PHP5to7_MAYBE_DESTROY(headers); -} -/* }}} */ - - -/* {{{ proto AMQPEnvelope::getBody()*/ -PHP_METHOD (amqp_envelope_class, getBody) { - PHP5to7_READ_PROP_RV_PARAM_DECL; - - PHP_AMQP_NOPARAMS(); - - zval* zv = PHP_AMQP_READ_THIS_PROP("body"); - - if (Z_STRLEN_P(zv) == 0) { - /* BC */ - RETURN_FALSE; - } - - RETURN_ZVAL(zv, 1, 0); -} -/* }}} */ - -/* {{{ proto AMQPEnvelope::getRoutingKey() */ -PHP_METHOD (amqp_envelope_class, getRoutingKey) { - PHP5to7_READ_PROP_RV_PARAM_DECL; - PHP_AMQP_NOPARAMS(); - PHP_AMQP_RETURN_THIS_PROP("routing_key"); -} -/* }}} */ - -/* {{{ proto AMQPEnvelope::getDeliveryMode() */ -PHP_METHOD (amqp_envelope_class, getDeliveryMode) { - PHP5to7_READ_PROP_RV_PARAM_DECL; - PHP_AMQP_NOPARAMS(); - PHP_AMQP_RETURN_THIS_PROP("delivery_mode"); -} -/* }}} */ - - -/* {{{ proto AMQPEnvelope::getDeliveryTag() */ -PHP_METHOD (amqp_envelope_class, getDeliveryTag) { - PHP5to7_READ_PROP_RV_PARAM_DECL; - PHP_AMQP_NOPARAMS(); - PHP_AMQP_RETURN_THIS_PROP("delivery_tag"); -} -/* }}} */ - -/* {{{ proto AMQPEnvelope::getExchangeName() */ -PHP_METHOD (amqp_envelope_class, getExchangeName) { - PHP5to7_READ_PROP_RV_PARAM_DECL; - PHP_AMQP_NOPARAMS(); - PHP_AMQP_RETURN_THIS_PROP("exchange_name"); -} -/* }}} */ - -/* {{{ proto AMQPEnvelope::isRedelivery() */ -PHP_METHOD (amqp_envelope_class, isRedelivery) { - PHP5to7_READ_PROP_RV_PARAM_DECL; - PHP_AMQP_NOPARAMS(); - PHP_AMQP_RETURN_THIS_PROP("is_redelivery"); -} -/* }}} */ - -/* {{{ proto AMQPEnvelope::getContentType() */ -PHP_METHOD (amqp_envelope_class, getContentType) { - PHP5to7_READ_PROP_RV_PARAM_DECL; - PHP_AMQP_NOPARAMS(); - PHP_AMQP_RETURN_THIS_PROP("content_type"); -} -/* }}} */ - -/* {{{ proto AMQPEnvelope::getContentEncoding() */ -PHP_METHOD (amqp_envelope_class, getContentEncoding) { - PHP5to7_READ_PROP_RV_PARAM_DECL; - PHP_AMQP_NOPARAMS(); - PHP_AMQP_RETURN_THIS_PROP("content_encoding"); -} -/* }}} */ - -/* {{{ proto AMQPEnvelope::getType() */ -PHP_METHOD (amqp_envelope_class, getType) { - PHP5to7_READ_PROP_RV_PARAM_DECL; - PHP_AMQP_NOPARAMS(); - PHP_AMQP_RETURN_THIS_PROP("type"); -} -/* }}} */ - -/* {{{ proto AMQPEnvelope::getTimestamp() */ -PHP_METHOD (amqp_envelope_class, getTimestamp) { - PHP5to7_READ_PROP_RV_PARAM_DECL; - PHP_AMQP_NOPARAMS(); - PHP_AMQP_RETURN_THIS_PROP("timestamp"); -} -/* }}} */ - -/* {{{ proto AMQPEnvelope::getPriority() */ -PHP_METHOD (amqp_envelope_class, getPriority) { - PHP5to7_READ_PROP_RV_PARAM_DECL; - PHP_AMQP_NOPARAMS(); - PHP_AMQP_RETURN_THIS_PROP("priority"); -} -/* }}} */ - -/* {{{ proto AMQPEnvelope::getExpiration() -check amqp envelope */ -PHP_METHOD (amqp_envelope_class, getExpiration) { - PHP5to7_READ_PROP_RV_PARAM_DECL; - PHP_AMQP_NOPARAMS(); - PHP_AMQP_RETURN_THIS_PROP("expiration"); -} -/* }}} */ - -/* {{{ proto AMQPEnvelope::getUserId() */ -PHP_METHOD (amqp_envelope_class, getUserId) { - PHP5to7_READ_PROP_RV_PARAM_DECL; - PHP_AMQP_NOPARAMS(); - PHP_AMQP_RETURN_THIS_PROP("user_id"); -} -/* }}} */ - -/* {{{ proto AMQPEnvelope::getAppId() */ -PHP_METHOD (amqp_envelope_class, getAppId) { - PHP5to7_READ_PROP_RV_PARAM_DECL; - PHP_AMQP_NOPARAMS(); - PHP_AMQP_RETURN_THIS_PROP("app_id"); -} -/* }}} */ - -/* {{{ proto AMQPEnvelope::getMessageId() */ -PHP_METHOD (amqp_envelope_class, getMessageId) { - PHP5to7_READ_PROP_RV_PARAM_DECL; - PHP_AMQP_NOPARAMS(); - PHP_AMQP_RETURN_THIS_PROP("message_id"); -} -/* }}} */ - -/* {{{ proto AMQPEnvelope::getReplyTo() */ -PHP_METHOD (amqp_envelope_class, getReplyTo) { - PHP5to7_READ_PROP_RV_PARAM_DECL; - PHP_AMQP_NOPARAMS(); - PHP_AMQP_RETURN_THIS_PROP("reply_to"); -} -/* }}} */ - -/* {{{ proto AMQPEnvelope::getCorrelationId() */ -PHP_METHOD (amqp_envelope_class, getCorrelationId) { - PHP5to7_READ_PROP_RV_PARAM_DECL; - PHP_AMQP_NOPARAMS(); - PHP_AMQP_RETURN_THIS_PROP("correlation_id"); -} -/* }}} */ - - -/* {{{ proto AMQPEnvelope::getHeader(string name) */ -PHP_METHOD (amqp_envelope_class, getHeader) { - PHP5to7_READ_PROP_RV_PARAM_DECL; - - char *key; PHP5to7_param_str_len_type_t key_len; - PHP5to7_zval_t *tmp = NULL; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &key, &key_len) == FAILURE) { - return; - } - - zval* zv = PHP_AMQP_READ_THIS_PROP("headers"); - - /* Look for the hash key */ - if (!PHP5to7_ZEND_HASH_FIND(HASH_OF(zv), key, key_len + 1, tmp)) { - RETURN_FALSE; - } - - RETURN_ZVAL(PHP5to7_MAYBE_DEREF(tmp), 1, 0); -} -/* }}} */ - - -/* {{{ proto AMQPEnvelope::hasHeader(string name) */ -PHP_METHOD (amqp_envelope_class, hasHeader) { - PHP5to7_READ_PROP_RV_PARAM_DECL; - - char *key; PHP5to7_param_str_len_type_t key_len; - PHP5to7_zval_t *tmp = NULL; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &key, &key_len) == FAILURE) { - return; - } - - zval* zv = PHP_AMQP_READ_THIS_PROP("headers"); - - /* Look for the hash key */ - if (!PHP5to7_ZEND_HASH_FIND(HASH_OF(zv), key, key_len + 1, tmp)) { - RETURN_FALSE; - } - - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto AMQPEnvelope::getHeaders() */ -PHP_METHOD (amqp_envelope_class, getHeaders) { - PHP5to7_READ_PROP_RV_PARAM_DECL; - PHP_AMQP_NOPARAMS(); - PHP_AMQP_RETURN_THIS_PROP("headers"); -} -/* }}} */ - -/* amqp_envelope_class ARG_INFO definition */ -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class__construct, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getBody, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getRoutingKey, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getDeliveryTag, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getDeliveryMode, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getExchangeName, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_isRedelivery, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getContentType, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getContentEncoding, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getType, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getTimestamp, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getPriority, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getExpiration, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getUserId, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getAppId, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getMessageId, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getReplyTo, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getCorrelationId, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getHeaders, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getHeader, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) - ZEND_ARG_INFO(0, name) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_hasHeader, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) - ZEND_ARG_INFO(0, name) -ZEND_END_ARG_INFO() - -zend_function_entry amqp_envelope_class_functions[] = { - PHP_ME(amqp_envelope_class, __construct, arginfo_amqp_envelope_class__construct, ZEND_ACC_PUBLIC) - PHP_ME(amqp_envelope_class, getBody, arginfo_amqp_envelope_class_getBody, ZEND_ACC_PUBLIC) - PHP_ME(amqp_envelope_class, getRoutingKey, arginfo_amqp_envelope_class_getRoutingKey, ZEND_ACC_PUBLIC) - PHP_ME(amqp_envelope_class, getDeliveryTag, arginfo_amqp_envelope_class_getDeliveryTag, ZEND_ACC_PUBLIC) - PHP_ME(amqp_envelope_class, getDeliveryMode, arginfo_amqp_envelope_class_getDeliveryMode, ZEND_ACC_PUBLIC) - PHP_ME(amqp_envelope_class, getExchangeName, arginfo_amqp_envelope_class_getExchangeName, ZEND_ACC_PUBLIC) - PHP_ME(amqp_envelope_class, isRedelivery, arginfo_amqp_envelope_class_isRedelivery, ZEND_ACC_PUBLIC) - PHP_ME(amqp_envelope_class, getContentType, arginfo_amqp_envelope_class_getContentType, ZEND_ACC_PUBLIC) - PHP_ME(amqp_envelope_class, getContentEncoding, arginfo_amqp_envelope_class_getContentEncoding, ZEND_ACC_PUBLIC) - PHP_ME(amqp_envelope_class, getType, arginfo_amqp_envelope_class_getType, ZEND_ACC_PUBLIC) - PHP_ME(amqp_envelope_class, getTimestamp, arginfo_amqp_envelope_class_getTimestamp, ZEND_ACC_PUBLIC) - PHP_ME(amqp_envelope_class, getPriority, arginfo_amqp_envelope_class_getPriority, ZEND_ACC_PUBLIC) - PHP_ME(amqp_envelope_class, getExpiration, arginfo_amqp_envelope_class_getExpiration, ZEND_ACC_PUBLIC) - PHP_ME(amqp_envelope_class, getUserId, arginfo_amqp_envelope_class_getUserId, ZEND_ACC_PUBLIC) - PHP_ME(amqp_envelope_class, getAppId, arginfo_amqp_envelope_class_getAppId, ZEND_ACC_PUBLIC) - PHP_ME(amqp_envelope_class, getMessageId, arginfo_amqp_envelope_class_getMessageId, ZEND_ACC_PUBLIC) - PHP_ME(amqp_envelope_class, getReplyTo, arginfo_amqp_envelope_class_getReplyTo, ZEND_ACC_PUBLIC) - PHP_ME(amqp_envelope_class, getCorrelationId, arginfo_amqp_envelope_class_getCorrelationId, ZEND_ACC_PUBLIC) - PHP_ME(amqp_envelope_class, getHeaders, arginfo_amqp_envelope_class_getHeaders, ZEND_ACC_PUBLIC) - PHP_ME(amqp_envelope_class, getHeader, arginfo_amqp_envelope_class_getHeader, ZEND_ACC_PUBLIC) - PHP_ME(amqp_envelope_class, hasHeader, arginfo_amqp_envelope_class_hasHeader, ZEND_ACC_PUBLIC) - - {NULL, NULL, NULL} /* Must be the last line in amqp_functions[] */ -}; - - -PHP_MINIT_FUNCTION (amqp_envelope) { - zend_class_entry ce; - - INIT_CLASS_ENTRY(ce, "AMQPEnvelope", amqp_envelope_class_functions); - this_ce = zend_register_internal_class(&ce TSRMLS_CC); - - - zend_declare_property_null(this_ce, ZEND_STRL("body"), ZEND_ACC_PRIVATE TSRMLS_CC); - - /* - deliver(consumer-tag consumer-tag, - delivery-tag delivery-tag, - redelivered redelivered, - exchange-name exchange, - shortstr routing-key) - - get-ok(delivery-tag delivery-tag, - redelivered redelivered, - exchange-name exchange, - shortstr routing-key, - message-count message-count) - */ - zend_declare_property_null(this_ce, ZEND_STRL("delivery_tag"), ZEND_ACC_PRIVATE TSRMLS_CC); - zend_declare_property_null(this_ce, ZEND_STRL("is_redelivery"), ZEND_ACC_PRIVATE TSRMLS_CC); - zend_declare_property_null(this_ce, ZEND_STRL("exchange_name"), ZEND_ACC_PRIVATE TSRMLS_CC); - zend_declare_property_null(this_ce, ZEND_STRL("routing_key"), ZEND_ACC_PRIVATE TSRMLS_CC); - - /* - shortstr content-type MIME content type. - shortstr content-encoding MIME content encoding. - table headers Message header field table. - octet delivery-mode Non-persistent (1) or persistent (2). - octet priority Message priority, 0 to 9. - shortstr correlation-id Application correlation identifier. - shortstr reply-to Address to reply to. - shortstr expiration Message expiration specification. - shortstr message-id Application message identifier. - timestamp timestamp Message timestamp. - shortstr type Message type name. - shortstr user-id Creating user id. - shortstr app-id Creating application id. - */ - zend_declare_property_null(this_ce, ZEND_STRL("content_type"), ZEND_ACC_PRIVATE TSRMLS_CC); - zend_declare_property_null(this_ce, ZEND_STRL("content_encoding"), ZEND_ACC_PRIVATE TSRMLS_CC); - zend_declare_property_null(this_ce, ZEND_STRL("headers"), ZEND_ACC_PRIVATE TSRMLS_CC); - zend_declare_property_null(this_ce, ZEND_STRL("delivery_mode"), ZEND_ACC_PRIVATE TSRMLS_CC); - zend_declare_property_null(this_ce, ZEND_STRL("priority"), ZEND_ACC_PRIVATE TSRMLS_CC); - zend_declare_property_null(this_ce, ZEND_STRL("correlation_id"), ZEND_ACC_PRIVATE TSRMLS_CC); - zend_declare_property_null(this_ce, ZEND_STRL("reply_to"), ZEND_ACC_PRIVATE TSRMLS_CC); - zend_declare_property_null(this_ce, ZEND_STRL("expiration"), ZEND_ACC_PRIVATE TSRMLS_CC); - zend_declare_property_null(this_ce, ZEND_STRL("message_id"), ZEND_ACC_PRIVATE TSRMLS_CC); - zend_declare_property_null(this_ce, ZEND_STRL("timestamp"), ZEND_ACC_PRIVATE TSRMLS_CC); - zend_declare_property_null(this_ce, ZEND_STRL("type"), ZEND_ACC_PRIVATE TSRMLS_CC); - zend_declare_property_null(this_ce, ZEND_STRL("user_id"), ZEND_ACC_PRIVATE TSRMLS_CC); - zend_declare_property_null(this_ce, ZEND_STRL("app_id"), ZEND_ACC_PRIVATE TSRMLS_CC); - - return SUCCESS; -} - - -void parse_amqp_table(amqp_table_t *table, zval *result) { - int i; - PHP5to7_zval_t value PHP5to7_MAYBE_SET_TO_NULL; - - assert(Z_TYPE_P(result) == IS_ARRAY); - - for (i = 0; i < table->num_entries; i++) { - PHP5to7_MAYBE_INIT(value); - - amqp_table_entry_t *entry = &(table->entries[i]); - switch (entry->value.kind) { - case AMQP_FIELD_KIND_BOOLEAN: - ZVAL_BOOL(PHP5to7_MAYBE_PTR(value), entry->value.value.boolean); - break; - case AMQP_FIELD_KIND_I8: ZVAL_LONG(PHP5to7_MAYBE_PTR(value), entry->value.value.i8); - break; - case AMQP_FIELD_KIND_U8: ZVAL_LONG(PHP5to7_MAYBE_PTR(value), entry->value.value.u8); - break; - case AMQP_FIELD_KIND_I16: ZVAL_LONG(PHP5to7_MAYBE_PTR(value), entry->value.value.i16); - break; - case AMQP_FIELD_KIND_U16: ZVAL_LONG(PHP5to7_MAYBE_PTR(value), entry->value.value.u16); - break; - case AMQP_FIELD_KIND_I32: ZVAL_LONG(PHP5to7_MAYBE_PTR(value), entry->value.value.i32); - break; - case AMQP_FIELD_KIND_U32: ZVAL_LONG(PHP5to7_MAYBE_PTR(value), entry->value.value.u32); - break; - case AMQP_FIELD_KIND_I64: ZVAL_LONG(PHP5to7_MAYBE_PTR(value), entry->value.value.i64); - break; - case AMQP_FIELD_KIND_U64: ZVAL_LONG(PHP5to7_MAYBE_PTR(value), entry->value.value.i64); - break; - case AMQP_FIELD_KIND_F32: ZVAL_DOUBLE(PHP5to7_MAYBE_PTR(value), entry->value.value.f32); - break; - case AMQP_FIELD_KIND_F64: ZVAL_DOUBLE(PHP5to7_MAYBE_PTR(value), entry->value.value.f64); - break; - case AMQP_FIELD_KIND_UTF8: - case AMQP_FIELD_KIND_BYTES: - PHP5to7_ZVAL_STRINGL_DUP(PHP5to7_MAYBE_PTR(value), entry->value.value.bytes.bytes, entry->value.value.bytes.len); - break; - case AMQP_FIELD_KIND_ARRAY: { - int j; - array_init(PHP5to7_MAYBE_PTR(value)); - for (j = 0; j < entry->value.value.array.num_entries; ++j) { - switch (entry->value.value.array.entries[j].kind) { - case AMQP_FIELD_KIND_UTF8: - PHP5to7_ADD_NEXT_INDEX_STRINGL_DUP( - PHP5to7_MAYBE_PTR(value), - entry->value.value.array.entries[j].value.bytes.bytes, - (uint) entry->value.value.array.entries[j].value.bytes.len - ); - break; - case AMQP_FIELD_KIND_TABLE: { - PHP5to7_zval_t subtable PHP5to7_MAYBE_SET_TO_NULL; - PHP5to7_MAYBE_INIT(subtable); - PHP5to7_ARRAY_INIT(subtable); - - parse_amqp_table( - &(entry->value.value.array.entries[j].value.table), - PHP5to7_MAYBE_PTR(subtable) - ); - add_next_index_zval(PHP5to7_MAYBE_PTR(value), PHP5to7_MAYBE_PTR(subtable)); - } - break; - default: - break; - } - } - } - break; - case AMQP_FIELD_KIND_TABLE: - PHP5to7_ARRAY_INIT(value); - parse_amqp_table(&(entry->value.value.table), PHP5to7_MAYBE_PTR(value)); - break; - case AMQP_FIELD_KIND_TIMESTAMP: ZVAL_DOUBLE(PHP5to7_MAYBE_PTR(value), entry->value.value.u64); - break; - case AMQP_FIELD_KIND_VOID: - case AMQP_FIELD_KIND_DECIMAL: - default: ZVAL_NULL(PHP5to7_MAYBE_PTR(value)); - break; - } - - if (Z_TYPE_P(PHP5to7_MAYBE_PTR(value)) != IS_NULL) { - char *key = estrndup(entry->key.bytes, (uint) entry->key.len); - add_assoc_zval(result, key, PHP5to7_MAYBE_PTR(value)); - efree(key); - } else { - PHP5to7_MAYBE_DESTROY(value); - } - } - return; -} - -/* -*Local variables: -*tab-width: 4 -*c-basic-offset: 4 -*End: -*vim600: noet sw=4 ts=4 fdm=marker -*vim<600: noet sw=4 ts=4 -*/ diff -Nru php-amqp-1.7.1/amqp-1.7.1/amqp_envelope.h php-amqp-1.9.3/amqp-1.7.1/amqp_envelope.h --- php-amqp-1.7.1/amqp-1.7.1/amqp_envelope.h 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/amqp_envelope.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,62 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2007 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 | - | Lead: | - | - Pieter de Zwart | - | Maintainers: | - | - Brad Rodriguez | - | - Jonathan Tansavatdi | - +----------------------------------------------------------------------+ -*/ - -/* $Id: amqp_envelope.h 321054 2011-12-16 01:23:28Z pdezwart $ */ - -extern zend_class_entry *amqp_envelope_class_entry; - -void convert_amqp_envelope_to_zval(amqp_envelope_t *amqp_envelope, zval *envelope TSRMLS_DC); - -PHP_METHOD(amqp_envelope_class, __construct); -PHP_METHOD(amqp_envelope_class, getBody); -PHP_METHOD(amqp_envelope_class, getRoutingKey); -PHP_METHOD(amqp_envelope_class, getDeliveryTag); -PHP_METHOD(amqp_envelope_class, getDeliveryMode); -PHP_METHOD(amqp_envelope_class, getExchangeName); -PHP_METHOD(amqp_envelope_class, isRedelivery); -PHP_METHOD(amqp_envelope_class, getContentType); -PHP_METHOD(amqp_envelope_class, getContentEncoding); -PHP_METHOD(amqp_envelope_class, getType); -PHP_METHOD(amqp_envelope_class, getTimestamp); -PHP_METHOD(amqp_envelope_class, getPriority); -PHP_METHOD(amqp_envelope_class, getExpiration); -PHP_METHOD(amqp_envelope_class, getUserId); -PHP_METHOD(amqp_envelope_class, getAppId); -PHP_METHOD(amqp_envelope_class, getMessageId); -PHP_METHOD(amqp_envelope_class, getReplyTo); -PHP_METHOD(amqp_envelope_class, getCorrelationId); -PHP_METHOD(amqp_envelope_class, getHeaders); -PHP_METHOD(amqp_envelope_class, getHeader); -PHP_METHOD(amqp_envelope_class, hasHeader); - -PHP_MINIT_FUNCTION(amqp_envelope); - - -/* -*Local variables: -*tab-width: 4 -*c-basic-offset: 4 -*End: -*vim600: noet sw=4 ts=4 fdm=marker -*vim<600: noet sw=4 ts=4 -*/ diff -Nru php-amqp-1.7.1/amqp-1.7.1/amqp_exchange.c php-amqp-1.9.3/amqp-1.7.1/amqp_exchange.c --- php-amqp-1.7.1/amqp-1.7.1/amqp_exchange.c 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/amqp_exchange.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,950 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2007 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 | - | Lead: | - | - Pieter de Zwart | - | Maintainers: | - | - Brad Rodriguez | - | - Jonathan Tansavatdi | - +----------------------------------------------------------------------+ -*/ - -/* $Id: amqp_exchange.c 327551 2012-09-09 03:49:34Z pdezwart $ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#include "php_ini.h" -#include "ext/standard/info.h" -#include "zend_exceptions.h" - -#ifdef PHP_WIN32 -# include "win32/php_stdint.h" -# include "win32/signal.h" -#else -# include -# include -#endif -#include -#include - -#ifdef PHP_WIN32 -# include "win32/unistd.h" -#else -# include -#endif - -#include "php_amqp.h" -#include "amqp_connection.h" -#include "amqp_channel.h" -#include "amqp_exchange.h" - -zend_class_entry *amqp_exchange_class_entry; -#define this_ce amqp_exchange_class_entry - -/* {{{ proto AMQPExchange::__construct(AMQPChannel channel); -create Exchange */ -PHP_METHOD(amqp_exchange_class, __construct) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - - PHP5to7_zval_t arguments PHP5to7_MAYBE_SET_TO_NULL; - - zval *channelObj; - amqp_channel_resource *channel_resource; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &channelObj) == FAILURE) { - return; - } - - PHP5to7_MAYBE_INIT(arguments); - PHP5to7_ARRAY_INIT(arguments); - zend_update_property(this_ce, getThis(), ZEND_STRL("arguments"), PHP5to7_MAYBE_PTR(arguments) TSRMLS_CC); - PHP5to7_MAYBE_DESTROY(arguments); - - channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(channelObj); - PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not create exchange."); - - zend_update_property(this_ce, getThis(), ZEND_STRL("channel"), channelObj TSRMLS_CC); - zend_update_property(this_ce, getThis(), ZEND_STRL("connection"), PHP_AMQP_READ_OBJ_PROP(amqp_channel_class_entry, channelObj, "connection") TSRMLS_CC); -} -/* }}} */ - - -/* {{{ proto AMQPExchange::getName() -Get the exchange name */ -PHP_METHOD(amqp_exchange_class, getName) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - - PHP_AMQP_NOPARAMS(); - - if (PHP_AMQP_READ_THIS_PROP_STRLEN("name") > 0) { - PHP_AMQP_RETURN_THIS_PROP("name"); - } else { - /* BC */ - RETURN_FALSE; - } -} -/* }}} */ - - -/* {{{ proto AMQPExchange::setName(string name) -Set the exchange name */ -PHP_METHOD(amqp_exchange_class, setName) -{ - char *name = NULL; - PHP5to7_param_str_len_type_t name_len = 0; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) { - return; - } - - /* Verify that the name is not null and not an empty string */ - if (name_len > 255) { - zend_throw_exception(amqp_exchange_exception_class_entry, "Invalid exchange name given, must be less than 255 characters long.", 0 TSRMLS_CC); - return; - } - - /* Set the exchange name */ - zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("name"), name, name_len TSRMLS_CC); -} -/* }}} */ - - -/* {{{ proto AMQPExchange::getFlags() -Get the exchange parameters */ -PHP_METHOD(amqp_exchange_class, getFlags) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - - PHP5to7_param_long_type_t flagBitmask = 0; - - PHP_AMQP_NOPARAMS(); - - if (PHP_AMQP_READ_THIS_PROP_BOOL("passive")) { - flagBitmask |= AMQP_PASSIVE; - } - - if (PHP_AMQP_READ_THIS_PROP_BOOL("durable")) { - flagBitmask |= AMQP_DURABLE; - } - - if (PHP_AMQP_READ_THIS_PROP_BOOL("auto_delete")) { - flagBitmask |= AMQP_AUTODELETE; - } - - if (PHP_AMQP_READ_THIS_PROP_BOOL("internal")) { - flagBitmask |= AMQP_INTERNAL; - } - - RETURN_LONG(flagBitmask); -} -/* }}} */ - - -/* {{{ proto AMQPExchange::setFlags(long bitmask) -Set the exchange parameters */ -PHP_METHOD(amqp_exchange_class, setFlags) -{ - PHP5to7_param_long_type_t flagBitmask; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &flagBitmask) == FAILURE) { - return; - } - - /* Set the flags based on the bitmask we were given */ - flagBitmask = flagBitmask ? flagBitmask & PHP_AMQP_EXCHANGE_FLAGS : flagBitmask; - - zend_update_property_bool(this_ce, getThis(), ZEND_STRL("passive"), IS_PASSIVE(flagBitmask) TSRMLS_CC); - zend_update_property_bool(this_ce, getThis(), ZEND_STRL("durable"), IS_DURABLE(flagBitmask) TSRMLS_CC); - zend_update_property_bool(this_ce, getThis(), ZEND_STRL("auto_delete"), IS_AUTODELETE(flagBitmask) TSRMLS_CC); - zend_update_property_bool(this_ce, getThis(), ZEND_STRL("internal"), IS_INTERNAL(flagBitmask) TSRMLS_CC); -} -/* }}} */ - - -/* {{{ proto AMQPExchange::getType() -Get the exchange type */ -PHP_METHOD(amqp_exchange_class, getType) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - - PHP_AMQP_NOPARAMS(); - - if (PHP_AMQP_READ_THIS_PROP_STRLEN("type") > 0) { - PHP_AMQP_RETURN_THIS_PROP("type"); - } else { - /* BC */ - RETURN_FALSE; - } -} -/* }}} */ - - -/* {{{ proto AMQPExchange::setType(string type) -Set the exchange type */ -PHP_METHOD(amqp_exchange_class, setType) -{ - char *type = NULL; PHP5to7_param_str_len_type_t type_len = 0; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &type, &type_len) == FAILURE) { - return; - } - - zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("type"), type, type_len TSRMLS_CC); -} -/* }}} */ - - -/* {{{ proto AMQPExchange::getArgument(string key) -Get the exchange argument referenced by key */ -PHP_METHOD(amqp_exchange_class, getArgument) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - - PHP5to7_zval_t *tmp = NULL; - - char *key; PHP5to7_param_str_len_type_t key_len; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &key, &key_len) == FAILURE) { - return; - } - - if (!PHP5to7_ZEND_HASH_FIND(PHP_AMQP_READ_THIS_PROP_ARR("arguments"), key, key_len + 1, tmp)) { - RETURN_FALSE; - } - - RETURN_ZVAL(PHP5to7_MAYBE_DEREF(tmp), 1, 0); -} -/* }}} */ - -/* {{{ proto AMQPExchange::hasArgument(string key) */ -PHP_METHOD(amqp_exchange_class, hasArgument) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - - PHP5to7_zval_t *tmp = NULL; - - char *key; PHP5to7_param_str_len_type_t key_len; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &key, &key_len) == FAILURE) { - return; - } - - if (!PHP5to7_ZEND_HASH_FIND(PHP_AMQP_READ_THIS_PROP_ARR("arguments"), key, (uint)(key_len + 1), tmp)) { - RETURN_FALSE; - } - - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto AMQPExchange::getArguments -Get the exchange arguments */ -PHP_METHOD(amqp_exchange_class, getArguments) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - PHP_AMQP_NOPARAMS(); - PHP_AMQP_RETURN_THIS_PROP("arguments"); -} -/* }}} */ - - -/* {{{ proto AMQPExchange::setArguments(array args) -Overwrite all exchange arguments with given args */ -PHP_METHOD(amqp_exchange_class, setArguments) -{ - zval *zvalArguments; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &zvalArguments) == FAILURE) { - return; - } - - zend_update_property(this_ce, getThis(), ZEND_STRL("arguments"), zvalArguments TSRMLS_CC); - - RETURN_TRUE; -} -/* }}} */ - - -/* {{{ proto AMQPExchange::setArgument(key, value) */ -PHP_METHOD(amqp_exchange_class, setArgument) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - - char *key= NULL; PHP5to7_param_str_len_type_t key_len = 0; - zval *value = NULL; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz", - &key, &key_len, - &value) == FAILURE) { - return; - } - - switch (Z_TYPE_P(value)) { - case IS_NULL: - PHP5to7_ZEND_HASH_DEL(PHP_AMQP_READ_THIS_PROP_ARR("arguments"), key, (uint) (key_len + 1)); - break; - PHP5to7_CASE_IS_BOOL: - case IS_LONG: - case IS_DOUBLE: - case IS_STRING: - PHP5to7_ZEND_HASH_ADD(PHP_AMQP_READ_THIS_PROP_ARR("arguments"), key, (uint) (key_len + 1), value, sizeof(zval *)); - Z_TRY_ADDREF_P(value); - break; - default: - zend_throw_exception(amqp_exchange_exception_class_entry, "The value parameter must be of type NULL, int, double or string.", 0 TSRMLS_CC); - return; - } - - RETURN_TRUE; -} -/* }}} */ - - -/* {{{ proto AMQPExchange::declareExchange(); -declare Exchange -*/ -PHP_METHOD(amqp_exchange_class, declareExchange) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - - amqp_channel_resource *channel_resource; - amqp_table_t *arguments; - - if (zend_parse_parameters_none() == FAILURE) { - return; - } - - channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel")); - PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not declare exchange."); - - /* Check that the exchange has a name */ - if (PHP_AMQP_READ_THIS_PROP_STRLEN("name") < 1) { - zend_throw_exception(amqp_exchange_exception_class_entry, "Could not declare exchange. Exchanges must have a name.", 0 TSRMLS_CC); - return; - } - - /* Check that the exchange has a name */ - if (PHP_AMQP_READ_THIS_PROP_STRLEN("type") < 1) { - zend_throw_exception(amqp_exchange_exception_class_entry, "Could not declare exchange. Exchanges must have a type.", 0 TSRMLS_CC); - return; - } - - arguments = convert_zval_to_amqp_table(PHP_AMQP_READ_THIS_PROP("arguments") TSRMLS_CC); - -#if AMQP_VERSION_MAJOR * 100 + AMQP_VERSION_MINOR * 10 + AMQP_VERSION_PATCH > 52 - amqp_exchange_declare( - channel_resource->connection_resource->connection_state, - channel_resource->channel_id, - amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STR("name")), - amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STR("type")), - PHP_AMQP_READ_THIS_PROP_BOOL("passive"), - PHP_AMQP_READ_THIS_PROP_BOOL("durable"), - PHP_AMQP_READ_THIS_PROP_BOOL("auto_delete"), - PHP_AMQP_READ_THIS_PROP_BOOL("internal"), - *arguments - ); -#else - amqp_exchange_declare( - channel_resource->connection_resource->connection_state, - channel_resource->channel_id, - amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STR("name")), - amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STR("type")), - PHP_AMQP_READ_THIS_PROP_BOOL("passive"), - PHP_AMQP_READ_THIS_PROP_BOOL("durable"), - *arguments - ); -#endif - - amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state); - - php_amqp_free_amqp_table(arguments); - - /* handle any errors that occured outside of signals */ - if (res.reply_type != AMQP_RESPONSE_NORMAL) { - PHP_AMQP_INIT_ERROR_MESSAGE(); - - php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, channel_resource->connection_resource, channel_resource TSRMLS_CC); - - php_amqp_zend_throw_exception(res, amqp_exchange_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC); - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - - PHP_AMQP_DESTROY_ERROR_MESSAGE(); - return; - } - - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - - RETURN_TRUE; -} -/* }}} */ - - -/* {{{ proto AMQPExchange::delete([string name[, long params]]); -delete Exchange -*/ -PHP_METHOD(amqp_exchange_class, delete) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - - amqp_channel_resource *channel_resource; - - char *name = NULL; PHP5to7_param_str_len_type_t name_len = 0; - PHP5to7_param_long_type_t flags = 0; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sl", - &name, &name_len, - &flags) == FAILURE) { - return; - } - - channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel")); - PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not delete exchange."); - - amqp_exchange_delete( - channel_resource->connection_resource->connection_state, - channel_resource->channel_id, - amqp_cstring_bytes(name_len ? name : PHP_AMQP_READ_THIS_PROP_STR("name")), - (AMQP_IFUNUSED & flags) ? 1 : 0 - ); - - amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state); - - if (res.reply_type != AMQP_RESPONSE_NORMAL) { - PHP_AMQP_INIT_ERROR_MESSAGE(); - - php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, channel_resource->connection_resource, channel_resource TSRMLS_CC); - - php_amqp_zend_throw_exception(res, amqp_exchange_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC); - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - - PHP_AMQP_DESTROY_ERROR_MESSAGE(); - return; - } - - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - - RETURN_TRUE; -} -/* }}} */ - - -/* {{{ proto AMQPExchange::publish(string msg, [string key, [int flags, [array headers]]]); -publish into Exchange -*/ -PHP_METHOD(amqp_exchange_class, publish) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - - zval *ini_arr = NULL; - PHP5to7_zval_t *tmp = NULL; - - amqp_channel_resource *channel_resource; - - char *key_name = NULL; PHP5to7_param_str_len_type_t key_len = 0; - char *msg = NULL; PHP5to7_param_str_len_type_t msg_len = 0; - PHP5to7_param_long_type_t flags = AMQP_NOPARAM; - -#ifndef PHP_WIN32 - /* Storage for previous signal handler during SIGPIPE override */ - void * old_handler; -#endif - - amqp_basic_properties_t props; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|sla/", - &msg, &msg_len, - &key_name, &key_len, - &flags, - &ini_arr) == FAILURE) { - return; - } - - /* By default (and for BC) content type is text/plain (may be skipped at all, then set props._flags to 0) */ - props.content_type = amqp_cstring_bytes("text/plain"); - props._flags = AMQP_BASIC_CONTENT_TYPE_FLAG; - - props.headers.entries = 0; - - { - if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF (ini_arr), "content_type", sizeof("content_type"), tmp)) { - SEPARATE_ZVAL(tmp); - convert_to_string(PHP5to7_MAYBE_DEREF(tmp)); - - if (Z_STRLEN_P(PHP5to7_MAYBE_DEREF(tmp)) > 0) { - props.content_type = amqp_cstring_bytes(Z_STRVAL_P(PHP5to7_MAYBE_DEREF(tmp))); - props._flags |= AMQP_BASIC_CONTENT_TYPE_FLAG; - } - } - - if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF (ini_arr), "content_encoding", sizeof("content_encoding"), tmp)) { - SEPARATE_ZVAL(tmp); - convert_to_string(PHP5to7_MAYBE_DEREF(tmp)); - - if (Z_STRLEN_P(PHP5to7_MAYBE_DEREF(tmp)) > 0) { - props.content_encoding = amqp_cstring_bytes(Z_STRVAL_P(PHP5to7_MAYBE_DEREF(tmp))); - props._flags |= AMQP_BASIC_CONTENT_ENCODING_FLAG; - } - } - - if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF (ini_arr), "message_id", sizeof("message_id"), tmp)) { - SEPARATE_ZVAL(tmp); - convert_to_string(PHP5to7_MAYBE_DEREF(tmp)); - - if (Z_STRLEN_P(PHP5to7_MAYBE_DEREF(tmp)) > 0) { - props.message_id = amqp_cstring_bytes(Z_STRVAL_P(PHP5to7_MAYBE_DEREF(tmp))); - props._flags |= AMQP_BASIC_MESSAGE_ID_FLAG; - } - } - - if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF (ini_arr), "user_id", sizeof("user_id"), tmp)) { - SEPARATE_ZVAL(tmp); - convert_to_string(PHP5to7_MAYBE_DEREF(tmp)); - - if (Z_STRLEN_P(PHP5to7_MAYBE_DEREF(tmp)) > 0) { - props.user_id = amqp_cstring_bytes(Z_STRVAL_P(PHP5to7_MAYBE_DEREF(tmp))); - props._flags |= AMQP_BASIC_USER_ID_FLAG; - } - } - - if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF (ini_arr), "app_id", sizeof("app_id"), tmp)) { - SEPARATE_ZVAL(tmp); - convert_to_string(PHP5to7_MAYBE_DEREF(tmp)); - - if (Z_STRLEN_P(PHP5to7_MAYBE_DEREF(tmp)) > 0) { - props.app_id = amqp_cstring_bytes(Z_STRVAL_P(PHP5to7_MAYBE_DEREF(tmp))); - props._flags |= AMQP_BASIC_APP_ID_FLAG; - } - } - - if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF (ini_arr), "delivery_mode", sizeof("delivery_mode"), tmp)) { - SEPARATE_ZVAL(tmp); - convert_to_long(PHP5to7_MAYBE_DEREF(tmp)); - - props.delivery_mode = (uint8_t)Z_LVAL_P(PHP5to7_MAYBE_DEREF(tmp)); - props._flags |= AMQP_BASIC_DELIVERY_MODE_FLAG; - } - - if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF (ini_arr), "priority", sizeof("priority"), tmp)) { - SEPARATE_ZVAL(tmp); - convert_to_long(PHP5to7_MAYBE_DEREF(tmp)); - - props.priority = (uint8_t)Z_LVAL_P(PHP5to7_MAYBE_DEREF(tmp)); - props._flags |= AMQP_BASIC_PRIORITY_FLAG; - } - - if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF (ini_arr), "timestamp", sizeof("timestamp"), tmp)) { - SEPARATE_ZVAL(tmp); - convert_to_long(PHP5to7_MAYBE_DEREF(tmp)); - - props.timestamp = (uint64_t)Z_LVAL_P(PHP5to7_MAYBE_DEREF(tmp)); - props._flags |= AMQP_BASIC_TIMESTAMP_FLAG; - } - - if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF (ini_arr), "expiration", sizeof("expiration"), tmp)) { - SEPARATE_ZVAL(tmp); - convert_to_string(PHP5to7_MAYBE_DEREF(tmp)); - - if (Z_STRLEN_P(PHP5to7_MAYBE_DEREF(tmp)) > 0) { - props.expiration = amqp_cstring_bytes(Z_STRVAL_P(PHP5to7_MAYBE_DEREF(tmp))); - props._flags |= AMQP_BASIC_EXPIRATION_FLAG; - } - } - - if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF (ini_arr), "type", sizeof("type"), tmp)) { - SEPARATE_ZVAL(tmp); - convert_to_string(PHP5to7_MAYBE_DEREF(tmp)); - - if (Z_STRLEN_P(PHP5to7_MAYBE_DEREF(tmp)) > 0) { - props.type = amqp_cstring_bytes(Z_STRVAL_P(PHP5to7_MAYBE_DEREF(tmp))); - props._flags |= AMQP_BASIC_TYPE_FLAG; - } - } - - if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF (ini_arr), "reply_to", sizeof("reply_to"), tmp)) { - SEPARATE_ZVAL(tmp); - convert_to_string(PHP5to7_MAYBE_DEREF(tmp)); - - if (Z_STRLEN_P(PHP5to7_MAYBE_DEREF(tmp)) > 0) { - props.reply_to = amqp_cstring_bytes(Z_STRVAL_P(PHP5to7_MAYBE_DEREF(tmp))); - props._flags |= AMQP_BASIC_REPLY_TO_FLAG; - } - } - if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF (ini_arr), "correlation_id", sizeof("correlation_id"), tmp)) { - SEPARATE_ZVAL(tmp); - convert_to_string(PHP5to7_MAYBE_DEREF(tmp)); - - if (Z_STRLEN_P(PHP5to7_MAYBE_DEREF(tmp)) > 0) { - props.correlation_id = amqp_cstring_bytes(Z_STRVAL_P(PHP5to7_MAYBE_DEREF(tmp))); - props._flags |= AMQP_BASIC_CORRELATION_ID_FLAG; - } - } - - } - - amqp_table_t *headers = NULL; - - if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "headers", sizeof("headers"), tmp)) { - SEPARATE_ZVAL(tmp); - convert_to_array(PHP5to7_MAYBE_DEREF(tmp)); - - headers = convert_zval_to_amqp_table(PHP5to7_MAYBE_DEREF(tmp) TSRMLS_CC); - - props._flags |= AMQP_BASIC_HEADERS_FLAG; - props.headers = *headers; - } - - channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel")); - PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not publish to exchange."); - -#ifndef PHP_WIN32 - /* Start ignoring SIGPIPE */ - old_handler = signal(SIGPIPE, SIG_IGN); -#endif - - zval *exchange_name = PHP_AMQP_READ_THIS_PROP("name"); - - /* NOTE: basic.publish is asynchronous and thus will not indicate failure if something goes wrong on the broker */ - int status = amqp_basic_publish( - channel_resource->connection_resource->connection_state, - channel_resource->channel_id, - (Z_TYPE_P(exchange_name) == IS_STRING && Z_STRLEN_P(exchange_name) > 0 ? amqp_cstring_bytes(Z_STRVAL_P(exchange_name)) : amqp_empty_bytes), /* exchange */ - (key_len > 0 ? amqp_cstring_bytes(key_name) : amqp_empty_bytes), /* routing key */ - (AMQP_MANDATORY & flags) ? 1 : 0, /* mandatory */ - (AMQP_IMMEDIATE & flags) ? 1 : 0, /* immediate */ - &props, - php_amqp_long_string(msg, msg_len) /* message body */ - ); - - if (headers) { - php_amqp_free_amqp_table(headers); - } - -#ifndef PHP_WIN32 - /* End ignoring of SIGPIPEs */ - signal(SIGPIPE, old_handler); -#endif - - if (status != AMQP_STATUS_OK) { - /* Emulate library error */ - amqp_rpc_reply_t res; - res.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION; - res.library_error = status; - - PHP_AMQP_INIT_ERROR_MESSAGE(); - - php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, channel_resource->connection_resource, channel_resource TSRMLS_CC); - - php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC); - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - - PHP_AMQP_DESTROY_ERROR_MESSAGE(); - return; - } - - RETURN_TRUE; -} -/* }}} */ - - -/* {{{ proto int exchange::bind(string srcExchangeName[, string routingKey, array arguments]); -bind exchange to exchange by routing key -*/ -PHP_METHOD(amqp_exchange_class, bind) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - - zval *zvalArguments = NULL; - - amqp_channel_resource *channel_resource; - - char *src_name; PHP5to7_param_str_len_type_t src_name_len = 0; - char *keyname; PHP5to7_param_str_len_type_t keyname_len = 0; - - amqp_table_t *arguments = NULL; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|sa", - &src_name, &src_name_len, - &keyname, &keyname_len, - &zvalArguments) == FAILURE) { - return; - } - - channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel")); - PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not bind to exchange."); - - if (zvalArguments) { - arguments = convert_zval_to_amqp_table(zvalArguments TSRMLS_CC); - } - - amqp_exchange_bind( - channel_resource->connection_resource->connection_state, - channel_resource->channel_id, - amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STR("name")), - (src_name_len > 0 ? amqp_cstring_bytes(src_name) : amqp_empty_bytes), - (keyname_len > 0 ? amqp_cstring_bytes(keyname) : amqp_empty_bytes), - (arguments ? *arguments : amqp_empty_table) - ); - - if (arguments) { - php_amqp_free_amqp_table(arguments); - } - - amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state); - - if (res.reply_type != AMQP_RESPONSE_NORMAL) { - PHP_AMQP_INIT_ERROR_MESSAGE(); - - php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, channel_resource->connection_resource, channel_resource TSRMLS_CC); - - php_amqp_zend_throw_exception(res, amqp_exchange_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC); - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - - PHP_AMQP_DESTROY_ERROR_MESSAGE(); - return; - } - - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto int exchange::unbind(string srcExchangeName[, string routingKey, array arguments]); -remove exchange to exchange binding by routing key -*/ -PHP_METHOD(amqp_exchange_class, unbind) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - - zval *zvalArguments = NULL; - - amqp_channel_resource *channel_resource; - - char *src_name; PHP5to7_param_str_len_type_t src_name_len = 0; - char *keyname; PHP5to7_param_str_len_type_t keyname_len = 0; - - amqp_table_t *arguments = NULL; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|sa", - &src_name, &src_name_len, - &keyname, &keyname_len, - &zvalArguments) == FAILURE) { - return; - } - - channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel")); - PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not unbind from exchange."); - - if (zvalArguments) { - arguments = convert_zval_to_amqp_table(zvalArguments TSRMLS_CC); - } - - amqp_exchange_unbind( - channel_resource->connection_resource->connection_state, - channel_resource->channel_id, - amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STR("name")), - (src_name_len > 0 ? amqp_cstring_bytes(src_name) : amqp_empty_bytes), - (keyname_len > 0 ? amqp_cstring_bytes(keyname) : amqp_empty_bytes), - (arguments ? *arguments : amqp_empty_table) - ); - - if (arguments) { - php_amqp_free_amqp_table(arguments); - } - - amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state); - - if (res.reply_type != AMQP_RESPONSE_NORMAL) { - PHP_AMQP_INIT_ERROR_MESSAGE(); - - php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, channel_resource->connection_resource, channel_resource TSRMLS_CC); - - php_amqp_zend_throw_exception(res, amqp_exchange_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC); - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - - PHP_AMQP_DESTROY_ERROR_MESSAGE(); - return; - } - - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto AMQPExchange::getChannel() -Get the AMQPChannel object in use */ -PHP_METHOD(amqp_exchange_class, getChannel) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - PHP_AMQP_NOPARAMS(); - PHP_AMQP_RETURN_THIS_PROP("channel"); -} -/* }}} */ - -/* {{{ proto AMQPExchange::getConnection() -Get the AMQPConnection object in use */ -PHP_METHOD(amqp_exchange_class, getConnection) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - PHP_AMQP_NOPARAMS(); - PHP_AMQP_RETURN_THIS_PROP("connection"); -} -/* }}} */ - -/* amqp_exchange ARG_INFO definition */ -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class__construct, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) - ZEND_ARG_OBJ_INFO(0, amqp_channel, AMQPChannel, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_getName, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_setName, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) - ZEND_ARG_INFO(0, exchange_name) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_getFlags, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_setFlags, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) - ZEND_ARG_INFO(0, flags) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_getType, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_setType, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) - ZEND_ARG_INFO(0, exchange_type) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_getArgument, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) - ZEND_ARG_INFO(0, argument) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_hasArgument, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) - ZEND_ARG_INFO(0, argument) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_getArguments, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_setArgument, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 2) - ZEND_ARG_INFO(0, key) - ZEND_ARG_INFO(0, value) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_setArguments, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) - ZEND_ARG_ARRAY_INFO(0, arguments, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_declareExchange, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_bind, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 2) - ZEND_ARG_INFO(0, exchange_name) - ZEND_ARG_INFO(0, routing_key) - ZEND_ARG_INFO(0, flags) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_unbind, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 2) - ZEND_ARG_INFO(0, exchange_name) - ZEND_ARG_INFO(0, routing_key) - ZEND_ARG_INFO(0, flags) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_delete, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) - ZEND_ARG_INFO(0, exchange_name) - ZEND_ARG_INFO(0, flags) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_publish, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) - ZEND_ARG_INFO(0, message) - ZEND_ARG_INFO(0, routing_key) - ZEND_ARG_INFO(0, flags) - ZEND_ARG_ARRAY_INFO(0, headers, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_getChannel, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_getConnection, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -zend_function_entry amqp_exchange_class_functions[] = { - PHP_ME(amqp_exchange_class, __construct, arginfo_amqp_exchange_class__construct, ZEND_ACC_PUBLIC) - - PHP_ME(amqp_exchange_class, getName, arginfo_amqp_exchange_class_getName, ZEND_ACC_PUBLIC) - PHP_ME(amqp_exchange_class, setName, arginfo_amqp_exchange_class_setName, ZEND_ACC_PUBLIC) - - PHP_ME(amqp_exchange_class, getFlags, arginfo_amqp_exchange_class_getFlags, ZEND_ACC_PUBLIC) - PHP_ME(amqp_exchange_class, setFlags, arginfo_amqp_exchange_class_setFlags, ZEND_ACC_PUBLIC) - - PHP_ME(amqp_exchange_class, getType, arginfo_amqp_exchange_class_getType, ZEND_ACC_PUBLIC) - PHP_ME(amqp_exchange_class, setType, arginfo_amqp_exchange_class_setType, ZEND_ACC_PUBLIC) - - PHP_ME(amqp_exchange_class, getArgument, arginfo_amqp_exchange_class_getArgument, ZEND_ACC_PUBLIC) - PHP_ME(amqp_exchange_class, getArguments, arginfo_amqp_exchange_class_getArguments, ZEND_ACC_PUBLIC) - PHP_ME(amqp_exchange_class, setArgument, arginfo_amqp_exchange_class_setArgument, ZEND_ACC_PUBLIC) - PHP_ME(amqp_exchange_class, setArguments, arginfo_amqp_exchange_class_setArguments, ZEND_ACC_PUBLIC) - PHP_ME(amqp_exchange_class, hasArgument, arginfo_amqp_exchange_class_hasArgument, ZEND_ACC_PUBLIC) - - PHP_ME(amqp_exchange_class, declareExchange,arginfo_amqp_exchange_class_declareExchange,ZEND_ACC_PUBLIC) - PHP_ME(amqp_exchange_class, bind, arginfo_amqp_exchange_class_bind, ZEND_ACC_PUBLIC) - PHP_ME(amqp_exchange_class, unbind, arginfo_amqp_exchange_class_unbind, ZEND_ACC_PUBLIC) - PHP_ME(amqp_exchange_class, delete, arginfo_amqp_exchange_class_delete, ZEND_ACC_PUBLIC) - PHP_ME(amqp_exchange_class, publish, arginfo_amqp_exchange_class_publish, ZEND_ACC_PUBLIC) - - PHP_ME(amqp_exchange_class, getChannel, arginfo_amqp_exchange_class_getChannel, ZEND_ACC_PUBLIC) - PHP_ME(amqp_exchange_class, getConnection, arginfo_amqp_exchange_class_getConnection, ZEND_ACC_PUBLIC) - - PHP_MALIAS(amqp_exchange_class, declare, declareExchange, arginfo_amqp_exchange_class_declareExchange, ZEND_ACC_PUBLIC | ZEND_ACC_DEPRECATED) - - {NULL, NULL, NULL} /* Must be the last line in amqp_functions[] */ -}; - -PHP_MINIT_FUNCTION(amqp_exchange) -{ - zend_class_entry ce; - - INIT_CLASS_ENTRY(ce, "AMQPExchange", amqp_exchange_class_functions); - this_ce = zend_register_internal_class(&ce TSRMLS_CC); - - zend_declare_property_null(this_ce, ZEND_STRL("connection"), ZEND_ACC_PRIVATE TSRMLS_CC); - zend_declare_property_null(this_ce, ZEND_STRL("channel"), ZEND_ACC_PRIVATE TSRMLS_CC); - - zend_declare_property_stringl(this_ce, ZEND_STRL("name"), "", 0, ZEND_ACC_PRIVATE TSRMLS_CC); - zend_declare_property_null(this_ce, ZEND_STRL("type"), ZEND_ACC_PRIVATE TSRMLS_CC); - zend_declare_property_bool(this_ce, ZEND_STRL("passive"), 0, ZEND_ACC_PRIVATE TSRMLS_CC); - zend_declare_property_bool(this_ce, ZEND_STRL("durable"), 0, ZEND_ACC_PRIVATE TSRMLS_CC); - zend_declare_property_bool(this_ce, ZEND_STRL("auto_delete"), 0, ZEND_ACC_PRIVATE TSRMLS_CC); - zend_declare_property_bool(this_ce, ZEND_STRL("internal"), 0, ZEND_ACC_PRIVATE TSRMLS_CC); - zend_declare_property_null(this_ce, ZEND_STRL("arguments"), ZEND_ACC_PRIVATE TSRMLS_CC); - - return SUCCESS; -} -/* -*Local variables: -*tab-width: 4 -*c-basic-offset: 4 -*End: -*vim600: noet sw=4 ts=4 fdm=marker -*vim<600: noet sw=4 ts=4 -*/ diff -Nru php-amqp-1.7.1/amqp-1.7.1/amqp_exchange.h php-amqp-1.9.3/amqp-1.7.1/amqp_exchange.h --- php-amqp-1.7.1/amqp-1.7.1/amqp_exchange.h 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/amqp_exchange.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,63 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2007 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 | - | Lead: | - | - Pieter de Zwart | - | Maintainers: | - | - Brad Rodriguez | - | - Jonathan Tansavatdi | - +----------------------------------------------------------------------+ -*/ - -/* $Id: amqp_exchange.h 318206 2011-10-19 04:17:01Z pdezwart $ */ - -extern zend_class_entry *amqp_exchange_class_entry; - -PHP_METHOD(amqp_exchange_class, __construct); - -PHP_METHOD(amqp_exchange_class, getName); -PHP_METHOD(amqp_exchange_class, setName); - -PHP_METHOD(amqp_exchange_class, getType); -PHP_METHOD(amqp_exchange_class, setType); - -PHP_METHOD(amqp_exchange_class, getFlags); -PHP_METHOD(amqp_exchange_class, setFlags); - -PHP_METHOD(amqp_exchange_class, getArgument); -PHP_METHOD(amqp_exchange_class, getArguments); -PHP_METHOD(amqp_exchange_class, setArgument); -PHP_METHOD(amqp_exchange_class, setArguments); -PHP_METHOD(amqp_exchange_class, hasArgument); - -PHP_METHOD(amqp_exchange_class, declareExchange); -PHP_METHOD(amqp_exchange_class, delete); -PHP_METHOD(amqp_exchange_class, bind); -PHP_METHOD(amqp_exchange_class, unbind); -PHP_METHOD(amqp_exchange_class, publish); - -PHP_METHOD(amqp_exchange_class, getChannel); -PHP_METHOD(amqp_exchange_class, getConnection); - -PHP_MINIT_FUNCTION(amqp_exchange); - -/* -*Local variables: -*tab-width: 4 -*c-basic-offset: 4 -*End: -*vim600: noet sw=4 ts=4 fdm=marker -*vim<600: noet sw=4 ts=4 -*/ diff -Nru php-amqp-1.7.1/amqp-1.7.1/amqp_queue.c php-amqp-1.9.3/amqp-1.7.1/amqp_queue.c --- php-amqp-1.7.1/amqp-1.7.1/amqp_queue.c 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/amqp_queue.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,1247 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2007 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 | - | Lead: | - | - Pieter de Zwart | - | Maintainers: | - | - Brad Rodriguez | - | - Jonathan Tansavatdi | - +----------------------------------------------------------------------+ -*/ - -/* $Id: amqp_queue.c 327551 2012-09-09 03:49:34Z pdezwart $ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#include "php_ini.h" -#include "ext/standard/info.h" -#include "zend_exceptions.h" - -#ifdef PHP_WIN32 -# include "win32/php_stdint.h" -# include "win32/signal.h" -#else -# include -# include -#endif -#include -#include - -#ifdef PHP_WIN32 -# include "win32/unistd.h" -#else -# include -#endif - -#include "php_amqp.h" -#include "amqp_envelope.h" -#include "amqp_connection.h" -#include "amqp_channel.h" -#include "amqp_queue.h" - -zend_class_entry *amqp_queue_class_entry; -#define this_ce amqp_queue_class_entry - - -/* {{{ proto AMQPQueue::__construct(AMQPChannel channel) -AMQPQueue constructor -*/ -PHP_METHOD(amqp_queue_class, __construct) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - - PHP5to7_zval_t arguments PHP5to7_MAYBE_SET_TO_NULL; - - zval *channelObj; - amqp_channel_resource *channel_resource; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &channelObj) == FAILURE) { - return; - } - - PHP5to7_MAYBE_INIT(arguments); - PHP5to7_ARRAY_INIT(arguments); - zend_update_property(this_ce, getThis(), ZEND_STRL("arguments"), PHP5to7_MAYBE_PTR(arguments) TSRMLS_CC); - PHP5to7_MAYBE_DESTROY(arguments); - - channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(channelObj); - PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not create queue."); - - zend_update_property(this_ce, getThis(), ZEND_STRL("channel"), channelObj TSRMLS_CC); - zend_update_property(this_ce, getThis(), ZEND_STRL("connection"), PHP_AMQP_READ_OBJ_PROP(amqp_channel_class_entry, channelObj, "connection") TSRMLS_CC); - -} -/* }}} */ - - -/* {{{ proto AMQPQueue::getName() -Get the queue name */ -PHP_METHOD(amqp_queue_class, getName) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - - PHP_AMQP_NOPARAMS(); - - if (PHP_AMQP_READ_THIS_PROP_STRLEN("name") > 0) { - PHP_AMQP_RETURN_THIS_PROP("name"); - } else { - /* BC */ - RETURN_FALSE; - } -} -/* }}} */ - - -/* {{{ proto AMQPQueue::setName(string name) -Set the queue name */ -PHP_METHOD(amqp_queue_class, setName) -{ - char *name = NULL; PHP5to7_param_str_len_type_t name_len = 0; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) { - return; - } - - if (name_len < 1 || name_len > 255) { - /* Verify that the name is not null and not an empty string */ - zend_throw_exception(amqp_queue_exception_class_entry, "Invalid queue name given, must be between 1 and 255 characters long.", 0 TSRMLS_CC); - return; - } - - /* Set the queue name */ - zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("name"), name, name_len TSRMLS_CC); - - /* BC */ - RETURN_TRUE; -} -/* }}} */ - - - -/* {{{ proto AMQPQueue::getFlags() -Get the queue parameters */ -PHP_METHOD(amqp_queue_class, getFlags) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - - PHP5to7_param_long_type_t flagBitmask = 0; - - PHP_AMQP_NOPARAMS(); - - if (PHP_AMQP_READ_THIS_PROP_BOOL("passive")) { - flagBitmask |= AMQP_PASSIVE; - } - - if (PHP_AMQP_READ_THIS_PROP_BOOL("durable")) { - flagBitmask |= AMQP_DURABLE; - } - - if (PHP_AMQP_READ_THIS_PROP_BOOL("exclusive")) { - flagBitmask |= AMQP_EXCLUSIVE; - } - - if (PHP_AMQP_READ_THIS_PROP_BOOL("auto_delete")) { - flagBitmask |= AMQP_AUTODELETE; - } - - RETURN_LONG(flagBitmask); -} -/* }}} */ - - -/* {{{ proto AMQPQueue::setFlags(long bitmask) -Set the queue parameters */ -PHP_METHOD(amqp_queue_class, setFlags) -{ - PHP5to7_param_long_type_t flagBitmask; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &flagBitmask) == FAILURE) { - return; - } - - /* Set the flags based on the bitmask we were given */ - flagBitmask = flagBitmask ? flagBitmask & PHP_AMQP_QUEUE_FLAGS : flagBitmask; - - zend_update_property_bool(this_ce, getThis(), ZEND_STRL("passive"), IS_PASSIVE(flagBitmask) TSRMLS_CC); - zend_update_property_bool(this_ce, getThis(), ZEND_STRL("durable"), IS_DURABLE(flagBitmask) TSRMLS_CC); - zend_update_property_bool(this_ce, getThis(), ZEND_STRL("exclusive"), IS_EXCLUSIVE(flagBitmask) TSRMLS_CC); - zend_update_property_bool(this_ce, getThis(), ZEND_STRL("auto_delete"), IS_AUTODELETE(flagBitmask) TSRMLS_CC); - - /* BC */ - RETURN_TRUE; -} -/* }}} */ - - -/* {{{ proto AMQPQueue::getArgument(string key) -Get the queue argument referenced by key */ -PHP_METHOD(amqp_queue_class, getArgument) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - - PHP5to7_zval_t *tmp = NULL; - - char *key; PHP5to7_param_str_len_type_t key_len; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &key, &key_len) == FAILURE) { - return; - } - - if (!PHP5to7_ZEND_HASH_FIND(PHP_AMQP_READ_THIS_PROP_ARR("arguments"), key, (uint)(key_len + 1), tmp)) { - RETURN_FALSE; - } - - RETURN_ZVAL(PHP5to7_MAYBE_DEREF(tmp), 1, 0); -} -/* }}} */ - -/* {{{ proto AMQPQueue::hasArgument(string key) */ -PHP_METHOD(amqp_queue_class, hasArgument) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - - PHP5to7_zval_t *tmp = NULL; - - char *key; PHP5to7_param_str_len_type_t key_len; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &key, &key_len) == FAILURE) { - return; - } - - if (!PHP5to7_ZEND_HASH_FIND(PHP_AMQP_READ_THIS_PROP_ARR("arguments"), key, (uint)(key_len + 1), tmp)) { - RETURN_FALSE; - } - - RETURN_TRUE; -} -/* }}} */ - - -/* {{{ proto AMQPQueue::getArguments -Get the queue arguments */ -PHP_METHOD(amqp_queue_class, getArguments) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - PHP_AMQP_NOPARAMS(); - PHP_AMQP_RETURN_THIS_PROP("arguments"); -} -/* }}} */ - -/* {{{ proto AMQPQueue::setArguments(array args) -Overwrite all queue arguments with given args */ -PHP_METHOD(amqp_queue_class, setArguments) -{ - zval *zvalArguments; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &zvalArguments) == FAILURE) { - return; - } - - zend_update_property(this_ce, getThis(), ZEND_STRL("arguments"), zvalArguments TSRMLS_CC); - - RETURN_TRUE; -} -/* }}} */ - - -/* {{{ proto AMQPQueue::setArgument(key, value) -Get the queue name */ -PHP_METHOD(amqp_queue_class, setArgument) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - - char *key= NULL; PHP5to7_param_str_len_type_t key_len = 0; - zval *value = NULL; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz", - &key, &key_len, - &value) == FAILURE) { - return; - } - - switch (Z_TYPE_P(value)) { - case IS_NULL: - PHP5to7_ZEND_HASH_DEL(PHP_AMQP_READ_THIS_PROP_ARR("arguments"), key, (uint) (key_len + 1)); - break; - PHP5to7_CASE_IS_BOOL: - case IS_LONG: - case IS_DOUBLE: - case IS_STRING: - PHP5to7_ZEND_HASH_ADD(PHP_AMQP_READ_THIS_PROP_ARR("arguments"), key, (uint) (key_len + 1), value, sizeof(zval *)); - Z_TRY_ADDREF_P(value); - break; - default: - zend_throw_exception(amqp_exchange_exception_class_entry, "The value parameter must be of type NULL, int, double or string.", 0 TSRMLS_CC); - return; - } - - RETURN_TRUE; -} -/* }}} */ - - -/* {{{ proto int AMQPQueue::declareQueue(); -declare queue -*/ -PHP_METHOD(amqp_queue_class, declareQueue) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - - amqp_channel_resource *channel_resource; - - char *name; - amqp_table_t *arguments; - PHP5to7_param_long_type_t message_count; - - if (zend_parse_parameters_none() == FAILURE) { - return; - } - - channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel")); - PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not declare queue."); - - arguments = convert_zval_to_amqp_table(PHP_AMQP_READ_THIS_PROP("arguments") TSRMLS_CC); - - amqp_queue_declare_ok_t *r = amqp_queue_declare( - channel_resource->connection_resource->connection_state, - channel_resource->channel_id, - amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STR("name")), - PHP_AMQP_READ_THIS_PROP_BOOL("passive"), - PHP_AMQP_READ_THIS_PROP_BOOL("durable"), - PHP_AMQP_READ_THIS_PROP_BOOL("exclusive"), - PHP_AMQP_READ_THIS_PROP_BOOL("auto_delete"), - *arguments - ); - - php_amqp_free_amqp_table(arguments); - - if (!r) { - amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state); - - PHP_AMQP_INIT_ERROR_MESSAGE(); - - php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, channel_resource->connection_resource, channel_resource TSRMLS_CC); - - php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC); - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - - PHP_AMQP_DESTROY_ERROR_MESSAGE(); - return; - } - - message_count = r->message_count; - - /* Set the queue name, in case it is an autogenerated queue name */ - name = stringify_bytes(r->queue); - zend_update_property_string(this_ce, getThis(), ZEND_STRL("name"), name TSRMLS_CC); - efree(name); - - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - - RETURN_LONG(message_count); -} -/* }}} */ - - -/* {{{ proto int AMQPQueue::bind(string exchangeName, [string routingKey, array arguments]); -bind queue to exchange by routing key -*/ -PHP_METHOD(amqp_queue_class, bind) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - - zval *zvalArguments = NULL; - - amqp_channel_resource *channel_resource; - - char *exchange_name; PHP5to7_param_str_len_type_t exchange_name_len; - char *keyname = NULL; PHP5to7_param_str_len_type_t keyname_len = 0; - - amqp_table_t *arguments = NULL; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|sa", - &exchange_name, &exchange_name_len, - &keyname, &keyname_len, - &zvalArguments) == FAILURE) { - return; - } - - channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel")); - PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not bind queue."); - - if (zvalArguments) { - arguments = convert_zval_to_amqp_table(zvalArguments TSRMLS_CC); - } - - amqp_queue_bind( - channel_resource->connection_resource->connection_state, - channel_resource->channel_id, - amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STR("name")), - (exchange_name_len > 0 ? amqp_cstring_bytes(exchange_name) : amqp_empty_bytes), - (keyname_len > 0 ? amqp_cstring_bytes(keyname) : amqp_empty_bytes), - (arguments ? *arguments : amqp_empty_table) - ); - - if (arguments) { - php_amqp_free_amqp_table(arguments); - } - - amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state); - - if (res.reply_type != AMQP_RESPONSE_NORMAL) { - PHP_AMQP_INIT_ERROR_MESSAGE(); - - php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, channel_resource->connection_resource, channel_resource TSRMLS_CC); - - php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC); - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - - PHP_AMQP_DESTROY_ERROR_MESSAGE(); - return; - } - - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - - RETURN_TRUE; -} -/* }}} */ - - -/* {{{ proto int AMQPQueue::get([bit flags=AMQP_NOPARAM]); -read messages from queue -return array (messages) -*/ -PHP_METHOD(amqp_queue_class, get) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - - amqp_channel_resource *channel_resource; - - PHP5to7_zval_t message PHP5to7_MAYBE_SET_TO_NULL; - PHP5to7_zval_t retval PHP5to7_MAYBE_SET_TO_NULL; - - PHP5to7_param_long_type_t flags = INI_INT("amqp.auto_ack") ? AMQP_AUTOACK : AMQP_NOPARAM; - - /* Parse out the method parameters */ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &flags) == FAILURE) { - return; - } - - channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel")); - PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not get messages from queue."); - - amqp_rpc_reply_t res = amqp_basic_get( - channel_resource->connection_resource->connection_state, - channel_resource->channel_id, - amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STR("name")), - (AMQP_AUTOACK & flags) ? 1 : 0 - ); - - if (res.reply_type != AMQP_RESPONSE_NORMAL) { - PHP_AMQP_INIT_ERROR_MESSAGE(); - - php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, channel_resource->connection_resource, channel_resource TSRMLS_CC); - - php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC); - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - - PHP_AMQP_DESTROY_ERROR_MESSAGE(); - return; - } - - if (AMQP_BASIC_GET_EMPTY_METHOD == res.reply.id) { - RETURN_FALSE; - } - - assert(AMQP_BASIC_GET_OK_METHOD == res.reply.id); - - /* Fill the envelope from response */ - amqp_basic_get_ok_t *get_ok_method = res.reply.decoded; - - amqp_envelope_t envelope; - - envelope.channel = channel_resource->channel_id; - envelope.consumer_tag = amqp_empty_bytes; - envelope.delivery_tag = get_ok_method->delivery_tag; - envelope.redelivered = get_ok_method->redelivered; - envelope.exchange = amqp_bytes_malloc_dup(get_ok_method->exchange); - envelope.routing_key = amqp_bytes_malloc_dup(get_ok_method->routing_key); - - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - - res = amqp_read_message( - channel_resource->connection_resource->connection_state, - channel_resource->channel_id, - &envelope.message, - 0 - ); - - if (AMQP_RESPONSE_NORMAL != res.reply_type) { - PHP_AMQP_INIT_ERROR_MESSAGE(); - - php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, channel_resource->connection_resource, channel_resource TSRMLS_CC); - - php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC); - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - - amqp_destroy_envelope(&envelope); - PHP_AMQP_DESTROY_ERROR_MESSAGE(); - return; - } - - PHP5to7_MAYBE_INIT(message); - - convert_amqp_envelope_to_zval(&envelope, PHP5to7_MAYBE_PTR(message) TSRMLS_CC); - - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - amqp_destroy_envelope(&envelope); - - RETVAL_ZVAL(PHP5to7_MAYBE_PTR(message), 1, 0); - PHP5to7_MAYBE_DESTROY(message); -} -/* }}} */ - - -/* {{{ proto array AMQPQueue::consume([callback, flags = , consumer_tag]); -consume the message -*/ -PHP_METHOD(amqp_queue_class, consume) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - - amqp_channel_resource *channel_resource; - - zend_fcall_info fci = empty_fcall_info; - zend_fcall_info_cache fci_cache = empty_fcall_info_cache; - - amqp_table_t *arguments; - - char *consumer_tag = NULL; PHP5to7_param_str_len_type_t consumer_tag_len = 0; - PHP5to7_param_long_type_t flags = INI_INT("amqp.auto_ack") ? AMQP_AUTOACK : AMQP_NOPARAM; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|f!ls", - &fci, &fci_cache, - &flags, - &consumer_tag, &consumer_tag_len) == FAILURE) { - return; - } - - channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel")); - PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not get channel."); - - if (!(AMQP_JUST_CONSUME & flags)) { - /* Setup the consume */ - arguments = convert_zval_to_amqp_table(PHP_AMQP_READ_THIS_PROP("arguments") TSRMLS_CC); - - amqp_basic_consume_ok_t *r = amqp_basic_consume( - channel_resource->connection_resource->connection_state, - channel_resource->channel_id, - amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STR("name")), - (consumer_tag_len > 0 ? amqp_cstring_bytes(consumer_tag) : amqp_empty_bytes), /* Consumer tag */ - (AMQP_NOLOCAL & flags) ? 1 : 0, /* No local */ - (AMQP_AUTOACK & flags) ? 1 : 0, /* no_ack, aka AUTOACK */ - PHP_AMQP_READ_THIS_PROP_BOOL("exclusive"), - *arguments - ); - - php_amqp_free_amqp_table(arguments); - - if (!r) { - amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state); - - PHP_AMQP_INIT_ERROR_MESSAGE(); - - php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, channel_resource->connection_resource, channel_resource TSRMLS_CC); - - zend_throw_exception(amqp_queue_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC); - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - - PHP_AMQP_DESTROY_ERROR_MESSAGE(); - return; - } - - /* Set the consumer tag name, in case it is an autogenerated consumer tag name */ - zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("consumer_tag"), (const char *) r->consumer_tag.bytes, (PHP5to7_param_str_len_type_t) r->consumer_tag.len TSRMLS_CC); - } - - if (!ZEND_FCI_INITIALIZED(fci)) { - /* Callback not set, we have nothing to do - real consuming may happens later */ - return; - } - - struct timeval tv = {0}; - struct timeval *tv_ptr = &tv; - - double read_timeout = PHP_AMQP_READ_OBJ_PROP_DOUBLE(amqp_connection_class_entry, PHP_AMQP_READ_THIS_PROP("connection"), "read_timeout"); - - if (read_timeout > 0) { - tv.tv_sec = (long int) read_timeout; - tv.tv_usec = (long int) ((read_timeout - tv.tv_sec) * 1000000); - } else { - tv_ptr = NULL; - } - - while(1) { - /* Initialize the message */ - PHP5to7_zval_t message PHP5to7_MAYBE_SET_TO_NULL; - - amqp_envelope_t envelope; - - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - - amqp_rpc_reply_t res = amqp_consume_message(channel_resource->connection_resource->connection_state, &envelope, tv_ptr, 0); - - if (AMQP_RESPONSE_LIBRARY_EXCEPTION == res.reply_type && AMQP_STATUS_TIMEOUT == res.library_error) { - PHP_AMQP_INIT_ERROR_MESSAGE(); - - zend_throw_exception(amqp_queue_exception_class_entry, "Consumer timeout exceed", 0 TSRMLS_CC); - - amqp_destroy_envelope(&envelope); - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - - PHP_AMQP_DESTROY_ERROR_MESSAGE(); - return; - } - - if (AMQP_RESPONSE_NORMAL != res.reply_type) { - PHP_AMQP_INIT_ERROR_MESSAGE(); - - php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, channel_resource->connection_resource, channel_resource TSRMLS_CC); - - php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC); - - amqp_destroy_envelope(&envelope); - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - - PHP_AMQP_DESTROY_ERROR_MESSAGE(); - return; - } - - PHP5to7_MAYBE_INIT(message); - convert_amqp_envelope_to_zval(&envelope, PHP5to7_MAYBE_PTR(message) TSRMLS_CC); - - amqp_destroy_envelope(&envelope); - - /* Make the callback */ - PHP5to7_zval_t params PHP5to7_MAYBE_SET_TO_NULL; - PHP5to7_zval_t retval PHP5to7_MAYBE_SET_TO_NULL; - - /* Build the parameter array */ - PHP5to7_MAYBE_INIT(params); - PHP5to7_ARRAY_INIT(params); - - /* Dump it into the params array */ - add_index_zval(PHP5to7_MAYBE_PTR(params), 0, PHP5to7_MAYBE_PTR(message)); - Z_ADDREF_P( PHP5to7_MAYBE_PTR(message)); - - /* Add a pointer to the queue: */ - add_index_zval(PHP5to7_MAYBE_PTR(params), 1, getThis()); - Z_ADDREF_P(getThis()); - - /* Convert everything to be callable */ - zend_fcall_info_args(&fci, PHP5to7_MAYBE_PTR(params) TSRMLS_CC); - /* Initialize the return value pointer */ - - PHP5to7_SET_FCI_RETVAL_PTR(fci, PHP5to7_MAYBE_PTR(retval)); - - /* Call the function, and track the return value */ - if (zend_call_function(&fci, &fci_cache TSRMLS_CC) == SUCCESS && PHP5to7_CHECK_FCI_RETVAL_PTR(fci)) { - RETVAL_ZVAL(PHP5to7_MAYBE_PTR(retval), 1, 1); - } - - /* Clean up our mess */ - zend_fcall_info_args_clear(&fci, 1); - PHP5to7_MAYBE_DESTROY(params); - PHP5to7_MAYBE_DESTROY(message); - - /* Check if user land function wants to bail */ - if (EG(exception) || PHP5to7_IS_FALSE_P(return_value)) { - break; - } - } - - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - return; -} -/* }}} */ - - -/* {{{ proto int AMQPQueue::ack(long deliveryTag, [bit flags=AMQP_NOPARAM]); - acknowledge the message -*/ -PHP_METHOD(amqp_queue_class, ack) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - - amqp_channel_resource *channel_resource; - - PHP5to7_param_long_type_t deliveryTag = 0; - PHP5to7_param_long_type_t flags = AMQP_NOPARAM; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|l", &deliveryTag, &flags ) == FAILURE) { - return; - } - - channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel")); - PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not ack message."); - - /* NOTE: basic.ack is asynchronous and thus will not indicate failure if something goes wrong on the broker */ - int status = amqp_basic_ack( - channel_resource->connection_resource->connection_state, - channel_resource->channel_id, - (uint64_t) deliveryTag, - (AMQP_MULTIPLE & flags) ? 1 : 0 - ); - - if (status != AMQP_STATUS_OK) { - /* Emulate library error */ - amqp_rpc_reply_t res; - res.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION; - res.library_error = status; - - PHP_AMQP_INIT_ERROR_MESSAGE(); - - php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, channel_resource->connection_resource, channel_resource TSRMLS_CC); - - php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC); - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - - PHP_AMQP_DESTROY_ERROR_MESSAGE(); - return; - } - - RETURN_TRUE; -} -/* }}} */ - - -/* {{{ proto int AMQPQueue::nack(long deliveryTag, [bit flags=AMQP_NOPARAM]); - acknowledge the message -*/ -PHP_METHOD(amqp_queue_class, nack) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - - amqp_channel_resource *channel_resource; - - PHP5to7_param_long_type_t deliveryTag = 0; - PHP5to7_param_long_type_t flags = AMQP_NOPARAM; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|l", &deliveryTag, &flags ) == FAILURE) { - return; - } - - channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel")); - PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not nack message."); - - /* NOTE: basic.nack is asynchronous and thus will not indicate failure if something goes wrong on the broker */ - int status = amqp_basic_nack( - channel_resource->connection_resource->connection_state, - channel_resource->channel_id, - (uint64_t) deliveryTag, - (AMQP_MULTIPLE & flags) ? 1 : 0, - (AMQP_REQUEUE & flags) ? 1 : 0 - ); - - if (status != AMQP_STATUS_OK) { - /* Emulate library error */ - amqp_rpc_reply_t res; - res.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION; - res.library_error = status; - - PHP_AMQP_INIT_ERROR_MESSAGE(); - - php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, channel_resource->connection_resource, channel_resource TSRMLS_CC); - - php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC); - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - - PHP_AMQP_DESTROY_ERROR_MESSAGE(); - return; - } - - RETURN_TRUE; -} -/* }}} */ - - -/* {{{ proto int AMQPQueue::reject(long deliveryTag, [bit flags=AMQP_NOPARAM]); - acknowledge the message -*/ -PHP_METHOD(amqp_queue_class, reject) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - - amqp_channel_resource *channel_resource; - - PHP5to7_param_long_type_t deliveryTag = 0; - PHP5to7_param_long_type_t flags = AMQP_NOPARAM; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|l", &deliveryTag, &flags) == FAILURE) { - return; - } - - channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel")); - PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not reject message."); - - /* NOTE: basic.reject is asynchronous and thus will not indicate failure if something goes wrong on the broker */ - int status = amqp_basic_reject( - channel_resource->connection_resource->connection_state, - channel_resource->channel_id, - (uint64_t) deliveryTag, - (AMQP_REQUEUE & flags) ? 1 : 0 - ); - - if (status != AMQP_STATUS_OK) { - /* Emulate library error */ - amqp_rpc_reply_t res; - res.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION; - res.library_error = status; - - PHP_AMQP_INIT_ERROR_MESSAGE(); - - php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, channel_resource->connection_resource, channel_resource TSRMLS_CC); - - php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC); - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - - PHP_AMQP_DESTROY_ERROR_MESSAGE(); - return; - } - - RETURN_TRUE; -} -/* }}} */ - - -/* {{{ proto int AMQPQueue::purge(); -purge queue -*/ -PHP_METHOD(amqp_queue_class, purge) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - - amqp_channel_resource *channel_resource; - - if (zend_parse_parameters_none() == FAILURE) { - return; - } - - channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel")); - PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not purge queue."); - - amqp_queue_purge_ok_t *r = amqp_queue_purge( - channel_resource->connection_resource->connection_state, - channel_resource->channel_id, - amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STR("name")) - ); - - if (!r) { - amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state); - - PHP_AMQP_INIT_ERROR_MESSAGE(); - - php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, channel_resource->connection_resource, channel_resource TSRMLS_CC); - - php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC); - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - - PHP_AMQP_DESTROY_ERROR_MESSAGE(); - return; - } - - /* long message_count = r->message_count; */ - - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - - /* RETURN_LONG(message_count) */; - - /* BC */ - RETURN_TRUE; -} -/* }}} */ - - -/* {{{ proto int AMQPQueue::cancel([string consumer_tag]); -cancel queue to consumer -*/ -PHP_METHOD(amqp_queue_class, cancel) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - - amqp_channel_resource *channel_resource; - - char *consumer_tag = NULL; PHP5to7_param_str_len_type_t consumer_tag_len = 0; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &consumer_tag, &consumer_tag_len) == FAILURE) { - return; - } - - channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel")); - PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not cancel queue."); - - if (!consumer_tag_len && !PHP_AMQP_READ_THIS_PROP_STRLEN("consumer_tag")) { - return; - } - - amqp_basic_cancel_ok_t *r = amqp_basic_cancel( - channel_resource->connection_resource->connection_state, - channel_resource->channel_id, - consumer_tag_len > 0 ? amqp_cstring_bytes(consumer_tag) : amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STR("consumer_tag")) - ); - - if (!r) { - amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state); - - PHP_AMQP_INIT_ERROR_MESSAGE(); - - php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, channel_resource->connection_resource, channel_resource TSRMLS_CC); - - php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC); - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - - PHP_AMQP_DESTROY_ERROR_MESSAGE(); - return; - } - - if (!consumer_tag_len || strcmp(consumer_tag, PHP_AMQP_READ_THIS_PROP_STR("consumer_tag")) != 0) { - zend_update_property_null(this_ce, getThis(), ZEND_STRL("consumer_tag") TSRMLS_CC); - } - - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - - RETURN_TRUE; -} -/* }}} */ - - -/* {{{ proto int AMQPQueue::unbind(string exchangeName, [string routingKey, array arguments]); -unbind queue from exchange -*/ -PHP_METHOD(amqp_queue_class, unbind) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - - zval *zvalArguments = NULL; - amqp_channel_resource *channel_resource; - - char *exchange_name; PHP5to7_param_str_len_type_t exchange_name_len; - char *keyname = NULL; PHP5to7_param_str_len_type_t keyname_len = 0; - - amqp_table_t *arguments = NULL; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|sa", - &exchange_name, &exchange_name_len, - &keyname, &keyname_len, - &zvalArguments) == FAILURE) { - return; - } - - channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel")); - PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not unbind queue."); - - if (zvalArguments) { - arguments = convert_zval_to_amqp_table(zvalArguments TSRMLS_CC); - } - - amqp_queue_unbind( - channel_resource->connection_resource->connection_state, - channel_resource->channel_id, - amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STR("name")), - (exchange_name_len > 0 ? amqp_cstring_bytes(exchange_name) : amqp_empty_bytes), - (keyname_len > 0 ? amqp_cstring_bytes(keyname) : amqp_empty_bytes), - (arguments ? *arguments : amqp_empty_table) - ); - - if (arguments) { - php_amqp_free_amqp_table(arguments); - } - - amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state); - - if (res.reply_type != AMQP_RESPONSE_NORMAL) { - PHP_AMQP_INIT_ERROR_MESSAGE(); - - php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, channel_resource->connection_resource, channel_resource TSRMLS_CC); - - php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC); - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - - PHP_AMQP_DESTROY_ERROR_MESSAGE(); - return; - } - - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - - RETURN_TRUE; -} -/* }}} */ - - -/* {{{ proto int AMQPQueue::delete([long flags = AMQP_NOPARAM]]); -delete queue and return the number of messages deleted in it -*/ -PHP_METHOD(amqp_queue_class, delete) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - - amqp_channel_resource *channel_resource; - - PHP5to7_param_long_type_t flags = AMQP_NOPARAM; - - PHP5to7_param_long_type_t message_count; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &flags) == FAILURE) { - return; - } - - channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel")); - PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not delete queue."); - - amqp_queue_delete_ok_t * r = amqp_queue_delete( - channel_resource->connection_resource->connection_state, - channel_resource->channel_id, - amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STR("name")), - (AMQP_IFUNUSED & flags) ? 1 : 0, - (AMQP_IFEMPTY & flags) ? 1 : 0 - ); - - if (!r) { - amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state); - - PHP_AMQP_INIT_ERROR_MESSAGE(); - - php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, channel_resource->connection_resource, channel_resource TSRMLS_CC); - - php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC); - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - - PHP_AMQP_DESTROY_ERROR_MESSAGE(); - return; - } - - message_count = r->message_count; - - php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); - - RETURN_LONG(message_count); -} -/* }}} */ - -/* {{{ proto AMQPChannel::getChannel() -Get the AMQPChannel object in use */ -PHP_METHOD(amqp_queue_class, getChannel) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - PHP_AMQP_NOPARAMS(); - PHP_AMQP_RETURN_THIS_PROP("channel"); -} -/* }}} */ - -/* {{{ proto AMQPChannel::getConnection() -Get the AMQPConnection object in use */ -PHP_METHOD(amqp_queue_class, getConnection) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - PHP_AMQP_NOPARAMS(); - PHP_AMQP_RETURN_THIS_PROP("connection"); -} -/* }}} */ - -/* {{{ proto string AMQPChannel::getConsumerTag() -Get latest consumer tag*/ -PHP_METHOD(amqp_queue_class, getConsumerTag) -{ - PHP5to7_READ_PROP_RV_PARAM_DECL; - PHP_AMQP_NOPARAMS(); - PHP_AMQP_RETURN_THIS_PROP("consumer_tag"); -} - -/* }}} */ -/* amqp_queue_class ARG_INFO definition */ -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class__construct, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) - ZEND_ARG_OBJ_INFO(0, amqp_channel, AMQPChannel, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_getName, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_setName, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) - ZEND_ARG_INFO(0, queue_name) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_getFlags, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_setFlags, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) - ZEND_ARG_INFO(0, flags) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_getArgument, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) - ZEND_ARG_INFO(0, argument) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_getArguments, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_setArgument, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 2) - ZEND_ARG_INFO(0, key) - ZEND_ARG_INFO(0, value) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_hasArgument, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) - ZEND_ARG_INFO(0, key) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_setArguments, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) - ZEND_ARG_ARRAY_INFO(0, arguments, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_declareQueue, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_bind, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) - ZEND_ARG_INFO(0, exchange_name) - ZEND_ARG_INFO(0, routing_key) - ZEND_ARG_INFO(0, arguments) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_get, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) - ZEND_ARG_INFO(0, flags) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_consume, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) - ZEND_ARG_INFO(0, callback) - ZEND_ARG_INFO(0, flags) - ZEND_ARG_INFO(0, consumer_tag) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_ack, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) - ZEND_ARG_INFO(0, delivery_tag) - ZEND_ARG_INFO(0, flags) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_nack, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) - ZEND_ARG_INFO(0, delivery_tag) - ZEND_ARG_INFO(0, flags) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_reject, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) - ZEND_ARG_INFO(0, delivery_tag) - ZEND_ARG_INFO(0, flags) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_purge, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_cancel, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) - ZEND_ARG_INFO(0, consumer_tag) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_unbind, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) - ZEND_ARG_INFO(0, exchange_name) - ZEND_ARG_INFO(0, routing_key) - ZEND_ARG_INFO(0, arguments) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_delete, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) - ZEND_ARG_INFO(0, flags) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_getChannel, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_getConnection, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_getConsumerTag, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) -ZEND_END_ARG_INFO() - -zend_function_entry amqp_queue_class_functions[] = { - PHP_ME(amqp_queue_class, __construct, arginfo_amqp_queue_class__construct, ZEND_ACC_PUBLIC) - - PHP_ME(amqp_queue_class, getName, arginfo_amqp_queue_class_getName, ZEND_ACC_PUBLIC) - PHP_ME(amqp_queue_class, setName, arginfo_amqp_queue_class_setName, ZEND_ACC_PUBLIC) - - PHP_ME(amqp_queue_class, getFlags, arginfo_amqp_queue_class_getFlags, ZEND_ACC_PUBLIC) - PHP_ME(amqp_queue_class, setFlags, arginfo_amqp_queue_class_setFlags, ZEND_ACC_PUBLIC) - - PHP_ME(amqp_queue_class, getArgument, arginfo_amqp_queue_class_getArgument, ZEND_ACC_PUBLIC) - PHP_ME(amqp_queue_class, getArguments, arginfo_amqp_queue_class_getArguments, ZEND_ACC_PUBLIC) - PHP_ME(amqp_queue_class, setArgument, arginfo_amqp_queue_class_setArgument, ZEND_ACC_PUBLIC) - PHP_ME(amqp_queue_class, setArguments, arginfo_amqp_queue_class_setArguments, ZEND_ACC_PUBLIC) - PHP_ME(amqp_queue_class, hasArgument, arginfo_amqp_queue_class_hasArgument, ZEND_ACC_PUBLIC) - - PHP_ME(amqp_queue_class, declareQueue, arginfo_amqp_queue_class_declareQueue, ZEND_ACC_PUBLIC) - PHP_ME(amqp_queue_class, bind, arginfo_amqp_queue_class_bind, ZEND_ACC_PUBLIC) - - PHP_ME(amqp_queue_class, get, arginfo_amqp_queue_class_get, ZEND_ACC_PUBLIC) - PHP_ME(amqp_queue_class, consume, arginfo_amqp_queue_class_consume, ZEND_ACC_PUBLIC) - PHP_ME(amqp_queue_class, ack, arginfo_amqp_queue_class_ack, ZEND_ACC_PUBLIC) - PHP_ME(amqp_queue_class, nack, arginfo_amqp_queue_class_nack, ZEND_ACC_PUBLIC) - PHP_ME(amqp_queue_class, reject, arginfo_amqp_queue_class_reject, ZEND_ACC_PUBLIC) - PHP_ME(amqp_queue_class, purge, arginfo_amqp_queue_class_purge, ZEND_ACC_PUBLIC) - - PHP_ME(amqp_queue_class, cancel, arginfo_amqp_queue_class_cancel, ZEND_ACC_PUBLIC) - PHP_ME(amqp_queue_class, delete, arginfo_amqp_queue_class_delete, ZEND_ACC_PUBLIC) - PHP_ME(amqp_queue_class, unbind, arginfo_amqp_queue_class_unbind, ZEND_ACC_PUBLIC) - - PHP_ME(amqp_queue_class, getChannel, arginfo_amqp_queue_class_getChannel, ZEND_ACC_PUBLIC) - PHP_ME(amqp_queue_class, getConnection, arginfo_amqp_queue_class_getConnection, ZEND_ACC_PUBLIC) - PHP_ME(amqp_queue_class, getConsumerTag, arginfo_amqp_queue_class_getConsumerTag, ZEND_ACC_PUBLIC) - - PHP_MALIAS(amqp_queue_class, declare, declareQueue, arginfo_amqp_queue_class_declareQueue, ZEND_ACC_PUBLIC | ZEND_ACC_DEPRECATED) - - {NULL, NULL, NULL} /* Must be the last line in amqp_functions[] */ -}; - -PHP_MINIT_FUNCTION(amqp_queue) -{ - zend_class_entry ce; - - INIT_CLASS_ENTRY(ce, "AMQPQueue", amqp_queue_class_functions); - this_ce = zend_register_internal_class(&ce TSRMLS_CC); - - zend_declare_property_null(this_ce, ZEND_STRL("connection"), ZEND_ACC_PRIVATE TSRMLS_CC); - zend_declare_property_null(this_ce, ZEND_STRL("channel"), ZEND_ACC_PRIVATE TSRMLS_CC); - - zend_declare_property_stringl(this_ce, ZEND_STRL("name"), "", 0, ZEND_ACC_PRIVATE TSRMLS_CC); - zend_declare_property_null(this_ce, ZEND_STRL("consumer_tag"), ZEND_ACC_PRIVATE TSRMLS_CC); - - zend_declare_property_bool(this_ce, ZEND_STRL("passive"), 0, ZEND_ACC_PRIVATE TSRMLS_CC); - zend_declare_property_bool(this_ce, ZEND_STRL("durable"), 0, ZEND_ACC_PRIVATE TSRMLS_CC); - zend_declare_property_bool(this_ce, ZEND_STRL("exclusive"), 0, ZEND_ACC_PRIVATE TSRMLS_CC); - /* By default, the auto_delete flag should be set */ - zend_declare_property_bool(this_ce, ZEND_STRL("auto_delete"), 1, ZEND_ACC_PRIVATE TSRMLS_CC); - - - - zend_declare_property_null(this_ce, ZEND_STRL("arguments"), ZEND_ACC_PRIVATE TSRMLS_CC); - - return SUCCESS; -} - -/* -*Local variables: -*tab-width: 4 -*tabstop: 4 -*c-basic-offset: 4 -*End: -*vim600: noet sw=4 ts=4 fdm=marker -*vim<600: noet sw=4 ts=4 -*/ diff -Nru php-amqp-1.7.1/amqp-1.7.1/amqp_queue.h php-amqp-1.9.3/amqp-1.7.1/amqp_queue.h --- php-amqp-1.7.1/amqp-1.7.1/amqp_queue.h 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/amqp_queue.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2007 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 | - | Lead: | - | - Pieter de Zwart | - | Maintainers: | - | - Brad Rodriguez | - | - Jonathan Tansavatdi | - +----------------------------------------------------------------------+ -*/ - -/* $Id: amqp_queue.h 321959 2012-01-09 17:56:10Z pdezwart $ */ - -extern zend_class_entry *amqp_queue_class_entry; - -PHP_METHOD(amqp_queue_class, __construct); - -PHP_METHOD(amqp_queue_class, getName); -PHP_METHOD(amqp_queue_class, setName); - -PHP_METHOD(amqp_queue_class, getFlags); -PHP_METHOD(amqp_queue_class, setFlags); - -PHP_METHOD(amqp_queue_class, getArgument); -PHP_METHOD(amqp_queue_class, getArguments); -PHP_METHOD(amqp_queue_class, setArgument); -PHP_METHOD(amqp_queue_class, setArguments); -PHP_METHOD(amqp_queue_class, hasArgument); - -PHP_METHOD(amqp_queue_class, declareQueue); -PHP_METHOD(amqp_queue_class, bind); - -PHP_METHOD(amqp_queue_class, get); -PHP_METHOD(amqp_queue_class, consume); -PHP_METHOD(amqp_queue_class, ack); -PHP_METHOD(amqp_queue_class, nack); -PHP_METHOD(amqp_queue_class, reject); -PHP_METHOD(amqp_queue_class, purge); - -PHP_METHOD(amqp_queue_class, cancel); -PHP_METHOD(amqp_queue_class, unbind); -PHP_METHOD(amqp_queue_class, delete); - -PHP_METHOD(amqp_queue_class, getChannel); -PHP_METHOD(amqp_queue_class, getConnection); -PHP_METHOD(amqp_queue_class, getConsumerTag); - -PHP_MINIT_FUNCTION(amqp_queue); - -/* -*Local variables: -*tab-width: 4 -*c-basic-offset: 4 -*End: -*vim600: noet sw=4 ts=4 fdm=marker -*vim<600: noet sw=4 ts=4 -*/ diff -Nru php-amqp-1.7.1/amqp-1.7.1/benchmark.php php-amqp-1.9.3/amqp-1.7.1/benchmark.php --- php-amqp-1.7.1/amqp-1.7.1/benchmark.php 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/benchmark.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,102 +0,0 @@ -getVersion().')'; -} catch (Exception $e) { - $xdebug = '(without xdebug)'; -} - -$ext = new ReflectionExtension('amqp'); -$srcVersion = $ext->getVersion(); - -echo 'Running benchmark for php-amqp ', $srcVersion, ' on PHP ', PHP_VERSION, ' ', $xdebug, PHP_EOL; - -$iterations = 10000; - -if (isset($argv[1])) { - $iterations = max((int) $argv[1], 0) ?: $iterations; -} -echo ' running ', $iterations, ' iterations:', PHP_EOL, PHP_EOL; - - -$conn = new AMQPConnection(); -$conn->connect(); - -$ch = new AMQPChannel($conn); - -$exchange = new AMQPExchange($ch); -$exchange->setType(AMQP_EX_TYPE_FANOUT); -$exchange->setFlags(AMQP_AUTODELETE); -$exchange->setName('benchmark_exchange_' . microtime(true)); -$exchange->declareExchange(); - -$q = new AMQPQueue($ch); -$q->setFlags(AMQP_AUTODELETE); -$q->declareQueue(); -$q->bind($exchange->getName()); - - -$message = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."; - -$timer = microtime(true); -for ($i = 0; $i < $iterations; $i++) { - $exchange->publish($message); -} -$timer = microtime(true) - $timer; - -echo 'Publish: ', $iterations, ' iterations took ', $timer, 'sec', PHP_EOL; - - -$timer = microtime(true); -for ($i = 0; $i < $iterations; $i++) { - if (!$q->get(AMQP_AUTOACK)) { - echo 'GET failed', PHP_EOL; - } -} -$timer = microtime(true) - $timer; - -echo ' Get: ', $iterations, ' iterations took ', $timer, 'sec', PHP_EOL; - -$q->delete(); -$exchange->delete(); - -echo PHP_EOL; -// ================================== - - -$exchange = new AMQPExchange($ch); -$exchange->setType(AMQP_EX_TYPE_FANOUT); -$exchange->setFlags(AMQP_AUTODELETE); -$exchange->setName('benchmark_exchange_' . microtime(true)); -$exchange->declareExchange(); - -$q = new AMQPQueue($ch); -$q->setFlags(AMQP_AUTODELETE); -$q->declareQueue(); -$q->bind($exchange->getName()); - -$timer = microtime(true); -for ($i = 0; $i < $iterations; $i++) { - $exchange->publish($message); -} -$timer = microtime(true) - $timer; - -echo 'Publish: ', $iterations, ' iterations took ', $timer, 'sec', PHP_EOL; - -$consumer_iterations = $iterations; - -$timer = microtime(true); -$q->consume( - function () use (&$consumer_iterations) { - return (--$consumer_iterations > 0); - }, - AMQP_AUTOACK); -$timer = microtime(true) - $timer; - -echo 'Consume: ', $iterations, ' iterations took ', $timer, 'sec', PHP_EOL; - -$q->delete(); -$exchange->delete(); diff -Nru php-amqp-1.7.1/amqp-1.7.1/config.m4 php-amqp-1.9.3/amqp-1.7.1/config.m4 --- php-amqp-1.7.1/amqp-1.7.1/config.m4 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/config.m4 1970-01-01 00:00:00.000000000 +0000 @@ -1,157 +0,0 @@ -dnl $Id: config.m4 322428 2012-01-17 21:42:40Z pdezwart $ -dnl config.m4 for extension amqp - -dnl Comments in this file start with the string 'dnl'. -dnl Remove where necessary. This file will not work -dnl without editing. -dnl amqp -dnl If your extension references something external, use with: - - -dnl Make sure that the comment is aligned: -PHP_ARG_WITH(amqp, for amqp support, -[ --with-amqp Include amqp support]) - -PHP_ARG_WITH(librabbitmq-dir, for amqp, -[ --with-librabbitmq-dir[=DIR] Set the path to librabbitmq install prefix.], yes) - - -if test "$PHP_AMQP" != "no"; then - dnl Write more examples of tests here... - - AC_MSG_RESULT($PHP_AMQP) - - dnl # --with-amqp -> check with-path - - SEARCH_FOR="amqp_framing.h" - AC_PATH_PROG(PKG_CONFIG, pkg-config, no) - - if test "$PHP_LIBRABBITMQ_DIR" = "yes" -a -x $PKG_CONFIG; then - AC_MSG_CHECKING([for amqp using pkg-config]) - - if ! $PKG_CONFIG --exists librabbitmq ; then - AC_MSG_ERROR([librabbitmq not found]) - fi - - PHP_AMQP_VERSION=`$PKG_CONFIG librabbitmq --modversion` - AC_MSG_RESULT([found version $PHP_AMQP_VERSION]) - - if ! $PKG_CONFIG librabbitmq --atleast-version 0.5.2 ; then - AC_MSG_ERROR([librabbitmq must be version 0.5.2 or greater]) - fi - if ! $PKG_CONFIG librabbitmq --atleast-version 0.6.0 ; then - AC_MSG_WARN([librabbitmq 0.6.0 or greater recommended]) - fi - - PHP_AMQP_LIBS=`$PKG_CONFIG librabbitmq --libs` - PHP_AMQP_INCS=`$PKG_CONFIG librabbitmq --cflags` - - PHP_EVAL_LIBLINE($PHP_AMQP_LIBS, AMQP_SHARED_LIBADD) - PHP_EVAL_INCLINE($PHP_AMQP_INCS) - - else - AC_MSG_CHECKING([for amqp files in default path]) - if test "$PHP_LIBRABBITMQ_DIR" != "no" && test "$PHP_LIBRABBITMQ_DIR" != "yes"; then - for i in $PHP_LIBRABBITMQ_DIR; do - if test -r $i/include/$SEARCH_FOR; - then - AMQP_DIR=$i - AC_MSG_RESULT(found in $i) - break - fi - done - else - for i in $PHP_AMQP /usr/local /usr ; do - if test -r $i/include/$SEARCH_FOR; - then - AMQP_DIR=$i - AC_MSG_RESULT(found in $i) - break - fi - done - fi - - if test -z "$AMQP_DIR"; then - AC_MSG_RESULT([not found]) - AC_MSG_ERROR([Please reinstall the librabbitmq distribution itself or (re)install librabbitmq development package if it available in your system]) - fi - - dnl # --with-amqp -> add include path - PHP_ADD_INCLUDE($AMQP_DIR/include) - - old_CFLAGS=$CFLAGS - CFLAGS="$CFLAGS -I$AMQP_DIR/include" - - AC_CACHE_CHECK(for librabbitmq version, ac_cv_librabbitmq_version, [ - AC_TRY_RUN([ - #include "amqp.h" - #include - - int main () - { - FILE *testfile = fopen("conftestval", "w"); - - if (NULL == testfile) { - return 1; - } - - fprintf(testfile, "%s\n", AMQ_VERSION_STRING); - fclose(testfile); - - return 0; - } - ], [ac_cv_librabbitmq_version=`cat ./conftestval`], [ac_cv_librabbitmq_version=NONE], [ac_cv_librabbitmq_version=NONE]) - ]) - - CFLAGS=$old_CFLAGS - - if test "$ac_cv_librabbitmq_version" != "NONE"; then - ac_IFS=$IFS - IFS=. - set $ac_cv_librabbitmq_version - IFS=$ac_IFS - LIBRABBITMQ_API_VERSION=`expr [$]1 \* 1000000 + [$]2 \* 1000 + [$]3` - - if test "$LIBRABBITMQ_API_VERSION" -lt 5001 ; then - AC_MSG_ERROR([librabbitmq must be version 0.5.2 or greater, $ac_cv_librabbitmq_version version given instead]) - fi - - if test "$LIBRABBITMQ_API_VERSION" -lt 6000 ; then - AC_MSG_WARN([librabbitmq 0.6.0 or greater recommended, current version is $ac_cv_librabbitmq_version]) - fi - else - AC_MSG_ERROR([could not determine librabbitmq version]) - fi - - dnl # --with-amqp -> check for lib and symbol presence - LIBNAME=rabbitmq - LIBSYMBOL=rabbitmq - - PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $AMQP_DIR/$PHP_LIBDIR, AMQP_SHARED_LIBADD) - fi - PHP_SUBST(AMQP_SHARED_LIBADD) - - if test -z "$TRAVIS" ; then - type git &>/dev/null - - if test $? -eq 0 ; then - git describe --abbrev=0 --tags &>/dev/null - - if test $? -eq 0 ; then - AC_DEFINE_UNQUOTED([PHP_AMQP_VERSION], ["`git describe --abbrev=0 --tags`-`git rev-parse --abbrev-ref HEAD`-dev"], [git version]) - fi - - git rev-parse --short HEAD &>/dev/null - - if test $? -eq 0 ; then - AC_DEFINE_UNQUOTED([PHP_AMQP_REVISION], ["`git rev-parse --short HEAD`"], [git revision]) - fi - else - AC_MSG_NOTICE([git not installed. Cannot obtain php_amqp version tag. Install git.]) - fi - fi - - AMQP_SOURCES="amqp.c amqp_exchange.c amqp_queue.c amqp_connection.c amqp_connection_resource.c amqp_channel.c amqp_envelope.c" - - PHP_NEW_EXTENSION(amqp, $AMQP_SOURCES, $ext_shared) -fi diff -Nru php-amqp-1.7.1/amqp-1.7.1/config.w32 php-amqp-1.9.3/amqp-1.7.1/config.w32 --- php-amqp-1.7.1/amqp-1.7.1/config.w32 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/config.w32 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -ARG_WITH("amqp", "AMQP support", "no"); - -if (PHP_AMQP != "no") { - if (CHECK_HEADER_ADD_INCLUDE("amqp.h", "CFLAGS_AMQP", PHP_PHP_BUILD + "\\include;" + PHP_AMQP) && - CHECK_LIB("rabbitmq.4.lib", "amqp", PHP_PHP_BUILD + "\\lib;" + PHP_AMQP)) { -// ADD_FLAG("CFLAGS_AMQP", "/D HAVE_AMQP_GETSOCKOPT"); - EXTENSION('amqp', 'amqp.c amqp_exchange.c amqp_queue.c amqp_connection.c amqp_connection_resource.c amqp_channel.c amqp_envelope.c'); - AC_DEFINE('HAVE_AMQP', 1); - } else { - WARNING("amqp not enabled; libraries and headers not found"); - } -} diff -Nru php-amqp-1.7.1/amqp-1.7.1/CREDITS php-amqp-1.9.3/amqp-1.7.1/CREDITS --- php-amqp-1.7.1/amqp-1.7.1/CREDITS 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/CREDITS 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -AMQP bindings for PHP -All who contributed to php-amqp project -Alexandre Kalendarev (original author) -Pieter de Zwart (lead) -Andrey Hristov (contributor) -Brad Rodriguez (contributor) -John Skopis (contributor - PHP < 5.3 compatibility) -Andy Wick (contributor - bug fixes, custom headers support) -Jonathan Tansavatdi (contributor) -Bernhard Weisshuhn (maintainer) -Lars Strojny (maintainer) -Anatoliy Belsky (contributor) -Alex Sladkov (contributor) -Vladimir Kartaviy (contributor) -Florin Patan (reported) -Ilya a.k.a. coodix (contributor) -Bogdan Padalko (contributor) -Dmitry Vinogradov (contributor) -Peter Hansen (contributor) -Michael K. Squires (contributor) \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.7.1/LICENSE php-amqp-1.9.3/amqp-1.7.1/LICENSE --- php-amqp-1.7.1/amqp-1.7.1/LICENSE 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/LICENSE 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ --------------------------------------------------------------------- - The PHP License, version 3.01 -Copyright (c) 1999 - 2012 The PHP Group. All rights reserved. --------------------------------------------------------------------- - -Redistribution and use in source and binary forms, with or without -modification, is permitted provided that the following conditions -are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - 3. The name "PHP" must not be used to endorse or promote products - derived from this software without prior written permission. For - written permission, please contact group@php.net. - - 4. Products derived from this software may not be called "PHP", nor - may "PHP" appear in their name, without prior written permission - from group@php.net. You may indicate that your software works in - conjunction with PHP by saying "Foo for PHP" instead of calling - it "PHP Foo" or "phpfoo" - - 5. The PHP Group may publish revised and/or new versions of the - license from time to time. Each version will be given a - distinguishing version number. - Once covered code has been published under a particular version - of the license, you may always continue to use it under the terms - of that version. You may also choose to use such covered code - under the terms of any subsequent version of the license - published by the PHP Group. No one other than the PHP Group has - the right to modify the terms applicable to covered code created - under this License. - - 6. Redistributions of any form whatsoever must retain the following - acknowledgment: - "This product includes PHP software, freely available from - ". - -THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND -ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP -DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -OF THE POSSIBILITY OF SUCH DAMAGE. - --------------------------------------------------------------------- - -This software consists of voluntary contributions made by many -individuals on behalf of the PHP Group. - -The PHP Group can be contacted via Email at group@php.net. - -For more information on the PHP Group and the PHP project, -please see . - -PHP includes the Zend Engine, freely available at -. diff -Nru php-amqp-1.7.1/amqp-1.7.1/php5_support.h php-amqp-1.9.3/amqp-1.7.1/php5_support.h --- php-amqp-1.7.1/amqp-1.7.1/php5_support.h 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/php5_support.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,114 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2007 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 | - | Lead: | - | - Pieter de Zwart | - | Maintainers: | - | - Brad Rodriguez | - | - Jonathan Tansavatdi | - +----------------------------------------------------------------------+ -*/ - -#ifndef PHP_AMQP_PHP5_SUPPORT_H -#define PHP_AMQP_PHP5_SUPPORT_H - -typedef int PHP5to7_param_str_len_type_t; -typedef long PHP5to7_param_long_type_t; -typedef zval* PHP5to7_zval_t; - -#define PHP5to7_MAYBE_SET_TO_NULL = NULL - -#define PHP5to7_MAYBE_DEREF(zv) (*(zv)) -#define PHP5to7_MAYBE_PTR(zv) (zv) - -#define PHP5to7_MAYBE_INIT(zv) MAKE_STD_ZVAL(zv); -#define PHP5to7_ARRAY_INIT(zv) array_init(zv); -#define PHP5to7_MAYBE_DESTROY(zv) zval_ptr_dtor(&(zv)); - -#define PHP5to7_ZVAL_STRINGL_DUP(z, s, l) ZVAL_STRINGL((z), (s), (l), 1) - -#define PHP5to7_ADD_NEXT_INDEX_STRINGL_DUP(arg, str, length) add_next_index_stringl((arg), (str), (uint)(length), 1) - -#define PHP5to7_ZEND_HASH_FIND(ht, str, len, res) \ - (zend_hash_find((ht), (str), (uint)(len), (void **) &(res)) != FAILURE) - -#define PHP5to7_ZEND_HASH_DEL(ht, key, len) zend_hash_del_key_or_index((ht), (key), (uint)(len), 0, HASH_DEL_KEY); -#define PHP5to7_ZEND_HASH_ADD(ht, key, len, pData, nDataSize) (zend_hash_add((ht), (key), (uint)(len), &(pData), nDataSize, NULL) != FAILURE) -#define PHP5to7_ZEND_HASH_STR_UPD_MEM(ht, key, len, pData, nDataSize) PHP5to7_ZEND_HASH_ADD((ht), (key), (len), (pData), (nDataSize)) -#define PHP5to7_ZEND_HASH_STR_FIND_PTR(ht, key, len, res) PHP5to7_ZEND_HASH_FIND((ht), (key), (len), (res)) -#define PHP5to7_ZEND_HASH_STR_DEL(ht, key, len) PHP5to7_ZEND_HASH_DEL((ht), (key), (len)) - -#define PHP5to7_SET_FCI_RETVAL_PTR(fci, pzv) (fci).retval_ptr_ptr = &(pzv); -#define PHP5to7_CHECK_FCI_RETVAL_PTR(fci) ((fci).retval_ptr_ptr && *(fci).retval_ptr_ptr) - -#define PHP5to7_IS_FALSE_P(pzv) ((Z_TYPE_P(pzv) == IS_BOOL && !Z_BVAL_P(pzv))) - -#define PHP5to7_obj_free_zend_object void -#define PHP5to7_zend_object_value zend_object_value -#define PHP5to7_zend_register_internal_class_ex(ce, parent_ce) zend_register_internal_class_ex((ce), (parent_ce), NULL TSRMLS_CC) - -#define PHP5to7_ECALLOC_CONNECTION_OBJECT(ce) (amqp_connection_object*)ecalloc(1, sizeof(amqp_connection_object)) -#define PHP5to7_ECALLOC_CHANNEL_OBJECT(ce) (amqp_channel_object*)ecalloc(1, sizeof(amqp_channel_object)) - -#define PHP5to7_CASE_IS_BOOL case IS_BOOL - -#define PHP5to7_READ_PROP_RV_PARAM_DECL -#define PHP5to7_READ_PROP_RV_PARAM_CC - - -#define PHP5to7_ZEND_REAL_HASH_KEY_T void - -#define PHP5to7_ZEND_HASH_FOREACH_KEY_VAL(ht, num_key, real_key, key, key_len, data, val, pos) \ - for ( \ - zend_hash_internal_pointer_reset_ex((ht), &(pos)); \ - zend_hash_get_current_data_ex((ht), (void**) &(data), &(pos)) == SUCCESS && ((value) = *(data)); \ - zend_hash_move_forward_ex((ht), &(pos)) \ - ) - -#define PHP5to7_ZEND_HASH_KEY_IS_STRING(ht, real_key, key, key_len, num_key, pos) \ - (zend_hash_get_current_key_ex((ht), &(key), &(key_len), &(num_key), 0, &(pos)) == HASH_KEY_IS_STRING) - -#define PHP5to7_ZEND_HASH_KEY_MAYBE_UNPACK(real_key, key, key_len) - -#define PHP5to7_ZEND_HASH_FOREACH_CONTINUE continue -#define PHP5to7_ZEND_HASH_FOREACH_END() - -#define Z_TRY_ADDREF_P(pz) Z_ADDREF_P(pz) - -/* Resources stuff */ - -typedef int PHP5to7_zend_resource_t; -typedef zend_rsrc_list_entry PHP5to7_zend_resource_store_t; -typedef zend_rsrc_list_entry PHP5to7_zend_resource_le_t; - -#define PHP5to7_ZEND_RESOURCE_DTOR_ARG rsrc -#define Z_RES_P(le) (le) - -#define PHP5to7_ZEND_RESOURCE_EMPTY 0 -#define PHP5to7_ZEND_RESOURCE_LE_EMPTY NULL -#define PHP5to7_ZEND_RSRC_TYPE_P(le) Z_TYPE_P(le) -#define PHP5to7_ZEND_REGISTER_RESOURCE(rsrc_pointer, rsrc_type) ZEND_REGISTER_RESOURCE(NULL, (rsrc_pointer), (rsrc_type)) - - -#endif //PHP_AMQP_PHP5_SUPPORT_H - -/* -*Local variables: -*tab-width: 4 -*c-basic-offset: 4 -*End: -*vim600: noet sw=4 ts=4 fdm=marker -*vim<600: noet sw=4 ts=4 -*/ diff -Nru php-amqp-1.7.1/amqp-1.7.1/php7_support.h php-amqp-1.9.3/amqp-1.7.1/php7_support.h --- php-amqp-1.7.1/amqp-1.7.1/php7_support.h 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/php7_support.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,106 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2007 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 | - | Lead: | - | - Pieter de Zwart | - | Maintainers: | - | - Brad Rodriguez | - | - Jonathan Tansavatdi | - +----------------------------------------------------------------------+ -*/ - -#ifndef PHP_AMQP_PHP7_SUPPORT_H -#define PHP_AMQP_PHP7_SUPPORT_H - -typedef size_t PHP5to7_param_str_len_type_t; -typedef zend_long PHP5to7_param_long_type_t; -typedef zval PHP5to7_zval_t; - -#define PHP5to7_MAYBE_SET_TO_NULL - -#define PHP5to7_MAYBE_DEREF(zv) (zv) -#define PHP5to7_MAYBE_PTR(zv) (&(zv)) - -#define PHP5to7_MAYBE_INIT(zv) -#define PHP5to7_ARRAY_INIT(zv) array_init(&(zv)); -#define PHP5to7_MAYBE_DESTROY(zv) if (!Z_ISUNDEF(zv)) { zval_ptr_dtor(&(zv)); } - -#define PHP5to7_ZVAL_STRINGL_DUP(z, s, l) ZVAL_STRINGL((z), (s), (l)) -#define PHP5to7_ADD_NEXT_INDEX_STRINGL_DUP(arg, str, length) add_next_index_stringl((arg), (str), (size_t)(length)) - -#define PHP5to7_ZEND_HASH_FIND(ht, str, len, res) \ - ((res = zend_hash_str_find((ht), (str), (size_t)(len - 1))) != NULL) - -#define PHP5to7_ZEND_HASH_DEL(ht, key, len) zend_hash_str_del_ind((ht), (key), (uint)(len - 1)) -#define PHP5to7_ZEND_HASH_ADD(ht, key, len, pData, nDataSize) zend_hash_str_add((ht), (key), (uint)(len - 1), (pData)) -#define PHP5to7_ZEND_HASH_STR_UPD_MEM(ht, key, len, pData, nDataSize) zend_hash_str_update_mem((ht), (key), (size_t)(len), &(pData), (nDataSize)) -#define PHP5to7_ZEND_HASH_STR_FIND_PTR(ht, key, len, res) ((res = zend_hash_str_find_ptr((ht), (key), (size_t)(len))) != NULL) -#define PHP5to7_ZEND_HASH_STR_DEL(ht, key, len) zend_hash_str_del_ind((ht), (key), (uint)(len)) - -#define PHP5to7_SET_FCI_RETVAL_PTR(fci, pzv) (fci).retval = (pzv); -#define PHP5to7_CHECK_FCI_RETVAL_PTR(fci) ((fci).retval) - -#define PHP5to7_IS_FALSE_P(pzv) (Z_TYPE_P(return_value) == IS_FALSE) - -#define PHP5to7_obj_free_zend_object zend_object -#define PHP5to7_zend_object_value zend_object * -#define PHP5to7_zend_register_internal_class_ex(ce, parent_ce) zend_register_internal_class_ex((ce), (parent_ce) TSRMLS_CC) - -#define PHP5to7_ECALLOC_CONNECTION_OBJECT(ce) (amqp_connection_object*)ecalloc(1, sizeof(amqp_connection_object) + zend_object_properties_size(ce)) -#define PHP5to7_ECALLOC_CHANNEL_OBJECT(ce) (amqp_channel_object*)ecalloc(1, sizeof(amqp_channel_object) + zend_object_properties_size(ce)) - -#define PHP5to7_CASE_IS_BOOL case IS_TRUE: case IS_FALSE - -#define PHP5to7_READ_PROP_RV_PARAM_DECL zval rv; -#define PHP5to7_READ_PROP_RV_PARAM_CC , (&rv) - -#define Z_BVAL_P(zval_p) (Z_TYPE_P(zval_p) == IS_TRUE) - -#define PHP5to7_ZEND_REAL_HASH_KEY_T zend_string - -#define PHP5to7_ZEND_HASH_FOREACH_KEY_VAL(ht, num_key, real_key, key, key_len, data, val, pos) \ - ZEND_HASH_FOREACH_KEY_VAL((ht), (num_key), (real_key), (val)) - -#define PHP5to7_ZEND_HASH_KEY_IS_STRING(ht, real_key, key, key_len, num_key, pos) \ - (real_key) - -#define PHP5to7_ZEND_HASH_KEY_MAYBE_UNPACK(real_key, key, key_len) \ - (key_len) = ZSTR_LEN(real_key); \ - (key) = ZSTR_VAL(real_key); - -#define PHP5to7_ZEND_HASH_FOREACH_CONTINUE continue -#define PHP5to7_ZEND_HASH_FOREACH_END() ZEND_HASH_FOREACH_END(); - -/* Resources stuff */ -typedef zend_resource* PHP5to7_zend_resource_t; -typedef zend_resource PHP5to7_zend_resource_store_t; -typedef zval PHP5to7_zend_resource_le_t; - -#define PHP5to7_ZEND_RESOURCE_DTOR_ARG res -#define PHP5to7_ZEND_RESOURCE_EMPTY NULL -#define PHP5to7_ZEND_RESOURCE_LE_EMPTY NULL -#define PHP5to7_ZEND_RSRC_TYPE_P(le) (le)->type -#define PHP5to7_ZEND_REGISTER_RESOURCE(rsrc_pointer, rsrc_type) zend_register_resource((rsrc_pointer), (rsrc_type)) - -#endif //PHP_AMQP_PHP7_SUPPORT_H - -/* -*Local variables: -*tab-width: 4 -*c-basic-offset: 4 -*End: -*vim600: noet sw=4 ts=4 fdm=marker -*vim<600: noet sw=4 ts=4 -*/ diff -Nru php-amqp-1.7.1/amqp-1.7.1/php_amqp.h php-amqp-1.9.3/amqp-1.7.1/php_amqp.h --- php-amqp-1.7.1/amqp-1.7.1/php_amqp.h 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/php_amqp.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,345 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2007 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 | - | Lead: | - | - Pieter de Zwart | - | Maintainers: | - | - Brad Rodriguez | - | - Jonathan Tansavatdi | - +----------------------------------------------------------------------+ -*/ - -/* $Id: php_amqp.h 327551 2012-09-09 03:49:34Z pdezwart $ */ - -#ifndef PHP_AMQP_H -#define PHP_AMQP_H - - - -#include "amqp.h" - -#if PHP_MAJOR_VERSION >= 7 - #include "php7_support.h" -#else - #include "php5_support.h" -#endif - -extern zend_module_entry amqp_module_entry; -#define phpext_amqp_ptr &amqp_module_entry - -#ifdef PHP_WIN32 -#define PHP_AMQP_API __declspec(dllexport) -#else -#define PHP_AMQP_API -#endif - -#ifdef ZTS -#include "TSRM.h" -#endif - -#define AMQP_NOPARAM 0 -/* Where is 1?*/ -#define AMQP_JUST_CONSUME 1 -#define AMQP_DURABLE 2 -#define AMQP_PASSIVE 4 -#define AMQP_EXCLUSIVE 8 -#define AMQP_AUTODELETE 16 -#define AMQP_INTERNAL 32 -#define AMQP_NOLOCAL 64 -#define AMQP_AUTOACK 128 -#define AMQP_IFEMPTY 256 -#define AMQP_IFUNUSED 512 -#define AMQP_MANDATORY 1024 -#define AMQP_IMMEDIATE 2048 -#define AMQP_MULTIPLE 4096 -#define AMQP_NOWAIT 8192 -#define AMQP_REQUEUE 16384 - -/* passive, durable, auto-delete, internal, no-wait (see https://www.rabbitmq.com/amqp-0-9-1-reference.html#exchange.declare) */ -#define PHP_AMQP_EXCHANGE_FLAGS (AMQP_PASSIVE | AMQP_DURABLE | AMQP_AUTODELETE | AMQP_INTERNAL) - -/* passive, durable, exclusive, auto-delete, no-wait (see https://www.rabbitmq.com/amqp-0-9-1-reference.html#queue.declare) */ -/* We don't support no-wait flag */ -#define PHP_AMQP_QUEUE_FLAGS (AMQP_PASSIVE | AMQP_DURABLE | AMQP_EXCLUSIVE | AMQP_AUTODELETE) - -#define AMQP_EX_TYPE_DIRECT "direct" -#define AMQP_EX_TYPE_FANOUT "fanout" -#define AMQP_EX_TYPE_TOPIC "topic" -#define AMQP_EX_TYPE_HEADERS "headers" - -#define PHP_AMQP_CONNECTION_RES_NAME "AMQP Connection Resource" - -PHP_MINIT_FUNCTION(amqp); -PHP_MSHUTDOWN_FUNCTION(amqp); -PHP_MINFO_FUNCTION(amqp); - -amqp_table_t *convert_zval_to_amqp_table(zval *zvalArguments TSRMLS_DC); -void php_amqp_free_amqp_table(amqp_table_t * table); - -char *stringify_bytes(amqp_bytes_t bytes); - -/* True global resources - no need for thread safety here */ -extern zend_class_entry *amqp_exception_class_entry, - *amqp_connection_exception_class_entry, - *amqp_channel_exception_class_entry, - *amqp_exchange_exception_class_entry, - *amqp_queue_exception_class_entry; - - -typedef struct _amqp_connection_resource amqp_connection_resource; -typedef struct _amqp_connection_object amqp_connection_object; - -typedef struct _amqp_channel_resource { - char is_connected; - amqp_channel_t channel_id; - amqp_connection_resource *connection_resource; -} amqp_channel_resource; - -/* NOTE: due to how interanlly PHP works with custom object, zend_object position in structure matters */ - -typedef struct _amqp_channel_object { -#if PHP_MAJOR_VERSION >= 7 - amqp_channel_resource *channel_resource; - zend_object zo; -#else - zend_object zo; - amqp_channel_resource *channel_resource; -#endif -} amqp_channel_object; - -struct _amqp_connection_resource { - zend_bool is_connected; - zend_bool is_persistent; - zend_bool is_dirty; - PHP5to7_zend_resource_t resource; - amqp_connection_object *parent; - amqp_channel_t max_slots; - amqp_channel_t used_slots; - amqp_channel_resource **slots; - amqp_connection_state_t connection_state; - amqp_socket_t *socket; -}; - -struct _amqp_connection_object { -#if PHP_MAJOR_VERSION >= 7 - amqp_connection_resource *connection_resource; - zend_object zo; -#else - zend_object zo; - amqp_connection_resource *connection_resource; -#endif -}; - -#define DEFAULT_PORT "5672" /* default AMQP port */ -#define DEFAULT_HOST "localhost" -#define DEFAULT_TIMEOUT "" -#define DEFAULT_READ_TIMEOUT "0" -#define DEFAULT_WRITE_TIMEOUT "0" -#define DEFAULT_CONNECT_TIMEOUT "0" -#define DEFAULT_VHOST "/" -#define DEFAULT_LOGIN "guest" -#define DEFAULT_PASSWORD "guest" -#define DEFAULT_AUTOACK "0" /* These are all strings to facilitate setting default ini values */ -#define DEFAULT_PREFETCH_COUNT "3" - -/* Usually, default is 0 which means 65535, but underlying rabbitmq-c library pool allocates minimal pool for each channel, - * so it takes a lot of memory to keep all that channels. Even after channel closing that buffer still keep memory allocation. - */ -/* #define DEFAULT_CHANNELS_PER_CONNECTION AMQP_DEFAULT_MAX_CHANNELS */ -#define PHP_AMQP_PROTOCOL_MAX_CHANNELS 256 - -/* AMQP_DEFAULT_FRAME_SIZE 131072 */ - -#if PHP_AMQP_PROTOCOL_MAX_CHANNELS > 0 - #define PHP_AMQP_MAX_CHANNELS PHP_AMQP_PROTOCOL_MAX_CHANNELS -#else - #define PHP_AMQP_MAX_CHANNELS 65535 // Note that the maximum number of channels the protocol supports is 65535 (2^16, with the 0-channel reserved) -#endif - -#define PHP_AMQP_MAX_FRAME INT_MAX -#define PHP_AMQP_MAX_HEARTBEAT INT_MAX - -#define PHP_AMQP_DEFAULT_CHANNEL_MAX PHP_AMQP_MAX_CHANNELS -#define PHP_AMQP_DEFAULT_FRAME_MAX AMQP_DEFAULT_FRAME_SIZE -#define PHP_AMQP_DEFAULT_HEARTBEAT AMQP_DEFAULT_HEARTBEAT - -#define PHP_AMQP_STRINGIFY(value) PHP_AMQP_TO_STRING(value) -#define PHP_AMQP_TO_STRING(value) #value - - -#define DEFAULT_CHANNEL_MAX PHP_AMQP_STRINGIFY(PHP_AMQP_MAX_CHANNELS) -#define DEFAULT_FRAME_MAX PHP_AMQP_STRINGIFY(PHP_AMQP_DEFAULT_FRAME_MAX) -#define DEFAULT_HEARTBEAT PHP_AMQP_STRINGIFY(PHP_AMQP_DEFAULT_HEARTBEAT) - - -#define IS_PASSIVE(bitmask) (AMQP_PASSIVE & (bitmask)) ? 1 : 0 -#define IS_DURABLE(bitmask) (AMQP_DURABLE & (bitmask)) ? 1 : 0 -#define IS_EXCLUSIVE(bitmask) (AMQP_EXCLUSIVE & (bitmask)) ? 1 : 0 -#define IS_AUTODELETE(bitmask) (AMQP_AUTODELETE & (bitmask)) ? 1 : 0 -#define IS_INTERNAL(bitmask) (AMQP_INTERNAL & (bitmask)) ? 1 : 0 -#define IS_NOWAIT(bitmask) (AMQP_NOWAIT & (bitmask)) ? 1 : 0 /* NOTE: always 0 in rabbitmq-c internals, so don't use it unless you are clearly understand aftermath*/ - -#define PHP_AMQP_NOPARAMS() if (zend_parse_parameters_none() == FAILURE) { return; } - -#define PHP_AMQP_RETURN_THIS_PROP(prop_name) \ - zval * _zv = zend_read_property(this_ce, getThis(), ZEND_STRL(prop_name), 0 PHP5to7_READ_PROP_RV_PARAM_CC TSRMLS_CC); \ - RETURN_ZVAL(_zv, 1, 0); \ - -#define PHP_AMQP_READ_OBJ_PROP(cls, obj, name) zend_read_property((cls), (obj), ZEND_STRL(name), 0 PHP5to7_READ_PROP_RV_PARAM_CC TSRMLS_CC) -#define PHP_AMQP_READ_OBJ_PROP_DOUBLE(cls, obj, name) Z_DVAL_P(PHP_AMQP_READ_OBJ_PROP((cls), (obj), (name))) - -#define PHP_AMQP_READ_THIS_PROP(name) zend_read_property(this_ce, getThis(), ZEND_STRL(name), 0 PHP5to7_READ_PROP_RV_PARAM_CC TSRMLS_CC) -#define PHP_AMQP_READ_THIS_PROP_BOOL(name) Z_BVAL_P(PHP_AMQP_READ_THIS_PROP(name)) -#define PHP_AMQP_READ_THIS_PROP_STR(name) Z_STRVAL_P(PHP_AMQP_READ_THIS_PROP(name)) -#define PHP_AMQP_READ_THIS_PROP_STRLEN(name) (Z_TYPE_P(PHP_AMQP_READ_THIS_PROP(name)) == IS_STRING ? Z_STRLEN_P(PHP_AMQP_READ_THIS_PROP(name)) : 0) -#define PHP_AMQP_READ_THIS_PROP_ARR(name) Z_ARRVAL_P(PHP_AMQP_READ_THIS_PROP(name)) -#define PHP_AMQP_READ_THIS_PROP_LONG(name) Z_LVAL_P(PHP_AMQP_READ_THIS_PROP(name)) -#define PHP_AMQP_READ_THIS_PROP_DOUBLE(name) Z_DVAL_P(PHP_AMQP_READ_THIS_PROP(name)) - - -#if PHP_MAJOR_VERSION >= 7 - static inline amqp_connection_object *php_amqp_connection_object_fetch(zend_object *obj) { - return (amqp_connection_object *)((char *)obj - XtOffsetOf(amqp_connection_object, zo)); - } - - static inline amqp_channel_object *php_amqp_channel_object_fetch(zend_object *obj) { - return (amqp_channel_object *)((char *)obj - XtOffsetOf(amqp_channel_object, zo)); - } - - #define PHP_AMQP_GET_CONNECTION(obj) php_amqp_connection_object_fetch(Z_OBJ_P(obj)) - #define PHP_AMQP_GET_CHANNEL(obj) php_amqp_channel_object_fetch(Z_OBJ_P(obj)) - - #define PHP_AMQP_FETCH_CONNECTION(obj) php_amqp_connection_object_fetch(obj) - #define PHP_AMQP_FETCH_CHANNEL(obj) php_amqp_channel_object_fetch(obj) - -#else - #define PHP_AMQP_GET_CONNECTION(obj) (amqp_connection_object *)zend_object_store_get_object((obj) TSRMLS_CC) - #define PHP_AMQP_GET_CHANNEL(obj) (amqp_channel_object *)zend_object_store_get_object((obj) TSRMLS_CC) - - #define PHP_AMQP_FETCH_CONNECTION(obj) (amqp_connection_object*)(obj) - #define PHP_AMQP_FETCH_CHANNEL(obj) (amqp_channel_object*)(obj) -#endif - - -#define PHP_AMQP_GET_CHANNEL_RESOURCE(obj) (IS_OBJECT == Z_TYPE_P(obj) ? (PHP_AMQP_GET_CHANNEL(obj))->channel_resource : NULL) - -#define PHP_AMQP_VERIFY_CONNECTION_ERROR(error, reason) \ - char verify_connection_error_tmp[255]; \ - snprintf(verify_connection_error_tmp, 255, "%s %s", error, reason); \ - zend_throw_exception(amqp_connection_exception_class_entry, verify_connection_error_tmp, 0 TSRMLS_CC); \ - return; \ - -#define PHP_AMQP_VERIFY_CONNECTION(connection, error) \ - if (!connection) { \ - PHP_AMQP_VERIFY_CONNECTION_ERROR(error, "Stale reference to the connection object.") \ - } \ - if (!(connection)->connection_resource || !(connection)->connection_resource->is_connected) { \ - PHP_AMQP_VERIFY_CONNECTION_ERROR(error, "No connection available.") \ - } \ - -#define PHP_AMQP_VERIFY_CHANNEL_ERROR(error, reason) \ - char verify_channel_error_tmp[255]; \ - snprintf(verify_channel_error_tmp, 255, "%s %s", error, reason); \ - zend_throw_exception(amqp_channel_exception_class_entry, verify_channel_error_tmp, 0 TSRMLS_CC); \ - return; \ - -#define PHP_AMQP_VERIFY_CHANNEL_RESOURCE(resource, error) \ - if (!resource) { \ - PHP_AMQP_VERIFY_CHANNEL_ERROR(error, "Stale reference to the channel object.") \ - } \ - if (!(resource)->is_connected) { \ - PHP_AMQP_VERIFY_CHANNEL_ERROR(error, "No channel available.") \ - } \ - if (!(resource)->connection_resource) { \ - PHP_AMQP_VERIFY_CONNECTION_ERROR(error, "Stale reference to the connection object.") \ - } \ - if (!(resource)->connection_resource->is_connected) { \ - PHP_AMQP_VERIFY_CONNECTION_ERROR(error, "No connection available.") \ - } \ - -#define PHP_AMQP_VERIFY_CHANNEL_CONNECTION_RESOURCE(resource, error) \ - if (!resource) { \ - PHP_AMQP_VERIFY_CHANNEL_ERROR(error, "Stale reference to the channel object.") \ - } \ - if (!(resource)->connection_resource) { \ - PHP_AMQP_VERIFY_CONNECTION_ERROR(error, "Stale reference to the connection object.") \ - } \ - if (!(resource)->connection_resource->is_connected) { \ - PHP_AMQP_VERIFY_CONNECTION_ERROR(error, "No connection available.") \ - } \ - - -#define PHP_AMQP_ERROR_MESSAGE_PTR &php_amqp_internal_error_message -#define PHP_AMQP_ERROR_MESSAGE php_amqp_internal_error_message - -#define PHP_AMQP_INIT_ERROR_MESSAGE()\ - char *PHP_AMQP_ERROR_MESSAGE = NULL; - -#define PHP_AMQP_DESTROY_ERROR_MESSAGE()\ - if (PHP_AMQP_ERROR_MESSAGE != NULL) { efree(PHP_AMQP_ERROR_MESSAGE); } - -#if ZEND_MODULE_API_NO >= 20100000 - #define AMQP_OBJECT_PROPERTIES_INIT(obj, ce) object_properties_init(&(obj), ce); -#else - #define AMQP_OBJECT_PROPERTIES_INIT(obj, ce) \ - do { \ - zval *tmp; \ - zend_hash_copy((obj).properties, &(ce)->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); \ - } while (0); -#endif - - -#define AMQP_ERROR_CATEGORY_MASK (1 << 29) - - -#ifdef PHP_WIN32 -# define AMQP_OS_SOCKET_TIMEOUT_ERRNO AMQP_ERROR_CATEGORY_MASK | WSAETIMEDOUT -#else -# define AMQP_OS_SOCKET_TIMEOUT_ERRNO AMQP_ERROR_CATEGORY_MASK | EAGAIN -#endif - - -#ifdef ZTS -#define AMQP_G(v) TSRMG(amqp_globals_id, zend_amqp_globals *, v) -#else -#define AMQP_G(v) (amqp_globals.v) -#endif - -#ifndef PHP_AMQP_VERSION -#define PHP_AMQP_VERSION "1.7.1" -#endif - -#ifndef PHP_AMQP_REVISION -#define PHP_AMQP_REVISION "release" -#endif - -void php_amqp_error(amqp_rpc_reply_t reply, char **message, amqp_connection_resource *connection_resource, amqp_channel_resource *channel_resource TSRMLS_DC); -void php_amqp_zend_throw_exception(amqp_rpc_reply_t reply, zend_class_entry *exception_ce, const char *message, PHP5to7_param_long_type_t code TSRMLS_DC); - -void php_amqp_maybe_release_buffers_on_channel(amqp_connection_resource *connection_resource, amqp_channel_resource *channel_resource); - -amqp_bytes_t php_amqp_long_string(char const *cstr, PHP5to7_param_str_len_type_t len); - -#endif /* PHP_AMQP_H */ - - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: noet sw=4 ts=4 fdm=marker - * vim<600: noet sw=4 ts=4 - */ diff -Nru php-amqp-1.7.1/amqp-1.7.1/stubs/AMQPChannelException.php php-amqp-1.9.3/amqp-1.7.1/stubs/AMQPChannelException.php --- php-amqp-1.7.1/amqp-1.7.1/stubs/AMQPChannelException.php 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/stubs/AMQPChannelException.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ - amqp.host The host to connect too. Note: Max 1024 characters. - * 'port' => amqp.port Port on the host. - * 'vhost' => amqp.vhost The virtual host on the host. Note: Max 128 characters. - * 'login' => amqp.login The login name to use. Note: Max 128 characters. - * 'password' => amqp.password Password. Note: Max 128 characters. - * 'read_timeout' => Timeout in for income activity. Note: 0 or greater seconds. May be fractional. - * 'write_timeout' => Timeout in for outcome activity. Note: 0 or greater seconds. May be fractional. - * 'connect_timeout' => Connection timeout. Note: 0 or greater seconds. May be fractional. - * - * Connection tuning options (see http://www.rabbitmq.com/amqp-0-9-1-reference.html#connection.tune for details): - * 'channel_max' => Specifies highest channel number that the server permits. 0 means standard extension limit - * (see PHP_AMQP_MAX_CHANNELS constant) - * 'frame_max' => The largest frame size that the server proposes for the connection, including frame header - * and end-byte. 0 means standard extension limit (depends on librabbimq default frame size limit) - * 'heartbeat' => The delay, in seconds, of the connection heartbeat that the server wants. - * 0 means the server does not want a heartbeat. Note, librabbitmq has limited heartbeat support, - * which means heartbeats checked only during blocking calls. - * ) - * - * @param array $credentials Optional array of credential information for - * connecting to the AMQP broker. - */ - public function __construct(array $credentials = array()) - { - } - - /** - * Closes the transient connection with the AMQP broker. - * - * This method will close an open connection with the AMQP broker. - * - * @return boolean true if connection was successfully closed, false otherwise. - */ - public function disconnect() - { - } - - /** - * Get the configured host. - * - * @return string The configured hostname of the broker - */ - public function getHost() - { - } - - /** - * Get the configured login. - * - * @return string The configured login as a string. - */ - public function getLogin() - { - } - - /** - * Get the configured password. - * - * @return string The configured password as a string. - */ - public function getPassword() - { - } - - /** - * Get the configured port. - * - * @return int The configured port as an integer. - */ - public function getPort() - { - } - - /** - * Get the configured vhost. - * - * @return string The configured virtual host as a string. - */ - public function getVhost() - { - } - - /** - * Check whether the connection to the AMQP broker is still valid. - * - * It does so by checking the return status of the last connect-command. - * - * @return boolean True if connected, false otherwise. - */ - public function isConnected() - { - } - - /** - * Establish a persistent connection with the AMQP broker. - * - * This method will initiate a connection with the AMQP broker - * or reuse an existing one if present. - * - * @throws AMQPConnectionException - * @return boolean TRUE on success or throws an exception on failure. - */ - public function pconnect() - { - } - - /** - * Closes a persistent connection with the AMQP broker. - * - * This method will close an open persistent connection with the AMQP - * broker. - * - * @return boolean true if connection was found and closed, - * false if no persistent connection with this host, - * port, vhost and login could be found, - */ - public function pdisconnect() - { - } - - /** - * Close any open transient connections and initiate a new one with the AMQP broker. - * - * @return boolean TRUE on success or FALSE on failure. - */ - public function reconnect() - { - } - - /** - * Close any open persistent connections and initiate a new one with the AMQP broker. - * - * @return boolean TRUE on success or FALSE on failure. - */ - public function preconnect() - { - } - - - /** - * Set the hostname used to connect to the AMQP broker. - * - * @param string $host The hostname of the AMQP broker. - * - * @throws AMQPConnectionException If host is longer then 1024 characters. - * - * @return boolean TRUE on success or FALSE on failure. - */ - public function setHost($host) - { - } - - /** - * Set the login string used to connect to the AMQP broker. - * - * @param string $login The login string used to authenticate - * with the AMQP broker. - * - * @throws AMQPConnectionException If login is longer then 32 characters. - * - * @return boolean TRUE on success or FALSE on failure. - */ - public function setLogin($login) - { - } - - /** - * Set the password string used to connect to the AMQP broker. - * - * @param string $password The password string used to authenticate - * with the AMQP broker. - * - * @throws AMQPConnectionException If password is longer then 32characters. - * - * @return boolean TRUE on success or FALSE on failure. - */ - public function setPassword($password) - { - } - - /** - * Set the port used to connect to the AMQP broker. - * - * @param integer $port The port used to connect to the AMQP broker. - * - * @throws AMQPConnectionException If port is longer not between - * 1 and 65535. - * - * @return boolean TRUE on success or FALSE on failure. - */ - public function setPort($port) - { - } - - /** - * Sets the virtual host to which to connect on the AMQP broker. - * - * @param string $vhost The virtual host to use on the AMQP - * broker. - * - * @throws AMQPConnectionException If host is longer then 32 characters. - * - * @return boolean true on success or false on failure. - */ - public function setVhost($vhost) - { - } - - /** - * Sets the interval of time to wait for income activity from AMQP broker - * - * @deprecated use AMQPConnection::setReadTimout($timeout) instead - * - * @param int $timeout - * - * @return bool - */ - public function setTimeout($timeout) - { - } - - /** - * Get the configured interval of time to wait for income activity - * from AMQP broker - * - * @deprecated use AMQPConnection::getReadTimout() instead - * - * @return float - */ - public function getTimeout() - { - } - - /** - * Sets the interval of time to wait for income activity from AMQP broker - * - * @param int $timeout - * - * @return bool - */ - public function setReadTimeout($timeout) - { - } - - /** - * Get the configured interval of time to wait for income activity - * from AMQP broker - * - * @return float - */ - public function getReadTimeout() - { - } - - /** - * Sets the interval of time to wait for outcome activity to AMQP broker - * - * @param int $timeout - * - * @return bool - */ - public function setWriteTimeout($timeout) - { - } - - /** - * Get the configured interval of time to wait for outcome activity - * to AMQP broker - * - * @return float - */ - public function getWriteTimeout() - { - } - - /** - * Return last used channel id during current connection session. - * - * @return int - */ - public function getUsedChannels() - { - } - - /** - * Get the maximum number of channels the connection can handle. - * - * When connection is connected, effective connection value returned, which is normally the same as original - * correspondent value passed to constructor, otherwise original value passed to constructor returned. - * - * @return int - */ - public function getMaxChannels() - { - } - - /** - * Get max supported frame size per connection in bytes. - * - * When connection is connected, effective connection value returned, which is normally the same as original - * correspondent value passed to constructor, otherwise original value passed to constructor returned. - * - * @return int - */ - public function getMaxFrameSize() - { - } - - /** - * Get number of seconds between heartbeats of the connection in seconds. - * - * When connection is connected, effective connection value returned, which is normally the same as original - * correspondent value passed to constructor, otherwise original value passed to constructor returned. - * - * @return int - */ - public function getHeartbeatInterval() - { - } - - /** - * Whether connection persistent. - * - * When connection is not connected, boolean false always returned - * - * @return bool - */ - public function isPersistent() - { - } -} diff -Nru php-amqp-1.7.1/amqp-1.7.1/stubs/AMQPEnvelope.php php-amqp-1.9.3/amqp-1.7.1/stubs/AMQPEnvelope.php --- php-amqp-1.7.1/amqp-1.7.1/stubs/AMQPEnvelope.php 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/stubs/AMQPEnvelope.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,197 +0,0 @@ -= 0.5.3) - * - * @return void - */ - public function setFlags($flags) - { - } - - /** - * Set the name of the exchange. - * - * @param string $exchange_name The name of the exchange to set as string. - * - * @return void - */ - public function setName($exchange_name) - { - } - - /** - * Set the type of the exchange. - * - * Set the type of the exchange. This can be any of AMQP_EX_TYPE_DIRECT, - * AMQP_EX_TYPE_FANOUT, AMQP_EX_TYPE_HEADERS or AMQP_EX_TYPE_TOPIC. - * - * @param string $exchange_type The type of exchange as a string. - * - * @return void - */ - public function setType($exchange_type) - { - } - - /** - * Get the AMQPChannel object in use - * - * @return AMQPChannel - */ - public function getChannel() - { - } - - /** - * Get the AMQPConnection object in use - * - * @return AMQPConnection - */ - public function getConnection() - { - } -} diff -Nru php-amqp-1.7.1/amqp-1.7.1/stubs/AMQP.php php-amqp-1.9.3/amqp-1.7.1/stubs/AMQP.php --- php-amqp-1.7.1/amqp-1.7.1/stubs/AMQP.php 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/stubs/AMQP.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,125 +0,0 @@ - ---FILE-- -connect(); - -$channel_1 = new AMQPChannel($connection_1); -$channel_1->setPrefetchCount(5); - -$exchange_1 = new AMQPExchange($channel_1); -$exchange_1->setType(AMQP_EX_TYPE_TOPIC); -$exchange_1->setName('test_' . $time); -$exchange_1->setFlags(AMQP_AUTODELETE); -$exchange_1->declareExchange(); - -$queue_1 = new AMQPQueue($channel_1); -$queue_1->setName('test_' . $time); -$queue_1->setFlags(AMQP_DURABLE); -$queue_1->declareQueue(); - -$queue_1->bind($exchange_1->getName(), 'test'); - -$messages_count = 0; -while ($messages_count++ < 10) { - $exchange_1->publish('test message #' . $messages_count, 'test'); - //echo 'published test message #' . $messages_count, PHP_EOL; -} - -$consume = 2; // NOTE: by default prefetch-count=3, so in consumer below we will ignore prefetched messages 3-5, - // and they will not seen by other consumers until we redeliver it. -$queue_1->consume(function(AMQPEnvelope $e, AMQPQueue $q) use (&$consume) { - echo 'consumed ', $e->getBody(), ' ', ($e->isRedelivery() ? '(redelivered)' : '(original)'), PHP_EOL; - $q->ack($e->getDeliveryTag()); - - return (-- $consume > 0); -}); -$queue_1->cancel(); // we have to do that to prevent redelivering to the same consumer - -$connection_2 = new AMQPConnection(); -$connection_2->setReadTimeout(1); - -$connection_2->connect(); -$channel_2 = new AMQPChannel($connection_2); -$channel_2->setPrefetchCount(8); - - -$queue_2 = new AMQPQueue($channel_2); -$queue_2->setName('test_' . $time); - -$consume = 10; -try { - - $queue_2->consume(function (AMQPEnvelope $e, AMQPQueue $q) use (&$consume) { - echo 'consumed ' . $e->getBody(), ' ', ($e->isRedelivery() ? '(redelivered)' : '(original)'), PHP_EOL; - $q->ack($e->getDeliveryTag()); - - return (--$consume > 0); - }); - -} catch (AMQPException $e) { - echo get_class($e), ': ', $e->getMessage(), PHP_EOL; -} -$queue_2->cancel(); -//var_dump($connection_2, $channel_2);die; - - -// yes, we do it repeatedly, basic.recover works in a slightly different way than it looks like. As it said, -// it "asks the server to redeliver all unacknowledged messages on a specified channel. -// ZERO OR MORE messages MAY BE redelivered" -$channel_1->basicRecover(); - -echo 'redelivered', PHP_EOL; - -$consume = 10; -try { - - $queue_2->consume(function (AMQPEnvelope $e, AMQPQueue $q) use (&$consume) { - echo 'consumed ' . $e->getBody(), ' ', ($e->isRedelivery() ? '(redelivered)' : '(original)'), PHP_EOL; - $q->ack($e->getDeliveryTag()); - - return (--$consume > 0); - }); - -} catch (AMQPException $e) { - echo get_class($e), ': ', $e->getMessage(), PHP_EOL; -} - - -?> ---EXPECT-- -consumed test message #1 (original) -consumed test message #2 (original) -consumed test message #8 (original) -consumed test message #9 (original) -consumed test message #10 (original) -AMQPQueueException: Consumer timeout exceed -redelivered -consumed test message #3 (redelivered) -consumed test message #4 (redelivered) -consumed test message #5 (redelivered) -consumed test message #6 (redelivered) -consumed test message #7 (redelivered) -AMQPQueueException: Consumer timeout exceed diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpchannel_construct_basic.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpchannel_construct_basic.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpchannel_construct_basic.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpchannel_construct_basic.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ ---TEST-- -AMQPChannel constructor ---SKIPIF-- - ---FILE-- -connect(); -$ch = new AMQPChannel($cnn); -echo get_class($ch) . "\n"; -echo $ch->isConnected() ? 'true' : 'false'; -?> ---EXPECT-- -AMQPChannel -true \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpchannel_getChannelId.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpchannel_getChannelId.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpchannel_getChannelId.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpchannel_getChannelId.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ ---TEST-- -AMQPChannel::getChannelId ---SKIPIF-- - ---FILE-- -connect(); -$ch = new AMQPChannel($cnn); - -var_dump($ch->getChannelId()); - -$cnn->disconnect(); -var_dump($ch->getChannelId()); - -?> ---EXPECT-- -int(1) -int(1) \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpchannel_get_connection.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpchannel_get_connection.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpchannel_get_connection.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpchannel_get_connection.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ ---TEST-- -AMQPChannel getConnection test ---SKIPIF-- - ---FILE-- -connect(); -$ch = new AMQPChannel($cnn); - -$cnn2 = new AMQPConnection(); - -echo $cnn === $ch->getConnection() ? 'same' : 'not same', PHP_EOL; -echo $cnn2 === $ch->getConnection() ? 'same' : 'not same', PHP_EOL; - -$old_host = $cnn->getHost(); -$new_host = 'test'; - -$ch->getConnection()->setHost($new_host); - -echo $cnn->getHost() == $new_host ? 'by ref' : 'copy', PHP_EOL; - -?> ---EXPECT-- -same -not same -by ref diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpchannel_multi_channel_connection.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpchannel_multi_channel_connection.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpchannel_multi_channel_connection.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpchannel_multi_channel_connection.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ ---TEST-- -AMQPConnection - multiple AMQPChannels per AMQPConnection ---SKIPIF-- - ---FILE-- -connect(); - -$ch = new AMQPChannel($cnn); -echo get_class($ch) . "\n"; -echo $ch->isConnected() ? 'true' : 'false'; -echo "\n"; -$ch2 = new AMQPChannel($cnn); -echo get_class($ch) . "\n"; -echo $ch->isConnected() ? 'true' : 'false'; - -unset($ch2); - -$ch->setPrefetchCount(10); - -?> ---EXPECT-- -AMQPChannel -true -AMQPChannel -true diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpchannel_slots_usage.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpchannel_slots_usage.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpchannel_slots_usage.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpchannel_slots_usage.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ ---TEST-- -AMQPChannel slots usage ---SKIPIF-- - ---FILE-- -connect(); - -echo 'Used channels: ', $cnn->getUsedChannels(), PHP_EOL; - -$ch = new AMQPChannel($cnn); -echo 'Used channels: ', $cnn->getUsedChannels(), PHP_EOL; - -$ch = new AMQPChannel($cnn); -echo 'Used channels: ', $cnn->getUsedChannels(), PHP_EOL; - -$ch = null; -echo 'Used channels: ', $cnn->getUsedChannels(), PHP_EOL; -?> ---EXPECT-- -Used channels: 0 -Used channels: 1 -Used channels: 1 -Used channels: 0 diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpchannel_var_dump.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpchannel_var_dump.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpchannel_var_dump.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpchannel_var_dump.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +0,0 @@ ---TEST-- -AMQPChannel var_dump ---SKIPIF-- - ---FILE-- -connect(); -$ch = new AMQPChannel($cnn); - -var_dump($ch); -$cnn->disconnect(); -var_dump($ch); - -?> ---EXPECT-- -object(AMQPChannel)#2 (3) { - ["connection":"AMQPChannel":private]=> - object(AMQPConnection)#1 (11) { - ["login":"AMQPConnection":private]=> - string(5) "guest" - ["password":"AMQPConnection":private]=> - string(5) "guest" - ["host":"AMQPConnection":private]=> - string(9) "localhost" - ["vhost":"AMQPConnection":private]=> - string(1) "/" - ["port":"AMQPConnection":private]=> - int(5672) - ["read_timeout":"AMQPConnection":private]=> - float(0) - ["write_timeout":"AMQPConnection":private]=> - float(0) - ["connect_timeout":"AMQPConnection":private]=> - float(0) - ["channel_max":"AMQPConnection":private]=> - int(256) - ["frame_max":"AMQPConnection":private]=> - int(131072) - ["heartbeat":"AMQPConnection":private]=> - int(0) - } - ["prefetch_count":"AMQPChannel":private]=> - int(3) - ["prefetch_size":"AMQPChannel":private]=> - int(0) -} -object(AMQPChannel)#2 (3) { - ["connection":"AMQPChannel":private]=> - object(AMQPConnection)#1 (11) { - ["login":"AMQPConnection":private]=> - string(5) "guest" - ["password":"AMQPConnection":private]=> - string(5) "guest" - ["host":"AMQPConnection":private]=> - string(9) "localhost" - ["vhost":"AMQPConnection":private]=> - string(1) "/" - ["port":"AMQPConnection":private]=> - int(5672) - ["read_timeout":"AMQPConnection":private]=> - float(0) - ["write_timeout":"AMQPConnection":private]=> - float(0) - ["connect_timeout":"AMQPConnection":private]=> - float(0) - ["channel_max":"AMQPConnection":private]=> - int(256) - ["frame_max":"AMQPConnection":private]=> - int(131072) - ["heartbeat":"AMQPConnection":private]=> - int(0) - } - ["prefetch_count":"AMQPChannel":private]=> - int(3) - ["prefetch_size":"AMQPChannel":private]=> - int(0) -} diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_connection_getters.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_connection_getters.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_connection_getters.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_connection_getters.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,89 +0,0 @@ ---TEST-- -AMQPConnection - connection-specific getters ---SKIPIF-- - ---FILE-- -isConnected(), true), PHP_EOL; -echo 'channel_max: ', var_export($cnn->getMaxChannels(), true), PHP_EOL; -echo 'frame_max: ', var_export($cnn->getMaxFrameSize(), true), PHP_EOL; -echo 'heartbeat: ', var_export($cnn->getHeartbeatInterval(), true), PHP_EOL; -echo PHP_EOL; - -$cnn->connect(); - -echo 'connected: ', var_export($cnn->isConnected(), true), PHP_EOL; -echo 'channel_max: ', var_export($cnn->getMaxChannels(), true), PHP_EOL; -echo 'frame_max: ', var_export($cnn->getMaxFrameSize(), true), PHP_EOL; -echo 'heartbeat: ', var_export($cnn->getHeartbeatInterval(), true), PHP_EOL; -echo PHP_EOL; - -$cnn->disconnect(); - -echo 'connected: ', var_export($cnn->isConnected(), true), PHP_EOL; -echo 'channel_max: ', var_export($cnn->getMaxChannels(), true), PHP_EOL; -echo 'frame_max: ', var_export($cnn->getMaxFrameSize(), true), PHP_EOL; -echo 'heartbeat: ', var_export($cnn->getHeartbeatInterval(), true), PHP_EOL; -echo PHP_EOL; - - -$cnn = new AMQPConnection(array('channel_max' => '10', 'frame_max' => 10240, 'heartbeat' => 10)); - -echo 'connected: ', var_export($cnn->isConnected(), true), PHP_EOL; -echo 'channel_max: ', var_export($cnn->getMaxChannels(), true), PHP_EOL; -echo 'frame_max: ', var_export($cnn->getMaxFrameSize(), true), PHP_EOL; -echo 'heartbeat: ', var_export($cnn->getHeartbeatInterval(), true), PHP_EOL; -echo PHP_EOL; - -$cnn->connect(); - -echo 'connected: ', var_export($cnn->isConnected(), true), PHP_EOL; -echo 'channel_max: ', var_export($cnn->getMaxChannels(), true), PHP_EOL; -echo 'frame_max: ', var_export($cnn->getMaxFrameSize(), true), PHP_EOL; -echo 'heartbeat: ', var_export($cnn->getHeartbeatInterval(), true), PHP_EOL; -echo PHP_EOL; - -$cnn->disconnect(); - -echo 'connected: ', var_export($cnn->isConnected(), true), PHP_EOL; -echo 'channel_max: ', var_export($cnn->getMaxChannels(), true), PHP_EOL; -echo 'frame_max: ', var_export($cnn->getMaxFrameSize(), true), PHP_EOL; -echo 'heartbeat: ', var_export($cnn->getHeartbeatInterval(), true), PHP_EOL; -echo PHP_EOL; -?> ---EXPECT-- -connected: false -channel_max: 256 -frame_max: 131072 -heartbeat: 0 - -connected: true -channel_max: 256 -frame_max: 131072 -heartbeat: 0 - -connected: false -channel_max: 256 -frame_max: 131072 -heartbeat: 0 - -connected: false -channel_max: 10 -frame_max: 10240 -heartbeat: 10 - -connected: true -channel_max: 10 -frame_max: 10240 -heartbeat: 10 - -connected: false -channel_max: 10 -frame_max: 10240 -heartbeat: 10 diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_connect_login_failure.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_connect_login_failure.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_connect_login_failure.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_connect_login_failure.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ ---TEST-- -AMQPConnection connect login failure ---SKIPIF-- - ---FILE-- -setLogin('nonexistent-login-'.microtime(true)); -$cnn->setPassword('nonexistent-password-'.microtime(true)); - -//var_dump($cnn); - -echo ($cnn->isConnected() ? 'connected' : 'disconnected'), PHP_EOL; -// -try { - $cnn->connect(); - echo 'Connected', PHP_EOL; -} catch (AMQPException $e) { - echo get_class($e), ': ', $e->getMessage(), PHP_EOL; -} -// -echo ($cnn->isConnected() ? 'connected' : 'disconnected'), PHP_EOL; - -// NOTE: in real-world environment (incl. travis ci) "a socket error occurred" happens, but in vagrant environment "connection closed unexpectedly" happens. WTF? -?> ---EXPECTF-- -disconnected -AMQPConnectionException: %s error: %s - Potential login failure. -disconnected \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_construct_basic.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_construct_basic.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_construct_basic.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_construct_basic.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ ---TEST-- -AMQPConnection constructor ---SKIPIF-- - ---FILE-- -connect(); -echo get_class($cnn) . "\n"; -echo $cnn->isConnected() ? 'true' : 'false', PHP_EOL; -echo $cnn->isPersistent() ? 'true' : 'false', PHP_EOL; -?> ---EXPECT-- -AMQPConnection -true -false \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_construct_ini_read_timeout.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_construct_ini_read_timeout.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_construct_ini_read_timeout.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_construct_ini_read_timeout.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ ---TEST-- -AMQPConnection constructor with amqp.read_timeout ini value set ---SKIPIF-- - ---INI-- -amqp.read_timeout=202.202 ---FILE-- -getReadTimeout()); -?> ---EXPECTF-- -float(202.202) diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_construct_ini_timeout_and_read_timeout.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_construct_ini_timeout_and_read_timeout.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_construct_ini_timeout_and_read_timeout.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_construct_ini_timeout_and_read_timeout.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ ---TEST-- -AMQPConnection constructor with both amqp.timeout and amqp.read_timeout ini values set ---SKIPIF-- - ---INI-- -amqp.timeout = 101.101 -amqp.read_timeout = 202.202 ---FILE-- -getReadTimeout()); -?> ---EXPECTF-- -%s: AMQPConnection::__construct(): INI setting 'amqp.timeout' is deprecated; use 'amqp.read_timeout' instead in %s on line 2 - -Notice: AMQPConnection::__construct(): INI setting 'amqp.read_timeout' will be used instead of 'amqp.timeout' in %s on line 2 -float(202.202) diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_construct_ini_timeout_default.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_construct_ini_timeout_default.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_construct_ini_timeout_default.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_construct_ini_timeout_default.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ ---TEST-- -AMQPConnection constructor with amqp.timeout ini value set in code to it default value ---SKIPIF-- - ---FILE-- -getReadTimeout()); -?> ---EXPECTF-- -float(0) diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_construct_ini_timeout.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_construct_ini_timeout.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_construct_ini_timeout.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_construct_ini_timeout.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ ---TEST-- -AMQPConnection constructor with amqp.timeout ini value set ---SKIPIF-- - ---INI-- -amqp.timeout=101.101 ---FILE-- -getReadTimeout()); -?> ---EXPECTF-- -%s: AMQPConnection::__construct(): INI setting 'amqp.timeout' is deprecated; use 'amqp.read_timeout' instead in %s on line 2 -float(101.101) diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_construct_with_connect_timeout.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_construct_with_connect_timeout.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_construct_with_connect_timeout.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_construct_with_connect_timeout.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ ---TEST-- -AMQPConnection constructor with timeout parameter in credentials ---SKIPIF-- - ---FILE-- - -1.5)); -} catch (AMQPConnectionException $e) { - echo $e->getMessage(), PHP_EOL; -} - -$timeout = 10.5; - -// resolve hostname to don't waste time on resolve inside library while resolve operations are not under timings limit (yet) -$credentials = array('host' => gethostbyname('google.com'), 'connect_timeout' => $timeout); -//$credentials = array('host' => 'google.com', 'connect_timeout' => $timeout); -$cnn = new AMQPConnection($credentials); - -$start = microtime(true); - -try { - $cnn->connect(); -} catch (AMQPConnectionException $e) { - echo $e->getMessage(), PHP_EOL; - $end = microtime(true); - - $error = $end - $start - $timeout; - - $limit = abs(log10($timeout)); // empirical value - - echo 'error: ', $error, PHP_EOL; - echo 'limit: ', $limit, PHP_EOL; - - echo abs($error) <= $limit ? 'timings OK' : 'timings failed'; // error should be less than 5% of timeout value -} -?> ---EXPECTF-- -Parameter 'connect_timeout' must be greater than or equal to zero. -Socket error: could not connect to host. -error: %f -limit: %f -timings OK diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_construct_with_limits.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_construct_with_limits.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_construct_with_limits.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_construct_with_limits.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ ---TEST-- -AMQPConnection constructor with channel_max, frame_max and heartbeat limits ---SKIPIF-- - ---FILE-- - 10, - 'frame_max' => 10240, - 'heartbeat' => 5, -); -$cnn = new AMQPConnection($credentials); -$cnn->connect(); - -var_dump($cnn); -?> ---EXPECTF-- -object(AMQPConnection)#1 (11) { - ["login":"AMQPConnection":private]=> - string(5) "guest" - ["password":"AMQPConnection":private]=> - string(5) "guest" - ["host":"AMQPConnection":private]=> - string(9) "localhost" - ["vhost":"AMQPConnection":private]=> - string(1) "/" - ["port":"AMQPConnection":private]=> - %s(5672) - ["read_timeout":"AMQPConnection":private]=> - %s(0) - ["write_timeout":"AMQPConnection":private]=> - %s(0) - ["connect_timeout":"AMQPConnection":private]=> - %s(0) - ["channel_max":"AMQPConnection":private]=> - %s(10) - ["frame_max":"AMQPConnection":private]=> - %s(10240) - ["heartbeat":"AMQPConnection":private]=> - %s(5) -} \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_construct_with_timeout_and_read_timeout.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_construct_with_timeout_and_read_timeout.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_construct_with_timeout_and_read_timeout.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_construct_with_timeout_and_read_timeout.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ ---TEST-- -AMQPConnection constructor with both timeout and read_timeout parameters in credentials ---SKIPIF-- - ---FILE-- - 101.101, 'read_timeout' => 202.202); -$cnn = new AMQPConnection($credentials); -var_dump($cnn->getReadTimeout()); -?> ---EXPECTF-- -Notice: AMQPConnection::__construct(): Parameter 'timeout' is deprecated, 'read_timeout' used instead in %s on line 3 -float(202.202) diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_construct_with_timeout.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_construct_with_timeout.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_construct_with_timeout.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_construct_with_timeout.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ ---TEST-- -AMQPConnection constructor with timeout parameter in credentials ---SKIPIF-- - ---FILE-- - 101.101); -$cnn = new AMQPConnection($credentials); -var_dump($cnn->getReadTimeout()); -?> ---EXPECTF-- -%s: AMQPConnection::__construct(): Parameter 'timeout' is deprecated; use 'read_timeout' instead in %s on line 3 -float(101.101) diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_construct_with_write_timeout.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_construct_with_write_timeout.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_construct_with_write_timeout.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_construct_with_write_timeout.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ ---TEST-- -AMQPConnection constructor with write_timeout parameter in creadentials ---SKIPIF-- - ---FILE-- - 303.303); -$cnn = new AMQPConnection($credentials); -var_dump($cnn->getWriteTimeout()); -?> ---EXPECT-- -float(303.303) diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_getUsedChannels.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_getUsedChannels.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_getUsedChannels.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_getUsedChannels.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ ---TEST-- -AMQPConnection::getUsedChannels() ---SKIPIF-- - ---FILE-- -getUsedChannels(), PHP_EOL; -$cnn->connect(); -echo get_class($cnn), '::getUsedChannels():', $cnn->getUsedChannels(), PHP_EOL; - -$ch = new AMQPChannel($cnn); -echo get_class($cnn), '::getUsedChannels():', $cnn->getUsedChannels(), PHP_EOL; - -$ch = null; -echo get_class($cnn), '::getUsedChannels():', $cnn->getUsedChannels(), PHP_EOL; - -?> ---EXPECTF-- -AMQPConnection::getUsedChannels(): -Warning: AMQPConnection::getUsedChannels(): Connection is not connected. in %s on line %d -0 -AMQPConnection::getUsedChannels():0 -AMQPConnection::getUsedChannels():1 -AMQPConnection::getUsedChannels():0 diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_heartbeat.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_heartbeat.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_heartbeat.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_heartbeat.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ ---TEST-- -AMQPConnection - heartbeats support ---SKIPIF-- - ---FILE-- - $heartbeat); -$cnn = new AMQPConnection($credentials); -$cnn->connect(); - -echo 'heartbeat: ', var_export($cnn->getHeartbeatInterval(), true), PHP_EOL; -echo 'connected: ', var_export($cnn->isConnected(), true), PHP_EOL; -echo 'persistent: ', var_export($cnn->isPersistent(), true), PHP_EOL; - -sleep($heartbeat*5); - -try { - $ch = new AMQPChannel($cnn); - echo 'channel created', PHP_EOL; -} catch (AMQPException $e) { - echo get_class($e), ': ', $e->getMessage(), PHP_EOL; -} - -echo 'heartbeat: ', var_export($cnn->getHeartbeatInterval(), true), PHP_EOL; -echo 'connected: ', var_export($cnn->isConnected(), true), PHP_EOL; -echo 'persistent: ', var_export($cnn->isPersistent(), true), PHP_EOL; - -?> ---EXPECTF-- -heartbeat: 2 -connected: true -persistent: false -AMQPException: Library error: a socket error occurred -heartbeat: 2 -connected: false -persistent: false diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_heartbeat_with_consumer.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_heartbeat_with_consumer.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_heartbeat_with_consumer.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_heartbeat_with_consumer.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,90 +0,0 @@ ---TEST-- -AMQPConnection heartbeats support (with active consumer) ---SKIPIF-- - ---FILE-- - $heartbeat, 'read_timeout' => $heartbeat * 20); -$cnn = new AMQPConnection($credentials); -$cnn->connect(); - -var_dump($cnn); - -$ch = new AMQPChannel($cnn); - -$q_dead_name = 'test.queue.dead.' . microtime(true); -$q_name = 'test.queue.' . microtime(true); - -$e = new AMQPExchange($ch); - -$q = new AMQPQueue($ch); -$q->setName($q_name); -$q->declareQueue(); - - -$q_dead = new AMQPQueue($ch); -$q_dead->setName($q_dead_name); -$q_dead->setArgument('x-dead-letter-exchange', ''); -$q_dead->setArgument('x-dead-letter-routing-key', $q_name); -$q_dead->setArgument('x-message-ttl', $heartbeat * 10 * 1000); -$q_dead->declareQueue(); - -$e->publish('test message 1 (should be dead lettered)', $q_dead_name); - -$t = microtime(true); -$q->consume(function (AMQPEnvelope $envelope) { - echo 'Consumed: ', $envelope->getBody(), PHP_EOL; - return false; -}); -$t = microtime(true) - $t; - -echo 'Consuming took: ', (float) round($t, 4), 'sec', PHP_EOL; - -$t_min = (float)round($heartbeat * 9.5, 4); -$t_max = (float)round($heartbeat * 10.5, 4); - -if ($t > $t_min && $t < $t_max) { - echo "Timing OK ($t_min < $t < $t_max)", PHP_EOL; -} else { - echo "Timing ERROR ($t_min < $t < $t_max)", PHP_EOL; -} - -$ch2 = new AMQPChannel($cnn); - -sleep($heartbeat/2); - -$ch3 = new AMQPChannel($cnn); - -echo 'Done', PHP_EOL - -?> ---EXPECTF-- -object(AMQPConnection)#1 (11) { - ["login":"AMQPConnection":private]=> - string(5) "guest" - ["password":"AMQPConnection":private]=> - string(5) "guest" - ["host":"AMQPConnection":private]=> - string(9) "localhost" - ["vhost":"AMQPConnection":private]=> - string(1) "/" - ["port":"AMQPConnection":private]=> - %s(5672) - ["read_timeout":"AMQPConnection":private]=> - %s(40) - ["write_timeout":"AMQPConnection":private]=> - %s(0) - ["connect_timeout":"AMQPConnection":private]=> - %s(0) - ["channel_max":"AMQPConnection":private]=> - %s(256) - ["frame_max":"AMQPConnection":private]=> - %s(131072) - ["heartbeat":"AMQPConnection":private]=> - %s(2) -} -Consumed: test message 1 (should be dead lettered) -Consuming took: %fsec -Timing OK (%f < %f < %f) -Done \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_heartbeat_with_persistent.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_heartbeat_with_persistent.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_heartbeat_with_persistent.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_heartbeat_with_persistent.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +0,0 @@ ---TEST-- -AMQPConnection - heartbeats support with persistent connections ---SKIPIF-- - ---FILE-- - $heartbeat); - -$cnn = new AMQPConnection($credentials); - -echo 'heartbeat: ', var_export($cnn->getHeartbeatInterval(), true), PHP_EOL; -echo 'connected: ', var_export($cnn->isConnected(), true), PHP_EOL; -echo 'persistent: ', var_export($cnn->isPersistent(), true), PHP_EOL; -echo PHP_EOL; - -$cnn->pconnect(); - -echo 'heartbeat: ', var_export($cnn->getHeartbeatInterval(), true), PHP_EOL; -echo 'connected: ', var_export($cnn->isConnected(), true), PHP_EOL; -echo 'persistent: ', var_export($cnn->isPersistent(), true), PHP_EOL; -echo PHP_EOL; - -sleep($heartbeat*5); - -try { - $ch = new AMQPChannel($cnn); - echo 'channel created', PHP_EOL; -} catch (AMQPException $e) { - echo get_class($e), ': ', $e->getMessage(), PHP_EOL; -} - -echo PHP_EOL; -echo 'heartbeat: ', var_export($cnn->getHeartbeatInterval(), true), PHP_EOL; -echo 'connected: ', var_export($cnn->isConnected(), true), PHP_EOL; -echo 'persistent: ', var_export($cnn->isPersistent(), true), PHP_EOL; -echo PHP_EOL; - -$cnn = new AMQPConnection($credentials); -$cnn->pconnect(); - -echo 'heartbeat: ', var_export($cnn->getHeartbeatInterval(), true), PHP_EOL; -echo 'connected: ', var_export($cnn->isConnected(), true), PHP_EOL; -echo 'persistent: ', var_export($cnn->isPersistent(), true), PHP_EOL; -echo PHP_EOL; - - -$ch = new AMQPChannel($cnn); -echo 'channel created', PHP_EOL; -echo PHP_EOL; - -echo 'heartbeat: ', var_export($cnn->getHeartbeatInterval(), true), PHP_EOL; -echo 'connected: ', var_export($cnn->isConnected(), true), PHP_EOL; -echo 'persistent: ', var_export($cnn->isPersistent(), true), PHP_EOL; -echo PHP_EOL; - -$cnn->pdisconnect(); - -echo 'heartbeat: ', var_export($cnn->getHeartbeatInterval(), true), PHP_EOL; -echo 'connected: ', var_export($cnn->isConnected(), true), PHP_EOL; -echo 'persistent: ', var_export($cnn->isPersistent(), true), PHP_EOL; -echo PHP_EOL; - -?> ---EXPECTF-- -heartbeat: 2 -connected: false -persistent: false - -heartbeat: 2 -connected: true -persistent: true - -AMQPException: Library error: a socket error occurred - -heartbeat: 2 -connected: false -persistent: false - -heartbeat: 2 -connected: true -persistent: true - -channel created - -heartbeat: 2 -connected: true -persistent: true - -heartbeat: 2 -connected: false -persistent: false diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_persistent_construct_basic.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_persistent_construct_basic.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_persistent_construct_basic.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_persistent_construct_basic.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ ---TEST-- -AMQPConnection persitent constructor ---SKIPIF-- - ---FILE-- -pconnect(); -echo get_class($cnn) . "\n"; -echo $cnn->isConnected() ? 'true' : 'false', PHP_EOL; -echo $cnn->isPersistent() ? 'true' : 'false', PHP_EOL; -?> ---EXPECT-- -AMQPConnection -true -true \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_persistent_in_use.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_persistent_in_use.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_persistent_in_use.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_persistent_in_use.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ ---TEST-- -AMQPConnection persitent connection resource can't be used by multiple connection ---SKIPIF-- - ---FILE-- -pconnect(); -echo $cnn->isConnected() ? 'true' : 'false', PHP_EOL; - -echo PHP_EOL; - -$cnn2 = new AMQPConnection(); -echo get_class($cnn), PHP_EOL; - -try { - $cnn2->pconnect(); - echo 'reused', PHP_EOL; -} catch (AMQPException $e) { - echo get_class($e), ': ', $e->getMessage(), PHP_EOL; -} -echo $cnn->isConnected() ? 'true' : 'false', PHP_EOL; - -?> ---EXPECT-- -AMQPConnection -true - -AMQPConnection -AMQPConnectionException: There are already established persistent connection to the same resource. -true \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_persistent_reusable.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_persistent_reusable.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_persistent_reusable.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_persistent_reusable.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ ---TEST-- -AMQPConnection persistent connection are reusable ---SKIPIF-- - ---FILE-- -pconnect(); -echo get_class($cnn), PHP_EOL; -echo $cnn->isConnected() ? 'true' : 'false', PHP_EOL; - -if ($manual) { - $ch = new AMQPChannel($cnn); - sleep(10); - $ch = null; -} - -$cnn = null; -echo PHP_EOL; - -if ($manual) { - sleep(10); -} - -$cnn = new AMQPConnection(); -$cnn->pconnect(); -echo get_class($cnn), PHP_EOL; -echo $cnn->isConnected() ? 'true' : 'false', PHP_EOL; - -if ($manual) { - $ch = new AMQPChannel($cnn); - sleep(10); - $ch = null; -} - -$cnn->pdisconnect(); - -?> ---EXPECT-- -AMQPConnection -true - -AMQPConnection -true diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_setHost.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_setHost.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_setHost.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_setHost.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ ---TEST-- -AMQPConnection setHost ---SKIPIF-- - ---FILE-- -getHost()); -$cnn->setHost('nonexistent'); -var_dump($cnn->getHost()); ---EXPECTF-- -string(9) "localhost" -string(11) "nonexistent" diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_setLogin.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_setLogin.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_setLogin.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_setLogin.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ ---TEST-- -AMQPConnection setLogin ---SKIPIF-- - ---FILE-- -getLogin()); -$cnn->setLogin('nonexistent'); -var_dump($cnn->getLogin()); ---EXPECTF-- -string(5) "guest" -string(11) "nonexistent" diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_setPassword.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_setPassword.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_setPassword.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_setPassword.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ ---TEST-- -AMQPConnection setPassword ---SKIPIF-- - ---FILE-- -getPassword()); -$cnn->setPassword('nonexistent'); -var_dump($cnn->getPassword()); ---EXPECTF-- -string(5) "guest" -string(11) "nonexistent" diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_setPort_int.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_setPort_int.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_setPort_int.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_setPort_int.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ ---TEST-- -AMQPConnection constructor ---SKIPIF-- - ---FILE-- -setPort(12345), true), PHP_EOL; -echo $cnn->getPort(), PHP_EOL; -?> ---EXPECT-- -true -12345 diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_setPort_out_of_range.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_setPort_out_of_range.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_setPort_out_of_range.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_setPort_out_of_range.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ ---TEST-- -AMQPConnection setPort with int out of range ---SKIPIF-- - ---FILE-- -setPort(1234567890); -} catch (Exception $e) { - echo $e->getMessage(); -} -?> ---EXPECT-- -Invalid port given. Value must be between 1 and 65535. \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_setPort_string.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_setPort_string.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_setPort_string.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_setPort_string.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ ---TEST-- -AMQPConnection setPort with string ---SKIPIF-- - ---FILE-- -setPort('12345'); -?> ---EXPECT-- -1 \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_setReadTimeout_float.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_setReadTimeout_float.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_setReadTimeout_float.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_setReadTimeout_float.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ ---TEST-- -AMQPConnection setReadTimeout float ---SKIPIF-- - ---FILE-- -setReadTimeout(.34); -var_dump($cnn->getReadTimeout()); -$cnn->setReadTimeout(4.7e-2); -var_dump($cnn->getReadTimeout());?> ---EXPECT-- -float(0.34) -float(0.047) diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_setReadTimeout_int.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_setReadTimeout_int.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_setReadTimeout_int.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_setReadTimeout_int.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ ---TEST-- -AMQPConnection setReadTimeout int ---SKIPIF-- - ---FILE-- -setReadTimeout(3); -var_dump($cnn->getReadTimeout()); -?> ---EXPECT-- -float(3) diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_setReadTimeout_out_of_range.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_setReadTimeout_out_of_range.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_setReadTimeout_out_of_range.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_setReadTimeout_out_of_range.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ ---TEST-- -AMQPConnection setReadTimeout out of range ---SKIPIF-- - ---FILE-- -setReadTimeout(-1); -} catch (Exception $e) { - echo get_class($e); - echo PHP_EOL; - echo $e->getMessage(); -} -?> ---EXPECT-- -AMQPConnectionException -Parameter 'read_timeout' must be greater than or equal to zero. diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_setReadTimeout_string.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_setReadTimeout_string.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_setReadTimeout_string.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_setReadTimeout_string.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ ---TEST-- -AMQPConnection setReadTimeout string ---SKIPIF-- - ---FILE-- -setReadTimeout(".34"); -var_dump($cnn->getReadTimeout()); -$cnn->setReadTimeout("4.7e-2"); -var_dump($cnn->getReadTimeout());?> ---EXPECT-- -float(0.34) -float(0.047) diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_setTimeout_deprecated.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_setTimeout_deprecated.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_setTimeout_deprecated.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_setTimeout_deprecated.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ ---TEST-- -AMQPConnection setTimeout deprecated ---SKIPIF-- - ---FILE-- -setTimeout(0); -$cnn->getTimeout(); -?> ---EXPECTF-- -%s: AMQPConnection::setTimeout(): AMQPConnection::setTimeout($timeout) method is deprecated; use AMQPConnection::setReadTimeout($timeout) instead in %s on line 3 - -%s: AMQPConnection::getTimeout(): AMQPConnection::getTimeout() method is deprecated; use AMQPConnection::getReadTimeout() instead in %s on line 4 diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_setTimeout_float.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_setTimeout_float.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_setTimeout_float.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_setTimeout_float.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ ---TEST-- -AMQPConnection setTimeout float ---SKIPIF-- - ---FILE-- -setTimeout(.34); -var_dump($cnn->getTimeout()); -$cnn->setTimeout(4.7e-2); -var_dump($cnn->getTimeout());?> ---EXPECTF-- -%s: AMQPConnection::setTimeout(): AMQPConnection::setTimeout($timeout) method is deprecated; use AMQPConnection::setReadTimeout($timeout) instead in %s on line 3 - -%s: AMQPConnection::getTimeout(): AMQPConnection::getTimeout() method is deprecated; use AMQPConnection::getReadTimeout() instead in %s on line 4 -float(0.34) - -%s: AMQPConnection::setTimeout(): AMQPConnection::setTimeout($timeout) method is deprecated; use AMQPConnection::setReadTimeout($timeout) instead in %s on line 5 - -%s: AMQPConnection::getTimeout(): AMQPConnection::getTimeout() method is deprecated; use AMQPConnection::getReadTimeout() instead in %s on line 6 -float(0.047) diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_setTimeout_int.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_setTimeout_int.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_setTimeout_int.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_setTimeout_int.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ ---TEST-- -AMQPConnection setTimeout int ---SKIPIF-- - ---FILE-- -setTimeout(3); -var_dump($cnn->getTimeout()); -?> ---EXPECTF-- -%s: AMQPConnection::setTimeout(): AMQPConnection::setTimeout($timeout) method is deprecated; use AMQPConnection::setReadTimeout($timeout) instead in %s on line 3 - -%s: AMQPConnection::getTimeout(): AMQPConnection::getTimeout() method is deprecated; use AMQPConnection::getReadTimeout() instead in %s on line 4 -float(3) diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_setTimeout_out_of_range.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_setTimeout_out_of_range.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_setTimeout_out_of_range.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_setTimeout_out_of_range.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ ---TEST-- -AMQPConnection setTimeout out of range ---SKIPIF-- - ---FILE-- -setTimeout(-1); -} catch (Exception $e) { - echo get_class($e); - echo PHP_EOL; - echo $e->getMessage(); -} -?> ---EXPECTF-- -%s: AMQPConnection::setTimeout(): AMQPConnection::setTimeout($timeout) method is deprecated; use AMQPConnection::setReadTimeout($timeout) instead in %s on line 4 -AMQPConnectionException -Parameter 'timeout' must be greater than or equal to zero. diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_setTimeout_string.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_setTimeout_string.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_setTimeout_string.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_setTimeout_string.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ ---TEST-- -AMQPConnection setTimeout string ---SKIPIF-- - ---FILE-- -setTimeout(".34"); -var_dump($cnn->getTimeout()); -$cnn->setTimeout("4.7e-2"); -var_dump($cnn->getTimeout());?> ---EXPECTF-- -%s: AMQPConnection::setTimeout(): AMQPConnection::setTimeout($timeout) method is deprecated; use AMQPConnection::setReadTimeout($timeout) instead in %s on line 3 - -%s: AMQPConnection::getTimeout(): AMQPConnection::getTimeout() method is deprecated; use AMQPConnection::getReadTimeout() instead in %s on line 4 -float(0.34) - -%s: AMQPConnection::setTimeout(): AMQPConnection::setTimeout($timeout) method is deprecated; use AMQPConnection::setReadTimeout($timeout) instead in %s on line 5 - -%s: AMQPConnection::getTimeout(): AMQPConnection::getTimeout() method is deprecated; use AMQPConnection::getReadTimeout() instead in %s on line 6 -float(0.047) diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_setVhost.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_setVhost.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_setVhost.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_setVhost.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ ---TEST-- -AMQPConnection setVhost ---SKIPIF-- - ---FILE-- -getVhost()); -$cnn->setVhost('nonexistent'); -var_dump($cnn->getVhost()); ---EXPECTF-- -string(1) "/" -string(11) "nonexistent" diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_setWriteTimeout_float.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_setWriteTimeout_float.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_setWriteTimeout_float.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_setWriteTimeout_float.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ ---TEST-- -AMQPConnection setWriteTimeout float ---SKIPIF-- - ---FILE-- -setWriteTimeout(.34); -var_dump($cnn->getWriteTimeout()); -$cnn->setWriteTimeout(4.7e-2); -var_dump($cnn->getWriteTimeout());?> ---EXPECT-- -float(0.34) -float(0.047) diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_setWriteTimeout_int.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_setWriteTimeout_int.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_setWriteTimeout_int.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_setWriteTimeout_int.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ ---TEST-- -AMQPConnection setWriteTimeout int ---SKIPIF-- - ---FILE-- -setWriteTimeout(3); -var_dump($cnn->getWriteTimeout()); -?> ---EXPECT-- -float(3) diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_setWriteTimeout_out_of_range.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_setWriteTimeout_out_of_range.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_setWriteTimeout_out_of_range.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_setWriteTimeout_out_of_range.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ ---TEST-- -AMQPConnection setWriteTimeout out of range ---SKIPIF-- - ---FILE-- -setWriteTimeout(-1); -} catch (Exception $e) { - echo get_class($e); - echo PHP_EOL; - echo $e->getMessage(); -} -?> ---EXPECT-- -AMQPConnectionException -Parameter 'write_timeout' must be greater than or equal to zero. diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_setWriteTimeout_string.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_setWriteTimeout_string.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_setWriteTimeout_string.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_setWriteTimeout_string.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ ---TEST-- -AMQPConnection setWriteTimeout string ---SKIPIF-- - ---FILE-- -setWriteTimeout(".34"); -var_dump($cnn->getWriteTimeout()); -$cnn->setWriteTimeout("4.7e-2"); -var_dump($cnn->getWriteTimeout()); -?> ---EXPECT-- -float(0.34) -float(0.047) diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_toomanychannels.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_toomanychannels.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_toomanychannels.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_toomanychannels.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ ---TEST-- -AMQPConnection too many channels on a connection ---SKIPIF-- - ---FILE-- -connect(); - -$channels = array(); - -for ($i = 0; $i < PHP_AMQP_MAX_CHANNELS; $i++) { - $channel = $channels[] = new AMQPChannel($cnn); - //echo '#', $channel->getChannelId(), ', used ', $cnn->getUsedChannels(), ' of ', $cnn->getMaxChannels(), PHP_EOL; -} - -echo "Good\n"; - -try { - new AMQPChannel($cnn); - echo "Bad\n"; -} catch(Exception $e) { - echo get_class($e), ': ', $e->getMessage(), PHP_EOL; -} - -?> ---EXPECT-- -Good -AMQPChannelException: Could not create channel. Connection has no open channel slots remaining. \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_var_dump.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_var_dump.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpconnection_var_dump.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpconnection_var_dump.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,100 +0,0 @@ ---TEST-- -AMQPConnection var_dump ---SKIPIF-- - ---FILE-- -isConnected()); -var_dump($cnn); -$cnn->connect(); -var_dump($cnn->isConnected()); -$cnn->connect(); -var_dump($cnn->isConnected()); -var_dump($cnn); - -$cnn->disconnect(); -var_dump($cnn->isConnected()); -var_dump($cnn); -?> ---EXPECT-- -bool(false) -object(AMQPConnection)#1 (11) { - ["login":"AMQPConnection":private]=> - string(5) "guest" - ["password":"AMQPConnection":private]=> - string(5) "guest" - ["host":"AMQPConnection":private]=> - string(9) "localhost" - ["vhost":"AMQPConnection":private]=> - string(1) "/" - ["port":"AMQPConnection":private]=> - int(5672) - ["read_timeout":"AMQPConnection":private]=> - float(0) - ["write_timeout":"AMQPConnection":private]=> - float(0) - ["connect_timeout":"AMQPConnection":private]=> - float(0) - ["channel_max":"AMQPConnection":private]=> - int(256) - ["frame_max":"AMQPConnection":private]=> - int(131072) - ["heartbeat":"AMQPConnection":private]=> - int(0) -} -bool(true) -bool(true) -object(AMQPConnection)#1 (11) { - ["login":"AMQPConnection":private]=> - string(5) "guest" - ["password":"AMQPConnection":private]=> - string(5) "guest" - ["host":"AMQPConnection":private]=> - string(9) "localhost" - ["vhost":"AMQPConnection":private]=> - string(1) "/" - ["port":"AMQPConnection":private]=> - int(5672) - ["read_timeout":"AMQPConnection":private]=> - float(0) - ["write_timeout":"AMQPConnection":private]=> - float(0) - ["connect_timeout":"AMQPConnection":private]=> - float(0) - ["channel_max":"AMQPConnection":private]=> - int(256) - ["frame_max":"AMQPConnection":private]=> - int(131072) - ["heartbeat":"AMQPConnection":private]=> - int(0) -} -bool(false) -object(AMQPConnection)#1 (11) { - ["login":"AMQPConnection":private]=> - string(5) "guest" - ["password":"AMQPConnection":private]=> - string(5) "guest" - ["host":"AMQPConnection":private]=> - string(9) "localhost" - ["vhost":"AMQPConnection":private]=> - string(1) "/" - ["port":"AMQPConnection":private]=> - int(5672) - ["read_timeout":"AMQPConnection":private]=> - float(0) - ["write_timeout":"AMQPConnection":private]=> - float(0) - ["connect_timeout":"AMQPConnection":private]=> - float(0) - ["channel_max":"AMQPConnection":private]=> - int(256) - ["frame_max":"AMQPConnection":private]=> - int(131072) - ["heartbeat":"AMQPConnection":private]=> - int(0) -} diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpenvelope_construct.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpenvelope_construct.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpenvelope_construct.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpenvelope_construct.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,51 +0,0 @@ ---TEST-- -AMQPEnvelope construct ---SKIPIF-- - ---EXPECT-- -object(AMQPEnvelope)#1 (18) { - ["body":"AMQPEnvelope":private]=> - string(0) "" - ["delivery_tag":"AMQPEnvelope":private]=> - int(0) - ["is_redelivery":"AMQPEnvelope":private]=> - bool(false) - ["exchange_name":"AMQPEnvelope":private]=> - string(0) "" - ["routing_key":"AMQPEnvelope":private]=> - string(0) "" - ["content_type":"AMQPEnvelope":private]=> - string(0) "" - ["content_encoding":"AMQPEnvelope":private]=> - string(0) "" - ["headers":"AMQPEnvelope":private]=> - array(0) { - } - ["delivery_mode":"AMQPEnvelope":private]=> - int(1) - ["priority":"AMQPEnvelope":private]=> - int(0) - ["correlation_id":"AMQPEnvelope":private]=> - string(0) "" - ["reply_to":"AMQPEnvelope":private]=> - string(0) "" - ["expiration":"AMQPEnvelope":private]=> - string(0) "" - ["message_id":"AMQPEnvelope":private]=> - string(0) "" - ["timestamp":"AMQPEnvelope":private]=> - int(0) - ["type":"AMQPEnvelope":private]=> - string(0) "" - ["user_id":"AMQPEnvelope":private]=> - string(0) "" - ["app_id":"AMQPEnvelope":private]=> - string(0) "" -} \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpenvelope_get_accessors.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpenvelope_get_accessors.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpenvelope_get_accessors.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpenvelope_get_accessors.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ ---TEST-- -AMQPEnvelope test get*() accessors ---SKIPIF-- - ---FILE-- -connect(); -$ch = new AMQPChannel($cnn); -// Declare a new exchange -$ex = new AMQPExchange($ch); -$ex->setName('exchange-'.microtime(true)); -$ex->setType(AMQP_EX_TYPE_FANOUT); -$ex->declareExchange(); -// Create a new queue -$q = new AMQPQueue($ch); -$q->setName('queue1' . microtime(true)); -$q->declareQueue(); -// Bind it on the exchange to routing.key -$q->bind($ex->getName(), 'routing.*'); -// Publish a message to the exchange with a routing key -$ex->publish('message', 'routing.1', AMQP_NOPARAM, array('headers' => array('foo' => 'bar'))); - -// Read from the queue -$msg = $q->get(); -dump_message($msg); - -$header = $msg->getHeader('foo'); -var_dump($header); -$header = 'changed'; -$header = $msg->getHeader('foo'); -var_dump($header); - -?> ---EXPECTF-- -AMQPEnvelope - getBody: - string(7) "message" - getContentType: - string(10) "text/plain" - getRoutingKey: - string(9) "routing.1" - getDeliveryTag: - int(1) - getDeliveryMode: - int(1) - getExchangeName: - string(%d) "exchange-%f" - isRedelivery: - bool(false) - getContentEncoding: - string(0) "" - getType: - string(0) "" - getTimeStamp: - int(0) - getPriority: - int(0) - getExpiration: - string(0) "" - getUserId: - string(0) "" - getAppId: - string(0) "" - getMessageId: - string(0) "" - getReplyTo: - string(0) "" - getCorrelationId: - string(0) "" - getHeaders: - array(1) { - ["foo"]=> - string(3) "bar" -} -string(3) "bar" -string(3) "bar" \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpenvelope_var_dump.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpenvelope_var_dump.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpenvelope_var_dump.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpenvelope_var_dump.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,114 +0,0 @@ ---TEST-- -AMQPEnvelope var_dump ---SKIPIF-- -connect(); -$ch = new AMQPChannel($cnn); -// Declare a new exchange -$ex = new AMQPExchange($ch); -$ex->setName('exchange1'); -$ex->setType(AMQP_EX_TYPE_FANOUT); -$ex->declareExchange(); -// Create a new queue -$q = new AMQPQueue($ch); -$q->setName('queue1' . microtime(true)); -$q->declareQueue(); -// Bind it on the exchange to routing.key -$q->bind($ex->getName(), 'routing.*'); -// Publish a message to the exchange with a routing key -$ex->publish('message', 'routing.1'); -$ex->publish('message', 'routing.1', AMQP_NOPARAM, array("headers" => array("test" => "passed"))); - -// Read from the queue -$q->consume("consumeThings"); -$q->consume("consumeThings"); -?> ---EXPECTF-- -object(AMQPEnvelope)#5 (18) { - ["body":"AMQPEnvelope":private]=> - string(7) "message" - ["delivery_tag":"AMQPEnvelope":private]=> - int(1) - ["is_redelivery":"AMQPEnvelope":private]=> - bool(false) - ["exchange_name":"AMQPEnvelope":private]=> - string(9) "exchange1" - ["routing_key":"AMQPEnvelope":private]=> - string(9) "routing.1" - ["content_type":"AMQPEnvelope":private]=> - string(10) "text/plain" - ["content_encoding":"AMQPEnvelope":private]=> - string(0) "" - ["headers":"AMQPEnvelope":private]=> - array(0) { - } - ["delivery_mode":"AMQPEnvelope":private]=> - int(1) - ["priority":"AMQPEnvelope":private]=> - int(0) - ["correlation_id":"AMQPEnvelope":private]=> - string(0) "" - ["reply_to":"AMQPEnvelope":private]=> - string(0) "" - ["expiration":"AMQPEnvelope":private]=> - string(0) "" - ["message_id":"AMQPEnvelope":private]=> - string(0) "" - ["timestamp":"AMQPEnvelope":private]=> - int(0) - ["type":"AMQPEnvelope":private]=> - string(0) "" - ["user_id":"AMQPEnvelope":private]=> - string(0) "" - ["app_id":"AMQPEnvelope":private]=> - string(0) "" -} -object(AMQPEnvelope)#%d (18) { - ["body":"AMQPEnvelope":private]=> - string(7) "message" - ["delivery_tag":"AMQPEnvelope":private]=> - int(2) - ["is_redelivery":"AMQPEnvelope":private]=> - bool(false) - ["exchange_name":"AMQPEnvelope":private]=> - string(9) "exchange1" - ["routing_key":"AMQPEnvelope":private]=> - string(9) "routing.1" - ["content_type":"AMQPEnvelope":private]=> - string(10) "text/plain" - ["content_encoding":"AMQPEnvelope":private]=> - string(0) "" - ["headers":"AMQPEnvelope":private]=> - array(1) { - ["test"]=> - string(6) "passed" - } - ["delivery_mode":"AMQPEnvelope":private]=> - int(1) - ["priority":"AMQPEnvelope":private]=> - int(0) - ["correlation_id":"AMQPEnvelope":private]=> - string(0) "" - ["reply_to":"AMQPEnvelope":private]=> - string(0) "" - ["expiration":"AMQPEnvelope":private]=> - string(0) "" - ["message_id":"AMQPEnvelope":private]=> - string(0) "" - ["timestamp":"AMQPEnvelope":private]=> - int(0) - ["type":"AMQPEnvelope":private]=> - string(0) "" - ["user_id":"AMQPEnvelope":private]=> - string(0) "" - ["app_id":"AMQPEnvelope":private]=> - string(0) "" -} \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_attributes.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_attributes.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_attributes.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_attributes.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ ---TEST-- -AMQPExchange attributes ---SKIPIF-- - ---FILE-- -connect(); -$ch = new AMQPChannel($cnn); - -$ex = new AMQPExchange($ch); - -$ex->setArguments(array('existent' => 'value', 'false' => false)); - -foreach (array('existent', 'false', 'nonexistent') as $key) { - echo "$key: ", var_export($ex->hasArgument($key), true), ', ', var_export($ex->getArgument($key)), PHP_EOL; -} - -?> ---EXPECT-- -existent: true, 'value' -false: true, false -nonexistent: false, false diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_bind.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_bind.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_bind.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_bind.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ ---TEST-- -AMQPExchange::bind ---SKIPIF-- - ---FILE-- -connect(); - -$ch = new AMQPChannel($cnn); - -// Declare a new exchange -$ex = new AMQPExchange($ch); -$ex->setName('exchange-' . microtime(true)); -$ex->setType(AMQP_EX_TYPE_FANOUT); -$ex->declareExchange(); - -// Declare a new exchange -$ex2 = new AMQPExchange($ch); -$ex2->setName('exchange2-' . microtime(true)); -$ex2->setType(AMQP_EX_TYPE_FANOUT); -$ex2->declareExchange(); - -var_dump($ex->bind($ex2->getName(), 'test-key-1')); -var_dump($ex->bind($ex2->getName(), 'test-key-1')); - -?> ---EXPECT-- -bool(true) -bool(true) \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_bind_with_arguments.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_bind_with_arguments.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_bind_with_arguments.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_bind_with_arguments.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ ---TEST-- -AMQPExchange::bind with arguments ---SKIPIF-- - ---FILE-- -connect(); - -$ch = new AMQPChannel($cnn); - -// Declare a new exchange -$ex = new AMQPExchange($ch); -$ex->setName('exchange-' . microtime(true)); -$ex->setType(AMQP_EX_TYPE_FANOUT); -$ex->declareExchange(); - -// Declare a new exchange -$ex2 = new AMQPExchange($ch); -$ex2->setName('exchange2-' . microtime(true)); -$ex2->setType(AMQP_EX_TYPE_FANOUT); -$ex2->declareExchange(); - -$time = microtime(true); - -var_dump($ex->bind($ex2->getName(), 'test', array('test' => 'passed', 'at' => $time))); -var_dump($ex->bind($ex2->getName(), 'test', array('test' => 'passed', 'at' => $time))); - -?> ---EXPECT-- -bool(true) -bool(true) \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_bind_without_key.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_bind_without_key.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_bind_without_key.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_bind_without_key.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ ---TEST-- -AMQPExchange::bind without key ---SKIPIF-- - ---FILE-- -connect(); - -$ch = new AMQPChannel($cnn); - -// Declare a new exchange -$ex = new AMQPExchange($ch); -$ex->setName('exchange-' . microtime(true)); -$ex->setType(AMQP_EX_TYPE_FANOUT); -$ex->declareExchange(); - -// Declare a new exchange -$ex2 = new AMQPExchange($ch); -$ex2->setName('exchange2-' . microtime(true)); -$ex2->setType(AMQP_EX_TYPE_FANOUT); -$ex2->declareExchange(); - -var_dump($ex->bind($ex2->getName())); -var_dump($ex->bind($ex2->getName(), null)); -var_dump($ex->bind($ex2->getName(), '')); - -?> ---EXPECT-- -bool(true) -bool(true) -bool(true) \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_bind_without_key_with_arguments.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_bind_without_key_with_arguments.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_bind_without_key_with_arguments.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_bind_without_key_with_arguments.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ ---TEST-- -AMQPExchange::bind without key with arguments ---SKIPIF-- - ---FILE-- -connect(); - -$ch = new AMQPChannel($cnn); - -// Declare a new exchange -$ex = new AMQPExchange($ch); -$ex->setName('exchange-' . microtime(true)); -$ex->setType(AMQP_EX_TYPE_FANOUT); -$ex->declareExchange(); - -// Declare a new exchange -$ex2 = new AMQPExchange($ch); -$ex2->setName('exchange2-' . microtime(true)); -$ex2->setType(AMQP_EX_TYPE_FANOUT); -$ex2->declareExchange(); - -$time = microtime(true); - -var_dump($ex->bind($ex2->getName(), null, array('test' => 'passed', 'at' => $time, 'i am' => 'first'))); -var_dump($ex->bind($ex2->getName(), '', array('test' => 'passed', 'at' => $time, 'i am' => 'second'))); - -?> ---EXPECT-- -bool(true) -bool(true) \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_channel_refcount.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_channel_refcount.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_channel_refcount.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_channel_refcount.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ ---TEST-- -AMQPExchange channel refcount ---SKIPIF-- - ---FILE-- -connect(); - - $ch = new AMQPChannel($cnn); - - $ex = new AMQPExchange($ch); - - $ex->setName("refcount-testing"); - - return $ex; -} - -$ex = buildExchange(); - -echo $ex->getName() . "\n"; - -$ex->setType(AMQP_EX_TYPE_FANOUT); - -$ex->declareExchange(); - -$ex->delete(); - -?> ---EXPECT-- -refcount-testing diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_construct_basic.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_construct_basic.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_construct_basic.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_construct_basic.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ ---TEST-- -AMQPExchange constructor ---SKIPIF-- - ---FILE-- -connect(); - -$ch = new AMQPChannel($cnn); - -$ex = new AMQPExchange($ch); -echo get_class($ex); -?> ---EXPECT-- -AMQPExchange \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_declare_basic.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_declare_basic.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_declare_basic.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_declare_basic.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ ---TEST-- -AMQPExchange ---SKIPIF-- - ---FILE-- -connect(); - -$ch = new AMQPChannel($cnn); - -$ex = new AMQPExchange($ch); -$ex->setName("exchange-" . microtime(true)); -$ex->setType(AMQP_EX_TYPE_FANOUT); -echo $ex->declareExchange() ? "true" : "false"; -?> ---EXPECT-- -true diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_declare_existent.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_declare_existent.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_declare_existent.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_declare_existent.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ ---TEST-- -AMQPExchange ---SKIPIF-- - ---FILE-- -connect(); - -$ch = new AMQPChannel($cnn); - -echo 'Channel id: ', $ch->getChannelId(), PHP_EOL; - -$exchangge_name = "exchange-" . microtime(true); - -$ex = new AMQPExchange($ch); -$ex->setName($exchangge_name); -$ex->setType(AMQP_EX_TYPE_FANOUT); -echo "Exchange declared: ", $ex->declareExchange() ? "true" : "false", PHP_EOL; - -try { - $ex = new AMQPExchange($ch); - $ex->setName($exchangge_name); - $ex->setType(AMQP_EX_TYPE_TOPIC); - $ex->declareExchange(); - echo 'exchange ', $ex->getName(), ' declared', PHP_EOL; -} catch (AMQPException $e) { - echo get_class($e), ': ', $e->getMessage(), PHP_EOL; -} - -echo "Channel connected: ", $ch->isConnected() ? "true" : "false", PHP_EOL; -echo "Connection connected: ", $cnn->isConnected() ? "true" : "false", PHP_EOL; - -try { - $ex = new AMQPExchange($ch); - echo "New exchange class created", PHP_EOL; -} catch (AMQPException $e) { - echo get_class($e), ': ', $e->getMessage(), PHP_EOL; -} -?> ---EXPECTF-- -Channel id: 1 -Exchange declared: true -AMQPExchangeException: Server channel error: 406, message: PRECONDITION_FAILED - %s exchange 'exchange-%f' in vhost '/'%s -Channel connected: false -Connection connected: true -AMQPChannelException: Could not create exchange. No channel available. \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_declare_without_name.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_declare_without_name.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_declare_without_name.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_declare_without_name.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ ---TEST-- -AMQPExchange::declareExchange() without name set ---SKIPIF-- - ---FILE-- -connect(); - -$ch = new AMQPChannel($cnn); - - -$ex = new AMQPExchange($ch); -$ex->setType(AMQP_EX_TYPE_FANOUT); - -try { - $ex->declareExchange(); - echo 'Exchange declared', PHP_EOL; -} catch (AMQPException $e) { - echo get_class($e), ': ', $e->getMessage(), PHP_EOL; -} -?> ---EXPECTF-- -AMQPExchangeException: Could not declare exchange. Exchanges must have a name. diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_declare_without_type.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_declare_without_type.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_declare_without_type.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_declare_without_type.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ ---TEST-- -AMQPExchange::declareExchange() without type set ---SKIPIF-- - ---FILE-- -connect(); - -$ch = new AMQPChannel($cnn); - -$exchangge_name = "exchange-" . microtime(true); - -$ex = new AMQPExchange($ch); -$ex->setName($exchangge_name); - -try { - $ex->declareExchange(); - echo 'Exchange declared', PHP_EOL; -} catch (AMQPException $e) { - echo get_class($e), ': ', $e->getMessage(), PHP_EOL; -} -?> ---EXPECTF-- -AMQPExchangeException: Could not declare exchange. Exchanges must have a type. diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_declare_with_stalled_reference.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_declare_with_stalled_reference.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_declare_with_stalled_reference.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_declare_with_stalled_reference.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ ---TEST-- -AMQPExchange - declare with stalled reference ---SKIPIF-- - ---FILE-- -declareExchange(); -} catch (\Exception $e) { - echo get_class($e), ': ', $e->getMessage(), PHP_EOL; -} - -?> ---EXPECT-- -AMQPChannelException: Could not declare exchange. Stale reference to the channel object. diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_get_channel.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_get_channel.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_get_channel.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_get_channel.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ ---TEST-- -AMQPExchange getChannel() test ---SKIPIF-- - ---FILE-- -connect(); - -$ch = new AMQPChannel($cnn); -$ch2 = new AMQPChannel($cnn); - -$ex = new AMQPExchange($ch); - - -echo $ch === $ex->getChannel() ? 'same' : 'not same', PHP_EOL; -echo $ch2 === $ex->getChannel() ? 'same' : 'not same', PHP_EOL; - -$old_prefetch = $ch->getPrefetchCount(); -$new_prefetch = 999; - -$ex->getChannel()->setPrefetchCount($new_prefetch); - -echo $ch->getPrefetchCount() == $new_prefetch ? 'by ref' : 'copy', PHP_EOL; - -?> ---EXPECT-- -same -not same -by ref diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_get_connection.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_get_connection.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_get_connection.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_get_connection.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ ---TEST-- -AMQPExchange getConnection test ---SKIPIF-- - ---FILE-- -connect(); -$ch = new AMQPChannel($cnn); - -$ex = new AMQPExchange($ch); - -$cnn2 = new AMQPConnection(); - -echo $cnn === $ex->getConnection() ? 'same' : 'not same', PHP_EOL; -echo $cnn2 === $ex->getConnection() ? 'same' : 'not same', PHP_EOL; - -$old_host = $cnn->getHost(); -$new_host = 'test'; - -$ex->getConnection()->setHost($new_host); - -echo $cnn->getHost() == $new_host ? 'by ref' : 'copy', PHP_EOL; - -?> ---EXPECT-- -same -not same -by ref diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_invalid_type.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_invalid_type.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_invalid_type.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_invalid_type.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ ---TEST-- -AMQPExchange ---SKIPIF-- - ---FILE-- -connect(); - -$ch = new AMQPChannel($cnn); - -$ex = new AMQPExchange($ch); -$ex->setName("exchange-" . microtime(true)); -$ex->setType("invalid_exchange_type"); - -echo "Channel ", $ch->isConnected() ? 'connected' : 'disconnected', PHP_EOL; -echo "Connection ", $cnn->isConnected() ? 'connected' : 'disconnected', PHP_EOL; - -try { - $ex->declareExchange(); -} catch (AMQPException $e) { - echo get_class($e), ': ', $e->getMessage(), PHP_EOL; -} - -echo "Channel ", $ch->isConnected() ? 'connected' : 'disconnected', PHP_EOL; -echo "Connection ", $cnn->isConnected() ? 'connected' : 'disconnected', PHP_EOL; - -?> ---EXPECT-- -Channel connected -Connection connected -AMQPConnectionException: Server connection error: 503, message: COMMAND_INVALID - unknown exchange type 'invalid_exchange_type' -Channel disconnected -Connection disconnected \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_publish_basic.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_publish_basic.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_publish_basic.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_publish_basic.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ ---TEST-- -AMQPExchange ---SKIPIF-- - ---FILE-- -connect(); - -$ch = new AMQPChannel($cnn); - -$ex = new AMQPExchange($ch); -$ex->setName("exchange-" . microtime(true)); -$ex->setType(AMQP_EX_TYPE_FANOUT); -$ex->declareExchange(); -echo $ex->publish('message', 'routing.key') ? 'true' : 'false'; -$ex->delete(); -?> ---EXPECT-- -true diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_publish_empty_routing_key.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_publish_empty_routing_key.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_publish_empty_routing_key.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_publish_empty_routing_key.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ ---TEST-- -AMQPExchange publish with empty routing key ---SKIPIF-- - ---FILE-- -connect(); - -$ch = new AMQPChannel($cnn); - -$ex = new AMQPExchange($ch); -$ex->setName("exchange-" . microtime(true)); -$ex->setType(AMQP_EX_TYPE_FANOUT); -$ex->declareExchange(); -echo $ex->publish('message') ? 'true' : 'false'; -$ex->delete(); -?> ---EXPECT-- -true diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_publish_timeout.disabled php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_publish_timeout.disabled --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_publish_timeout.disabled 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_publish_timeout.disabled 1970-01-01 00:00:00.000000000 +0000 @@ -1,57 +0,0 @@ ---TEST-- -AMQPExchange ---SKIPIF-- - ---FILE-- - $timeout)); -$conn->connect(); - -$chan = new AMQPChannel($conn); - -$ex = new AMQPExchange($chan); -$ex->setName("exchange-pub-timeout-" . time()); -$ex->setType(AMQP_EX_TYPE_FANOUT); -$ex->declare(); - -$queue = new AMQPQueue($chan); -$queue->setName('queue-for-'.$ex->getName()); -$queue->setFlags(AMQP_EXCLUSIVE); -$queue->declare(); -$queue->bind($ex->getName(), 'ignored-for-fanout'); - -$message = str_repeat('d41d8cd98f00b204e9800998ecf8427e', 32); // 32768 - 1mb, 32 - 1Kb -$start = $end = 0; - -// try to exceed resources limit -try { - while(true) { - $start = microtime(true); - $ex->publish($message, 'ignored-for-fanout', AMQP_NOPARAM, array('expiration' => 5000)); - } -} catch (Exception $e) {} - -try { - while(true) { - $start = microtime(true); - // at this point publishing should be banned immediately - $ex->publish($message, 'ignored-for-fanout', AMQP_NOPARAM, array('expiration' => 5000)); - } -} catch (Exception $e) { - $end = microtime(true); - echo get_class($e); - echo PHP_EOL; - echo $e->getMessage(); - echo PHP_EOL; -} -//$delay = abs($end - $start - $timeout); -//echo $delay < 0.005 ? 'true' : 'false'; -?> ---EXPECT-- -AMQPExchangeException -Socket error: Resource temporarily unavailable Binary files /tmp/tmp16NgSN/W688uipSRy/php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_publish_with_null.phpt and /tmp/tmp16NgSN/uIFclp_y0o/php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_publish_with_null.phpt differ diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_publish_with_properties_ignore_num_header.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_publish_with_properties_ignore_num_header.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_publish_with_properties_ignore_num_header.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_publish_with_properties_ignore_num_header.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ ---TEST-- -AMQPExchange publish with properties - ignore numeric keys in headers ---SKIPIF-- - ---FILE-- -connect(); - -$ch = new AMQPChannel($cnn); - -$ex = new AMQPExchange($ch); -$ex->setName("exchange-" . microtime(true)); -$ex->setType(AMQP_EX_TYPE_FANOUT); -$ex->declareExchange(); - - -echo $ex->publish('message', 'routing.key', AMQP_NOPARAM, array('headers' => 'ignored')) ? 'true' : 'false', PHP_EOL; -echo $ex->publish('message', 'routing.key', AMQP_NOPARAM, array('headers' => array(2 => 'ignore_me'))) ? 'true' : 'false', PHP_EOL; - -$ex->delete(); - - -?> ---EXPECTF-- -Warning: AMQPExchange::publish(): Ignoring non-string header field '0' in %s on line %d -true - -Warning: AMQPExchange::publish(): Ignoring non-string header field '2' in %s on line %d -true diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_publish_with_properties_ignore_unsupported_header_values.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_publish_with_properties_ignore_unsupported_header_values.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_publish_with_properties_ignore_unsupported_header_values.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_publish_with_properties_ignore_unsupported_header_values.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ ---TEST-- -AMQPExchange publish with properties - ignore unsupported header values (NULL, object, resources) ---SKIPIF-- - ---FILE-- -connect(); - -$ch = new AMQPChannel($cnn); - -$ex = new AMQPExchange($ch); -$ex->setName("exchange-" . microtime(true)); -$ex->setType(AMQP_EX_TYPE_FANOUT); -$ex->declareExchange(); - -$attrs = array( - 'headers' => array( - 'null' => null, - 'object' => new stdClass(), - 'resource' => fopen(__FILE__, 'r'), - ), -); - -echo $ex->publish('message', 'routing.key', AMQP_NOPARAM, $attrs) ? 'true' : 'false'; - -$ex->delete(); - - -?> ---EXPECTF-- -Warning: AMQPExchange::publish(): Ignoring field 'null' due to unsupported value type (null) in %s on line %d - -Warning: AMQPExchange::publish(): Ignoring field 'object' due to unsupported value type (object) in %s on line %d - -Warning: AMQPExchange::publish(): Ignoring field 'resource' due to unsupported value type (resource) in %s on line %d -true \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_publish_with_properties_nested_header.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_publish_with_properties_nested_header.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_publish_with_properties_nested_header.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_publish_with_properties_nested_header.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,142 +0,0 @@ ---TEST-- -AMQPExchange publish with properties - nested header values ---SKIPIF-- - ---FILE-- -connect(); - -$ch = new AMQPChannel($cnn); - -$ex = new AMQPExchange($ch); -$ex->setName("exchange-" . microtime(true)); -$ex->setType(AMQP_EX_TYPE_FANOUT); -$ex->declareExchange(); - -$q = new AMQPQueue($ch); -$q->setName('queue-' . microtime(true)); -$q->declareQueue(); -$q->bind($ex->getName()); - -$headers = array( - 'nested' => array( - 'string' => 'passed', - 999 => 'numeric works', - 'sub-nested' => array( - 'should' => 'works', - 42 => 'too' - ), - ), -); - -$ex->publish('message', 'routing.key', AMQP_NOPARAM, array('headers' => $headers)); - -$message =$q->get(AMQP_AUTOACK); -var_dump($message->getHeaders()); -var_dump($headers); -echo $message->getHeaders() === $headers ? 'same' : 'differs'; -echo PHP_EOL, PHP_EOL; - - -$headers = array( - 'x-death' => array( - array ( - 'reason' => 'rejected', - 'queue' => 'my_queue', - 'time' => 1410527691, - 'exchange' => 'my_exchange', - 'routing-keys' => array ('my_routing_key') - ) - ) -); - -$ex->publish('message', 'routing.key', AMQP_NOPARAM, array('headers' => $headers)); - -$message =$q->get(AMQP_AUTOACK); -var_dump($message->getHeaders()); -var_dump($headers); -echo $message->getHeaders() === $headers ? 'same' : 'differs'; -echo PHP_EOL, PHP_EOL; - -?> ---EXPECT-- -array(1) { - ["nested"]=> - array(3) { - ["string"]=> - string(6) "passed" - [999]=> - string(13) "numeric works" - ["sub-nested"]=> - array(2) { - ["should"]=> - string(5) "works" - [42]=> - string(3) "too" - } - } -} -array(1) { - ["nested"]=> - array(3) { - ["string"]=> - string(6) "passed" - [999]=> - string(13) "numeric works" - ["sub-nested"]=> - array(2) { - ["should"]=> - string(5) "works" - [42]=> - string(3) "too" - } - } -} -same - -array(1) { - ["x-death"]=> - array(1) { - [0]=> - array(5) { - ["reason"]=> - string(8) "rejected" - ["queue"]=> - string(8) "my_queue" - ["time"]=> - int(1410527691) - ["exchange"]=> - string(11) "my_exchange" - ["routing-keys"]=> - array(1) { - [0]=> - string(14) "my_routing_key" - } - } - } -} -array(1) { - ["x-death"]=> - array(1) { - [0]=> - array(5) { - ["reason"]=> - string(8) "rejected" - ["queue"]=> - string(8) "my_queue" - ["time"]=> - int(1410527691) - ["exchange"]=> - string(11) "my_exchange" - ["routing-keys"]=> - array(1) { - [0]=> - string(14) "my_routing_key" - } - } - } -} -same \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_publish_with_properties.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_publish_with_properties.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_publish_with_properties.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_publish_with_properties.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,112 +0,0 @@ ---TEST-- -AMQPExchange publish with properties ---SKIPIF-- - ---FILE-- -connect(); - -$ch = new AMQPChannel($cnn); - -$ex = new AMQPExchange($ch); -$ex->setName("exchange-" . microtime(true)); -$ex->setType(AMQP_EX_TYPE_FANOUT); -$ex->declareExchange(); - -$q = new AMQPQueue($ch); -$q->declareQueue(); - -$q->bind($ex->getName()); - -$attrs = array( - 'content_type' => 1, // should be string - 'content_encoding' => 2, // should be string - 'message_id' => 3, // should be string - //'user_id' => 4, // should be string // NOTE: fail due to Validated User-ID https://www.rabbitmq.com/validated-user-id.html, @see tests/amqpexchange_publish_with_properties_user_id_failure.phpt test - 'app_id' => 5, // should be string - 'delivery_mode' => '1-non-persistent', // should be long - 'priority' => '2high', // should be long - 'timestamp' => '123now', // should be long - 'expiration' => 100000000, // should be string // NOTE: in fact it is milliseconds for how long to stay in queue, see https://www.rabbitmq.com/ttl.html#per-message-ttl for details - 'type' => 7, // should be string - 'reply_to' => 8, // should be string - 'correlation_id' => 9, // should be string - //'headers' => 'not array', // should be array // NOTE: covered in tests/amqpexchange_publish_with_properties_ignore_num_header.phpt -); - -$attrs_control = array( - 'content_type' => 1, // should be string - 'content_encoding' => 2, // should be string - 'message_id' => 3, // should be string - //'user_id' => 4, // should be string // NOTE: fail due to Validated User-ID https://www.rabbitmq.com/validated-user-id.html, @see tests/amqpexchange_publish_with_properties_user_id_failure.phpt test - 'app_id' => 5, // should be string - 'delivery_mode' => '1-non-persistent', // should be long - 'priority' => '2high', // should be long - 'timestamp' => '123now', // should be long - 'expiration' => 100000000, // should be string // NOTE: in fact it is milliseconds for how long to stay in queue, see https://www.rabbitmq.com/ttl.html#per-message-ttl for details - 'type' => 7, // should be string - 'reply_to' => 8, // should be string - 'correlation_id' => 9, // should be string - //'headers' => 'not array', // should be array // NOTE: covered in tests/amqpexchange_publish_with_properties_ignore_num_header.phpt -); - -echo $ex->publish('message', 'routing.key', AMQP_NOPARAM, $attrs) ? 'true' : 'false', PHP_EOL; - - -//var_dump($attrs, $attrs_control); -echo 'Message attributes are ', $attrs === $attrs_control ? 'the same' : 'not the same', PHP_EOL; - -$msg = $q->get(AMQP_AUTOACK); - - -dump_message($msg); - -$ex->delete(); -$q->delete(); - - -?> ---EXPECTF-- -true -Message attributes are the same -AMQPEnvelope - getBody: - string(7) "message" - getContentType: - string(1) "1" - getRoutingKey: - string(11) "routing.key" - getDeliveryTag: - int(1) - getDeliveryMode: - int(1) - getExchangeName: - string(%d) "exchange-%f" - isRedelivery: - bool(false) - getContentEncoding: - string(1) "2" - getType: - string(1) "7" - getTimeStamp: - int(123) - getPriority: - int(2) - getExpiration: - string(9) "100000000" - getUserId: - string(0) "" - getAppId: - string(1) "5" - getMessageId: - string(1) "3" - getReplyTo: - string(1) "8" - getCorrelationId: - string(1) "9" - getHeaders: - array(0) { -} \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_publish_with_properties_user_id_failure.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_publish_with_properties_user_id_failure.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_publish_with_properties_user_id_failure.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_publish_with_properties_user_id_failure.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ ---TEST-- -AMQPExchange publish with properties - user_id failure ---SKIPIF-- - ---FILE-- -connect(); - -$ch = new AMQPChannel($cnn); - -$ex = new AMQPExchange($ch); -$ex->setName("exchange-" . microtime(true)); -$ex->setType(AMQP_EX_TYPE_FANOUT); -$ex->declareExchange(); - -echo "Channel ", $ch->isConnected() ? 'connected' : 'disconnected', PHP_EOL; -echo "Connection ", $cnn->isConnected() ? 'connected' : 'disconnected', PHP_EOL; - -try { - // NOTE: basic.publish is asynchronous, so ... - echo $ex->publish('message', 'routing.key', AMQP_NOPARAM, array('user_id' => 'unknown-' . microtime(true))) ? 'true' : 'false', PHP_EOL; -} catch (AMQPException $e) { - echo get_class($e), ': ', $e->getMessage(), PHP_EOL; -} - -echo "Channel ", $ch->isConnected() ? 'connected' : 'disconnected', PHP_EOL; -echo "Connection ", $cnn->isConnected() ? 'connected' : 'disconnected', PHP_EOL; - -try { - // NOTE: ... the next socket (not only channel) operation will fail, which may lead to very strange issues - // if we operate here,on different entity, for example on queue. - - $q = new AMQPQueue($ch); - $q->declareQueue(); - - echo "Queue declared", PHP_EOL; -} catch (AMQPException $e) { - echo get_class($e), ': ', $e->getMessage(), PHP_EOL; -} - -echo "Channel ", $ch->isConnected() ? 'connected' : 'disconnected', PHP_EOL; -echo "Connection ", $cnn->isConnected() ? 'connected' : 'disconnected', PHP_EOL; - -?> ---EXPECTF-- -Channel connected -Connection connected -true -Channel connected -Connection connected -AMQPQueueException: Server channel error: 406, message: PRECONDITION_FAILED - user_id property set to 'unknown-%f' but authenticated user was 'guest' -Channel disconnected -Connection connected \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_setArgument.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_setArgument.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_setArgument.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_setArgument.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,284 +0,0 @@ ---TEST-- -AMQPExchange::setArgument() test ---SKIPIF-- - ---FILE-- -connect(); - -$ch = new AMQPChannel($cnn); - -$heartbeat = 10; -$e_name_ae = 'test.exchange.ae.' . microtime(true); -$e_name = 'test.exchange.' . microtime(true); - -$ex_ae = new AMQPExchange($ch); -$ex_ae->setName($e_name_ae); -$ex_ae->setFlags(AMQP_AUTODELETE); -$ex_ae->setType(AMQP_EX_TYPE_FANOUT); -$ex_ae->declareExchange(); - -var_dump($ex_ae); - - -$ex = new AMQPExchange($ch); -$ex->setName($e_name); -$ex->setFlags(AMQP_AUTODELETE); -$ex->setType(AMQP_EX_TYPE_FANOUT); -// some real keys -$ex->setArgument("x-ha-policy", "all"); -$ex->setArgument("alternate-exchange", $e_name_ae); -// some custom keys to test various cases -$ex->setArgument('x-empty-string', ''); -$ex->setArgument('x-alternate-exchange-one-more-time', $e_name_ae); -$ex->setArgument('x-numeric-argument', $heartbeat * 10 * 1000); -$ex->declareExchange(); - -var_dump($ex); -$ex->setArgument('x-alternate-exchange-one-more-time', null); // remov key -var_dump($ex); -?> ---EXPECTF-- -object(AMQPExchange)#3 (9) { - ["connection":"AMQPExchange":private]=> - object(AMQPConnection)#1 (11) { - ["login":"AMQPConnection":private]=> - string(5) "guest" - ["password":"AMQPConnection":private]=> - string(5) "guest" - ["host":"AMQPConnection":private]=> - string(9) "localhost" - ["vhost":"AMQPConnection":private]=> - string(1) "/" - ["port":"AMQPConnection":private]=> - %s(5672) - ["read_timeout":"AMQPConnection":private]=> - %s(0) - ["write_timeout":"AMQPConnection":private]=> - %s(0) - ["connect_timeout":"AMQPConnection":private]=> - %s(0) - ["channel_max":"AMQPConnection":private]=> - %s(256) - ["frame_max":"AMQPConnection":private]=> - %s(131072) - ["heartbeat":"AMQPConnection":private]=> - %s(0) - } - ["channel":"AMQPExchange":private]=> - object(AMQPChannel)#2 (3) { - ["connection":"AMQPChannel":private]=> - object(AMQPConnection)#1 (11) { - ["login":"AMQPConnection":private]=> - string(5) "guest" - ["password":"AMQPConnection":private]=> - string(5) "guest" - ["host":"AMQPConnection":private]=> - string(9) "localhost" - ["vhost":"AMQPConnection":private]=> - string(1) "/" - ["port":"AMQPConnection":private]=> - %s(5672) - ["read_timeout":"AMQPConnection":private]=> - %s(0) - ["write_timeout":"AMQPConnection":private]=> - %s(0) - ["connect_timeout":"AMQPConnection":private]=> - %s(0) - ["channel_max":"AMQPConnection":private]=> - %s(256) - ["frame_max":"AMQPConnection":private]=> - %s(131072) - ["heartbeat":"AMQPConnection":private]=> - %s(0) - } - ["prefetch_count":"AMQPChannel":private]=> - %s(3) - ["prefetch_size":"AMQPChannel":private]=> - %s(0) - } - ["name":"AMQPExchange":private]=> - string(%d) "test.exchange.ae.%f" - ["type":"AMQPExchange":private]=> - string(6) "fanout" - ["passive":"AMQPExchange":private]=> - bool(false) - ["durable":"AMQPExchange":private]=> - bool(false) - ["auto_delete":"AMQPExchange":private]=> - bool(true) - ["internal":"AMQPExchange":private]=> - bool(false) - ["arguments":"AMQPExchange":private]=> - array(0) { - } -} -object(AMQPExchange)#4 (9) { - ["connection":"AMQPExchange":private]=> - object(AMQPConnection)#1 (11) { - ["login":"AMQPConnection":private]=> - string(5) "guest" - ["password":"AMQPConnection":private]=> - string(5) "guest" - ["host":"AMQPConnection":private]=> - string(9) "localhost" - ["vhost":"AMQPConnection":private]=> - string(1) "/" - ["port":"AMQPConnection":private]=> - %s(5672) - ["read_timeout":"AMQPConnection":private]=> - %s(0) - ["write_timeout":"AMQPConnection":private]=> - %s(0) - ["connect_timeout":"AMQPConnection":private]=> - %s(0) - ["channel_max":"AMQPConnection":private]=> - %s(256) - ["frame_max":"AMQPConnection":private]=> - %s(131072) - ["heartbeat":"AMQPConnection":private]=> - %s(0) - } - ["channel":"AMQPExchange":private]=> - object(AMQPChannel)#2 (3) { - ["connection":"AMQPChannel":private]=> - object(AMQPConnection)#1 (11) { - ["login":"AMQPConnection":private]=> - string(5) "guest" - ["password":"AMQPConnection":private]=> - string(5) "guest" - ["host":"AMQPConnection":private]=> - string(9) "localhost" - ["vhost":"AMQPConnection":private]=> - string(1) "/" - ["port":"AMQPConnection":private]=> - %s(5672) - ["read_timeout":"AMQPConnection":private]=> - %s(0) - ["write_timeout":"AMQPConnection":private]=> - %s(0) - ["connect_timeout":"AMQPConnection":private]=> - %s(0) - ["channel_max":"AMQPConnection":private]=> - %s(256) - ["frame_max":"AMQPConnection":private]=> - %s(131072) - ["heartbeat":"AMQPConnection":private]=> - %s(0) - } - ["prefetch_count":"AMQPChannel":private]=> - %s(3) - ["prefetch_size":"AMQPChannel":private]=> - %s(0) - } - ["name":"AMQPExchange":private]=> - string(%d) "test.exchange.%f" - ["type":"AMQPExchange":private]=> - string(6) "fanout" - ["passive":"AMQPExchange":private]=> - bool(false) - ["durable":"AMQPExchange":private]=> - bool(false) - ["auto_delete":"AMQPExchange":private]=> - bool(true) - ["internal":"AMQPExchange":private]=> - bool(false) - ["arguments":"AMQPExchange":private]=> - array(5) { - ["x-ha-policy"]=> - string(3) "all" - ["alternate-exchange"]=> - string(%d) "test.exchange.ae.%f" - ["x-empty-string"]=> - string(0) "" - ["x-alternate-exchange-one-more-time"]=> - string(%d) "test.exchange.ae.%f" - ["x-numeric-argument"]=> - %s(100000) - } -} -object(AMQPExchange)#4 (9) { - ["connection":"AMQPExchange":private]=> - object(AMQPConnection)#1 (11) { - ["login":"AMQPConnection":private]=> - string(5) "guest" - ["password":"AMQPConnection":private]=> - string(5) "guest" - ["host":"AMQPConnection":private]=> - string(9) "localhost" - ["vhost":"AMQPConnection":private]=> - string(1) "/" - ["port":"AMQPConnection":private]=> - %s(5672) - ["read_timeout":"AMQPConnection":private]=> - %s(0) - ["write_timeout":"AMQPConnection":private]=> - %s(0) - ["connect_timeout":"AMQPConnection":private]=> - %s(0) - ["channel_max":"AMQPConnection":private]=> - %s(256) - ["frame_max":"AMQPConnection":private]=> - %s(131072) - ["heartbeat":"AMQPConnection":private]=> - %s(0) - } - ["channel":"AMQPExchange":private]=> - object(AMQPChannel)#2 (3) { - ["connection":"AMQPChannel":private]=> - object(AMQPConnection)#1 (11) { - ["login":"AMQPConnection":private]=> - string(5) "guest" - ["password":"AMQPConnection":private]=> - string(5) "guest" - ["host":"AMQPConnection":private]=> - string(9) "localhost" - ["vhost":"AMQPConnection":private]=> - string(1) "/" - ["port":"AMQPConnection":private]=> - %s(5672) - ["read_timeout":"AMQPConnection":private]=> - %s(0) - ["write_timeout":"AMQPConnection":private]=> - %s(0) - ["connect_timeout":"AMQPConnection":private]=> - %s(0) - ["channel_max":"AMQPConnection":private]=> - %s(256) - ["frame_max":"AMQPConnection":private]=> - %s(131072) - ["heartbeat":"AMQPConnection":private]=> - %s(0) - } - ["prefetch_count":"AMQPChannel":private]=> - %s(3) - ["prefetch_size":"AMQPChannel":private]=> - %s(0) - } - ["name":"AMQPExchange":private]=> - string(%d) "test.exchange.%f" - ["type":"AMQPExchange":private]=> - string(6) "fanout" - ["passive":"AMQPExchange":private]=> - bool(false) - ["durable":"AMQPExchange":private]=> - bool(false) - ["auto_delete":"AMQPExchange":private]=> - bool(true) - ["internal":"AMQPExchange":private]=> - bool(false) - ["arguments":"AMQPExchange":private]=> - array(4) { - ["x-ha-policy"]=> - string(3) "all" - ["alternate-exchange"]=> - string(%d) "test.exchange.ae.%f" - ["x-empty-string"]=> - string(0) "" - ["x-numeric-argument"]=> - %s(100000) - } -} diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_set_flag.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_set_flag.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_set_flag.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_set_flag.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ ---TEST-- -AMQPExchange set flag string ---SKIPIF-- - ---FILE-- -connect(); - -$ch = new AMQPChannel($cnn); - -$ex = new AMQPExchange($ch); - -echo $ex->getFlags(); -$ex->setFlags("2"); -echo $ex->getFlags(); - -$ex->setFlags(NULL); -echo $ex->getFlags(); - -$ex->setFlags(2); -echo $ex->getFlags(); - -?> ---EXPECT-- -0202 \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_set_flags.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_set_flags.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_set_flags.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_set_flags.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,98 +0,0 @@ ---TEST-- -AMQPExchange setFlags() ---SKIPIF-- -connect(); -$ch = new AMQPChannel($cnn); -// Declare a new exchange -$ex = new AMQPExchange($ch); -$ex->setName('exchange-' . microtime(true)); -$ex->setType(AMQP_EX_TYPE_FANOUT); -$ex->setArguments(array("x-ha-policy" => "all")); -$ex->setFlags(AMQP_PASSIVE | AMQP_DURABLE | AMQP_AUTODELETE | AMQP_INTERNAL); - -var_dump($ex); -?> ---EXPECTF-- -object(AMQPExchange)#3 (9) { - ["connection":"AMQPExchange":private]=> - object(AMQPConnection)#1 (11) { - ["login":"AMQPConnection":private]=> - string(5) "guest" - ["password":"AMQPConnection":private]=> - string(5) "guest" - ["host":"AMQPConnection":private]=> - string(9) "localhost" - ["vhost":"AMQPConnection":private]=> - string(1) "/" - ["port":"AMQPConnection":private]=> - int(5672) - ["read_timeout":"AMQPConnection":private]=> - float(0) - ["write_timeout":"AMQPConnection":private]=> - float(0) - ["connect_timeout":"AMQPConnection":private]=> - float(0) - ["channel_max":"AMQPConnection":private]=> - int(256) - ["frame_max":"AMQPConnection":private]=> - int(131072) - ["heartbeat":"AMQPConnection":private]=> - int(0) - } - ["channel":"AMQPExchange":private]=> - object(AMQPChannel)#2 (3) { - ["connection":"AMQPChannel":private]=> - object(AMQPConnection)#1 (11) { - ["login":"AMQPConnection":private]=> - string(5) "guest" - ["password":"AMQPConnection":private]=> - string(5) "guest" - ["host":"AMQPConnection":private]=> - string(9) "localhost" - ["vhost":"AMQPConnection":private]=> - string(1) "/" - ["port":"AMQPConnection":private]=> - int(5672) - ["read_timeout":"AMQPConnection":private]=> - float(0) - ["write_timeout":"AMQPConnection":private]=> - float(0) - ["connect_timeout":"AMQPConnection":private]=> - float(0) - ["channel_max":"AMQPConnection":private]=> - int(256) - ["frame_max":"AMQPConnection":private]=> - int(131072) - ["heartbeat":"AMQPConnection":private]=> - int(0) - } - ["prefetch_count":"AMQPChannel":private]=> - int(3) - ["prefetch_size":"AMQPChannel":private]=> - int(0) - } - ["name":"AMQPExchange":private]=> - string(%d) "exchange-%f" - ["type":"AMQPExchange":private]=> - string(6) "fanout" - ["passive":"AMQPExchange":private]=> - bool(true) - ["durable":"AMQPExchange":private]=> - bool(true) - ["auto_delete":"AMQPExchange":private]=> - bool(true) - ["internal":"AMQPExchange":private]=> - bool(true) - ["arguments":"AMQPExchange":private]=> - array(1) { - ["x-ha-policy"]=> - string(3) "all" - } -} \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_unbind.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_unbind.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_unbind.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_unbind.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ ---TEST-- -AMQPExchange::unbind ---SKIPIF-- - ---FILE-- -connect(); - -$ch = new AMQPChannel($cnn); - -// Declare a new exchange -$ex = new AMQPExchange($ch); -$ex->setName('exchange-unbind-' . microtime(true)); -$ex->setType(AMQP_EX_TYPE_FANOUT); -$ex->declareExchange(); - -// Declare a new exchange -$ex2 = new AMQPExchange($ch); -$ex2->setName('exchange2-unbind-' . microtime(true)); -$ex2->setType(AMQP_EX_TYPE_FANOUT); -$ex2->declareExchange(); - -var_dump($ex->bind($ex2->getName(), 'test-key-1')); - -var_dump($ex->unbind($ex2->getName(), 'test-key-1')); -var_dump($ex->unbind($ex2->getName(), 'test-key-1')); - -?> ---EXPECT-- -bool(true) -bool(true) -bool(true) \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_unbind_with_arguments.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_unbind_with_arguments.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_unbind_with_arguments.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_unbind_with_arguments.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ ---TEST-- -AMQPExchange::unbind with arguments ---SKIPIF-- - ---FILE-- -connect(); - -$ch = new AMQPChannel($cnn); - -// Declare a new exchange -$ex = new AMQPExchange($ch); -$ex->setName('exchange-unbind-' . microtime(true)); -$ex->setType(AMQP_EX_TYPE_FANOUT); -$ex->declareExchange(); - -// Declare a new exchange -$ex2 = new AMQPExchange($ch); -$ex2->setName('exchange2-exchange-unbind-' . microtime(true)); -$ex2->setType(AMQP_EX_TYPE_FANOUT); -$ex2->declareExchange(); - -$time = microtime(true); - -var_dump($ex->bind($ex2->getName(), 'test', array('test' => 'passed', 'at' => $time))); - -var_dump($ex->unbind($ex2->getName(), 'test', array('test' => 'passed', 'at' => $time))); -var_dump($ex->unbind($ex2->getName(), 'test', array('test' => 'passed', 'at' => $time))); - -?> ---EXPECT-- -bool(true) -bool(true) -bool(true) \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_unbind_without_key.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_unbind_without_key.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_unbind_without_key.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_unbind_without_key.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ ---TEST-- -AMQPExchange::unbind without key ---SKIPIF-- - ---FILE-- -connect(); - -$ch = new AMQPChannel($cnn); - -// Declare a new exchange -$ex = new AMQPExchange($ch); -$ex->setName('exchange-unbind-' . microtime(true)); -$ex->setType(AMQP_EX_TYPE_FANOUT); -$ex->declareExchange(); - -// Declare a new exchange -$ex2 = new AMQPExchange($ch); -$ex2->setName('exchange2-unbind-' . microtime(true)); -$ex2->setType(AMQP_EX_TYPE_FANOUT); -$ex2->declareExchange(); - -var_dump($ex->bind($ex2->getName())); -var_dump($ex->unbind($ex2->getName())); -var_dump($ex->unbind($ex2->getName())); - - -?> ---EXPECT-- -bool(true) -bool(true) -bool(true) \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_unbind_without_key_with_arguments.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_unbind_without_key_with_arguments.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_unbind_without_key_with_arguments.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_unbind_without_key_with_arguments.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ ---TEST-- -AMQPExchange::unbind without key with arguments ---SKIPIF-- - ---FILE-- -connect(); - -$ch = new AMQPChannel($cnn); - -// Declare a new exchange -$ex = new AMQPExchange($ch); -$ex->setName('exchange-unbind-' . microtime(true)); -$ex->setType(AMQP_EX_TYPE_FANOUT); -$ex->declareExchange(); - -// Declare a new exchange -$ex2 = new AMQPExchange($ch); -$ex2->setName('exchange2-unbind-' . microtime(true)); -$ex2->setType(AMQP_EX_TYPE_FANOUT); -$ex2->declareExchange(); - -$time = microtime(true); - -var_dump($ex->bind($ex2->getName(), null, array('test' => 'passed', 'at' => $time, 'i am' => 'first'))); -var_dump($ex->unbind($ex2->getName(), null, array('test' => 'passed', 'at' => $time, 'i am' => 'first'))); -var_dump($ex->unbind($ex2->getName(), null, array('test' => 'passed', 'at' => $time, 'i am' => 'first'))); - -var_dump($ex->bind($ex2->getName(), '', array('test' => 'passed', 'at' => $time, 'i am' => 'second'))); -var_dump($ex->unbind($ex2->getName(), '', array('test' => 'passed', 'at' => $time, 'i am' => 'second'))); -var_dump($ex->unbind($ex2->getName(), '', array('test' => 'passed', 'at' => $time, 'i am' => 'second'))); - -?> ---EXPECT-- -bool(true) -bool(true) -bool(true) -bool(true) -bool(true) -bool(true) \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_var_dump.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_var_dump.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpexchange_var_dump.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpexchange_var_dump.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,171 +0,0 @@ ---TEST-- -AMQPExchange var_dump ---SKIPIF-- -connect(); -$ch = new AMQPChannel($cnn); -// Declare a new exchange -$ex = new AMQPExchange($ch); -$ex->setName('exchange-' . microtime(true)); -$ex->setType(AMQP_EX_TYPE_FANOUT); -var_dump($ex); -$ex->setArguments(array("x-ha-policy" => "all")); -var_dump($ex); -?> ---EXPECTF-- -object(AMQPExchange)#3 (9) { - ["connection":"AMQPExchange":private]=> - object(AMQPConnection)#1 (11) { - ["login":"AMQPConnection":private]=> - string(5) "guest" - ["password":"AMQPConnection":private]=> - string(5) "guest" - ["host":"AMQPConnection":private]=> - string(9) "localhost" - ["vhost":"AMQPConnection":private]=> - string(1) "/" - ["port":"AMQPConnection":private]=> - int(5672) - ["read_timeout":"AMQPConnection":private]=> - float(0) - ["write_timeout":"AMQPConnection":private]=> - float(0) - ["connect_timeout":"AMQPConnection":private]=> - float(0) - ["channel_max":"AMQPConnection":private]=> - int(256) - ["frame_max":"AMQPConnection":private]=> - int(131072) - ["heartbeat":"AMQPConnection":private]=> - int(0) - } - ["channel":"AMQPExchange":private]=> - object(AMQPChannel)#2 (3) { - ["connection":"AMQPChannel":private]=> - object(AMQPConnection)#1 (11) { - ["login":"AMQPConnection":private]=> - string(5) "guest" - ["password":"AMQPConnection":private]=> - string(5) "guest" - ["host":"AMQPConnection":private]=> - string(9) "localhost" - ["vhost":"AMQPConnection":private]=> - string(1) "/" - ["port":"AMQPConnection":private]=> - int(5672) - ["read_timeout":"AMQPConnection":private]=> - float(0) - ["write_timeout":"AMQPConnection":private]=> - float(0) - ["connect_timeout":"AMQPConnection":private]=> - float(0) - ["channel_max":"AMQPConnection":private]=> - int(256) - ["frame_max":"AMQPConnection":private]=> - int(131072) - ["heartbeat":"AMQPConnection":private]=> - int(0) - } - ["prefetch_count":"AMQPChannel":private]=> - int(3) - ["prefetch_size":"AMQPChannel":private]=> - int(0) - } - ["name":"AMQPExchange":private]=> - string(%d) "exchange-%f" - ["type":"AMQPExchange":private]=> - string(6) "fanout" - ["passive":"AMQPExchange":private]=> - bool(false) - ["durable":"AMQPExchange":private]=> - bool(false) - ["auto_delete":"AMQPExchange":private]=> - bool(false) - ["internal":"AMQPExchange":private]=> - bool(false) - ["arguments":"AMQPExchange":private]=> - array(0) { - } -} -object(AMQPExchange)#3 (9) { - ["connection":"AMQPExchange":private]=> - object(AMQPConnection)#1 (11) { - ["login":"AMQPConnection":private]=> - string(5) "guest" - ["password":"AMQPConnection":private]=> - string(5) "guest" - ["host":"AMQPConnection":private]=> - string(9) "localhost" - ["vhost":"AMQPConnection":private]=> - string(1) "/" - ["port":"AMQPConnection":private]=> - int(5672) - ["read_timeout":"AMQPConnection":private]=> - float(0) - ["write_timeout":"AMQPConnection":private]=> - float(0) - ["connect_timeout":"AMQPConnection":private]=> - float(0) - ["channel_max":"AMQPConnection":private]=> - int(256) - ["frame_max":"AMQPConnection":private]=> - int(131072) - ["heartbeat":"AMQPConnection":private]=> - int(0) - } - ["channel":"AMQPExchange":private]=> - object(AMQPChannel)#2 (3) { - ["connection":"AMQPChannel":private]=> - object(AMQPConnection)#1 (11) { - ["login":"AMQPConnection":private]=> - string(5) "guest" - ["password":"AMQPConnection":private]=> - string(5) "guest" - ["host":"AMQPConnection":private]=> - string(9) "localhost" - ["vhost":"AMQPConnection":private]=> - string(1) "/" - ["port":"AMQPConnection":private]=> - int(5672) - ["read_timeout":"AMQPConnection":private]=> - float(0) - ["write_timeout":"AMQPConnection":private]=> - float(0) - ["connect_timeout":"AMQPConnection":private]=> - float(0) - ["channel_max":"AMQPConnection":private]=> - int(256) - ["frame_max":"AMQPConnection":private]=> - int(131072) - ["heartbeat":"AMQPConnection":private]=> - int(0) - } - ["prefetch_count":"AMQPChannel":private]=> - int(3) - ["prefetch_size":"AMQPChannel":private]=> - int(0) - } - ["name":"AMQPExchange":private]=> - string(%d) "exchange-%f" - ["type":"AMQPExchange":private]=> - string(6) "fanout" - ["passive":"AMQPExchange":private]=> - bool(false) - ["durable":"AMQPExchange":private]=> - bool(false) - ["auto_delete":"AMQPExchange":private]=> - bool(false) - ["internal":"AMQPExchange":private]=> - bool(false) - ["arguments":"AMQPExchange":private]=> - array(1) { - ["x-ha-policy"]=> - string(3) "all" - } -} \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_attributes.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_attributes.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_attributes.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_attributes.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ ---TEST-- -AMQPQueue attributes ---SKIPIF-- - ---FILE-- -connect(); -$ch = new AMQPChannel($cnn); - -$q = new AMQPQueue($ch); - -$q->setArguments(array('existent' => 'value', 'false' => false)); - -foreach (array('existent', 'false', 'nonexistent') as $key) { - echo "$key: ", var_export($q->hasArgument($key), true), ', ', var_export($q->getArgument($key)), PHP_EOL; -} - -?> ---EXPECT-- -existent: true, 'value' -false: true, false -nonexistent: false, false diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_bind_basic_empty_routing_key.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_bind_basic_empty_routing_key.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_bind_basic_empty_routing_key.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_bind_basic_empty_routing_key.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ ---TEST-- -AMQPQueue ---SKIPIF-- - ---FILE-- -connect(); - -$ch = new AMQPChannel($cnn); - -$ex = new AMQPExchange($ch); -$ex->setName('exchange-' . microtime(true)); -$ex->setType(AMQP_EX_TYPE_DIRECT); -$ex->declareExchange(); - -$queue = new AMQPQueue($ch); -$queue->setName("queue-" . microtime(true)); -$queue->declareQueue(); -var_dump($queue->bind($ex->getName())); - -$queue->delete(); -$ex->delete(); -?> ---EXPECT-- -bool(true) diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_bind_basic_headers_arguments.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_bind_basic_headers_arguments.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_bind_basic_headers_arguments.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_bind_basic_headers_arguments.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ ---TEST-- -AMQPQueue ---SKIPIF-- - ---FILE-- -connect(); - -$ch = new AMQPChannel($cnn); - -$ex = new AMQPExchange($ch); -$ex->setName('exchange-' . microtime(true)); -$ex->setType(AMQP_EX_TYPE_HEADERS); -$ex->declareExchange(); - -$queue = new AMQPQueue($ch); -$queue->setName("queue-" . microtime(true)); -$queue->declareQueue(); - -$arguments = array('x-match' => 'all', 'type' => 'custom'); -var_dump($queue->bind($ex->getName(), '', $arguments)); - -$queue->delete(); -$ex->delete(); -?> ---EXPECT-- -bool(true) diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_bind_basic.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_bind_basic.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_bind_basic.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_bind_basic.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ ---TEST-- -AMQPQueue ---SKIPIF-- - ---FILE-- -connect(); - -$ch = new AMQPChannel($cnn); - -$ex = new AMQPExchange($ch); -$ex->setName('exchange-' . microtime(true)); -$ex->setType(AMQP_EX_TYPE_DIRECT); -$ex->declareExchange(); - -$queue = new AMQPQueue($ch); -$queue->setName("queue-" . microtime(true)); -$queue->declareQueue(); -var_dump($queue->bind($ex->getName(), 'routing.key')); - -$queue->delete(); -$ex->delete(); -?> ---EXPECT-- -bool(true) diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_cancel.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_cancel.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_cancel.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_cancel.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,144 +0,0 @@ ---TEST-- -AMQPQueue cancel ---SKIPIF-- - ---FILE-- -connect(); - return $conn; -} - -function create_channel($connection) { - $channel = new AMQPChannel($connection); - $channel->setPrefetchCount(1); - return $channel; -} - -function create_exchange($channel) { - $exchange = new AMQPExchange($channel); - $exchange->setName('test_cancel_exchange'); - $exchange->setType(AMQP_EX_TYPE_DIRECT); - $exchange->declareExchange(); - return $exchange; -} - -function create_queue($channel) { - $queue = new AMQPQueue($channel); - $queue->setName('test_cancel_queue'); - $queue->setFlags(AMQP_NOPARAM); - $queue->declareQueue(); - $queue->bind('test_cancel_exchange', 'test_cancel_routing_key'); - return $queue; -} - -class TrivialAcceptor { - private $count = 0; - private $maxCount; - - public function __construct($maxCount) { - $this->maxCount = $maxCount; - } - - public function accept($envelope, $queue) { - var_dump( - $envelope->getBody(), - $envelope->getDeliveryTag(), - $envelope->isRedelivery() - ); - echo "\n"; - $queue->ack($envelope->getDeliveryTag()); - $this->count++; - return $this->count < $this->maxCount; - } -} - -function get_acceptor($count) { - $acceptorObject = new TrivialAcceptor($count); - return array($acceptorObject, 'accept'); -} - -function send_message($exchange, $message) { - $exchange->publish($message, 'test_cancel_routing_key'); -} - -function wait_for_messages($queue, $consumer_tag, $message_count, $cancel_afterwards) { - $consumeMethod = new ReflectionMethod('AMQPQueue', 'consume'); - switch ($consumeMethod->getNumberOfParameters()) - { - case 3: - $queue->consume(get_acceptor($message_count), AMQP_NOPARAM, $consumer_tag); - if ($cancel_afterwards) - $queue->cancel($consumer_tag); - break; - - case 2: - $queue->consume(get_acceptor($message_count), AMQP_NOPARAM); - if ($cancel_afterwards) - $queue->cancel(); - break; - - default: - echo "AMQP::consume() takes neither 2 nor 3 parameters"; - exit(1); - } -} - -$consumer_tag_prefix = uniqid(); - -$send_conn = create_connection(); -$send_chan = create_channel($send_conn); -$exchange = create_exchange($send_chan); - -$recv_conn_1 = create_connection(); -$recv_chan_1 = create_channel($recv_conn_1); -$queue_1 = create_queue($recv_chan_1); - -send_message($exchange, 'message 0'); -wait_for_messages($queue_1, $consumer_tag_prefix.'_1', 1, true); - -send_message($exchange, 'message 1'); -send_message($exchange, 'message 2'); - -$recv_chan_2 = create_channel($recv_conn_1); -$queue_2 = create_queue($recv_chan_2); - -wait_for_messages($queue_2, $consumer_tag_prefix.'_2', 2, false); - -$recv_conn_1->disconnect(); -sleep(1); - -$recv_conn_2 = create_connection(); -$recv_chan_3 = create_channel($recv_conn_2); -$queue_3 = create_queue($recv_chan_3); - -send_message($exchange, 'message 3'); -send_message($exchange, 'message 4'); - -wait_for_messages($queue_3, $consumer_tag_prefix.'_3', 2, false); - -$queue_3->delete(AMQP_NOPARAM); -$exchange->delete(); -?> ---EXPECT-- -string(9) "message 0" -int(1) -bool(false) - -string(9) "message 1" -int(1) -bool(false) - -string(9) "message 2" -int(2) -bool(false) - -string(9) "message 3" -int(1) -bool(false) - -string(9) "message 4" -int(2) -bool(false) - diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_construct_basic.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_construct_basic.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_construct_basic.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_construct_basic.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ ---TEST-- -AMQPQueue constructor ---SKIPIF-- - ---FILE-- -connect(); - -$ch = new AMQPChannel($cnn); - -$queue = new AMQPQueue($ch); -echo get_class($queue); -?> ---EXPECT-- -AMQPQueue \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_consume_basic.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_consume_basic.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_consume_basic.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_consume_basic.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,139 +0,0 @@ ---TEST-- -AMQPQueue::consume basic ---SKIPIF-- - ---FILE-- -connect(); - -$ch = new AMQPChannel($cnn); - -// Declare a new exchange -$ex = new AMQPExchange($ch); -$ex->setName('exchange-' . microtime(true)); -$ex->setType(AMQP_EX_TYPE_FANOUT); -$ex->declareExchange(); - -// Create a new queue -$q = new AMQPQueue($ch); -$q->setName('queue-' . microtime(true)); -$q->declareQueue(); - -// Bind it on the exchange to routing.key -$q->bind($ex->getName(), 'routing.*'); - -// Publish a message to the exchange with a routing key -$ex->publish('message1', 'routing.1', AMQP_NOPARAM, array('content_type' => 'plain/test', 'headers' => array('foo' => 'bar'))); -$ex->publish('message2', 'routing.2', AMQP_NOPARAM, array('delivery_mode' => AMQP_DURABLE)); -$ex->publish('message3', 'routing.3', AMQP_DURABLE); // this is wrong way to make messages persistent - -$count = 0; - -function consumeThingsTwoTimes($message, $queue) { - global $count; - - echo "call #$count", PHP_EOL; - // Read from the queue - dump_message($message); - echo PHP_EOL; - $count++; - - if ($count >= 2) { - return false; - } - - return true; -} - -// Read from the queue -$q->consume("consumeThingsTwoTimes", AMQP_AUTOACK); - -$q->delete(); -$ex->delete(); - -?> ---EXPECTF-- -call #0 -AMQPEnvelope - getBody: - string(8) "message1" - getContentType: - string(10) "plain/test" - getRoutingKey: - string(9) "routing.1" - getDeliveryTag: - int(1) - getDeliveryMode: - int(1) - getExchangeName: - string(%d) "exchange-%f" - isRedelivery: - bool(false) - getContentEncoding: - string(0) "" - getType: - string(0) "" - getTimeStamp: - int(0) - getPriority: - int(0) - getExpiration: - string(0) "" - getUserId: - string(0) "" - getAppId: - string(0) "" - getMessageId: - string(0) "" - getReplyTo: - string(0) "" - getCorrelationId: - string(0) "" - getHeaders: - array(1) { - ["foo"]=> - string(3) "bar" -} - -call #1 -AMQPEnvelope - getBody: - string(8) "message2" - getContentType: - string(10) "text/plain" - getRoutingKey: - string(9) "routing.2" - getDeliveryTag: - int(2) - getDeliveryMode: - int(2) - getExchangeName: - string(%d) "exchange-%f" - isRedelivery: - bool(false) - getContentEncoding: - string(0) "" - getType: - string(0) "" - getTimeStamp: - int(0) - getPriority: - int(0) - getExpiration: - string(0) "" - getUserId: - string(0) "" - getAppId: - string(0) "" - getMessageId: - string(0) "" - getReplyTo: - string(0) "" - getCorrelationId: - string(0) "" - getHeaders: - array(0) { -} \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_consume_multiple_no_doubles.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_consume_multiple_no_doubles.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_consume_multiple_no_doubles.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_consume_multiple_no_doubles.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ ---TEST-- -AMQPQueue::consume multiple (no doubles) ---SKIPIF-- - ---FILE-- -connect(); - -$ch = new AMQPChannel($cnn); - -// Create a new queue -$q = new AMQPQueue($ch); -$q->setName('queue-' . microtime(true)); -$q->declareQueue(); - -var_dump($q->getConsumerTag()); -$q->consume(); -var_dump($tag1=$q->getConsumerTag()); -$q->consume(null, AMQP_JUST_CONSUME); -var_dump($tag2=$q->getConsumerTag()); - -echo ($tag1 == $tag2 ? 'equals' : 'differs'), PHP_EOL; - - -?> ---EXPECTF-- -NULL -string(%d) "amq.ctag-%s" -string(%d) "amq.ctag-%s" -equals \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_consume_multiple.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_consume_multiple.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_consume_multiple.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_consume_multiple.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ ---TEST-- -AMQPQueue::consume multiple ---SKIPIF-- - ---FILE-- -connect(); - -$ch = new AMQPChannel($cnn); - -// Declare a new exchange -$ex = new AMQPExchange($ch); -$ex->setName('exchange-' . $time); -$ex->setType(AMQP_EX_TYPE_TOPIC); -$ex->declareExchange(); - -// Create and bind queues -$q1 = new AMQPQueue($ch); -$q1->setName('queue-one-' . $time); -$q1->declareQueue(); -$q1->bind($ex->getName(), 'routing.one'); - -$q2 = new AMQPQueue($ch); -$q2->setName('queue-two-' . $time); -$q2->declareQueue(); -$q2->bind($ex->getName(), 'routing.two'); - -$q3 = new AMQPQueue($ch); -$q3->setName('queue-three-' . $time); -$q3->declareQueue(); -$q3->bind($ex->getName(), 'routing.three'); - - -// Publish a message to the exchange with a routing key -$ex->publish('message1', 'routing.one'); -$ex->publish('message2', 'routing.two'); -$ex->publish('message3', 'routing.three'); - -$count = 0; - -function consumeThings(AMQPEnvelope $message, AMQPQueue $queue) -{ - global $count; - - echo $message->getBody() . "-" . $message->getRoutingKey() . "\n"; - - $count++; - - $queue->ack($message->getDeliveryTag()); - - if ($count >= 2) { - return false; - } - - return true; -} - -$q1->consume(); -$q2->consume('consumeThings'); - -// This is important! -$q1->cancel(); -$q2->cancel(); - -?> ---EXPECT-- -message1-routing.one -message2-routing.two diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_consume_nonexistent.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_consume_nonexistent.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_consume_nonexistent.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_consume_nonexistent.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ ---TEST-- -AMQPQueue::consume from nonexistent queue ---SKIPIF-- - ---FILE-- -setReadTimeout(10); // both are empirical values that should be far enough to deal with busy RabbitMQ broker -$cnn->setWriteTimeout(10); -$cnn->connect(); - -$ch = new AMQPChannel($cnn); - -// Declare a new exchange -$ex = new AMQPExchange($ch); -$ex->setName('exchange-' . microtime(true)); -$ex->setType(AMQP_EX_TYPE_FANOUT); -$ex->declareExchange(); - -// Create a new queue -$q = new AMQPQueue($ch); -$q->setName('nonexistent-' . microtime(true)); - -try { - $q->consume('noop'); -} catch (Exception $e) { - echo get_class($e), ': ', $e->getMessage(); -} - -?> ---EXPECTF-- -AMQPQueueException: Server channel error: 404, message: NOT_FOUND - no queue 'nonexistent-%f' in vhost '/' diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_consume_timeout.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_consume_timeout.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_consume_timeout.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_consume_timeout.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ ---TEST-- -AMQPQueue::consume with timeout ---SKIPIF-- - ---FILE-- - $timeout)); -$conn->connect(); -$chan = new AMQPChannel($conn); -$queue = new AMQPQueue($chan); -$queue->setFlags(AMQP_EXCLUSIVE); -$queue->declareQueue(); -$start = microtime(true); -try { - $queue->consume('nop'); -} catch (AMQPException $e) { - echo get_class($e), ': ', $e->getMessage(); - echo PHP_EOL; -} -$end = microtime(true); -$error = $end - $start - $timeout; -$limit = abs(log10($timeout)); // empirical value - -echo 'timeout: ', $timeout, PHP_EOL; -echo 'takes: ', $end - $start, PHP_EOL; -echo 'error: ', $error, PHP_EOL; -echo 'limit: ', $limit, PHP_EOL; - -echo abs($error) <= $limit ? 'timings OK' : 'timings failed'; // error should be less than 5% of timeout value -$queue->delete(); -?> ---EXPECTF-- -AMQPQueueException: Consumer timeout exceed -timeout: %f -takes: %f -error: %f -limit: %f -timings OK diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_declare_basic.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_declare_basic.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_declare_basic.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_declare_basic.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ ---TEST-- -AMQPQueue ---SKIPIF-- - ---FILE-- -connect(); -$ch = new AMQPChannel($cnn); - -$ex = new AMQPExchange($ch); -$ex->setName('exchange-' . microtime(true)); -$ex->setType(AMQP_EX_TYPE_DIRECT); -$ex->declareExchange(); - -$queue = new AMQPQueue($ch); -$queue->setName("queue-" . microtime(true)); -$queue->declareQueue(); -var_dump($queue->bind($ex->getName(), 'routing.key')); - -$queue->delete(); -$ex->delete(); -?> ---EXPECT-- -bool(true) diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_declare_with_arguments.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_declare_with_arguments.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_declare_with_arguments.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_declare_with_arguments.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ ---TEST-- -AMQPQueue::declareQueue() - with arguments ---SKIPIF-- - ---FILE-- -connect(); -$ch = new AMQPChannel($cnn); - -$ex = new AMQPExchange($ch); -$ex->setName('exchange-' . microtime(true)); -$ex->setType(AMQP_EX_TYPE_DIRECT); -$ex->declareExchange(); - -$queue = new AMQPQueue($ch); -$queue->setName("queue-" . microtime(true)); -$queue->setArgument('x-dead-letter-exchange', ''); -$queue->setArgument('x-dead-letter-routing-key', 'some key'); -$queue->setArgument('x-message-ttl', 42); -$queue->setFlags(AMQP_AUTODELETE); -$res = $queue->declareQueue(); - -var_dump($res); - -$queue->delete(); -?> ---EXPECT-- -int(0) diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_declare_with_stalled_reference.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_declare_with_stalled_reference.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_declare_with_stalled_reference.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_declare_with_stalled_reference.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ ---TEST-- -AMQPQueue - declare with stalled reference ---SKIPIF-- - ---FILE-- -declareQueue(); -} catch (\Exception $e) { - echo get_class($e), ': ', $e->getMessage(), PHP_EOL; -} - -?> ---EXPECT-- -AMQPChannelException: Could not declare queue. Stale reference to the channel object. diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_delete_basic.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_delete_basic.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_delete_basic.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_delete_basic.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ ---TEST-- -AMQPQueue ---SKIPIF-- - ---FILE-- -connect(); -$ch = new AMQPChannel($cnn); - -$ex = new AMQPExchange($ch); -$ex->setName('exchange-' . microtime(true)); -$ex->setType(AMQP_EX_TYPE_FANOUT); -$ex->declareExchange(); - -$queue = new AMQPQueue($ch); -$queue->setName("queue-" . microtime(true)); -$queue->declareQueue(); -$queue->bind($ex->getName()); - -var_dump($queue->delete()); -var_dump($queue->delete()); - -$queue->declareQueue(); -$queue->bind($ex->getName()); - -$ex->publish('test 1'); -$ex->publish('test 2'); -$ex->publish('test 3'); - -var_dump($queue->delete()); - -$ex->publish('test 1'); -$ex->publish('test 2'); -$ex->publish('test 3'); - -var_dump($queue->delete()); - -$ex->delete(); -?> ---EXPECT-- -int(0) -int(0) -int(3) -int(0) diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_empty_name.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_empty_name.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_empty_name.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_empty_name.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ ---TEST-- -AMQPQueue declared with empty name ---SKIPIF-- - ---FILE-- -connect(); -$ch = new AMQPChannel($cnn); - -$ex = new AMQPExchange($ch); -$ex->setName('exchange-' . microtime(true)); -$ex->setType(AMQP_EX_TYPE_DIRECT); -$ex->declareExchange(); - -$queue = new AMQPQueue($ch); -$queue->declareQueue(); -var_dump(substr($queue->getName(), 0, strlen('amq.gen-'))); - -$queue->delete(); -$ex->delete(); -?> ---EXPECT-- -string(8) "amq.gen-" diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_get_basic.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_get_basic.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_get_basic.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_get_basic.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,165 +0,0 @@ ---TEST-- -AMQPQueue::get basic ---SKIPIF-- - ---FILE-- -connect(); - -$ch = new AMQPChannel($cnn); - -// Declare a new exchange -$ex = new AMQPExchange($ch); -$ex->setName('exchange-'. microtime(true)); -$ex->setType(AMQP_EX_TYPE_FANOUT); -$ex->declareExchange(); - -// Create a new queue -$q = new AMQPQueue($ch); -$q->setName('queue-' . microtime(true)); -$q->declareQueue(); - -// Bind it on the exchange to routing.key -$q->bind($ex->getName(), 'routing.*'); -// Publish a message to the exchange with a routing key -$ex->publish('message1', 'routing.1', AMQP_NOPARAM, array('content_type' => 'plain/test', 'headers' => array('foo' => 'bar'))); -$ex->publish('message2', 'routing.2', AMQP_DURABLE); -$ex->publish('message3', 'routing.3'); - -for ($i = 0; $i < 4; $i++) { - echo "call #$i", PHP_EOL; - // Read from the queue - $msg = $q->get(AMQP_AUTOACK); - dump_message($msg); - echo PHP_EOL; -} - -?> ---EXPECTF-- -call #0 -AMQPEnvelope - getBody: - string(8) "message1" - getContentType: - string(10) "plain/test" - getRoutingKey: - string(9) "routing.1" - getDeliveryTag: - int(1) - getDeliveryMode: - int(1) - getExchangeName: - string(%d) "exchange-%f" - isRedelivery: - bool(false) - getContentEncoding: - string(0) "" - getType: - string(0) "" - getTimeStamp: - int(0) - getPriority: - int(0) - getExpiration: - string(0) "" - getUserId: - string(0) "" - getAppId: - string(0) "" - getMessageId: - string(0) "" - getReplyTo: - string(0) "" - getCorrelationId: - string(0) "" - getHeaders: - array(1) { - ["foo"]=> - string(3) "bar" -} - -call #1 -AMQPEnvelope - getBody: - string(8) "message2" - getContentType: - string(10) "text/plain" - getRoutingKey: - string(9) "routing.2" - getDeliveryTag: - int(2) - getDeliveryMode: - int(1) - getExchangeName: - string(%d) "exchange-%f" - isRedelivery: - bool(false) - getContentEncoding: - string(0) "" - getType: - string(0) "" - getTimeStamp: - int(0) - getPriority: - int(0) - getExpiration: - string(0) "" - getUserId: - string(0) "" - getAppId: - string(0) "" - getMessageId: - string(0) "" - getReplyTo: - string(0) "" - getCorrelationId: - string(0) "" - getHeaders: - array(0) { -} - -call #2 -AMQPEnvelope - getBody: - string(8) "message3" - getContentType: - string(10) "text/plain" - getRoutingKey: - string(9) "routing.3" - getDeliveryTag: - int(3) - getDeliveryMode: - int(1) - getExchangeName: - string(%d) "exchange-%f" - isRedelivery: - bool(false) - getContentEncoding: - string(0) "" - getType: - string(0) "" - getTimeStamp: - int(0) - getPriority: - int(0) - getExpiration: - string(0) "" - getUserId: - string(0) "" - getAppId: - string(0) "" - getMessageId: - string(0) "" - getReplyTo: - string(0) "" - getCorrelationId: - string(0) "" - getHeaders: - array(0) { -} - -call #3 -bool(false) \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_get_channel.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_get_channel.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_get_channel.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_get_channel.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ ---TEST-- -AMQPQueue getChannel() test ---SKIPIF-- - ---FILE-- -connect(); - -$ch = new AMQPChannel($cnn); -$ch2 = new AMQPChannel($cnn); - -$q = new AMQPQueue($ch); - -echo $ch === $q->getChannel() ? 'same' : 'not same', PHP_EOL; -echo $ch2 === $q->getChannel() ? 'same' : 'not same', PHP_EOL; - -$old_prefetch = $ch->getPrefetchCount(); -$new_prefetch = 999; - -$q->getChannel()->setPrefetchCount($new_prefetch); - -echo $ch->getPrefetchCount() == $new_prefetch ? 'by ref' : 'copy', PHP_EOL; - -?> ---EXPECT-- -same -not same -by ref diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_get_connection.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_get_connection.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_get_connection.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_get_connection.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ ---TEST-- -AMQPQueue getConnection test ---SKIPIF-- - ---FILE-- -connect(); - -$ch = new AMQPChannel($cnn); - -$q = new AMQPQueue($ch); - -$cnn2 = new AMQPConnection(); - -echo $cnn === $q->getConnection() ? 'same' : 'not same', PHP_EOL; -echo $cnn2 === $q->getConnection() ? 'same' : 'not same', PHP_EOL; - -$old_host = $cnn->getHost(); -$new_host = 'test'; - -$q->getConnection()->setHost($new_host); - -echo $cnn->getHost() == $new_host ? 'by ref' : 'copy', PHP_EOL; - -?> ---EXPECT-- -same -not same -by ref diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_get_empty_body.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_get_empty_body.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_get_empty_body.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_get_empty_body.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ ---TEST-- -AMQPQueue::get empty body ---SKIPIF-- - ---FILE-- -connect(); - -$ch = new AMQPChannel($cnn); - -// Declare a new exchange -$ex = new AMQPExchange($ch); -$ex->setName('exchange' . microtime(true)); -$ex->setType(AMQP_EX_TYPE_FANOUT); -$ex->declareExchange(); - -// Create a new queue -$q = new AMQPQueue($ch); -$q->setName('queue1' . microtime(true)); -$q->declareQueue(); - -// Bind it on the exchange to routing.key -$q->bind($ex->getName(), 'routing.*'); - -// Publish a message to the exchange with a routing key -$ex->publish('', 'routing.1'); - -// Read from the queue -$msg = $q->get(AMQP_AUTOACK); -echo "'" . $msg->getBody() . "'\n"; - -$msg = $q->get(AMQP_AUTOACK); - -if ($msg === FALSE) { - echo "No more messages\n"; -} - -$ex->delete(); -$q->delete(); -?> ---EXPECT-- -'' -No more messages diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_get_headers.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_get_headers.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_get_headers.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_get_headers.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,62 +0,0 @@ ---TEST-- -AMQPQueue::get headers ---SKIPIF-- - ---FILE-- -connect(); - -$ch = new AMQPChannel($cnn); - -// Declare a new exchange -$ex = new AMQPExchange($ch); -$ex->setName('exchange' . microtime(true)); -$ex->setType(AMQP_EX_TYPE_FANOUT); -$ex->declareExchange(); - -// Create a new queue -$q = new AMQPQueue($ch); -$q->setName('queue1' . microtime(true)); -$q->declareQueue(); - -// Bind it on the exchange to routing.key -$q->bind($ex->getName(), 'routing.*'); - -// Publish a message to the exchange with a routing key -$ex->publish('body', 'routing.1', AMQP_NOPARAM, array("headers" => array( - "first" => "one", - "second" => 2 -))); - -// Read from the queue -$msg = $q->get(AMQP_AUTOACK); - -echo $msg->getBody() . "\n"; -var_dump($msg->getHeaders()); -echo $msg->getContentType() . "\n"; - -var_dump($msg->hasHeader("first")); -echo $msg->getHeader("first") . "\n"; -echo $msg->getHeader("second") . "\n"; - -echo 'Has nonexistent header: ', var_export($msg->hasHeader("nonexistent"), true), PHP_EOL; -echo 'Get nonexistent header: ', var_export($msg->getHeader("nonexistent"), true), PHP_EOL; - -$ex->delete(); -$q->delete(); -?> ---EXPECT-- -body -array(2) { - ["first"]=> - string(3) "one" - ["second"]=> - int(2) -} -text/plain -bool(true) -one -2 -Has nonexistent header: false -Get nonexistent header: false diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_get_nonexistent.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_get_nonexistent.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_get_nonexistent.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_get_nonexistent.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ ---TEST-- -AMQPQueue::get from nonexistent queue ---SKIPIF-- - ---FILE-- -setReadTimeout(10); // both are empirical values that should be far enough to deal with busy RabbitMQ broker -$cnn->setWriteTimeout(10); -$cnn->connect(); - -$ch = new AMQPChannel($cnn); - -// Declare a new exchange -$ex = new AMQPExchange($ch); -$ex->setName('exchange-' . microtime(true)); -$ex->setType(AMQP_EX_TYPE_FANOUT); -$ex->declareExchange(); - -// Create a new queue -$q = new AMQPQueue($ch); -$q->setName('nonexistent-' . microtime(true)); - -try { - $q->get(); -} catch (Exception $e) { - echo get_class($e), ': ', $e->getMessage(); -} - -?> ---EXPECTF-- -AMQPQueueException: Server channel error: 404, message: NOT_FOUND - no queue 'nonexistent-%f' in vhost '/' diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_nack.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_nack.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_nack.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_nack.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ ---TEST-- -AMQPQueue::nack ---SKIPIF-- - ---FILE-- -connect(); - -$ch = new AMQPChannel($cnn); - -// Declare a new exchange -$ex = new AMQPExchange($ch); -$ex->setName('testnack' . microtime(true)); -$ex->setType(AMQP_EX_TYPE_FANOUT); -$ex->declareExchange(); -$exchangeName = $ex->getName(); - -// Create a new queue -$q = new AMQPQueue($ch); -$q->setName('testnack' . microtime(true)); -$q->declareQueue(); -$q->bind($exchangeName, '#'); - -// Bind it on the exchange to routing.key -// Publish a message to the exchange with a routing key -$ex->publish('message', 'foo'); - -$env = $q->get(AMQP_NOPARAM); -echo $env->getBody() . PHP_EOL; -echo $env->isRedelivery() ? 'true' : 'false'; -echo PHP_EOL; - -// send the message back to the queue -$q->nack($env->getDeliveryTag(), AMQP_REQUEUE); - -// read again -$env2 = $q->get(AMQP_NOPARAM); -if (false !== $env2) { - $q->ack($env2->getDeliveryTag()); - echo $env2->getBody() . PHP_EOL; - echo $env2->isRedelivery() ? 'true' : 'false'; - echo PHP_EOL; -} else { - echo "could not read message" . PHP_EOL; -} - -$ex->delete(); -$q->delete(); ---EXPECT-- -message -false -message -true diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_nested_arrays.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_nested_arrays.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_nested_arrays.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_nested_arrays.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,64 +0,0 @@ ---TEST-- -AMQPQueue::get headers ---SKIPIF-- - ---FILE-- -connect(); - -$ch = new AMQPChannel($cnn); - -$ex = new AMQPExchange($ch); -$ex->setName('exchange' . microtime(true)); -$ex->setType(AMQP_EX_TYPE_TOPIC); -$ex->declareExchange(); -$q = new AMQPQueue($ch); -$q->setName('queue1' . microtime(true)); -$q->declareQueue(); -$q->bind($ex->getName(), '#'); - - -// publish a message: -$ex->publish( - 'body', 'routing.1', AMQP_NOPARAM, array( - 'headers' => array( - 'foo' => 'bar', - 'baz' => array('a', 'bc', 'def') - ) - ) -); - -// Read from the queue -$msg = $q->get(AMQP_AUTOACK); - -var_dump($msg->getHeaders()); -echo $msg->getHeader('foo') . "\n"; -var_dump($msg->getHeader('baz')); - -$ex->delete(); -$q->delete(); -?> ---EXPECT-- -array(2) { - ["foo"]=> - string(3) "bar" - ["baz"]=> - array(3) { - [0]=> - string(1) "a" - [1]=> - string(2) "bc" - [2]=> - string(3) "def" - } -} -bar -array(3) { - [0]=> - string(1) "a" - [1]=> - string(2) "bc" - [2]=> - string(3) "def" -} diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_nested_headers.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_nested_headers.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_nested_headers.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_nested_headers.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,86 +0,0 @@ ---TEST-- -AMQPQueue::get headers ---SKIPIF-- - ---FILE-- -connect(); - -$ch = new AMQPChannel($cnn); - -// create an error exchange and bind a queue to it: -$errorXchange = new AMQPExchange($ch); -$errorXchange->setName('errorXchange' . microtime(true)); -$errorXchange->setType(AMQP_EX_TYPE_TOPIC); -$errorXchange->declareExchange(); - -$errorQ = new AMQPQueue($ch); -$errorQ->setName('errorQueue' . microtime(true)); -$errorQ->declareQueue(); -$errorQ->bind($errorXchange->getName(), '#'); - - -// Declare a new exchange and queue using this dead-letter-exchange: -$ex = new AMQPExchange($ch); -$ex->setName('exchange-' . microtime(true)); -$ex->setType(AMQP_EX_TYPE_TOPIC); -$ex->declareExchange(); -$q = new AMQPQueue($ch); -$q->setName('queue-' . microtime(true)); -$q->setArgument('x-dead-letter-exchange', $errorXchange->getName()); -$q->declareQueue(); -$q->bind($ex->getName(), '#'); - - -// publish a message: -$ex->publish( - 'body', 'routing.1', AMQP_NOPARAM, array( - 'headers' => array( - 'foo' => 'bar', - 'baz' => array('a', 'bc', 'def') - ) - ) -); - -// Read from the queue and reject, so it gets dead-lettered: -$msg = $q->get(AMQP_NOPARAM); -$q->nack($msg->getDeliveryTag()); - -sleep(1); -// Now read from the error queue: -$msg = $errorQ->get(AMQP_AUTOACK); - -$header = $msg->getHeader('x-death'); - -echo isset($header[0]['count']) ? 'with' : 'without', ' count ', PHP_EOL; - -unset($header[0]['count']); - -var_dump($header); - -$ex->delete(); -$q->delete(); -$errorXchange->delete(); -$errorQ->delete(); -?> ---EXPECTF-- -%s -array(1) { - [0]=> - array(5) { - ["reason"]=> - string(8) "rejected" - ["queue"]=> - string(%d) "queue-%f" - ["time"]=> - float(%d) - ["exchange"]=> - string(%d) "exchange-%f" - ["routing-keys"]=> - array(1) { - [0]=> - string(9) "routing.1" - } - } -} \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_purge_basic.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_purge_basic.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_purge_basic.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_purge_basic.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ ---TEST-- -AMQPQueue ---SKIPIF-- - ---FILE-- - ---EXPECT-- diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_setArgument.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_setArgument.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_setArgument.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_setArgument.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,270 +0,0 @@ ---TEST-- -AMQPQueue::setArgument() test ---SKIPIF-- - ---FILE-- -connect(); - -$ch = new AMQPChannel($cnn); - -$heartbeat = 10; -$q_dead_name = 'test.queue.dead.' . microtime(true); -$q_name = 'test.queue.' . microtime(true); - -$q = new AMQPQueue($ch); -$q->setName($q_name); -$q->setFlags(AMQP_AUTODELETE); -$q->declareQueue(); - -var_dump($q); - - -$q_dead = new AMQPQueue($ch); -$q_dead->setName($q_dead_name); -$q_dead->setArgument('x-dead-letter-exchange', ''); -$q_dead->setArgument('x-dead-letter-routing-key', $q_name); -$q_dead->setArgument('x-message-ttl', $heartbeat * 10 * 1000); -$q_dead->setFlags(AMQP_AUTODELETE); -$q_dead->declareQueue(); - -var_dump($q_dead); -$q_dead->setArgument('x-dead-letter-routing-key', null); // removes this key -var_dump($q_dead); -?> ---EXPECTF-- -object(AMQPQueue)#3 (9) { - ["connection":"AMQPQueue":private]=> - object(AMQPConnection)#1 (11) { - ["login":"AMQPConnection":private]=> - string(5) "guest" - ["password":"AMQPConnection":private]=> - string(5) "guest" - ["host":"AMQPConnection":private]=> - string(9) "localhost" - ["vhost":"AMQPConnection":private]=> - string(1) "/" - ["port":"AMQPConnection":private]=> - %s(5672) - ["read_timeout":"AMQPConnection":private]=> - %s(0) - ["write_timeout":"AMQPConnection":private]=> - %s(0) - ["connect_timeout":"AMQPConnection":private]=> - %s(0) - ["channel_max":"AMQPConnection":private]=> - %s(256) - ["frame_max":"AMQPConnection":private]=> - %s(131072) - ["heartbeat":"AMQPConnection":private]=> - %s(0) - } - ["channel":"AMQPQueue":private]=> - object(AMQPChannel)#2 (3) { - ["connection":"AMQPChannel":private]=> - object(AMQPConnection)#1 (11) { - ["login":"AMQPConnection":private]=> - string(5) "guest" - ["password":"AMQPConnection":private]=> - string(5) "guest" - ["host":"AMQPConnection":private]=> - string(9) "localhost" - ["vhost":"AMQPConnection":private]=> - string(1) "/" - ["port":"AMQPConnection":private]=> - %s(5672) - ["read_timeout":"AMQPConnection":private]=> - %s(0) - ["write_timeout":"AMQPConnection":private]=> - %s(0) - ["connect_timeout":"AMQPConnection":private]=> - %s(0) - ["channel_max":"AMQPConnection":private]=> - %s(256) - ["frame_max":"AMQPConnection":private]=> - %s(131072) - ["heartbeat":"AMQPConnection":private]=> - %s(0) - } - ["prefetch_count":"AMQPChannel":private]=> - %s(3) - ["prefetch_size":"AMQPChannel":private]=> - %s(0) - } - ["name":"AMQPQueue":private]=> - string(%d) "test.queue.%f" - ["consumer_tag":"AMQPQueue":private]=> - NULL - ["passive":"AMQPQueue":private]=> - bool(false) - ["durable":"AMQPQueue":private]=> - bool(false) - ["exclusive":"AMQPQueue":private]=> - bool(false) - ["auto_delete":"AMQPQueue":private]=> - bool(true) - ["arguments":"AMQPQueue":private]=> - array(0) { - } -} -object(AMQPQueue)#4 (9) { - ["connection":"AMQPQueue":private]=> - object(AMQPConnection)#1 (11) { - ["login":"AMQPConnection":private]=> - string(5) "guest" - ["password":"AMQPConnection":private]=> - string(5) "guest" - ["host":"AMQPConnection":private]=> - string(9) "localhost" - ["vhost":"AMQPConnection":private]=> - string(1) "/" - ["port":"AMQPConnection":private]=> - %s(5672) - ["read_timeout":"AMQPConnection":private]=> - %s(0) - ["write_timeout":"AMQPConnection":private]=> - %s(0) - ["connect_timeout":"AMQPConnection":private]=> - %s(0) - ["channel_max":"AMQPConnection":private]=> - %s(256) - ["frame_max":"AMQPConnection":private]=> - %s(131072) - ["heartbeat":"AMQPConnection":private]=> - %s(0) - } - ["channel":"AMQPQueue":private]=> - object(AMQPChannel)#2 (3) { - ["connection":"AMQPChannel":private]=> - object(AMQPConnection)#1 (11) { - ["login":"AMQPConnection":private]=> - string(5) "guest" - ["password":"AMQPConnection":private]=> - string(5) "guest" - ["host":"AMQPConnection":private]=> - string(9) "localhost" - ["vhost":"AMQPConnection":private]=> - string(1) "/" - ["port":"AMQPConnection":private]=> - %s(5672) - ["read_timeout":"AMQPConnection":private]=> - %s(0) - ["write_timeout":"AMQPConnection":private]=> - %s(0) - ["connect_timeout":"AMQPConnection":private]=> - %s(0) - ["channel_max":"AMQPConnection":private]=> - %s(256) - ["frame_max":"AMQPConnection":private]=> - %s(131072) - ["heartbeat":"AMQPConnection":private]=> - %s(0) - } - ["prefetch_count":"AMQPChannel":private]=> - %s(3) - ["prefetch_size":"AMQPChannel":private]=> - %s(0) - } - ["name":"AMQPQueue":private]=> - string(%d) "test.queue.dead.%f" - ["consumer_tag":"AMQPQueue":private]=> - NULL - ["passive":"AMQPQueue":private]=> - bool(false) - ["durable":"AMQPQueue":private]=> - bool(false) - ["exclusive":"AMQPQueue":private]=> - bool(false) - ["auto_delete":"AMQPQueue":private]=> - bool(true) - ["arguments":"AMQPQueue":private]=> - array(3) { - ["x-dead-letter-exchange"]=> - string(0) "" - ["x-dead-letter-routing-key"]=> - string(%d) "test.queue.%f" - ["x-message-ttl"]=> - %s(100000) - } -} -object(AMQPQueue)#4 (9) { - ["connection":"AMQPQueue":private]=> - object(AMQPConnection)#1 (11) { - ["login":"AMQPConnection":private]=> - string(5) "guest" - ["password":"AMQPConnection":private]=> - string(5) "guest" - ["host":"AMQPConnection":private]=> - string(9) "localhost" - ["vhost":"AMQPConnection":private]=> - string(1) "/" - ["port":"AMQPConnection":private]=> - %s(5672) - ["read_timeout":"AMQPConnection":private]=> - %s(0) - ["write_timeout":"AMQPConnection":private]=> - %s(0) - ["connect_timeout":"AMQPConnection":private]=> - %s(0) - ["channel_max":"AMQPConnection":private]=> - %s(256) - ["frame_max":"AMQPConnection":private]=> - %s(131072) - ["heartbeat":"AMQPConnection":private]=> - %s(0) - } - ["channel":"AMQPQueue":private]=> - object(AMQPChannel)#2 (3) { - ["connection":"AMQPChannel":private]=> - object(AMQPConnection)#1 (11) { - ["login":"AMQPConnection":private]=> - string(5) "guest" - ["password":"AMQPConnection":private]=> - string(5) "guest" - ["host":"AMQPConnection":private]=> - string(9) "localhost" - ["vhost":"AMQPConnection":private]=> - string(1) "/" - ["port":"AMQPConnection":private]=> - %s(5672) - ["read_timeout":"AMQPConnection":private]=> - %s(0) - ["write_timeout":"AMQPConnection":private]=> - %s(0) - ["connect_timeout":"AMQPConnection":private]=> - %s(0) - ["channel_max":"AMQPConnection":private]=> - %s(256) - ["frame_max":"AMQPConnection":private]=> - %s(131072) - ["heartbeat":"AMQPConnection":private]=> - %s(0) - } - ["prefetch_count":"AMQPChannel":private]=> - %s(3) - ["prefetch_size":"AMQPChannel":private]=> - %s(0) - } - ["name":"AMQPQueue":private]=> - string(%d) "test.queue.dead.%f" - ["consumer_tag":"AMQPQueue":private]=> - NULL - ["passive":"AMQPQueue":private]=> - bool(false) - ["durable":"AMQPQueue":private]=> - bool(false) - ["exclusive":"AMQPQueue":private]=> - bool(false) - ["auto_delete":"AMQPQueue":private]=> - bool(true) - ["arguments":"AMQPQueue":private]=> - array(2) { - ["x-dead-letter-exchange"]=> - string(0) "" - ["x-message-ttl"]=> - %s(100000) - } -} diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_unbind_basic_empty_routing_key.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_unbind_basic_empty_routing_key.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_unbind_basic_empty_routing_key.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_unbind_basic_empty_routing_key.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ ---TEST-- -AMQPQueue ---SKIPIF-- - ---FILE-- -connect(); - -$ch = new AMQPChannel($cnn); - -$ex = new AMQPExchange($ch); -$ex->setName('exchange-' . microtime(true)); -$ex->setType(AMQP_EX_TYPE_DIRECT); -$ex->declareExchange(); - -$queue = new AMQPQueue($ch); -$queue->setName("queue-" . microtime(true)); -$queue->declareQueue(); -var_dump($queue->bind($ex->getName())); -var_dump($queue->unbind($ex->getName())); - -$queue->delete(); -$ex->delete(); -?> ---EXPECT-- -bool(true) -bool(true) diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_unbind_basic_headers_arguments.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_unbind_basic_headers_arguments.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_unbind_basic_headers_arguments.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_unbind_basic_headers_arguments.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ ---TEST-- -AMQPQueue ---SKIPIF-- - ---FILE-- -connect(); - -$ch = new AMQPChannel($cnn); - -$ex = new AMQPExchange($ch); -$ex->setName('exchange-' . microtime(true)); -$ex->setType(AMQP_EX_TYPE_DIRECT); -$ex->declareExchange(); - -$queue = new AMQPQueue($ch); -$queue->setName("queue-" . microtime(true)); -$queue->declareQueue(); - -$arguments = array('x-match' => 'all', 'type' => 'custom'); - -var_dump($queue->bind($ex->getName(), '', $arguments)); -var_dump($queue->unbind($ex->getName(), '', $arguments)); - -$queue->delete(); -$ex->delete(); -?> ---EXPECT-- -bool(true) -bool(true) diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_var_dump.phpt php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_var_dump.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/amqpqueue_var_dump.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/amqpqueue_var_dump.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,98 +0,0 @@ ---TEST-- -AMQPQueue var_dump ---SKIPIF-- -connect(); -$ch = new AMQPChannel($cnn); -// Declare a new exchange -$ex = new AMQPExchange($ch); -$ex->setName('exchange1'); -$ex->setType(AMQP_EX_TYPE_FANOUT); -$ex->declareExchange(); -// Create a new queue -$q = new AMQPQueue($ch); -$q->setName('queue_var_dump'); -$q->declareQueue(); -var_dump($q); -?> ---EXPECT-- -object(AMQPQueue)#4 (9) { - ["connection":"AMQPQueue":private]=> - object(AMQPConnection)#1 (11) { - ["login":"AMQPConnection":private]=> - string(5) "guest" - ["password":"AMQPConnection":private]=> - string(5) "guest" - ["host":"AMQPConnection":private]=> - string(9) "localhost" - ["vhost":"AMQPConnection":private]=> - string(1) "/" - ["port":"AMQPConnection":private]=> - int(5672) - ["read_timeout":"AMQPConnection":private]=> - float(0) - ["write_timeout":"AMQPConnection":private]=> - float(0) - ["connect_timeout":"AMQPConnection":private]=> - float(0) - ["channel_max":"AMQPConnection":private]=> - int(256) - ["frame_max":"AMQPConnection":private]=> - int(131072) - ["heartbeat":"AMQPConnection":private]=> - int(0) - } - ["channel":"AMQPQueue":private]=> - object(AMQPChannel)#2 (3) { - ["connection":"AMQPChannel":private]=> - object(AMQPConnection)#1 (11) { - ["login":"AMQPConnection":private]=> - string(5) "guest" - ["password":"AMQPConnection":private]=> - string(5) "guest" - ["host":"AMQPConnection":private]=> - string(9) "localhost" - ["vhost":"AMQPConnection":private]=> - string(1) "/" - ["port":"AMQPConnection":private]=> - int(5672) - ["read_timeout":"AMQPConnection":private]=> - float(0) - ["write_timeout":"AMQPConnection":private]=> - float(0) - ["connect_timeout":"AMQPConnection":private]=> - float(0) - ["channel_max":"AMQPConnection":private]=> - int(256) - ["frame_max":"AMQPConnection":private]=> - int(131072) - ["heartbeat":"AMQPConnection":private]=> - int(0) - } - ["prefetch_count":"AMQPChannel":private]=> - int(3) - ["prefetch_size":"AMQPChannel":private]=> - int(0) - } - ["name":"AMQPQueue":private]=> - string(14) "queue_var_dump" - ["consumer_tag":"AMQPQueue":private]=> - NULL - ["passive":"AMQPQueue":private]=> - bool(false) - ["durable":"AMQPQueue":private]=> - bool(false) - ["exclusive":"AMQPQueue":private]=> - bool(false) - ["auto_delete":"AMQPQueue":private]=> - bool(true) - ["arguments":"AMQPQueue":private]=> - array(0) { - } -} \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/bug_17831.phpt php-amqp-1.9.3/amqp-1.7.1/tests/bug_17831.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/bug_17831.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/bug_17831.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ ---TEST-- -Segfault when publishing to non existent exchange ---SKIPIF-- - ---FILE-- -connect(); - -$ch = new AMQPChannel($c); - -$ex = new AMQPExchange($ch); -$ex->setName("exchange-" . microtime(true)); -$ex->setType(AMQP_EX_TYPE_FANOUT); -$ex->declareExchange(); -try { - $ex->publish("data", "bar"); - echo "Success\n"; -} catch (Exception $e) { - echo "Success\n"; -} -$ex->delete(); -?> ---EXPECT-- -Success diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/bug_19707.phpt php-amqp-1.9.3/amqp-1.7.1/tests/bug_19707.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/bug_19707.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/bug_19707.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,61 +0,0 @@ ---TEST-- -AMQPQueue::get() doesn't return the message ---SKIPIF-- - ---FILE-- -connect(); - -$ch = new AMQPChannel($cnn); - -$ex = new AMQPExchange($ch); -$ex->setName("exchange_testing_19707"); -$ex->setType(AMQP_EX_TYPE_FANOUT); -$ex->declareExchange(); - -$q = new AMQPQueue($ch); -$q->setName('queue' . microtime(true)); -$q->setFlags(AMQP_DURABLE); -$q->declareQueue(); - -$q->bind($ex->getName(), 'routing.key'); - -$ex->publish('message', 'routing.key'); - -$msg = $q->get(); - -echo "message received from get:\n"; -$funcs = array( - 'getAppId', 'getBody', 'getContentEncoding', 'getContentType', - 'getCorrelationId', 'getDeliveryTag', 'getExchangeName', 'getExpiration', - 'getHeaders', 'getMessageId', 'getPriority', 'getReplyTo', 'getRoutingKey', - 'getTimeStamp', 'getType', 'getUserId', 'isRedelivery' -); -foreach ($funcs as $func) { - printf("%s => %s\n", $func, var_export($msg->$func(), true)); -}; - -$q->delete(); -$ex->delete(); -?> ---EXPECT-- -message received from get: -getAppId => '' -getBody => 'message' -getContentEncoding => '' -getContentType => 'text/plain' -getCorrelationId => '' -getDeliveryTag => 1 -getExchangeName => 'exchange_testing_19707' -getExpiration => '' -getHeaders => array ( -) -getMessageId => '' -getPriority => 0 -getReplyTo => '' -getRoutingKey => 'routing.key' -getTimeStamp => 0 -getType => '' -getUserId => '' -isRedelivery => false \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/bug_19840.phpt php-amqp-1.9.3/amqp-1.7.1/tests/bug_19840.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/bug_19840.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/bug_19840.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ ---TEST-- -Bug 19840: Connection Exception ---SKIPIF-- - ---FILE-- -connect(); - echo "No exception thrown\n"; -} catch (Exception $e) { - echo get_class($e), ': ', $e->getMessage(); -} -?> ---EXPECT-- -AMQPConnectionException: Socket error: could not connect to host. \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/bug_61533.phpt php-amqp-1.9.3/amqp-1.7.1/tests/bug_61533.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/bug_61533.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/bug_61533.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ ---TEST-- -Constructing AMQPQueue with AMQPConnection segfaults ---SKIPIF-- - ---FILE-- -connect(); -$chan = new AMQPChannel($conn); - -if (!class_exists('TypeError')) { - class TypeError extends Exception {} -} - -try { - error_reporting(error_reporting() & ~E_WARNING); - $queue = new AMQPQueue($conn); -} catch (TypeError $e) { - echo get_class($e), ': ', $e->getMessage(), '.', PHP_EOL; // we pad exception message with dot to make EXPETF be the same on PHP 5 and PHP 7 -} - -?> ---EXPECTF-- -%s: Argument 1 passed to AMQPQueue::__construct() must be an instance of AMQPChannel, instance of AMQPConnection given%s diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/bug_62354.phpt php-amqp-1.9.3/amqp-1.7.1/tests/bug_62354.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/bug_62354.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/bug_62354.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ ---TEST-- -Constructing AMQPQueue with AMQPConnection segfaults ---SKIPIF-- - ---FILE-- -conn = new AMQPConnection(); -$funcs = array( - 'getHost', 'getLogin', 'getPassword', 'getPort', 'getVHost', 'isConnected' -); -foreach ($funcs as $func) { - printf("%s => %s\n", $func, var_export($o->conn->$func(), true)); -}; -?> ---EXPECT-- -getHost => 'localhost' -getLogin => 'guest' -getPassword => 'guest' -getPort => 5672 -getVHost => '/' -isConnected => false \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/bug_gh147.phpt php-amqp-1.9.3/amqp-1.7.1/tests/bug_gh147.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/bug_gh147.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/bug_gh147.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ ---TEST-- -#147 Segfault when catchable fatal error happens in consumer ---SKIPIF-- - ---FILE-- -connect(); - -$channel = new AMQPChannel($connection); -$channel->setPrefetchCount(2); - -$exchange = new AMQPExchange($channel); -$exchange->setType(AMQP_EX_TYPE_TOPIC); -$exchange->setName('test_' . $time); -$exchange->setFlags(AMQP_AUTODELETE); -$exchange->declareExchange(); - -$queue = new AMQPQueue($channel); -$queue->setName('test_' . $time); -$queue->declareQueue(); - -$queue->bind($exchange->getName(), 'test'); - -$exchange->publish('test message', 'test'); - -echo 'start', PHP_EOL; -$queue->consume(function(AMQPEnvelope $e) use (&$consume) { - echo 'consuming'; - $e . 'should fail'; - - return false; -}); - -echo 'done', PHP_EOL; - - -?> ---EXPECTF-- -start -consuming -Catchable fatal error: Object of class %s could not be converted to string in %s on line %d \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/bug_gh155_direct_reply_to.phpt php-amqp-1.9.3/amqp-1.7.1/tests/bug_gh155_direct_reply_to.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/bug_gh155_direct_reply_to.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/bug_gh155_direct_reply_to.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,76 +0,0 @@ ---TEST-- -#155 RabbitMQ's Direct reply-to (related to consume multiple) ---SKIPIF-- - ---FILE-- -connect(); - -$channel = new AMQPChannel($conn); -$exchange = new AMQPExchange($channel); - - -$q_reply_to = new AMQPQueue($channel); -$q_reply_to->setName('amq.rabbitmq.reply-to'); -$q_reply_to->consume(null, AMQP_AUTOACK); - - -// this will be kind out long-living queue to -$q_request = new AMQPQueue($channel); -$q_request->setName('reply-to-requests'); -$q_request->setFlags(AMQP_DURABLE); -$q_request->declareQueue(); -$q_request->purge(); - -$q_request_name = $q_request->getName(); - -echo 'Publishing request...' . PHP_EOL; - -$exchange->publish('request', $q_request_name, AMQP_NOPARAM, array('reply_to' => 'amq.rabbitmq.reply-to')); - -$request_message = $q_request->get(AMQP_AUTOACK); - -$reply_to = $request_message->getReplyTo(); - -echo 'Reply-to queue: ', $reply_to, PHP_EOL; - -echo 'Prepare response queue...' . PHP_EOL; - -$channel_2 = new AMQPChannel($conn); - -$q_reply = new AMQPQueue($channel_2); -$q_reply->setName($reply_to); -$q_reply->setFlags(AMQP_PASSIVE); -$q_reply->declareQueue(); - -echo 'Publishing response...' . PHP_EOL; - -$exchange->publish('response', $reply_to, AMQP_NOPARAM); - - -echo 'Waiting for reply...' . PHP_EOL; -$q_reply_to->consume(function (AMQPEnvelope $message, AMQPQueue $queue) { - echo $message->getBody() . ': ' . $message->getRoutingKey() . PHP_EOL; - - echo 'Received on ', $queue->getName(), ' queue', PHP_EOL; - - return false; -}, AMQP_JUST_CONSUME); - -echo 'done', PHP_EOL; - - - -?> ---EXPECTF-- -Publishing request... -Reply-to queue: amq.rabbitmq.reply-to.%s.%s== -Prepare response queue... -Publishing response... -Waiting for reply... -response: amq.rabbitmq.reply-to.%s.%s== -Received on amq.rabbitmq.reply-to queue -done \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/bug_gh50-1.phpt php-amqp-1.9.3/amqp-1.7.1/tests/bug_gh50-1.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/bug_gh50-1.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/bug_gh50-1.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ ---TEST-- -Channel creation race condition (https://github.com/pdezwart/php-amqp/issues/50) (1) ---SKIPIF-- - ---FILE-- -connect(); - -for ($i = 0; $i < 3; $i++) { - - $channel = new AMQPChannel($connection); - var_dump($channel->getChannelId()); - - $queue = new AMQPQueue($channel); - $queue->setName('test' . $i); - - $queue->declareQueue(); - $queue->delete(); -} -?> -==DONE== ---EXPECT-- -int(1) -int(2) -int(1) -==DONE== diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/bug_gh50-2.phpt php-amqp-1.9.3/amqp-1.7.1/tests/bug_gh50-2.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/bug_gh50-2.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/bug_gh50-2.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ ---TEST-- -Channel creation race condition (https://github.com/pdezwart/php-amqp/issues/50) (2) ---SKIPIF-- - ---FILE-- -connect(); - -for ($i = 0; $i < 3; $i++) { - - $channel = new AMQPChannel($connection); - var_dump($channel->getChannelId()); - - $queue = new AMQPQueue($channel); - $queue->setName('test' . $i); - - $queue->declareQueue(); - $queue->delete(); - - unset($queue); - unset($channel); -} -?> -==DONE== ---EXPECT-- -int(1) -int(1) -int(1) -==DONE== diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/bug_gh50-3.phpt php-amqp-1.9.3/amqp-1.7.1/tests/bug_gh50-3.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/bug_gh50-3.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/bug_gh50-3.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ ---TEST-- -Channel creation race condition (https://github.com/pdezwart/php-amqp/issues/50) (3) ---SKIPIF-- - ---FILE-- -connect(); - -for ($i = 0; $i < 3; $i++) { - - $channel = new AMQPChannel($connection); - var_dump($channel->getChannelId()); - - $queue = new AMQPQueue($channel); - $queue->setName('test' . $i); - - $queue->declareQueue(); - $queue->delete(); -} - -$connection = new AMQPConnection(); -$connection->connect(); - -for ($i = 0; $i < 3; $i++) { - - $channel = new AMQPChannel($connection); - var_dump($channel->getChannelId()); - - $queue = new AMQPQueue($channel); - $queue->setName('test' . $i); - - $queue->declareQueue(); - $queue->delete(); -} - - -?> -==DONE== ---EXPECT-- -int(1) -int(2) -int(1) -int(1) -int(2) -int(1) -==DONE== diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/bug_gh50-4.phpt php-amqp-1.9.3/amqp-1.7.1/tests/bug_gh50-4.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/bug_gh50-4.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/bug_gh50-4.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ ---TEST-- -Channel creation race condition (https://github.com/pdezwart/php-amqp/issues/50) (4) ---SKIPIF-- - ---FILE-- -connect(); - -$channels = array(); - -for ($i = 0; $i < 3; $i++) { - - $channel = $channels[] = new AMQPChannel($connection); - var_dump($channel->getChannelId()); - - $queue = new AMQPQueue($channel); - $queue->setName('test' . $i); - - $queue->declareQueue(); - $queue->delete(); -} - -$connection = new AMQPConnection(); -$connection->connect(); - -for ($i = 0; $i < 3; $i++) { - - $channel = $channels[] = new AMQPChannel($connection); - var_dump($channel->getChannelId()); - - $queue = new AMQPQueue($channel); - $queue->setName('test' . $i); - - $queue->declareQueue(); - $queue->delete(); -} - - -?> -==DONE== ---EXPECT-- -int(1) -int(2) -int(3) -int(1) -int(2) -int(3) -==DONE== diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/bug_gh53-2.phpt php-amqp-1.9.3/amqp-1.7.1/tests/bug_gh53-2.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/bug_gh53-2.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/bug_gh53-2.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ ---TEST-- -Upgrade to RabbitMQ 3.1.0-1: AMQPConnectionException: connection closed unexpectedly (2) ---SKIPIF-- - ---FILE-- -connect(); - -$channel = new AMQPChannel($connection); - -$exchange = new AMQPExchange($channel); -$exchange->setName('exchange' . microtime(true)); -$exchange->setType(AMQP_EX_TYPE_TOPIC); -$exchange->declareExchange(); - -$queue = new AMQPQueue($channel); -$queue->setName('queue1' . microtime(true)); -$queue->declareQueue(); -$queue->bind($exchange->getName(), '#'); - -$exchange->publish('body1', 'routing.1'); -$exchange->publish('body2', 'routing.1'); - -$msg = $queue->get(AMQP_AUTOACK); -var_dump($msg->getBody()); - -$msg = $queue->get(AMQP_AUTOACK); -var_dump($msg->getBody()); - -?> -==DONE== ---EXPECT-- -string(5) "body1" -string(5) "body2" -==DONE== diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/bug_gh53.phpt php-amqp-1.9.3/amqp-1.7.1/tests/bug_gh53.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/bug_gh53.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/bug_gh53.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ ---TEST-- -Upgrade to RabbitMQ 3.1.0-1: AMQPConnectionException: connection closed unexpectedly ---SKIPIF-- - ---FILE-- -connect(); - -$channel = new AMQPChannel($connection); -var_dump($channel->getPrefetchSize()); -var_dump($channel->getPrefetchCount()); - -$channel->setPrefetchCount(10); -var_dump($channel->getPrefetchSize()); -var_dump($channel->getPrefetchCount()); - -// NOTE: RabbitMQ Doesn't support prefetch size -try { - $channel->setPrefetchSize(1024); - -} catch (AMQPConnectionException $e) { - echo get_class($e), ': ', $e->getMessage(), PHP_EOL; -} -var_dump($channel->isConnected()); -var_dump($connection->isConnected()); -var_dump($channel->getPrefetchSize()); -var_dump($channel->getPrefetchCount()); - -?> -==DONE== ---EXPECTF-- -int(0) -int(3) -int(0) -int(10) -AMQPConnectionException: Server connection error: 540, message: NOT_IMPLEMENTED - prefetch_size!=0 (%d) -bool(false) -bool(false) -int(0) -int(10) -==DONE== diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/bug_gh72-1.phpt php-amqp-1.9.3/amqp-1.7.1/tests/bug_gh72-1.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/bug_gh72-1.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/bug_gh72-1.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ ---TEST-- -#72 Publishing to an exchange with an empty name is valid and should not throw an exception (1) ---SKIPIF-- - ---FILE-- -connect(); -$channel = new AMQPChannel($connection); - -$exchange = new AMQPExchange($channel); -$exchange->setName(''); - -$exchange->publish('msg', 'key'); -?> -==DONE== ---EXPECT-- -==DONE== diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/bug_gh72-2.phpt php-amqp-1.9.3/amqp-1.7.1/tests/bug_gh72-2.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/bug_gh72-2.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/bug_gh72-2.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ ---TEST-- -#72 Publishing to an exchange with an empty name is valid and should not throw an exception (2) ---SKIPIF-- - ---FILE-- -connect(); -$channel = new AMQPChannel($connection); - -$exchange = new AMQPExchange($channel); - -try { - $exchange->setName(str_repeat('a', 256)); -} catch (AMQPExchangeException $e) { - var_dump($e->getMessage()); -} -?> -==DONE== ---EXPECT-- -string(67) "Invalid exchange name given, must be less than 255 characters long." -==DONE== diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/package-version.phpt php-amqp-1.9.3/amqp-1.7.1/tests/package-version.phpt --- php-amqp-1.7.1/amqp-1.7.1/tests/package-version.phpt 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/package-version.phpt 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ ---TEST-- -Compare version in package.xml and module ---SKIPIF-- - ---FILE-- -version->release; - -$ext = new ReflectionExtension('amqp'); -$srcVersion = $ext->getVersion(); - -if (0 === strcmp($packageVersion, $srcVersion)) { - echo "package.xml matches phpinfo() output\n"; -} else { - printf("src version: %s, package.xml: %s\n", $srcVersion, $packageVersion); -} -if (0 === strcmp($packageVersion, $ext->getVersion())) { - echo "package.xml matches extension version\n"; -} else { - printf("ext version: %s, package.xml: %s\n", $ext->getVersion(), $packageVersion); -} ---EXPECT-- -package.xml matches phpinfo() output -package.xml matches extension version diff -Nru php-amqp-1.7.1/amqp-1.7.1/tests/_test_helpers.php.inc php-amqp-1.9.3/amqp-1.7.1/tests/_test_helpers.php.inc --- php-amqp-1.7.1/amqp-1.7.1/tests/_test_helpers.php.inc 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.7.1/tests/_test_helpers.php.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -getBody()); - echo " getContentType:", PHP_EOL, " "; - var_dump($msg->getContentType()); - echo " getRoutingKey:", PHP_EOL, " "; - var_dump($msg->getRoutingKey()); - echo " getDeliveryTag:", PHP_EOL, " "; - var_dump($msg->getDeliveryTag()); - echo " getDeliveryMode:", PHP_EOL, " "; - var_dump($msg->getDeliveryMode()); - echo " getExchangeName:", PHP_EOL, " "; - var_dump($msg->getExchangeName()); - echo " isRedelivery:", PHP_EOL, " "; - var_dump($msg->isRedelivery()); - echo " getContentEncoding:", PHP_EOL, " "; - var_dump($msg->getContentEncoding()); - echo " getType:", PHP_EOL, " "; - var_dump($msg->getType()); - echo " getTimeStamp:", PHP_EOL, " "; - var_dump($msg->getTimeStamp()); - echo " getPriority:", PHP_EOL, " "; - var_dump($msg->getPriority()); - echo " getExpiration:", PHP_EOL, " "; - var_dump($msg->getExpiration()); - echo " getUserId:", PHP_EOL, " "; - var_dump($msg->getUserId()); - echo " getAppId:", PHP_EOL, " "; - var_dump($msg->getAppId()); - echo " getMessageId:", PHP_EOL, " "; - var_dump($msg->getMessageId()); - echo " getReplyTo:", PHP_EOL, " "; - var_dump($msg->getReplyTo()); - echo " getCorrelationId:", PHP_EOL, " "; - var_dump($msg->getCorrelationId()); - echo " getHeaders:", PHP_EOL, " "; - var_dump($msg->getHeaders()); - - return false; -} - -function consumeThings($message, $queue) { - var_dump($message); - return false; -} diff -Nru php-amqp-1.7.1/amqp-1.9.3/amqp_basic_properties.c php-amqp-1.9.3/amqp-1.9.3/amqp_basic_properties.c --- php-amqp-1.7.1/amqp-1.9.3/amqp_basic_properties.c 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/amqp_basic_properties.c 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,628 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2007 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 | + | Lead: | + | - Pieter de Zwart | + | Maintainers: | + | - Brad Rodriguez | + | - Jonathan Tansavatdi | + +----------------------------------------------------------------------+ +*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "php.h" +#include "php_ini.h" +#include "ext/standard/info.h" +#include "zend_exceptions.h" +#include "Zend/zend_interfaces.h" + +#include +#include + +#ifdef PHP_WIN32 +# include "win32/unistd.h" +# include "win32/php_stdint.h" +# include "win32/signal.h" +#else +# include +# include +# include +#endif + +#if HAVE_INTTYPES_H +# include +#endif + +#include "amqp_basic_properties.h" +#include "php_amqp.h" +#include "amqp_timestamp.h" +#include "amqp_decimal.h" + +zend_class_entry *amqp_basic_properties_class_entry; +#define this_ce amqp_basic_properties_class_entry + + +void php_amqp_basic_properties_convert_to_zval(amqp_basic_properties_t *props, zval *obj TSRMLS_DC) +{ + object_init_ex(obj, this_ce); + + php_amqp_basic_properties_extract(props, obj TSRMLS_CC); +} + +void php_amqp_basic_properties_set_empty_headers(zval *obj TSRMLS_DC) { + PHP5to7_zval_t headers PHP5to7_MAYBE_SET_TO_NULL; + + PHP5to7_MAYBE_INIT(headers); + PHP5to7_ARRAY_INIT(headers); + + zend_update_property(this_ce, obj, ZEND_STRL("headers"), PHP5to7_MAYBE_PTR(headers) TSRMLS_CC); + + PHP5to7_MAYBE_DESTROY(headers); +} + + +/* {{{ proto AMQPBasicProperties::__construct() */ +static PHP_METHOD(AMQPBasicProperties, __construct) { + + char *content_type = NULL; PHP5to7_param_str_len_type_t content_type_len = 0; + char *content_encoding = NULL; PHP5to7_param_str_len_type_t content_encoding_len = 0; + + zval *headers = NULL; + + PHP5to7_param_long_type_t delivery_mode = AMQP_DELIVERY_NONPERSISTENT; + PHP5to7_param_long_type_t priority = 0; + + char *correlation_id = NULL; PHP5to7_param_str_len_type_t correlation_id_len = 0; + char *reply_to = NULL; PHP5to7_param_str_len_type_t reply_to_len = 0; + char *expiration = NULL; PHP5to7_param_str_len_type_t expiration_len = 0; + char *message_id = NULL; PHP5to7_param_str_len_type_t message_id_len = 0; + + PHP5to7_param_long_type_t timestamp = 0; + + char *type = NULL; PHP5to7_param_str_len_type_t type_len = 0; + char *user_id = NULL; PHP5to7_param_str_len_type_t user_id_len = 0; + char *app_id = NULL; PHP5to7_param_str_len_type_t app_id_len = 0; + char *cluster_id = NULL; PHP5to7_param_str_len_type_t cluster_id_len = 0; + + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ssallsssslssss", + /* s */ &content_type, &content_type_len, + /* s */ &content_encoding, &content_encoding_len, + /* a */ &headers, + /* l */ &delivery_mode, + /* l */ &priority, + /* s */ &correlation_id, &correlation_id_len, + /* s */ &reply_to, &reply_to_len, + /* s */ &expiration, &expiration_len, + /* s */ &message_id, &message_id_len, + /* l */ ×tamp, + /* s */ &type, &type_len, + /* s */ &user_id, &user_id_len, + /* s */ &app_id, &app_id_len, + /* s */ &cluster_id, &cluster_id_len + ) == FAILURE) { + return; + } + zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("content_type"), content_type, content_type_len TSRMLS_CC); + zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("content_encoding"), content_encoding, content_encoding_len TSRMLS_CC); + + if (headers != NULL) { + zend_update_property(this_ce, getThis(), ZEND_STRL("headers"), headers TSRMLS_CC); + } else { + php_amqp_basic_properties_set_empty_headers(getThis() TSRMLS_CC); + } + + zend_update_property_long(this_ce, getThis(), ZEND_STRL("delivery_mode"), delivery_mode TSRMLS_CC); + zend_update_property_long(this_ce, getThis(), ZEND_STRL("priority"), priority TSRMLS_CC); + + zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("correlation_id"), correlation_id, correlation_id_len TSRMLS_CC); + zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("reply_to"), reply_to, reply_to_len TSRMLS_CC); + zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("expiration"), expiration, expiration_len TSRMLS_CC); + zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("message_id"), message_id, message_id_len TSRMLS_CC); + + zend_update_property_long(this_ce, getThis(), ZEND_STRL("timestamp"), timestamp TSRMLS_CC); + + zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("type"), type, type_len TSRMLS_CC); + zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("user_id"), user_id, user_id_len TSRMLS_CC); + zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("app_id"), app_id, app_id_len TSRMLS_CC); + zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("cluster_id"), cluster_id, cluster_id_len TSRMLS_CC); +} +/* }}} */ + +/* {{{ proto AMQPBasicProperties::getContentType() */ +static PHP_METHOD(AMQPBasicProperties, getContentType) { + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + PHP_AMQP_RETURN_THIS_PROP("content_type"); +} +/* }}} */ + +/* {{{ proto AMQPBasicProperties::getContentEncoding() */ +static PHP_METHOD(AMQPBasicProperties, getContentEncoding) { + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + PHP_AMQP_RETURN_THIS_PROP("content_encoding"); +} +/* }}} */ + +/* {{{ proto AMQPBasicProperties::getCorrelationId() */ +static PHP_METHOD(AMQPBasicProperties, getHeaders) { + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + PHP_AMQP_RETURN_THIS_PROP("headers"); +} +/* }}} */ + +/* {{{ proto AMQPBasicProperties::getDeliveryMode() */ +static PHP_METHOD(AMQPBasicProperties, getDeliveryMode) { + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + PHP_AMQP_RETURN_THIS_PROP("delivery_mode"); +} +/* }}} */ + +/* {{{ proto AMQPBasicProperties::getPriority() */ +static PHP_METHOD(AMQPBasicProperties, getPriority) { + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + PHP_AMQP_RETURN_THIS_PROP("priority"); +} +/* }}} */ + +/* {{{ proto AMQPBasicProperties::getCorrelationId() */ +static PHP_METHOD(AMQPBasicProperties, getCorrelationId) { + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + PHP_AMQP_RETURN_THIS_PROP("correlation_id"); +} +/* }}} */ + +/* {{{ proto AMQPBasicProperties::getReplyTo() */ +static PHP_METHOD(AMQPBasicProperties, getReplyTo) { + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + PHP_AMQP_RETURN_THIS_PROP("reply_to"); +} +/* }}} */ + +/* {{{ proto AMQPBasicProperties::getExpiration() +check amqp envelope */ +static PHP_METHOD(AMQPBasicProperties, getExpiration) { + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + PHP_AMQP_RETURN_THIS_PROP("expiration"); +} +/* }}} */ + +/* {{{ proto AMQPBasicProperties::getMessageId() */ +static PHP_METHOD(AMQPBasicProperties, getMessageId) { + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + PHP_AMQP_RETURN_THIS_PROP("message_id"); +} +/* }}} */ + +/* {{{ proto AMQPBasicProperties::getTimestamp() */ +static PHP_METHOD(AMQPBasicProperties, getTimestamp) { + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + PHP_AMQP_RETURN_THIS_PROP("timestamp"); +} +/* }}} */ + +/* {{{ proto AMQPBasicProperties::getType() */ +static PHP_METHOD(AMQPBasicProperties, getType) { + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + PHP_AMQP_RETURN_THIS_PROP("type"); +} +/* }}} */ + +/* {{{ proto AMQPBasicProperties::getUserId() */ +static PHP_METHOD(AMQPBasicProperties, getUserId) { + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + PHP_AMQP_RETURN_THIS_PROP("user_id"); +} +/* }}} */ + +/* {{{ proto AMQPBasicProperties::getAppId() */ +static PHP_METHOD(AMQPBasicProperties, getAppId) { + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + PHP_AMQP_RETURN_THIS_PROP("app_id"); +} +/* }}} */ + +/* {{{ proto AMQPBasicProperties::getClusterId() */ +static PHP_METHOD(AMQPBasicProperties, getClusterId) { + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + PHP_AMQP_RETURN_THIS_PROP("cluster_id"); +} +/* }}} */ + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_basic_properties_class__construct, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_basic_properties_class_getContentType, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_basic_properties_class_getContentEncoding, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_basic_properties_class_getHeaders, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_basic_properties_class_getDeliveryMode, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_basic_properties_class_getPriority, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_basic_properties_class_getCorrelationId, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_basic_properties_class_getReplyTo, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_basic_properties_class_getExpiration, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_basic_properties_class_getMessageId, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_basic_properties_class_getTimestamp, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_basic_properties_class_getType, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_basic_properties_class_getUserId, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_basic_properties_class_getAppId, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_basic_properties_class_getClusterId, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + + +zend_function_entry amqp_basic_properties_class_functions[] = { + PHP_ME(AMQPBasicProperties, __construct, arginfo_amqp_basic_properties_class__construct, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR) + + PHP_ME(AMQPBasicProperties, getContentType, arginfo_amqp_basic_properties_class_getContentType, ZEND_ACC_PUBLIC) + PHP_ME(AMQPBasicProperties, getContentEncoding, arginfo_amqp_basic_properties_class_getContentEncoding, ZEND_ACC_PUBLIC) + + PHP_ME(AMQPBasicProperties, getHeaders, arginfo_amqp_basic_properties_class_getHeaders, ZEND_ACC_PUBLIC) + + PHP_ME(AMQPBasicProperties, getDeliveryMode, arginfo_amqp_basic_properties_class_getDeliveryMode, ZEND_ACC_PUBLIC) + PHP_ME(AMQPBasicProperties, getPriority, arginfo_amqp_basic_properties_class_getPriority, ZEND_ACC_PUBLIC) + + PHP_ME(AMQPBasicProperties, getCorrelationId, arginfo_amqp_basic_properties_class_getCorrelationId, ZEND_ACC_PUBLIC) + PHP_ME(AMQPBasicProperties, getReplyTo, arginfo_amqp_basic_properties_class_getReplyTo, ZEND_ACC_PUBLIC) + PHP_ME(AMQPBasicProperties, getExpiration, arginfo_amqp_basic_properties_class_getExpiration, ZEND_ACC_PUBLIC) + PHP_ME(AMQPBasicProperties, getMessageId, arginfo_amqp_basic_properties_class_getMessageId, ZEND_ACC_PUBLIC) + + PHP_ME(AMQPBasicProperties, getTimestamp, arginfo_amqp_basic_properties_class_getTimestamp, ZEND_ACC_PUBLIC) + + PHP_ME(AMQPBasicProperties, getType, arginfo_amqp_basic_properties_class_getType, ZEND_ACC_PUBLIC) + PHP_ME(AMQPBasicProperties, getUserId, arginfo_amqp_basic_properties_class_getUserId, ZEND_ACC_PUBLIC) + PHP_ME(AMQPBasicProperties, getAppId, arginfo_amqp_basic_properties_class_getAppId, ZEND_ACC_PUBLIC) + PHP_ME(AMQPBasicProperties, getClusterId, arginfo_amqp_basic_properties_class_getClusterId, ZEND_ACC_PUBLIC) + + {NULL, NULL, NULL} +}; + + +PHP_MINIT_FUNCTION (amqp_basic_properties) { + zend_class_entry ce; + + INIT_CLASS_ENTRY(ce, "AMQPBasicProperties", amqp_basic_properties_class_functions); + this_ce = zend_register_internal_class(&ce TSRMLS_CC); + + zend_declare_property_stringl(this_ce, ZEND_STRL("content_type"), "", 0, ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_stringl(this_ce, ZEND_STRL("content_encoding"), "", 0, ZEND_ACC_PRIVATE TSRMLS_CC); + + zend_declare_property_null(this_ce, ZEND_STRL("headers"), ZEND_ACC_PRIVATE TSRMLS_CC); + + zend_declare_property_long(this_ce, ZEND_STRL("delivery_mode"), AMQP_DELIVERY_NONPERSISTENT, ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_long(this_ce, ZEND_STRL("priority"), 0, ZEND_ACC_PRIVATE TSRMLS_CC); + + zend_declare_property_stringl(this_ce, ZEND_STRL("correlation_id"), "", 0, ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_stringl(this_ce, ZEND_STRL("reply_to"), "", 0, ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_stringl(this_ce, ZEND_STRL("expiration"), "", 0, ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_stringl(this_ce, ZEND_STRL("message_id"), "", 0, ZEND_ACC_PRIVATE TSRMLS_CC); + + zend_declare_property_long(this_ce, ZEND_STRL("timestamp"), 0, ZEND_ACC_PRIVATE TSRMLS_CC); + + zend_declare_property_stringl(this_ce, ZEND_STRL("type"), "", 0, ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_stringl(this_ce, ZEND_STRL("user_id"), "", 0, ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_stringl(this_ce, ZEND_STRL("app_id"), "", 0, ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_stringl(this_ce, ZEND_STRL("cluster_id"), "", 0, ZEND_ACC_PRIVATE TSRMLS_CC); + + return SUCCESS; +} + + +void parse_amqp_table(amqp_table_t *table, zval *result TSRMLS_DC) { + int i; + zend_bool has_value = 0; + + PHP5to7_zval_t value PHP5to7_MAYBE_SET_TO_NULL; + + assert(Z_TYPE_P(result) == IS_ARRAY); + + for (i = 0; i < table->num_entries; i++) { + PHP5to7_MAYBE_INIT(value); + has_value = 1; + + amqp_table_entry_t *entry = &(table->entries[i]); + switch (entry->value.kind) { + case AMQP_FIELD_KIND_BOOLEAN: + ZVAL_BOOL(PHP5to7_MAYBE_PTR(value), entry->value.value.boolean); + break; + case AMQP_FIELD_KIND_I8: + ZVAL_LONG(PHP5to7_MAYBE_PTR(value), entry->value.value.i8); + break; + case AMQP_FIELD_KIND_U8: + ZVAL_LONG(PHP5to7_MAYBE_PTR(value), entry->value.value.u8); + break; + case AMQP_FIELD_KIND_I16: + ZVAL_LONG(PHP5to7_MAYBE_PTR(value), entry->value.value.i16); + break; + case AMQP_FIELD_KIND_U16: + ZVAL_LONG(PHP5to7_MAYBE_PTR(value), entry->value.value.u16); + break; + case AMQP_FIELD_KIND_I32: + ZVAL_LONG(PHP5to7_MAYBE_PTR(value), entry->value.value.i32); + break; + case AMQP_FIELD_KIND_U32: + ZVAL_LONG(PHP5to7_MAYBE_PTR(value), entry->value.value.u32); + break; + case AMQP_FIELD_KIND_I64: + ZVAL_LONG(PHP5to7_MAYBE_PTR(value), entry->value.value.i64); + break; + case AMQP_FIELD_KIND_U64: + if (entry->value.value.u64 > LONG_MAX) { + ZVAL_DOUBLE(PHP5to7_MAYBE_PTR(value), entry->value.value.u64); + } else { + ZVAL_LONG(PHP5to7_MAYBE_PTR(value), entry->value.value.u64); + } + break; + case AMQP_FIELD_KIND_F32: + ZVAL_DOUBLE(PHP5to7_MAYBE_PTR(value), entry->value.value.f32); + break; + case AMQP_FIELD_KIND_F64: + ZVAL_DOUBLE(PHP5to7_MAYBE_PTR(value), entry->value.value.f64); + break; + case AMQP_FIELD_KIND_UTF8: + case AMQP_FIELD_KIND_BYTES: + PHP5to7_ZVAL_STRINGL_DUP(PHP5to7_MAYBE_PTR(value), entry->value.value.bytes.bytes, entry->value.value.bytes.len); + break; + case AMQP_FIELD_KIND_ARRAY: { + int j; + array_init(PHP5to7_MAYBE_PTR(value)); + for (j = 0; j < entry->value.value.array.num_entries; ++j) { + switch (entry->value.value.array.entries[j].kind) { + case AMQP_FIELD_KIND_UTF8: + PHP5to7_ADD_NEXT_INDEX_STRINGL_DUP( + PHP5to7_MAYBE_PTR(value), + entry->value.value.array.entries[j].value.bytes.bytes, + (uint) entry->value.value.array.entries[j].value.bytes.len + ); + break; + case AMQP_FIELD_KIND_TABLE: { + PHP5to7_zval_t subtable PHP5to7_MAYBE_SET_TO_NULL; + PHP5to7_MAYBE_INIT(subtable); + PHP5to7_ARRAY_INIT(subtable); + + parse_amqp_table( + &(entry->value.value.array.entries[j].value.table), + PHP5to7_MAYBE_PTR(subtable) TSRMLS_CC + ); + add_next_index_zval(PHP5to7_MAYBE_PTR(value), PHP5to7_MAYBE_PTR(subtable)); + } + break; + default: + break; + } + } + } + break; + case AMQP_FIELD_KIND_TABLE: + PHP5to7_ARRAY_INIT(value); + parse_amqp_table(&(entry->value.value.table), PHP5to7_MAYBE_PTR(value) TSRMLS_CC); + break; + + case AMQP_FIELD_KIND_TIMESTAMP: { + char timestamp_str[20]; + PHP5to7_zval_t timestamp PHP5to7_MAYBE_SET_TO_NULL; + PHP5to7_MAYBE_INIT(timestamp); + + int length = snprintf(timestamp_str, sizeof(timestamp_str), ZEND_ULONG_FMT, entry->value.value.u64); + PHP5to7_ZVAL_STRINGL_DUP(PHP5to7_MAYBE_PTR(timestamp), (char *)timestamp_str, length); + object_init_ex(PHP5to7_MAYBE_PTR(value), amqp_timestamp_class_entry); + + zend_call_method_with_1_params( + &value, + amqp_timestamp_class_entry, + NULL, + "__construct", + NULL, + PHP5to7_MAYBE_PTR(timestamp) + ); + + PHP5to7_MAYBE_DESTROY(timestamp); + break; + } + + case AMQP_FIELD_KIND_VOID: + ZVAL_NULL(PHP5to7_MAYBE_PTR(value)); + break; + case AMQP_FIELD_KIND_DECIMAL: { + + PHP5to7_zval_t e PHP5to7_MAYBE_SET_TO_NULL; + PHP5to7_zval_t n PHP5to7_MAYBE_SET_TO_NULL; + PHP5to7_MAYBE_INIT(e); + PHP5to7_MAYBE_INIT(n); + + ZVAL_LONG(PHP5to7_MAYBE_PTR(e), entry->value.value.decimal.decimals); + ZVAL_LONG(PHP5to7_MAYBE_PTR(n), entry->value.value.decimal.value); + + object_init_ex(PHP5to7_MAYBE_PTR(value), amqp_decimal_class_entry); + + zend_call_method_with_2_params( + &value, + amqp_decimal_class_entry, + NULL, + "__construct", + NULL, + PHP5to7_MAYBE_PTR(e), + PHP5to7_MAYBE_PTR(n) + ); + + PHP5to7_MAYBE_DESTROY(e); + PHP5to7_MAYBE_DESTROY(n); + break; + } + default: + has_value = 0; + break; + } + + if (has_value) { + char *key = estrndup(entry->key.bytes, (uint) entry->key.len); + add_assoc_zval(result, key, PHP5to7_MAYBE_PTR(value)); + efree(key); + } else { + PHP5to7_MAYBE_DESTROY(value); + } + } + return; +} + +void php_amqp_basic_properties_extract(amqp_basic_properties_t *p, zval *obj TSRMLS_DC) +{ + PHP5to7_zval_t headers PHP5to7_MAYBE_SET_TO_NULL; + + PHP5to7_MAYBE_INIT(headers); + PHP5to7_ARRAY_INIT(headers); + + if (p->_flags & AMQP_BASIC_CONTENT_TYPE_FLAG) { + zend_update_property_stringl(this_ce, obj, ZEND_STRL("content_type"), (const char *) p->content_type.bytes, (PHP5to7_param_str_len_type_t) p->content_type.len TSRMLS_CC); + } else { + /* BC */ + zend_update_property_stringl(this_ce, obj, ZEND_STRL("content_type"), "", 0 TSRMLS_CC); + } + + if (p->_flags & AMQP_BASIC_CONTENT_ENCODING_FLAG) { + zend_update_property_stringl(this_ce, obj, ZEND_STRL("content_encoding"), (const char *) p->content_encoding.bytes, (PHP5to7_param_str_len_type_t) p->content_encoding.len TSRMLS_CC); + } else { + /* BC */ + zend_update_property_stringl(this_ce, obj, ZEND_STRL("content_encoding"), "", 0 TSRMLS_CC); + } + + if (p->_flags & AMQP_BASIC_HEADERS_FLAG) { + parse_amqp_table(&(p->headers), PHP5to7_MAYBE_PTR(headers) TSRMLS_CC); + } + + zend_update_property(this_ce, obj, ZEND_STRL("headers"), PHP5to7_MAYBE_PTR(headers) TSRMLS_CC); + + if (p->_flags & AMQP_BASIC_DELIVERY_MODE_FLAG) { + zend_update_property_long(this_ce, obj, ZEND_STRL("delivery_mode"), (PHP5to7_param_long_type_t) p->delivery_mode TSRMLS_CC); + } else { + /* BC */ + zend_update_property_long(this_ce, obj, ZEND_STRL("delivery_mode"), AMQP_DELIVERY_NONPERSISTENT TSRMLS_CC); + } + + if (p->_flags & AMQP_BASIC_PRIORITY_FLAG) { + zend_update_property_long(this_ce, obj, ZEND_STRL("priority"), (PHP5to7_param_long_type_t) p->priority TSRMLS_CC); + } else { + /* BC */ + zend_update_property_long(this_ce, obj, ZEND_STRL("priority"), 0 TSRMLS_CC); + } + + if (p->_flags & AMQP_BASIC_CORRELATION_ID_FLAG) { + zend_update_property_stringl(this_ce, obj, ZEND_STRL("correlation_id"), (const char *) p->correlation_id.bytes, (PHP5to7_param_str_len_type_t) p->correlation_id.len TSRMLS_CC); + } else { + /* BC */ + zend_update_property_stringl(this_ce, obj, ZEND_STRL("correlation_id"), "", 0 TSRMLS_CC); + } + + if (p->_flags & AMQP_BASIC_REPLY_TO_FLAG) { + zend_update_property_stringl(this_ce, obj, ZEND_STRL("reply_to"), (const char *) p->reply_to.bytes, (PHP5to7_param_str_len_type_t) p->reply_to.len TSRMLS_CC); + } else { + /* BC */ + zend_update_property_stringl(this_ce, obj, ZEND_STRL("reply_to"), "", 0 TSRMLS_CC); + } + + if (p->_flags & AMQP_BASIC_EXPIRATION_FLAG) { + zend_update_property_stringl(this_ce, obj, ZEND_STRL("expiration"), (const char *) p->expiration.bytes, (PHP5to7_param_str_len_type_t) p->expiration.len TSRMLS_CC); + } else { + /* BC */ + zend_update_property_stringl(this_ce, obj, ZEND_STRL("expiration"), "", 0 TSRMLS_CC); + } + + if (p->_flags & AMQP_BASIC_MESSAGE_ID_FLAG) { + zend_update_property_stringl(this_ce, obj, ZEND_STRL("message_id"), (const char *) p->message_id.bytes, (PHP5to7_param_str_len_type_t) p->message_id.len TSRMLS_CC); + } else { + /* BC */ + zend_update_property_stringl(this_ce, obj, ZEND_STRL("message_id"), "", 0 TSRMLS_CC); + } + + if (p->_flags & AMQP_BASIC_TIMESTAMP_FLAG) { + zend_update_property_long(this_ce, obj, ZEND_STRL("timestamp"), (PHP5to7_param_long_type_t) p->timestamp TSRMLS_CC); + } else { + /* BC */ + zend_update_property_long(this_ce, obj, ZEND_STRL("timestamp"), 0 TSRMLS_CC); + } + + if (p->_flags & AMQP_BASIC_TYPE_FLAG) { + zend_update_property_stringl(this_ce, obj, ZEND_STRL("type"), (const char *) p->type.bytes, (PHP5to7_param_str_len_type_t) p->type.len TSRMLS_CC); + } else { + /* BC */ + zend_update_property_stringl(this_ce, obj, ZEND_STRL("type"), "", 0 TSRMLS_CC); + } + + if (p->_flags & AMQP_BASIC_USER_ID_FLAG) { + zend_update_property_stringl(this_ce, obj, ZEND_STRL("user_id"), (const char *) p->user_id.bytes, (PHP5to7_param_str_len_type_t) p->user_id.len TSRMLS_CC); + } else { + /* BC */ + zend_update_property_stringl(this_ce, obj, ZEND_STRL("user_id"), "", 0 TSRMLS_CC); + } + + if (p->_flags & AMQP_BASIC_APP_ID_FLAG) { + zend_update_property_stringl(this_ce, obj, ZEND_STRL("app_id"), (const char *) p->app_id.bytes, (PHP5to7_param_str_len_type_t) p->app_id.len TSRMLS_CC); + } else { + /* BC */ + zend_update_property_stringl(this_ce, obj, ZEND_STRL("app_id"), "", 0 TSRMLS_CC); + } + + PHP5to7_MAYBE_DESTROY(headers); +} + + +/* +*Local variables: +*tab-width: 4 +*c-basic-offset: 4 +*End: +*vim600: noet sw=4 ts=4 fdm=marker +*vim<600: noet sw=4 ts=4 +*/ diff -Nru php-amqp-1.7.1/amqp-1.9.3/amqp_basic_properties.h php-amqp-1.9.3/amqp-1.9.3/amqp_basic_properties.h --- php-amqp-1.7.1/amqp-1.9.3/amqp_basic_properties.h 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/amqp_basic_properties.h 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,47 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2007 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 | + | Lead: | + | - Pieter de Zwart | + | Maintainers: | + | - Brad Rodriguez | + | - Jonathan Tansavatdi | + +----------------------------------------------------------------------+ +*/ + +#include "php.h" +#include "php_amqp.h" + +extern zend_class_entry *amqp_basic_properties_class_entry; + +void parse_amqp_table(amqp_table_t *table, zval *result TSRMLS_DC); +void php_amqp_basic_properties_extract(amqp_basic_properties_t *p, zval *obj TSRMLS_DC); + + +void php_amqp_basic_properties_convert_to_zval(amqp_basic_properties_t *props, zval *obj TSRMLS_DC); +void php_amqp_basic_properties_set_empty_headers(zval *obj TSRMLS_DC); + + +PHP_MINIT_FUNCTION(amqp_basic_properties); + + +/* +*Local variables: +*tab-width: 4 +*c-basic-offset: 4 +*End: +*vim600: noet sw=4 ts=4 fdm=marker +*vim<600: noet sw=4 ts=4 +*/ diff -Nru php-amqp-1.7.1/amqp-1.9.3/amqp.c php-amqp-1.9.3/amqp-1.9.3/amqp.c --- php-amqp-1.7.1/amqp-1.9.3/amqp.c 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/amqp.c 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,341 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2007 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 | + | Lead: | + | - Pieter de Zwart | + | Maintainers: | + | - Brad Rodriguez | + | - Jonathan Tansavatdi | + +----------------------------------------------------------------------+ +*/ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "php.h" +#include "php_ini.h" +#include "ext/standard/info.h" +#include "zend_ini.h" +#include "zend_exceptions.h" + +#ifdef PHP_WIN32 +# include "win32/php_stdint.h" +# include "win32/signal.h" +#else +# include +# include +#endif +#include +#include + +#include "php_amqp.h" +#include "amqp_connection.h" +#include "amqp_basic_properties.h" +#include "amqp_connection_resource.h" +#include "amqp_channel.h" +#include "amqp_envelope.h" +#include "amqp_exchange.h" +#include "amqp_queue.h" +#include "amqp_timestamp.h" +#include "amqp_decimal.h" + +#ifdef PHP_WIN32 +# include "win32/unistd.h" +#else +# include +#endif + +/* True global resources - no need for thread safety here */ + +zend_class_entry *amqp_exception_class_entry, + *amqp_connection_exception_class_entry, + *amqp_channel_exception_class_entry, + *amqp_queue_exception_class_entry, + *amqp_exchange_exception_class_entry, + *amqp_envelope_exception_class_entry, + *amqp_value_exception_class_entry; + +/* {{{ amqp_functions[] +* +*Every user visible function must have an entry in amqp_functions[]. +*/ +zend_function_entry amqp_functions[] = { + {NULL, NULL, NULL} +}; +/* }}} */ + +PHP_INI_BEGIN() + PHP_INI_ENTRY("amqp.host", DEFAULT_HOST, PHP_INI_ALL, NULL) + PHP_INI_ENTRY("amqp.vhost", DEFAULT_VHOST, PHP_INI_ALL, NULL) + PHP_INI_ENTRY("amqp.port", DEFAULT_PORT, PHP_INI_ALL, NULL) + PHP_INI_ENTRY("amqp.timeout", DEFAULT_TIMEOUT, PHP_INI_ALL, NULL) + PHP_INI_ENTRY("amqp.read_timeout", DEFAULT_READ_TIMEOUT, PHP_INI_ALL, NULL) + PHP_INI_ENTRY("amqp.write_timeout", DEFAULT_WRITE_TIMEOUT, PHP_INI_ALL, NULL) + PHP_INI_ENTRY("amqp.connect_timeout", DEFAULT_CONNECT_TIMEOUT, PHP_INI_ALL, NULL) + PHP_INI_ENTRY("amqp.login", DEFAULT_LOGIN, PHP_INI_ALL, NULL) + PHP_INI_ENTRY("amqp.password", DEFAULT_PASSWORD, PHP_INI_ALL, NULL) + PHP_INI_ENTRY("amqp.auto_ack", DEFAULT_AUTOACK, PHP_INI_ALL, NULL) + PHP_INI_ENTRY("amqp.prefetch_count", DEFAULT_PREFETCH_COUNT, PHP_INI_ALL, NULL) + PHP_INI_ENTRY("amqp.channel_max", DEFAULT_CHANNEL_MAX, PHP_INI_ALL, NULL) + PHP_INI_ENTRY("amqp.frame_max", DEFAULT_FRAME_MAX, PHP_INI_ALL, NULL) + PHP_INI_ENTRY("amqp.heartbeat", DEFAULT_HEARTBEAT, PHP_INI_ALL, NULL) + PHP_INI_ENTRY("amqp.cacert", DEFAULT_CACERT, PHP_INI_ALL, NULL) + PHP_INI_ENTRY("amqp.cert", DEFAULT_CERT, PHP_INI_ALL, NULL) + PHP_INI_ENTRY("amqp.key", DEFAULT_KEY, PHP_INI_ALL, NULL) + PHP_INI_ENTRY("amqp.verify", DEFAULT_VERIFY, PHP_INI_ALL, NULL) +PHP_INI_END() + +ZEND_DECLARE_MODULE_GLOBALS(amqp); + +static PHP_GINIT_FUNCTION(amqp) /* {{{ */ +{ + amqp_globals->error_message = NULL; + amqp_globals->error_code = 0; +} /* }}} */ + +static PHP_MINIT_FUNCTION(amqp) /* {{{ */ +{ + zend_class_entry ce; + + /* Set up the connection resource */ + le_amqp_connection_resource = zend_register_list_destructors_ex(amqp_connection_resource_dtor, NULL, PHP_AMQP_CONNECTION_RES_NAME, module_number); + le_amqp_connection_resource_persistent = zend_register_list_destructors_ex(NULL, amqp_connection_resource_dtor_persistent, PHP_AMQP_CONNECTION_RES_NAME, module_number); + + PHP_MINIT(amqp_connection)(INIT_FUNC_ARGS_PASSTHRU); + PHP_MINIT(amqp_channel)(INIT_FUNC_ARGS_PASSTHRU); + PHP_MINIT(amqp_queue)(INIT_FUNC_ARGS_PASSTHRU); + PHP_MINIT(amqp_exchange)(INIT_FUNC_ARGS_PASSTHRU); + PHP_MINIT(amqp_basic_properties)(INIT_FUNC_ARGS_PASSTHRU); + PHP_MINIT(amqp_envelope)(INIT_FUNC_ARGS_PASSTHRU); + PHP_MINIT(amqp_timestamp)(INIT_FUNC_ARGS_PASSTHRU); + PHP_MINIT(amqp_decimal)(INIT_FUNC_ARGS_PASSTHRU); + + /* Class Exceptions */ + INIT_CLASS_ENTRY(ce, "AMQPException", NULL); + amqp_exception_class_entry = PHP5to7_zend_register_internal_class_ex(&ce, zend_exception_get_default(TSRMLS_C)); + + INIT_CLASS_ENTRY(ce, "AMQPConnectionException", NULL); + amqp_connection_exception_class_entry = PHP5to7_zend_register_internal_class_ex(&ce, amqp_exception_class_entry); + + INIT_CLASS_ENTRY(ce, "AMQPChannelException", NULL); + amqp_channel_exception_class_entry = PHP5to7_zend_register_internal_class_ex(&ce, amqp_exception_class_entry); + + INIT_CLASS_ENTRY(ce, "AMQPQueueException", NULL); + amqp_queue_exception_class_entry = PHP5to7_zend_register_internal_class_ex(&ce, amqp_exception_class_entry); + + INIT_CLASS_ENTRY(ce, "AMQPEnvelopeException", NULL); + amqp_envelope_exception_class_entry = PHP5to7_zend_register_internal_class_ex(&ce, amqp_exception_class_entry); + zend_declare_property_null(amqp_envelope_exception_class_entry, ZEND_STRL("envelope"), ZEND_ACC_PUBLIC TSRMLS_CC); + + INIT_CLASS_ENTRY(ce, "AMQPExchangeException", NULL); + amqp_exchange_exception_class_entry = PHP5to7_zend_register_internal_class_ex(&ce, amqp_exception_class_entry); + + INIT_CLASS_ENTRY(ce, "AMQPValueException", NULL); + amqp_value_exception_class_entry = PHP5to7_zend_register_internal_class_ex(&ce, amqp_exception_class_entry); + + REGISTER_INI_ENTRIES(); + + REGISTER_LONG_CONSTANT("AMQP_NOPARAM", AMQP_NOPARAM, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("AMQP_JUST_CONSUME", AMQP_JUST_CONSUME, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("AMQP_DURABLE", AMQP_DURABLE, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("AMQP_PASSIVE", AMQP_PASSIVE, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("AMQP_EXCLUSIVE", AMQP_EXCLUSIVE, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("AMQP_AUTODELETE", AMQP_AUTODELETE, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("AMQP_INTERNAL", AMQP_INTERNAL, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("AMQP_NOLOCAL", AMQP_NOLOCAL, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("AMQP_AUTOACK", AMQP_AUTOACK, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("AMQP_IFEMPTY", AMQP_IFEMPTY, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("AMQP_IFUNUSED", AMQP_IFUNUSED, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("AMQP_MANDATORY", AMQP_MANDATORY, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("AMQP_IMMEDIATE", AMQP_IMMEDIATE, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("AMQP_MULTIPLE", AMQP_MULTIPLE, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("AMQP_NOWAIT", AMQP_NOWAIT, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("AMQP_REQUEUE", AMQP_REQUEUE, CONST_CS | CONST_PERSISTENT); + + REGISTER_STRING_CONSTANT("AMQP_EX_TYPE_DIRECT", AMQP_EX_TYPE_DIRECT, CONST_CS | CONST_PERSISTENT); + REGISTER_STRING_CONSTANT("AMQP_EX_TYPE_FANOUT", AMQP_EX_TYPE_FANOUT, CONST_CS | CONST_PERSISTENT); + REGISTER_STRING_CONSTANT("AMQP_EX_TYPE_TOPIC", AMQP_EX_TYPE_TOPIC, CONST_CS | CONST_PERSISTENT); + REGISTER_STRING_CONSTANT("AMQP_EX_TYPE_HEADERS",AMQP_EX_TYPE_HEADERS, CONST_CS | CONST_PERSISTENT); + + REGISTER_LONG_CONSTANT("AMQP_OS_SOCKET_TIMEOUT_ERRNO", AMQP_OS_SOCKET_TIMEOUT_ERRNO, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("PHP_AMQP_MAX_CHANNELS", PHP_AMQP_MAX_CHANNELS, CONST_CS | CONST_PERSISTENT); + + return SUCCESS; +} /* }}} */ + +static PHP_MSHUTDOWN_FUNCTION(amqp) /* {{{ */ +{ + UNREGISTER_INI_ENTRIES(); + + return SUCCESS; +} /* }}} */ + +static PHP_RSHUTDOWN_FUNCTION(amqp) /* {{{ */ +{ + if (NULL != PHP_AMQP_G(error_message)) { + efree(PHP_AMQP_G(error_message)); + PHP_AMQP_G(error_message) = NULL; + } + + PHP_AMQP_G(error_code) = 0; + + return SUCCESS; +} /* }}} */ + +static PHP_MINFO_FUNCTION(amqp) /* {{{ */ +{ + php_info_print_table_start(); + php_info_print_table_header(2, "Version", PHP_AMQP_VERSION); + php_info_print_table_header(2, "Revision", PHP_AMQP_REVISION); + php_info_print_table_header(2, "Compiled", __DATE__ " @ " __TIME__); + php_info_print_table_header(2, "AMQP protocol version", "0-9-1"); + php_info_print_table_header(2, "librabbitmq version", amqp_version()); + php_info_print_table_header(2, "Default max channels per connection", DEFAULT_CHANNEL_MAX); + php_info_print_table_header(2, "Default max frame size", DEFAULT_FRAME_MAX); + php_info_print_table_header(2, "Default heartbeats interval", DEFAULT_HEARTBEAT); + DISPLAY_INI_ENTRIES(); +} /* }}} */ + +/* {{{ amqp_module_entry +*/ +zend_module_entry amqp_module_entry = { + STANDARD_MODULE_HEADER, + "amqp", + amqp_functions, + PHP_MINIT(amqp), + PHP_MSHUTDOWN(amqp), + NULL, + PHP_RSHUTDOWN(amqp), + PHP_MINFO(amqp), + PHP_AMQP_VERSION, + PHP_MODULE_GLOBALS(amqp), + PHP_GINIT(amqp), + NULL, + NULL, + STANDARD_MODULE_PROPERTIES_EX +}; +/* }}} */ + +#ifdef COMPILE_DL_AMQP + ZEND_GET_MODULE(amqp) +#endif + +int php_amqp_error(amqp_rpc_reply_t reply, char **message, amqp_connection_resource *connection_resource, amqp_channel_resource *channel_resource TSRMLS_DC) +{ + return php_amqp_error_advanced(reply, message, connection_resource, channel_resource, 1 TSRMLS_CC); +} + +int php_amqp_error_advanced(amqp_rpc_reply_t reply, char **message, amqp_connection_resource *connection_resource, amqp_channel_resource *channel_resource, int fail_on_errors TSRMLS_DC) +{ + assert(connection_resource != NULL); + + PHP_AMQP_G(error_code) = 0; + if (*message != NULL) { + efree(*message); + } + + int res = php_amqp_connection_resource_error(reply, message, connection_resource, (amqp_channel_t)(channel_resource ? channel_resource->channel_id : 0) TSRMLS_CC); + + switch (res) { + case PHP_AMQP_RESOURCE_RESPONSE_OK: + break; + case PHP_AMQP_RESOURCE_RESPONSE_ERROR: + if (!fail_on_errors) { + break; + } + /* Library or other non-protocol or even protocol related errors may be here. */ + /* In most cases it designate some underlying hard errors. Fail fast. */ + case PHP_AMQP_RESOURCE_RESPONSE_ERROR_CONNECTION_CLOSED: + /* Mark connection resource as closed to prevent sending any further requests */ + connection_resource->is_connected = '\0'; + + /* Close connection with all its channels */ + php_amqp_disconnect_force(connection_resource TSRMLS_CC); + + break; + case PHP_AMQP_RESOURCE_RESPONSE_ERROR_CHANNEL_CLOSED: + /* Mark channel as closed to prevent sending channel.close request */ + assert(channel_resource != NULL); + if (channel_resource) { + channel_resource->is_connected = '\0'; + + /* Close channel */ + php_amqp_close_channel(channel_resource, 1 TSRMLS_CC); + } + /* No more error handling necessary, returning. */ + break; + default: + spprintf(message, 0, "Unknown server error, method id 0x%08X (not handled by extension)", reply.reply.id); + break; + } + + return res; +} + +void php_amqp_zend_throw_exception_short(amqp_rpc_reply_t reply, zend_class_entry *exception_ce TSRMLS_DC) { + php_amqp_zend_throw_exception(reply, exception_ce, PHP_AMQP_G(error_message), PHP_AMQP_G(error_code) TSRMLS_CC); +} + +void php_amqp_zend_throw_exception(amqp_rpc_reply_t reply, zend_class_entry *exception_ce, const char *message, PHP5to7_param_long_type_t code TSRMLS_DC) +{ + switch (reply.reply_type) { + case AMQP_RESPONSE_NORMAL: + break; + case AMQP_RESPONSE_NONE: + exception_ce = amqp_exception_class_entry; + break; + case AMQP_RESPONSE_LIBRARY_EXCEPTION: + exception_ce = amqp_exception_class_entry; + break; + case AMQP_RESPONSE_SERVER_EXCEPTION: + switch (reply.reply.id) { + case AMQP_CONNECTION_CLOSE_METHOD: + /* Fatal errors - pass them to connection level */ + exception_ce = amqp_connection_exception_class_entry; + break; + case AMQP_CHANNEL_CLOSE_METHOD: + /* Most channel-level errors occurs due to previously known action and thus their kind can be predicted. */ + /* exception_ce = amqp_channel_exception_class_entry; */ + break; + } + break; + /* Default for the above switch should be handled by the below default. */ + default: + exception_ce = amqp_exception_class_entry; + break; + } + + zend_throw_exception(exception_ce, message, code TSRMLS_CC); +} + + +void php_amqp_maybe_release_buffers_on_channel(amqp_connection_resource *connection_resource, amqp_channel_resource *channel_resource) +{ + assert(channel_resource != NULL); + assert(channel_resource->channel_id > 0); + + if (connection_resource) { + amqp_maybe_release_buffers_on_channel(connection_resource->connection_state, channel_resource->channel_id); + } +} + +/* +*Local variables: +*tab-width: 4 +*c-basic-offset: 4 +*End: +*vim600: noet sw=4 ts=4 fdm=marker +*vim<600: noet sw=4 ts=4 +*/ diff -Nru php-amqp-1.7.1/amqp-1.9.3/amqp_channel.c php-amqp-1.9.3/amqp-1.9.3/amqp_channel.c --- php-amqp-1.7.1/amqp-1.9.3/amqp_channel.c 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/amqp_channel.c 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,1230 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2007 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 | + | Lead: | + | - Pieter de Zwart | + | Maintainers: | + | - Brad Rodriguez | + | - Jonathan Tansavatdi | + +----------------------------------------------------------------------+ +*/ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "php.h" +#include "php_ini.h" +#include "ext/standard/info.h" +#include "zend_exceptions.h" + +#ifdef PHP_WIN32 +# include "win32/php_stdint.h" +# include "win32/signal.h" +#else +# include +# include +#endif + +#include +#include + +#ifdef PHP_WIN32 +# include "win32/unistd.h" +#else +# include +#endif + +#include "php_amqp.h" +#include "amqp_connection.h" +#include "amqp_methods_handling.h" +#include "amqp_connection_resource.h" +#include "amqp_channel.h" + +zend_class_entry *amqp_channel_class_entry; +#define this_ce amqp_channel_class_entry + +zend_object_handlers amqp_channel_object_handlers; + +void php_amqp_close_channel(amqp_channel_resource *channel_resource, zend_bool check_errors TSRMLS_DC) +{ + assert(channel_resource != NULL); + + amqp_connection_resource *connection_resource = channel_resource->connection_resource; + + if (connection_resource != NULL) { + /* First, remove it from active channels table to prevent recursion in case of connection error */ + php_amqp_connection_resource_unregister_channel(connection_resource, channel_resource->channel_id); + } else { + channel_resource->is_connected = '\0'; + } + + assert(channel_resource->connection_resource == NULL); + + if (!channel_resource->is_connected) { + /* Nothing to do more - channel was previously marked as closed, possibly, due to channel-level error */ + return; + } + + channel_resource->is_connected = '\0'; + + if (connection_resource && connection_resource->is_connected && channel_resource->channel_id > 0) { + assert(connection_resource != NULL); + + amqp_channel_close(connection_resource->connection_state, channel_resource->channel_id, AMQP_REPLY_SUCCESS); + + amqp_rpc_reply_t res = amqp_get_rpc_reply(connection_resource->connection_state); + + if (check_errors && PHP_AMQP_MAYBE_ERROR(res, channel_resource)) { + php_amqp_zend_throw_exception_short(res, amqp_channel_exception_class_entry TSRMLS_CC); + return; + } + + php_amqp_maybe_release_buffers_on_channel(connection_resource, channel_resource); + } +} + +#if PHP_MAJOR_VERSION >= 7 + +static void php_amqp_destroy_fci(zend_fcall_info *fci) { + if (fci->size > 0) { + zval_ptr_dtor(&fci->function_name); + if (fci->object != NULL) { + GC_REFCOUNT(fci->object)--; + } + fci->size = 0; + } +} + +static void php_amqp_duplicate_fci(zend_fcall_info *source) { + if (source->size > 0) { + + zval_add_ref(&source->function_name); + if (source->object != NULL) { + GC_REFCOUNT(source->object)++; + } + } +} + +static int php_amqp_get_fci_gc_data_count(zend_fcall_info *fci) { + int cnt = 0; + + if (fci->size > 0) { + cnt ++; + + if (fci->object != NULL) { + cnt++; + } + } + + return cnt; +} + +static zval * php_amqp_get_fci_gc_data(zend_fcall_info *fci, zval *gc_data) { + if (ZEND_FCI_INITIALIZED(*fci)) { + + ZVAL_COPY_VALUE(gc_data++, &fci->function_name); + + if (fci->object != NULL) { + ZVAL_OBJ(gc_data++, fci->object); + } + } + + return gc_data; +} + +static HashTable *amqp_channel_gc(zval *object, zval **table, int *n) /* {{{ */ +{ + amqp_channel_object *channel = PHP_AMQP_GET_CHANNEL(object); + + int basic_return_cnt = php_amqp_get_fci_gc_data_count(&channel->callbacks.basic_return.fci); + int basic_ack_cnt = php_amqp_get_fci_gc_data_count(&channel->callbacks.basic_ack.fci); + int basic_nack_cnt = php_amqp_get_fci_gc_data_count(&channel->callbacks.basic_nack.fci); + + int cnt = basic_return_cnt + basic_ack_cnt + basic_nack_cnt; + + if (cnt > channel->gc_data_count) { + channel->gc_data_count = cnt; + channel->gc_data = (zval *) erealloc(channel->gc_data, sizeof(zval) * cnt); + } + + zval *gc_data = channel->gc_data; + + gc_data = php_amqp_get_fci_gc_data(&channel->callbacks.basic_return.fci, gc_data); + gc_data = php_amqp_get_fci_gc_data(&channel->callbacks.basic_ack.fci, gc_data); + php_amqp_get_fci_gc_data(&channel->callbacks.basic_nack.fci, gc_data); + + *table = channel->gc_data; + *n = cnt; + + return zend_std_get_properties(object TSRMLS_CC); +} /* }}} */ + +#else +static void php_amqp_destroy_fci(zend_fcall_info *fci) { + if (fci->size > 0) { + zval_ptr_dtor(&fci->function_name); + if (fci->object_ptr != NULL) { + zval_ptr_dtor(&fci->object_ptr); + } + fci->size = 0; + } +} + +static void php_amqp_duplicate_fci(zend_fcall_info *source) { + if (source->size > 0) { + + zval_add_ref(&source->function_name); + if (source->object_ptr != NULL) { + zval_add_ref(&source->object_ptr); + } + } +} + +static int php_amqp_get_fci_gc_data_count(zend_fcall_info *fci) { + int cnt = 0; + + if (fci->size > 0) { + cnt ++; + + if (fci->object_ptr != NULL) { + cnt++; + } + } + + return cnt; +} + +static int php_amqp_get_fci_gc_data(zend_fcall_info *fci, zval **gc_data, int offset) { + + if (ZEND_FCI_INITIALIZED(*fci)) { + gc_data[offset++] = fci->function_name; + + if (fci->object_ptr != NULL) { + gc_data[offset++] = fci->object_ptr; + } + } + + return offset; +} + +static HashTable *amqp_channel_gc(zval *object, zval ***table, int *n TSRMLS_DC) /* {{{ */ +{ + amqp_channel_object *channel = PHP_AMQP_GET_CHANNEL(object); + + int basic_return_cnt = php_amqp_get_fci_gc_data_count(&channel->callbacks.basic_return.fci); + int basic_ack_cnt = php_amqp_get_fci_gc_data_count(&channel->callbacks.basic_ack.fci); + int basic_nack_cnt = php_amqp_get_fci_gc_data_count(&channel->callbacks.basic_nack.fci); + + int cnt = basic_return_cnt + basic_ack_cnt + basic_nack_cnt; + + if (cnt > channel->gc_data_count) { + channel->gc_data_count = cnt; + channel->gc_data = (zval **) erealloc(channel->gc_data, sizeof(zval *) * channel->gc_data_count); + } + + php_amqp_get_fci_gc_data(&channel->callbacks.basic_return.fci, channel->gc_data, 0); + php_amqp_get_fci_gc_data(&channel->callbacks.basic_ack.fci, channel->gc_data, basic_return_cnt); + php_amqp_get_fci_gc_data(&channel->callbacks.basic_nack.fci, channel->gc_data, basic_return_cnt + basic_ack_cnt); + + *table = channel->gc_data; + *n = cnt; + + return zend_std_get_properties(object TSRMLS_CC); +} /* }}} */ + +#endif + +static void php_amqp_clean_callbacks(amqp_channel_callbacks *callbacks) { + php_amqp_destroy_fci(&callbacks->basic_return.fci); + php_amqp_destroy_fci(&callbacks->basic_ack.fci); + php_amqp_destroy_fci(&callbacks->basic_nack.fci); +} + + +void amqp_channel_free(PHP5to7_obj_free_zend_object *object TSRMLS_DC) +{ + amqp_channel_object *channel = PHP_AMQP_FETCH_CHANNEL(object); + + if (channel->channel_resource != NULL) { + php_amqp_close_channel(channel->channel_resource, 0 TSRMLS_CC); + + efree(channel->channel_resource); + channel->channel_resource = NULL; + } + + if (channel->gc_data) { + efree(channel->gc_data); + } + + php_amqp_clean_callbacks(&channel->callbacks); + + zend_object_std_dtor(&channel->zo TSRMLS_CC); + +#if PHP_MAJOR_VERSION < 7 + if (channel->this_ptr) { + channel->this_ptr = NULL; + } + + efree(object); +#endif +} + + +PHP5to7_zend_object_value amqp_channel_ctor(zend_class_entry *ce TSRMLS_DC) +{ + amqp_channel_object *channel = PHP5to7_ECALLOC_CHANNEL_OBJECT(ce); + + zend_object_std_init(&channel->zo, ce TSRMLS_CC); + AMQP_OBJECT_PROPERTIES_INIT(channel->zo, ce); + +#if PHP_MAJOR_VERSION >=7 + channel->zo.handlers = &amqp_channel_object_handlers; + + return &channel->zo; +#else + PHP5to7_zend_object_value new_value; + + new_value.handle = zend_objects_store_put( + channel, + NULL, + (zend_objects_free_object_storage_t) amqp_channel_free, + NULL TSRMLS_CC + ); + + new_value.handlers = zend_get_std_object_handlers(); + + return new_value; +#endif +} + + +/* {{{ proto AMQPChannel::__construct(AMQPConnection obj) + */ +static PHP_METHOD(amqp_channel_class, __construct) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + + zval *connection_object = NULL; + + amqp_channel_resource *channel_resource; + amqp_channel_object *channel; + amqp_connection_object *connection; + + /* Parse out the method parameters */ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &connection_object) == FAILURE) { + zend_throw_exception(amqp_channel_exception_class_entry, "Parameter must be an instance of AMQPConnection.", 0 TSRMLS_CC); + RETURN_NULL(); + } + + PHP5to7_zval_t consumers PHP5to7_MAYBE_SET_TO_NULL; + + PHP5to7_MAYBE_INIT(consumers); + PHP5to7_ARRAY_INIT(consumers); + + zend_update_property(this_ce, getThis(), ZEND_STRL("consumers"), PHP5to7_MAYBE_PTR(consumers) TSRMLS_CC); + + PHP5to7_MAYBE_DESTROY(consumers); + + channel = PHP_AMQP_GET_CHANNEL(getThis()); +#if PHP_MAJOR_VERSION < 7 + channel->this_ptr = getThis(); +#endif + + /* Set the prefetch count */ + zend_update_property_long(this_ce, getThis(), ZEND_STRL("prefetch_count"), INI_INT("amqp.prefetch_count") TSRMLS_CC); + + /* Pull out and verify the connection */ + connection = PHP_AMQP_GET_CONNECTION(connection_object); + PHP_AMQP_VERIFY_CONNECTION(connection, "Could not create channel."); + + if (!connection->connection_resource) { + zend_throw_exception(amqp_channel_exception_class_entry, "Could not create channel. No connection resource.", 0 TSRMLS_CC); + return; + } + + if (!connection->connection_resource->is_connected) { + zend_throw_exception(amqp_channel_exception_class_entry, "Could not create channel. Connection resource is not connected.", 0 TSRMLS_CC); + return; + } + + zend_update_property(this_ce, getThis(), ZEND_STRL("connection"), connection_object TSRMLS_CC); + + channel_resource = (amqp_channel_resource*)ecalloc(1, sizeof(amqp_channel_resource)); + channel->channel_resource = channel_resource; + channel_resource->parent = channel; + + /* Figure out what the next available channel is on this connection */ + channel_resource->channel_id = php_amqp_connection_resource_get_available_channel_id(connection->connection_resource); + + /* Check that we got a valid channel */ + if (!channel_resource->channel_id) { + zend_throw_exception(amqp_channel_exception_class_entry, "Could not create channel. Connection has no open channel slots remaining.", 0 TSRMLS_CC); + return; + } + + if (php_amqp_connection_resource_register_channel(connection->connection_resource, channel_resource, channel_resource->channel_id) == FAILURE) { + zend_throw_exception(amqp_channel_exception_class_entry, "Could not create channel. Failed to add channel to connection slot.", 0 TSRMLS_CC); + } + + /* Open up the channel for use */ + amqp_channel_open_ok_t *r = amqp_channel_open(channel_resource->connection_resource->connection_state, channel_resource->channel_id); + + + if (!r) { + amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state); + + php_amqp_error(res, &PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource TSRMLS_CC); + + php_amqp_zend_throw_exception(res, amqp_channel_exception_class_entry, PHP_AMQP_G(error_message), PHP_AMQP_G(error_code) TSRMLS_CC); + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + + /* Prevent double free, it may happens in case case channel resource was already freed due to some hard error. */ + if (channel_resource->connection_resource) { + php_amqp_connection_resource_unregister_channel(channel_resource->connection_resource, channel_resource->channel_id); + channel_resource->channel_id = 0; + } + + return; + } + + /* r->channel_id is a 16-bit channel number insibe amqp_bytes_t, assertion below will without converting to uint16_t*/ + /* assert (r->channel_id == channel_resource->channel_id);*/ + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + + channel_resource->is_connected = '\1'; + + /* Set the prefetch count: */ + amqp_basic_qos( + channel_resource->connection_resource->connection_state, + channel_resource->channel_id, + 0, /* prefetch window size */ + (uint16_t)PHP_AMQP_READ_THIS_PROP_LONG("prefetch_count"), /* prefetch message count */ + /* NOTE that RabbitMQ has reinterpreted global flag field. See https://www.rabbitmq.com/amqp-0-9-1-reference.html#basic.qos.global for details */ + 0 /* global flag */ + ); + + amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state); + + if (PHP_AMQP_MAYBE_ERROR(res, channel_resource)) { + php_amqp_zend_throw_exception_short(res, amqp_channel_exception_class_entry TSRMLS_CC); + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + return; + } + + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); +} +/* }}} */ + + +/* {{{ proto bool amqp::isConnected() +check amqp channel */ +static PHP_METHOD(amqp_channel_class, isConnected) +{ + amqp_channel_resource *channel_resource; + + PHP_AMQP_NOPARAMS(); + + channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(getThis()); + + RETURN_BOOL(channel_resource && channel_resource->is_connected); +} +/* }}} */ + +/* {{{ proto bool AMQPChannel::close() +Close amqp channel */ +static PHP_METHOD(amqp_channel_class, close) +{ + amqp_channel_resource *channel_resource; + + PHP_AMQP_NOPARAMS(); + + channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(getThis()); + + if(channel_resource && channel_resource->is_connected) { + php_amqp_close_channel(channel_resource, 1 TSRMLS_CC); + } +} +/* }}} */ + +/* {{{ proto bool amqp::getChannelId() +get amqp channel ID */ +static PHP_METHOD(amqp_channel_class, getChannelId) +{ + amqp_channel_resource *channel_resource; + + PHP_AMQP_NOPARAMS(); + + channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(getThis()); + + if (!channel_resource) { + RETURN_NULL(); + } + + RETURN_LONG(channel_resource->channel_id); +} +/* }}} */ + +/* {{{ proto bool amqp::setPrefetchCount(long count) +set the number of prefetches */ +static PHP_METHOD(amqp_channel_class, setPrefetchCount) +{ + amqp_channel_resource *channel_resource; + PHP5to7_param_long_type_t prefetch_count; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &prefetch_count) == FAILURE) { + return; + } + + channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(getThis()); + PHP_AMQP_VERIFY_CHANNEL_CONNECTION_RESOURCE(channel_resource, "Could not set prefetch count."); + // TODO: verify that connection is active and resource exists. that is enough + + /* If we are already connected, set the new prefetch count */ + if (channel_resource->is_connected) { + amqp_basic_qos( + channel_resource->connection_resource->connection_state, + channel_resource->channel_id, + 0, + (uint16_t)prefetch_count, + 0 + ); + + amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state); + + if (PHP_AMQP_MAYBE_ERROR(res, channel_resource)) { + php_amqp_zend_throw_exception_short(res, amqp_channel_exception_class_entry TSRMLS_CC); + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + return; + } + + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + } + + /* Set the prefetch count - the implication is to disable the size */ + zend_update_property_long(this_ce, getThis(), ZEND_STRL("prefetch_count"), prefetch_count TSRMLS_CC); + zend_update_property_long(this_ce, getThis(), ZEND_STRL("prefetch_size"), 0 TSRMLS_CC); + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto long amqp::setPrefetchCount() +get the number of prefetches */ +static PHP_METHOD(amqp_channel_class, getPrefetchCount) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + PHP_AMQP_RETURN_THIS_PROP("prefetch_count") +} +/* }}} */ + + +/* {{{ proto bool amqp::setPrefetchSize(long size) +set the number of prefetches */ +static PHP_METHOD(amqp_channel_class, setPrefetchSize) +{ + amqp_channel_resource *channel_resource; + PHP5to7_param_long_type_t prefetch_size; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &prefetch_size) == FAILURE) { + return; + } + + channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(getThis()); + PHP_AMQP_VERIFY_CHANNEL_CONNECTION_RESOURCE(channel_resource, "Could not set prefetch size."); + + /* If we are already connected, set the new prefetch count */ + if (channel_resource->is_connected) { + amqp_basic_qos( + channel_resource->connection_resource->connection_state, + channel_resource->channel_id, + (uint16_t)prefetch_size, + 0, + 0 + ); + + amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state); + + if (PHP_AMQP_MAYBE_ERROR(res, channel_resource)) { + php_amqp_zend_throw_exception_short(res, amqp_channel_exception_class_entry TSRMLS_CC); + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + return; + } + + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + } + + /* Set the prefetch size - the implication is to disable the count */ + zend_update_property_long(this_ce, getThis(), ZEND_STRL("prefetch_count"), 0 TSRMLS_CC); + zend_update_property_long(this_ce, getThis(), ZEND_STRL("prefetch_size"), prefetch_size TSRMLS_CC); + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto long amqp::getPrefetchSize() +get the number of prefetches */ +static PHP_METHOD(amqp_channel_class, getPrefetchSize) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + PHP_AMQP_RETURN_THIS_PROP("prefetch_size") +} +/* }}} */ + + + +/* {{{ proto amqp::qos(long size, long count) +set the number of prefetches */ +static PHP_METHOD(amqp_channel_class, qos) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + + amqp_channel_resource *channel_resource; + PHP5to7_param_long_type_t prefetch_size; + PHP5to7_param_long_type_t prefetch_count; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &prefetch_size, &prefetch_count) == FAILURE) { + return; + } + + channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(getThis()); + PHP_AMQP_VERIFY_CHANNEL_CONNECTION_RESOURCE(channel_resource, "Could not set qos parameters."); + + /* Set the prefetch size - the implication is to disable the count */ + zend_update_property_long(this_ce, getThis(), ZEND_STRL("prefetch_size"), prefetch_size TSRMLS_CC); + zend_update_property_long(this_ce, getThis(), ZEND_STRL("prefetch_count"), prefetch_count TSRMLS_CC); + + /* If we are already connected, set the new prefetch count */ + if (channel_resource->is_connected) { + amqp_basic_qos( + channel_resource->connection_resource->connection_state, + channel_resource->channel_id, + (uint16_t)PHP_AMQP_READ_THIS_PROP_LONG("prefetch_size"), + (uint16_t)PHP_AMQP_READ_THIS_PROP_LONG("prefetch_count"), + /* NOTE that RabbitMQ has reinterpreted global flag field. See https://www.rabbitmq.com/amqp-0-9-1-reference.html#basic.qos.global for details */ + 0 /* Global flag - whether this change should affect every channel_resource */ + ); + + amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state); + + if (PHP_AMQP_MAYBE_ERROR(res, channel_resource)) { + php_amqp_zend_throw_exception_short(res, amqp_channel_exception_class_entry TSRMLS_CC); + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + return; + } + + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + } + + RETURN_TRUE; +} +/* }}} */ + + +/* {{{ proto amqp::startTransaction() +start a transaction on the given channel */ +static PHP_METHOD(amqp_channel_class, startTransaction) +{ + amqp_channel_resource *channel_resource; + + amqp_rpc_reply_t res; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { + return; + } + + channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(getThis()); + PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not start the transaction."); + + amqp_tx_select( + channel_resource->connection_resource->connection_state, + channel_resource->channel_id + ); + + res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state); + + if (PHP_AMQP_MAYBE_ERROR(res, channel_resource)) { + php_amqp_zend_throw_exception_short(res, amqp_channel_exception_class_entry TSRMLS_CC); + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + return; + } + + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + + RETURN_TRUE; +} +/* }}} */ + + +/* {{{ proto amqp::startTransaction() +start a transaction on the given channel */ +static PHP_METHOD(amqp_channel_class, commitTransaction) +{ + amqp_channel_resource *channel_resource; + + amqp_rpc_reply_t res; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { + return; + } + + channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(getThis()); + PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not start the transaction."); + + amqp_tx_commit( + channel_resource->connection_resource->connection_state, + channel_resource->channel_id + ); + + res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state); + + if (PHP_AMQP_MAYBE_ERROR(res, channel_resource)) { + php_amqp_zend_throw_exception_short(res, amqp_channel_exception_class_entry TSRMLS_CC); + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + return; + } + + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto amqp::startTransaction() +start a transaction on the given channel */ +static PHP_METHOD(amqp_channel_class, rollbackTransaction) +{ + amqp_channel_resource *channel_resource; + + amqp_rpc_reply_t res; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { + return; + } + + + channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(getThis()); + PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not rollback the transaction."); + + amqp_tx_rollback( + channel_resource->connection_resource->connection_state, + channel_resource->channel_id + ); + + res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state); + + if (PHP_AMQP_MAYBE_ERROR(res, channel_resource)) { + php_amqp_zend_throw_exception_short(res, amqp_channel_exception_class_entry TSRMLS_CC); + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + return; + } + + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto AMQPChannel::getConnection() +Get the AMQPConnection object in use */ +static PHP_METHOD(amqp_channel_class, getConnection) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + PHP_AMQP_RETURN_THIS_PROP("connection") +} +/* }}} */ + +/* {{{ proto bool amqp::basicRecover([bool requeue=TRUE]) +Redeliver unacknowledged messages */ +static PHP_METHOD(amqp_channel_class, basicRecover) +{ + amqp_channel_resource *channel_resource; + + amqp_rpc_reply_t res; + + zend_bool requeue = 1; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &requeue) == FAILURE) { + return; + } + + channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(getThis()); + PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not redeliver unacknowledged messages."); + + amqp_basic_recover( + channel_resource->connection_resource->connection_state, + channel_resource->channel_id, + (amqp_boolean_t) requeue + ); + + res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state); + + if (PHP_AMQP_MAYBE_ERROR(res, channel_resource)) { + php_amqp_zend_throw_exception_short(res, amqp_channel_exception_class_entry TSRMLS_CC); + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + return; + } + + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto bool amqp::confirmSelect() +Redeliver unacknowledged messages */ +PHP_METHOD(amqp_channel_class, confirmSelect) +{ + amqp_channel_resource *channel_resource; + amqp_rpc_reply_t res; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { + return; + } + + channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(getThis()); + PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not enable confirms mode."); + + amqp_confirm_select( + channel_resource->connection_resource->connection_state, + channel_resource->channel_id + ); + + res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state); + + if (PHP_AMQP_MAYBE_ERROR(res, channel_resource)) { + php_amqp_zend_throw_exception_short(res, amqp_channel_exception_class_entry TSRMLS_CC); + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + return; + } + + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto bool AMQPChannel::setReturnCallback(callable return_callback) +Set callback for basic.return server method handling */ +PHP_METHOD(amqp_channel_class, setReturnCallback) +{ + zend_fcall_info fci = empty_fcall_info; + zend_fcall_info_cache fcc = empty_fcall_info_cache; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "f!", &fci, &fcc) == FAILURE) { + return; + } + + amqp_channel_object *channel = PHP_AMQP_GET_CHANNEL(getThis()); + + php_amqp_destroy_fci(&channel->callbacks.basic_return.fci); + + if (ZEND_FCI_INITIALIZED(fci)) { + php_amqp_duplicate_fci(&fci); + channel->callbacks.basic_return.fci = fci; + channel->callbacks.basic_return.fcc = fcc; + } +} +/* }}} */ + +/* {{{ proto bool AMQPChannel::waitForBasicReturn([double timeout=0.0]) +Wait for basic.return method from server */ +PHP_METHOD(amqp_channel_class, waitForBasicReturn) +{ + amqp_channel_object *channel; + amqp_channel_resource *channel_resource; + amqp_method_t method; + + int status; + + double timeout = 0; + + struct timeval tv = {0}; + struct timeval *tv_ptr = &tv; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|d", &timeout) == FAILURE) { + return; + } + + if (timeout < 0) { + zend_throw_exception(amqp_channel_exception_class_entry, "Timeout must be greater than or equal to zero.", 0 TSRMLS_CC); + return; + } + + channel = PHP_AMQP_GET_CHANNEL(getThis()); + + channel_resource = channel->channel_resource; + PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not start wait loop for basic.return method."); + + if (timeout > 0) { + tv.tv_sec = (long int) timeout; + tv.tv_usec = (long int) ((timeout - tv.tv_sec) * 1000000); + } else { + tv_ptr = NULL; + } + + assert(channel_resource->channel_id > 0); + + while(1) { + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + + status = amqp_simple_wait_method_noblock(channel_resource->connection_resource->connection_state, channel_resource->channel_id, AMQP_BASIC_RETURN_METHOD, &method, tv_ptr); + + if (AMQP_STATUS_TIMEOUT == status) { + zend_throw_exception(amqp_queue_exception_class_entry, "Wait timeout exceed", 0 TSRMLS_CC); + + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + return; + } + + if (status != AMQP_STATUS_OK) { + /* Emulate library error */ + amqp_rpc_reply_t res; + + if (AMQP_RESPONSE_SERVER_EXCEPTION == status) { + res.reply_type = AMQP_RESPONSE_SERVER_EXCEPTION; + res.reply = method; + } else { + res.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION; + res.library_error = status; + } + + php_amqp_error(res, &PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource TSRMLS_CC); + + php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, PHP_AMQP_G(error_message), PHP_AMQP_G(error_code) TSRMLS_CC); + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + return; + } + + status = php_amqp_handle_basic_return(&PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource->channel_id, channel, &method TSRMLS_CC); + + if (PHP_AMQP_RESOURCE_RESPONSE_BREAK == status) { + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + break; + } + + if (PHP_AMQP_RESOURCE_RESPONSE_OK != status) { + /* Emulate library error */ + amqp_rpc_reply_t res; + res.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION; + res.library_error = status; + + php_amqp_error(res, &PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource TSRMLS_CC); + + php_amqp_zend_throw_exception(res, amqp_channel_exception_class_entry, PHP_AMQP_G(error_message), PHP_AMQP_G(error_code) TSRMLS_CC); + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + return; + } + } +} +/* }}} */ + +/* {{{ proto bool AMQPChannel::setConfirmCallback(callable ack_callback [, callable nack_callback = null]) +Set callback for basic.ack and, optionally, basic.nac server methods handling */ +PHP_METHOD(amqp_channel_class, setConfirmCallback) +{ + zend_fcall_info ack_fci = empty_fcall_info; + zend_fcall_info_cache ack_fcc = empty_fcall_info_cache; + + zend_fcall_info nack_fci = empty_fcall_info; + zend_fcall_info_cache nack_fcc = empty_fcall_info_cache; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "f!|f!", &ack_fci, &ack_fcc, &nack_fci, &nack_fcc) == FAILURE) { + return; + } + + amqp_channel_object *channel = PHP_AMQP_GET_CHANNEL(getThis()); + + php_amqp_destroy_fci(&channel->callbacks.basic_ack.fci); + + if (ZEND_FCI_INITIALIZED(ack_fci)) { + php_amqp_duplicate_fci(&ack_fci); + channel->callbacks.basic_ack.fci = ack_fci; + channel->callbacks.basic_ack.fcc = ack_fcc; + } + + php_amqp_destroy_fci(&channel->callbacks.basic_nack.fci); + + if (ZEND_FCI_INITIALIZED(nack_fci)) { + php_amqp_duplicate_fci(&nack_fci); + channel->callbacks.basic_nack.fci = nack_fci; + channel->callbacks.basic_nack.fcc = nack_fcc; + } +} +/* }}} */ + + +/* {{{ proto bool amqp::waitForConfirm([double timeout=0.0]) +Redeliver unacknowledged messages */ +PHP_METHOD(amqp_channel_class, waitForConfirm) +{ + amqp_channel_object *channel; + amqp_channel_resource *channel_resource; + amqp_method_t method; + + int status; + + double timeout = 0; + + struct timeval tv = {0}; + struct timeval *tv_ptr = &tv; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|d", &timeout) == FAILURE) { + return; + } + + if (timeout < 0) { + zend_throw_exception(amqp_channel_exception_class_entry, "Timeout must be greater than or equal to zero.", 0 TSRMLS_CC); + return; + } + + channel = PHP_AMQP_GET_CHANNEL(getThis()); + + channel_resource = channel->channel_resource; + PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not start wait loop for basic.return method."); + + if (timeout > 0) { + tv.tv_sec = (long int) timeout; + tv.tv_usec = (long int) ((timeout - tv.tv_sec) * 1000000); + } else { + tv_ptr = NULL; + } + + assert(channel_resource->channel_id > 0); + + + amqp_method_number_t expected_methods[] = { AMQP_BASIC_ACK_METHOD, AMQP_BASIC_NACK_METHOD, AMQP_BASIC_RETURN_METHOD, 0 }; + + while(1) { + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + + status = amqp_simple_wait_method_list_noblock(channel_resource->connection_resource->connection_state, channel_resource->channel_id, expected_methods, &method, tv_ptr); + + if (AMQP_STATUS_TIMEOUT == status) { + zend_throw_exception(amqp_queue_exception_class_entry, "Wait timeout exceed", 0 TSRMLS_CC); + + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + return; + } + + if (status != AMQP_STATUS_OK) { + /* Emulate library error */ + amqp_rpc_reply_t res; + + if (AMQP_RESPONSE_SERVER_EXCEPTION == status) { + res.reply_type = AMQP_RESPONSE_SERVER_EXCEPTION; + res.reply = method; + } else { + res.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION; + res.library_error = status; + } + + php_amqp_error(res, &PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource TSRMLS_CC); + + php_amqp_zend_throw_exception(res, amqp_channel_exception_class_entry, PHP_AMQP_G(error_message), PHP_AMQP_G(error_code) TSRMLS_CC); + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + return; + } + + switch(method.id) { + case AMQP_BASIC_ACK_METHOD: + status = php_amqp_handle_basic_ack(&PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource->channel_id, channel, &method TSRMLS_CC); + break; + case AMQP_BASIC_NACK_METHOD: + status = php_amqp_handle_basic_nack(&PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource->channel_id, channel, &method TSRMLS_CC); + break; + case AMQP_BASIC_RETURN_METHOD: + status = php_amqp_handle_basic_return(&PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource->channel_id, channel, &method TSRMLS_CC); + break; + default: + status = AMQP_STATUS_WRONG_METHOD; + } + + if (PHP_AMQP_RESOURCE_RESPONSE_BREAK == status) { + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + break; + } + + if (PHP_AMQP_RESOURCE_RESPONSE_OK != status) { + /* Emulate library error */ + amqp_rpc_reply_t res; + res.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION; + res.library_error = status; + + php_amqp_error(res, &PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource TSRMLS_CC); + + php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, PHP_AMQP_G(error_message), PHP_AMQP_G(error_code) TSRMLS_CC); + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + return; + } + } +} +/* }}} */ + +/* {{{ proto amqp::getConsumers() */ +static PHP_METHOD(amqp_channel_class, getConsumers) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + PHP_AMQP_RETURN_THIS_PROP("consumers"); +} +/* }}} */ + + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class__construct, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) + ZEND_ARG_OBJ_INFO(0, amqp_connection, AMQPConnection, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_isConnected, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_close, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_getChannelId, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_setPrefetchSize, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) + ZEND_ARG_INFO(0, size) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_getPrefetchSize, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_setPrefetchCount, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) + ZEND_ARG_INFO(0, count) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_getPrefetchCount, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_qos, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 2) + ZEND_ARG_INFO(0, size) + ZEND_ARG_INFO(0, count) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_startTransaction, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_commitTransaction, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_rollbackTransaction, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_getConnection, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_basicRecover, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) + ZEND_ARG_INFO(0, requeue) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_confirmSelect, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_setConfirmCallback, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) + ZEND_ARG_INFO(0, ack_callback) + ZEND_ARG_INFO(0, nack_callback) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_waitForConfirm, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) + ZEND_ARG_INFO(0, timeout) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_setReturnCallback, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) + ZEND_ARG_INFO(0, return_callback) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_waitForBasicReturn, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) + ZEND_ARG_INFO(0, timeout) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_getConsumers, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +//setConfirmsCallback + + +zend_function_entry amqp_channel_class_functions[] = { + PHP_ME(amqp_channel_class, __construct, arginfo_amqp_channel_class__construct, ZEND_ACC_PUBLIC) + PHP_ME(amqp_channel_class, isConnected, arginfo_amqp_channel_class_isConnected, ZEND_ACC_PUBLIC) + PHP_ME(amqp_channel_class, close, arginfo_amqp_channel_class_close, ZEND_ACC_PUBLIC) + + PHP_ME(amqp_channel_class, getChannelId, arginfo_amqp_channel_class_getChannelId, ZEND_ACC_PUBLIC) + + PHP_ME(amqp_channel_class, setPrefetchSize, arginfo_amqp_channel_class_setPrefetchSize, ZEND_ACC_PUBLIC) + PHP_ME(amqp_channel_class, getPrefetchSize, arginfo_amqp_channel_class_getPrefetchSize, ZEND_ACC_PUBLIC) + PHP_ME(amqp_channel_class, setPrefetchCount,arginfo_amqp_channel_class_setPrefetchCount,ZEND_ACC_PUBLIC) + PHP_ME(amqp_channel_class, getPrefetchCount,arginfo_amqp_channel_class_getPrefetchCount,ZEND_ACC_PUBLIC) + PHP_ME(amqp_channel_class, qos, arginfo_amqp_channel_class_qos, ZEND_ACC_PUBLIC) + + PHP_ME(amqp_channel_class, startTransaction, arginfo_amqp_channel_class_startTransaction, ZEND_ACC_PUBLIC) + PHP_ME(amqp_channel_class, commitTransaction, arginfo_amqp_channel_class_commitTransaction, ZEND_ACC_PUBLIC) + PHP_ME(amqp_channel_class, rollbackTransaction, arginfo_amqp_channel_class_rollbackTransaction, ZEND_ACC_PUBLIC) + + PHP_ME(amqp_channel_class, getConnection, arginfo_amqp_channel_class_getConnection, ZEND_ACC_PUBLIC) + + PHP_ME(amqp_channel_class, basicRecover, arginfo_amqp_channel_class_basicRecover, ZEND_ACC_PUBLIC) + + PHP_ME(amqp_channel_class, confirmSelect, arginfo_amqp_channel_class_confirmSelect, ZEND_ACC_PUBLIC) + PHP_ME(amqp_channel_class, waitForConfirm, arginfo_amqp_channel_class_waitForConfirm, ZEND_ACC_PUBLIC) + PHP_ME(amqp_channel_class, setConfirmCallback, arginfo_amqp_channel_class_setConfirmCallback, ZEND_ACC_PUBLIC) + + PHP_ME(amqp_channel_class, setReturnCallback, arginfo_amqp_channel_class_setReturnCallback, ZEND_ACC_PUBLIC) + PHP_ME(amqp_channel_class, waitForBasicReturn, arginfo_amqp_channel_class_waitForBasicReturn, ZEND_ACC_PUBLIC) + + PHP_ME(amqp_channel_class, getConsumers, arginfo_amqp_channel_class_getConsumers, ZEND_ACC_PUBLIC) + + {NULL, NULL, NULL} +}; + +PHP_MINIT_FUNCTION(amqp_channel) +{ + zend_class_entry ce; + + INIT_CLASS_ENTRY(ce, "AMQPChannel", amqp_channel_class_functions); + ce.create_object = amqp_channel_ctor; + amqp_channel_class_entry = zend_register_internal_class(&ce TSRMLS_CC); + + zend_declare_property_null(this_ce, ZEND_STRL("connection"), ZEND_ACC_PRIVATE TSRMLS_CC); + + zend_declare_property_null(this_ce, ZEND_STRL("prefetch_count"), ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_long(this_ce, ZEND_STRL("prefetch_size"), 0, ZEND_ACC_PRIVATE TSRMLS_CC); + + zend_declare_property_null(this_ce, ZEND_STRL("consumers"), ZEND_ACC_PRIVATE TSRMLS_CC); + +#if PHP_MAJOR_VERSION >=7 + memcpy(&amqp_channel_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); + + amqp_channel_object_handlers.offset = XtOffsetOf(amqp_channel_object, zo); + amqp_channel_object_handlers.free_obj = amqp_channel_free; +#endif + +#if ZEND_MODULE_API_NO >= 20100000 + amqp_channel_object_handlers.get_gc = amqp_channel_gc; +#endif + + return SUCCESS; +} +/* +*Local variables: +*tab-width: 4 +*c-basic-offset: 4 +*End: +*vim600: noet sw=4 ts=4 fdm=marker +*vim<600: noet sw=4 ts=4 +*/ diff -Nru php-amqp-1.7.1/amqp-1.9.3/amqp_channel.h php-amqp-1.9.3/amqp-1.9.3/amqp_channel.h --- php-amqp-1.7.1/amqp-1.9.3/amqp_channel.h 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/amqp_channel.h 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,36 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2007 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 | + | Lead: | + | - Pieter de Zwart | + | Maintainers: | + | - Brad Rodriguez | + | - Jonathan Tansavatdi | + +----------------------------------------------------------------------+ +*/ +extern zend_class_entry *amqp_channel_class_entry; + +void php_amqp_close_channel(amqp_channel_resource *channel_resource, zend_bool check_errors TSRMLS_DC); + +PHP_MINIT_FUNCTION(amqp_channel); + +/* +*Local variables: +*tab-width: 4 +*c-basic-offset: 4 +*End: +*vim600: noet sw=4 ts=4 fdm=marker +*vim<600: noet sw=4 ts=4 +*/ diff -Nru php-amqp-1.7.1/amqp-1.9.3/amqp_connection.c php-amqp-1.9.3/amqp-1.9.3/amqp_connection.c --- php-amqp-1.7.1/amqp-1.9.3/amqp_connection.c 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/amqp_connection.c 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,1471 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2007 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 | + | Lead: | + | - Pieter de Zwart | + | Maintainers: | + | - Brad Rodriguez | + | - Jonathan Tansavatdi | + +----------------------------------------------------------------------+ +*/ + + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "php.h" +#include "php_ini.h" +#include "zend_exceptions.h" + +#ifdef PHP_WIN32 +# include "win32/php_stdint.h" +# include "win32/signal.h" +#else +# include +# include +#endif +#include +#include +#include + +#ifdef PHP_WIN32 +# include "win32/unistd.h" +#else +# include +#endif + +#include "php_amqp.h" +#include "amqp_channel.h" +#include "amqp_connection_resource.h" +#include "amqp_connection.h" + +#ifndef E_DEPRECATED +#define E_DEPRECATED E_WARNING +#endif + +zend_class_entry *amqp_connection_class_entry; +#define this_ce amqp_connection_class_entry + +zend_object_handlers amqp_connection_object_handlers; + +#define PHP_AMQP_EXTRACT_CONNECTION_STR(name) \ + zdata = NULL; \ + if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), (name), sizeof(name), zdata)) { \ + convert_to_string(PHP5to7_MAYBE_DEREF(zdata)); \ + } \ + if (zdata && Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) > 0) { \ + zend_update_property_string(this_ce, getThis(), ZEND_STRL(name), Z_STRVAL_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC); \ + } else { \ + zend_update_property_string(this_ce, getThis(), ZEND_STRL(name), INI_STR("amqp." name) TSRMLS_CC); \ + } + +#define PHP_AMQP_EXTRACT_CONNECTION_BOOL(name) \ + zdata = NULL; \ + if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), (name), sizeof(name), zdata)) { \ + convert_to_long(PHP5to7_MAYBE_DEREF(zdata)); \ + } \ + if (zdata) { \ + zend_update_property_bool(this_ce, getThis(), ZEND_STRL(name), Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC); \ + } else { \ + zend_update_property_bool(this_ce, getThis(), ZEND_STRL(name), INI_INT("amqp." name) TSRMLS_CC); \ + } + +static int php_amqp_connection_resource_deleter(PHP5to7_zend_resource_le_t *el, amqp_connection_resource *connection_resource TSRMLS_DC) +{ + if (Z_RES_P(el)->ptr == connection_resource) { + return ZEND_HASH_APPLY_REMOVE | ZEND_HASH_APPLY_STOP; + } + + return ZEND_HASH_APPLY_KEEP; +} + +static PHP5to7_param_str_len_type_t php_amqp_get_connection_hash(amqp_connection_params *params, char **hash) { + return spprintf(hash, + 0, + "amqp_conn_res_h:%s_p:%d_v:%s_l:%s_p:%s_f:%d_c:%d_h:%d_cacert:%s_cert:%s_key:%s", + params->host, + params->port, + params->vhost, + params->login, + params->password, + params->frame_max, + params->channel_max, + params->heartbeat, + params->cacert, + params->cert, + params->key + ); +} + +static void php_amqp_cleanup_connection_resource(amqp_connection_resource *connection_resource TSRMLS_DC) +{ + if (!connection_resource) { + return; + } + + PHP5to7_zend_resource_t resource = connection_resource->resource; + + connection_resource->parent->connection_resource = NULL; + connection_resource->parent = NULL; + + if (connection_resource->is_dirty) { + if (connection_resource->is_persistent) { + zend_hash_apply_with_argument(&EG(persistent_list), (apply_func_arg_t)php_amqp_connection_resource_deleter, (void*)connection_resource TSRMLS_CC); + } + + zend_list_delete(resource); + } else { + if (connection_resource->is_persistent) { + connection_resource->resource = PHP5to7_ZEND_RESOURCE_EMPTY; + } + + if (connection_resource->resource != PHP5to7_ZEND_RESOURCE_EMPTY) { + zend_list_delete(resource); + } + } +} + +static void php_amqp_disconnect(amqp_connection_resource *resource TSRMLS_DC) +{ + php_amqp_prepare_for_disconnect(resource TSRMLS_CC); + php_amqp_cleanup_connection_resource(resource TSRMLS_CC); +} + + +void php_amqp_disconnect_force(amqp_connection_resource *resource TSRMLS_DC) +{ + php_amqp_prepare_for_disconnect(resource TSRMLS_CC); + resource->is_dirty = '\1'; + php_amqp_cleanup_connection_resource(resource TSRMLS_CC); +} + +/** + * php_amqp_connect + * handles connecting to amqp + * called by connect(), pconnect(), reconnect(), preconnect() + */ +int php_amqp_connect(amqp_connection_object *connection, zend_bool persistent, INTERNAL_FUNCTION_PARAMETERS) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + + char *key = NULL; + PHP5to7_param_str_len_type_t key_len = 0; + + if (connection->connection_resource) { + /* Clean up old memory allocations which are now invalid (new connection) */ + php_amqp_cleanup_connection_resource(connection->connection_resource TSRMLS_CC); + } + + assert(connection->connection_resource == NULL); + + amqp_connection_params connection_params; + + connection_params.host = PHP_AMQP_READ_THIS_PROP_STR("host"); + connection_params.port = (int)PHP_AMQP_READ_THIS_PROP_LONG("port"); + connection_params.vhost = PHP_AMQP_READ_THIS_PROP_STR("vhost"); + connection_params.login = PHP_AMQP_READ_THIS_PROP_STR("login"); + connection_params.password = PHP_AMQP_READ_THIS_PROP_STR("password"); + connection_params.frame_max = (int) PHP_AMQP_READ_THIS_PROP_LONG("frame_max"); + connection_params.channel_max = (int) PHP_AMQP_READ_THIS_PROP_LONG("channel_max"); + connection_params.heartbeat = (int) PHP_AMQP_READ_THIS_PROP_LONG("heartbeat"); + connection_params.read_timeout = PHP_AMQP_READ_THIS_PROP_DOUBLE("read_timeout"); + connection_params.write_timeout = PHP_AMQP_READ_THIS_PROP_DOUBLE("write_timeout"); + connection_params.connect_timeout = PHP_AMQP_READ_THIS_PROP_DOUBLE("connect_timeout"); + connection_params.cacert = PHP_AMQP_READ_THIS_PROP_STRLEN("cacert") ? PHP_AMQP_READ_THIS_PROP_STR("cacert") : NULL; + connection_params.cert = PHP_AMQP_READ_THIS_PROP_STRLEN("cert") ? PHP_AMQP_READ_THIS_PROP_STR("cert") : NULL; + connection_params.key = PHP_AMQP_READ_THIS_PROP_STRLEN("key") ? PHP_AMQP_READ_THIS_PROP_STR("key") : NULL; + connection_params.verify = (int) PHP_AMQP_READ_THIS_PROP_BOOL("verify"); + + if (persistent) { + PHP5to7_zend_resource_store_t *le = PHP5to7_ZEND_RESOURCE_EMPTY; + + /* Look for an established resource */ + key_len = php_amqp_get_connection_hash(&connection_params, &key); + + if (PHP5to7_ZEND_HASH_STR_FIND_PTR(&EG(persistent_list), key, key_len, le)) { + efree(key); + + if (le->type != le_amqp_connection_resource_persistent) { + /* hash conflict, given name associate with non-amqp persistent connection resource */ + return 0; + } + + /* An entry for this connection resource already exists */ + /* Stash the connection resource in the connection */ + connection->connection_resource = le->ptr; + + if (connection->connection_resource->resource != PHP5to7_ZEND_RESOURCE_EMPTY) { + /* resource in use! */ + connection->connection_resource = NULL; + + zend_throw_exception(amqp_connection_exception_class_entry, "There are already established persistent connection to the same resource.", 0 TSRMLS_CC); + return 0; + } + + connection->connection_resource->resource = PHP5to7_ZEND_REGISTER_RESOURCE(connection->connection_resource, persistent ? le_amqp_connection_resource_persistent : le_amqp_connection_resource); + connection->connection_resource->parent = connection; + + /* Set desired timeouts */ + if (php_amqp_set_resource_read_timeout(connection->connection_resource, PHP_AMQP_READ_THIS_PROP_DOUBLE("read_timeout") TSRMLS_CC) == 0 + || php_amqp_set_resource_write_timeout(connection->connection_resource, PHP_AMQP_READ_THIS_PROP_DOUBLE("write_timeout") TSRMLS_CC) == 0) { + + php_amqp_disconnect_force(connection->connection_resource TSRMLS_CC); + return 0; + } + + /* Set connection status to connected */ + connection->connection_resource->is_connected = '\1'; + connection->connection_resource->is_persistent = persistent; + + return 1; + } + + efree(key); + } + + connection->connection_resource = connection_resource_constructor(&connection_params, persistent TSRMLS_CC); + + if (connection->connection_resource == NULL) { + return 0; + } + + connection->connection_resource->resource = PHP5to7_ZEND_REGISTER_RESOURCE(connection->connection_resource, persistent ? le_amqp_connection_resource_persistent : le_amqp_connection_resource); + connection->connection_resource->parent = connection; + + /* Set connection status to connected */ + connection->connection_resource->is_connected = '\1'; + + if (persistent) { + connection->connection_resource->is_persistent = persistent; + + key_len = php_amqp_get_connection_hash(&connection_params, &key); + + PHP5to7_zend_resource_store_t new_le; + + /* Store a reference in the persistence list */ + new_le.ptr = connection->connection_resource; + new_le.type = persistent ? le_amqp_connection_resource_persistent : le_amqp_connection_resource; + + if (!PHP5to7_ZEND_HASH_STR_UPD_MEM(&EG(persistent_list), key, key_len, new_le, sizeof(PHP5to7_zend_resource_store_t))) { + efree(key); + php_amqp_disconnect_force(connection->connection_resource TSRMLS_CC); + return 0; + } + efree(key); + } + + return 1; +} + +void amqp_connection_free(PHP5to7_obj_free_zend_object *object TSRMLS_DC) +{ + amqp_connection_object *connection = PHP_AMQP_FETCH_CONNECTION(object); + + if (connection->connection_resource) { + php_amqp_disconnect(connection->connection_resource TSRMLS_CC); + } + + zend_object_std_dtor(&connection->zo TSRMLS_CC); + +#if PHP_MAJOR_VERSION < 7 + efree(object); +#endif +} + +PHP5to7_zend_object_value amqp_connection_ctor(zend_class_entry *ce TSRMLS_DC) +{ + amqp_connection_object* connection = PHP5to7_ECALLOC_CONNECTION_OBJECT(ce); + + zend_object_std_init(&connection->zo, ce TSRMLS_CC); + AMQP_OBJECT_PROPERTIES_INIT(connection->zo, ce); + +#if PHP_MAJOR_VERSION >=7 + connection->zo.handlers = &amqp_connection_object_handlers; + + return &connection->zo; +#else + PHP5to7_zend_object_value new_value; + + new_value.handle = zend_objects_store_put( + connection, + NULL, + (zend_objects_free_object_storage_t) amqp_connection_free, + NULL TSRMLS_CC + ); + + new_value.handlers = zend_get_std_object_handlers(); + + return new_value; +#endif +} + + +/* {{{ proto AMQPConnection::__construct([array optional]) + * The array can contain 'host', 'port', 'login', 'password', 'vhost', 'read_timeout', 'write_timeout', 'connect_timeout' and 'timeout' (deprecated) indexes + */ +static PHP_METHOD(amqp_connection_class, __construct) +{ + zval* ini_arr = NULL; + + PHP5to7_zval_t *zdata = NULL; + + /* Parse out the method parameters */ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a", &ini_arr) == FAILURE) { + return; + } + + /* Pull the login out of the $params array */ + zdata = NULL; + if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "login", sizeof("login"), zdata)) { + // TODO: check whether we need separate zval + convert_to_string(PHP5to7_MAYBE_DEREF(zdata)); + } + /* Validate the given login */ + if (zdata && Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) > 0) { + if (Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) < 128) { + zend_update_property(this_ce, getThis(), ZEND_STRL("login"), PHP5to7_MAYBE_DEREF(zdata)TSRMLS_CC); + } else { + zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'login' exceeds 128 character limit.", 0 TSRMLS_CC); + return; + } + } else { + zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("login"), INI_STR("amqp.login"), (PHP5to7_param_str_len_type_t) (strlen(INI_STR("amqp.login")) > 128 ? 128 : strlen(INI_STR("amqp.login"))) TSRMLS_CC); + } + + /* Pull the password out of the $params array */ + zdata = NULL; + if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "password", sizeof("password"), zdata)) { + convert_to_string(PHP5to7_MAYBE_DEREF(zdata)); + } + /* Validate the given password */ + if (zdata && Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) > 0) { + if (Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) < 128) { + zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("password"), Z_STRVAL_P(PHP5to7_MAYBE_DEREF(zdata)), Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC); + } else { + zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'password' exceeds 128 character limit.", 0 TSRMLS_CC); + return; + } + } else { + zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("password"), INI_STR("amqp.password"), (PHP5to7_param_str_len_type_t) (strlen(INI_STR("amqp.password")) > 128 ? 128 : strlen(INI_STR("amqp.password"))) TSRMLS_CC); + } + + /* Pull the host out of the $params array */ + zdata = NULL; + if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "host", sizeof("host"), zdata)) { + convert_to_string(PHP5to7_MAYBE_DEREF(zdata)); + } + /* Validate the given host */ + if (zdata && Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) > 0) { + if (Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) < 128) { + zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("host"), Z_STRVAL_P(PHP5to7_MAYBE_DEREF(zdata)), Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC); + } else { + zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'host' exceeds 128 character limit.", 0 TSRMLS_CC); + return; + } + } else { + zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("host"), INI_STR("amqp.host"), (PHP5to7_param_str_len_type_t) (strlen(INI_STR("amqp.host")) > 128 ? 128 : strlen(INI_STR("amqp.host"))) TSRMLS_CC); + } + + /* Pull the vhost out of the $params array */ + zdata = NULL; + if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "vhost", sizeof("vhost"), zdata)) { + convert_to_string(PHP5to7_MAYBE_DEREF(zdata)); + } + /* Validate the given vhost */ + if (zdata && Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) > 0) { + if (Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) < 128) { + zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("vhost"), Z_STRVAL_P(PHP5to7_MAYBE_DEREF(zdata)), Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC); + } else { + zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'vhost' exceeds 128 character limit.", 0 TSRMLS_CC); + return; + } + } else { + zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("vhost"), INI_STR("amqp.vhost"), (PHP5to7_param_str_len_type_t) (strlen(INI_STR("amqp.vhost")) > 128 ? 128 : strlen(INI_STR("amqp.vhost"))) TSRMLS_CC); + + } + + zend_update_property_long(this_ce, getThis(), ZEND_STRL("port"), INI_INT("amqp.port") TSRMLS_CC); + + if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "port", sizeof("port"), zdata)) { + convert_to_long(PHP5to7_MAYBE_DEREF(zdata)); + zend_update_property_long(this_ce, getThis(), ZEND_STRL("port"), Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC); + } + + zend_update_property_double(this_ce, getThis(), ZEND_STRL("read_timeout"), INI_FLT("amqp.read_timeout") TSRMLS_CC); + + if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "read_timeout", sizeof("read_timeout"), zdata)) { + convert_to_double(PHP5to7_MAYBE_DEREF(zdata)); + if (Z_DVAL_P(PHP5to7_MAYBE_DEREF(zdata)) < 0) { + zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'read_timeout' must be greater than or equal to zero.", 0 TSRMLS_CC); + } else { + zend_update_property_double(this_ce, getThis(), ZEND_STRL("read_timeout"), Z_DVAL_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC); + } + + if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "timeout", sizeof("timeout"), zdata)) { + /* 'read_timeout' takes precedence on 'timeout' but users have to know this */ + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Parameter 'timeout' is deprecated, 'read_timeout' used instead"); + } + + } else if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "timeout", sizeof("timeout"), zdata)) { + + php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "Parameter 'timeout' is deprecated; use 'read_timeout' instead"); + + convert_to_double(PHP5to7_MAYBE_DEREF(zdata)); + if (Z_DVAL_P(PHP5to7_MAYBE_DEREF(zdata)) < 0) { + zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'timeout' must be greater than or equal to zero.", 0 TSRMLS_CC); + } else { + zend_update_property_double(this_ce, getThis(), ZEND_STRL("read_timeout"), Z_DVAL_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC); + } + } else { + + assert(DEFAULT_TIMEOUT != NULL); + if (strcmp(DEFAULT_TIMEOUT, INI_STR("amqp.timeout")) != 0) { + php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "INI setting 'amqp.timeout' is deprecated; use 'amqp.read_timeout' instead"); + + if (strcmp(DEFAULT_READ_TIMEOUT, INI_STR("amqp.read_timeout")) == 0) { + zend_update_property_double(this_ce, getThis(), ZEND_STRL("read_timeout"), INI_FLT("amqp.timeout") TSRMLS_CC); + } else { + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "INI setting 'amqp.read_timeout' will be used instead of 'amqp.timeout'"); + zend_update_property_double(this_ce, getThis(), ZEND_STRL("read_timeout"), INI_FLT("amqp.read_timeout") TSRMLS_CC); + } + } else { + zend_update_property_double(this_ce, getThis(), ZEND_STRL("read_timeout"), INI_FLT("amqp.read_timeout") TSRMLS_CC); + } + } + + zend_update_property_double(this_ce, getThis(), ZEND_STRL("write_timeout"), INI_FLT("amqp.write_timeout") TSRMLS_CC); + + if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "write_timeout", sizeof("write_timeout"), zdata)) { + convert_to_double(PHP5to7_MAYBE_DEREF(zdata)); + if (Z_DVAL_P(PHP5to7_MAYBE_DEREF(zdata)) < 0) { + zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'write_timeout' must be greater than or equal to zero.", 0 TSRMLS_CC); + } else { + zend_update_property_double(this_ce, getThis(), ZEND_STRL("write_timeout"), Z_DVAL_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC); + } + } + + zend_update_property_double(this_ce, getThis(), ZEND_STRL("connect_timeout"), INI_FLT("amqp.connect_timeout") TSRMLS_CC); + + if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "connect_timeout", sizeof("connect_timeout"), zdata)) { + convert_to_double(PHP5to7_MAYBE_DEREF(zdata)); + if (Z_DVAL_P(PHP5to7_MAYBE_DEREF(zdata)) < 0) { + zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'connect_timeout' must be greater than or equal to zero.", 0 TSRMLS_CC); + } else { + zend_update_property_double(this_ce, getThis(), ZEND_STRL("connect_timeout"), Z_DVAL_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC); + + } + } + + zend_update_property_long(this_ce, getThis(), ZEND_STRL("channel_max"), INI_INT("amqp.channel_max") TSRMLS_CC); + + if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "channel_max", sizeof("channel_max"), zdata)) { + convert_to_long(PHP5to7_MAYBE_DEREF(zdata)); + if (Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) < 0 || Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) > PHP_AMQP_MAX_CHANNELS) { + zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'channel_max' is out of range.", 0 TSRMLS_CC); + } else { + if(Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) == 0) { + zend_update_property_long(this_ce, getThis(), ZEND_STRL("channel_max"), PHP_AMQP_DEFAULT_CHANNEL_MAX TSRMLS_CC); + } else { + zend_update_property_long(this_ce, getThis(), ZEND_STRL("channel_max"), Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC); + } + } + } + + zend_update_property_long(this_ce, getThis(), ZEND_STRL("frame_max"), INI_INT("amqp.frame_max") TSRMLS_CC); + + if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "frame_max", sizeof("frame_max"), zdata)) { + convert_to_long(PHP5to7_MAYBE_DEREF(zdata)); + if (Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) < 0 || Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) > PHP_AMQP_MAX_FRAME) { + zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'frame_max' is out of range.", 0 TSRMLS_CC); + } else { + if(Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) == 0) { + zend_update_property_long(this_ce, getThis(), ZEND_STRL("frame_max"), PHP_AMQP_DEFAULT_FRAME_MAX TSRMLS_CC); + } else { + zend_update_property_long(this_ce, getThis(), ZEND_STRL("frame_max"), Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC); + } + } + } + + zend_update_property_long(this_ce, getThis(), ZEND_STRL("heartbeat"), INI_INT("amqp.heartbeat") TSRMLS_CC); + + if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "heartbeat", sizeof("heartbeat"), zdata)) { + convert_to_long(PHP5to7_MAYBE_DEREF(zdata)); + if (Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) < 0 || Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) > PHP_AMQP_MAX_HEARTBEAT) { + zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'heartbeat' is out of range.", 0 TSRMLS_CC); + } else { + zend_update_property_long(this_ce, getThis(), ZEND_STRL("heartbeat"), Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC); + } + } + + PHP_AMQP_EXTRACT_CONNECTION_STR("cacert"); + PHP_AMQP_EXTRACT_CONNECTION_STR("key"); + PHP_AMQP_EXTRACT_CONNECTION_STR("cert"); + + PHP_AMQP_EXTRACT_CONNECTION_BOOL("verify"); +} +/* }}} */ + + +/* {{{ proto amqp::isConnected() +check amqp connection */ +static PHP_METHOD(amqp_connection_class, isConnected) +{ + amqp_connection_object *connection; + + PHP_AMQP_NOPARAMS(); + + /* Get the connection object out of the store */ + connection = PHP_AMQP_GET_CONNECTION(getThis()); + + /* If the channel_connect is 1, we have a connection */ + if (connection->connection_resource != NULL && connection->connection_resource->is_connected) { + RETURN_TRUE; + } + + /* We have no connection */ + RETURN_FALSE; +} +/* }}} */ + + +/* {{{ proto amqp::connect() +create amqp connection */ +static PHP_METHOD(amqp_connection_class, connect) +{ + amqp_connection_object *connection; + + PHP_AMQP_NOPARAMS(); + + /* Get the connection object out of the store */ + connection = PHP_AMQP_GET_CONNECTION(getThis()); + + if (connection->connection_resource && connection->connection_resource->is_connected) { + if (connection->connection_resource->is_persistent) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempt to start transient connection while persistent transient one already established. Continue."); + } + + RETURN_TRUE; + } + + /* Actually connect this resource to the broker */ + RETURN_BOOL(php_amqp_connect(connection, 0, INTERNAL_FUNCTION_PARAM_PASSTHRU)); +} +/* }}} */ + + +/* {{{ proto amqp::connect() +create amqp connection */ +static PHP_METHOD(amqp_connection_class, pconnect) +{ + amqp_connection_object *connection; + + PHP_AMQP_NOPARAMS(); + + /* Get the connection object out of the store */ + connection = PHP_AMQP_GET_CONNECTION(getThis()); + + if (connection->connection_resource && connection->connection_resource->is_connected) { + + assert(connection->connection_resource != NULL); + if (!connection->connection_resource->is_persistent) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempt to start persistent connection while transient one already established. Continue."); + } + + RETURN_TRUE; + } + + /* Actually connect this resource to the broker or use stored connection */ + RETURN_BOOL(php_amqp_connect(connection, 1, INTERNAL_FUNCTION_PARAM_PASSTHRU)); +} +/* }}} */ + + +/* {{{ proto amqp:pdisconnect() +destroy amqp persistent connection */ +static PHP_METHOD(amqp_connection_class, pdisconnect) +{ + amqp_connection_object *connection; + + PHP_AMQP_NOPARAMS(); + + /* Get the connection object out of the store */ + connection = PHP_AMQP_GET_CONNECTION(getThis()); + + if (!connection->connection_resource || !connection->connection_resource->is_connected) { + RETURN_TRUE; + } + + assert(connection->connection_resource != NULL); + + if (!connection->connection_resource->is_persistent) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempt to close persistent connection while transient one already established. Abort."); + + RETURN_FALSE; + } + + php_amqp_disconnect_force(connection->connection_resource TSRMLS_CC); + + RETURN_TRUE; +} +/* }}} */ + + +/* {{{ proto amqp::disconnect() +destroy amqp connection */ +static PHP_METHOD(amqp_connection_class, disconnect) +{ + amqp_connection_object *connection; + + PHP_AMQP_NOPARAMS(); + + /* Get the connection object out of the store */ + connection = PHP_AMQP_GET_CONNECTION(getThis()); + + if (!connection->connection_resource || !connection->connection_resource->is_connected) { + RETURN_TRUE; + } + + if (connection->connection_resource->is_persistent) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempt to close transient connection while persistent one already established. Abort."); + + RETURN_FALSE; + } + + assert(connection->connection_resource != NULL); + + php_amqp_disconnect(connection->connection_resource TSRMLS_CC); + + RETURN_TRUE; +} + +/* }}} */ + +/* {{{ proto amqp::reconnect() +recreate amqp connection */ +static PHP_METHOD(amqp_connection_class, reconnect) +{ + amqp_connection_object *connection; + + PHP_AMQP_NOPARAMS(); + + /* Get the connection object out of the store */ + connection = PHP_AMQP_GET_CONNECTION(getThis()); + + if (connection->connection_resource && connection->connection_resource->is_connected) { + + assert(connection->connection_resource != NULL); + + if (connection->connection_resource->is_persistent) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempt to reconnect persistent connection while transient one already established. Abort."); + + RETURN_FALSE; + } + + php_amqp_disconnect(connection->connection_resource TSRMLS_CC); + } + + RETURN_BOOL(php_amqp_connect(connection, 0, INTERNAL_FUNCTION_PARAM_PASSTHRU)); +} +/* }}} */ + +/* {{{ proto amqp::preconnect() +recreate amqp connection */ +static PHP_METHOD(amqp_connection_class, preconnect) +{ + amqp_connection_object *connection; + + PHP_AMQP_NOPARAMS(); + + /* Get the connection object out of the store */ + connection = PHP_AMQP_GET_CONNECTION(getThis()); + + + if (connection->connection_resource && connection->connection_resource->is_connected) { + + assert(connection->connection_resource != NULL); + + if (!connection->connection_resource->is_persistent) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempt to reconnect transient connection while persistent one already established. Abort."); + + RETURN_FALSE; + } + + php_amqp_disconnect_force(connection->connection_resource TSRMLS_CC); + } + + RETURN_BOOL(php_amqp_connect(connection, 1, INTERNAL_FUNCTION_PARAM_PASSTHRU)); +} +/* }}} */ + + +/* {{{ proto amqp::getLogin() +get the login */ +static PHP_METHOD(amqp_connection_class, getLogin) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + PHP_AMQP_RETURN_THIS_PROP("login"); +} +/* }}} */ + + +/* {{{ proto amqp::setLogin(string login) +set the login */ +static PHP_METHOD(amqp_connection_class, setLogin) +{ + char *login = NULL; PHP5to7_param_str_len_type_t login_len = 0; + + /* Get the login from the method params */ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &login, &login_len) == FAILURE) { + return; + } + + /* Validate login length */ + if (login_len > 128) { + zend_throw_exception(amqp_connection_exception_class_entry, "Invalid 'login' given, exceeds 128 characters limit.", 0 TSRMLS_CC); + return; + } + + zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("login"), login, login_len TSRMLS_CC); + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto amqp::getPassword() +get the password */ +static PHP_METHOD(amqp_connection_class, getPassword) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + PHP_AMQP_RETURN_THIS_PROP("password"); +} +/* }}} */ + + +/* {{{ proto amqp::setPassword(string password) +set the password */ +static PHP_METHOD(amqp_connection_class, setPassword) +{ + char *password = NULL; PHP5to7_param_str_len_type_t password_len = 0; + + /* Get the password from the method params */ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &password, &password_len) == FAILURE) { + return; + } + + /* Validate password length */ + if (password_len > 128) { + zend_throw_exception(amqp_connection_exception_class_entry, "Invalid 'password' given, exceeds 128 characters limit.", 0 TSRMLS_CC); + return; + } + + zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("password"), password, password_len TSRMLS_CC); + + RETURN_TRUE; +} +/* }}} */ + + +/* {{{ proto amqp::getHost() +get the host */ +static PHP_METHOD(amqp_connection_class, getHost) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + PHP_AMQP_RETURN_THIS_PROP("host"); +} +/* }}} */ + + +/* {{{ proto amqp::setHost(string host) +set the host */ +static PHP_METHOD(amqp_connection_class, setHost) +{ + char *host = NULL; PHP5to7_param_str_len_type_t host_len = 0; + + /* Get the host from the method params */ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &host, &host_len) == FAILURE) { + return; + } + + /* Validate host length */ + if (host_len > 1024) { + zend_throw_exception(amqp_connection_exception_class_entry, "Invalid 'host' given, exceeds 1024 character limit.", 0 TSRMLS_CC); + return; + } + + zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("host"), host, host_len TSRMLS_CC); + + RETURN_TRUE; +} +/* }}} */ + + +/* {{{ proto amqp::getPort() +get the port */ +static PHP_METHOD(amqp_connection_class, getPort) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + PHP_AMQP_RETURN_THIS_PROP("port"); +} +/* }}} */ + + +/* {{{ proto amqp::setPort(mixed port) +set the port */ +static PHP_METHOD(amqp_connection_class, setPort) +{ + zval *zvalPort; + int port; + + /* Get the port from the method params */ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &zvalPort) == FAILURE) { + return; + } + + /* Parse out the port*/ + switch (Z_TYPE_P(zvalPort)) { + case IS_DOUBLE: + port = (int)Z_DVAL_P(zvalPort); + break; + case IS_LONG: + port = (int)Z_LVAL_P(zvalPort); + break; + case IS_STRING: + convert_to_long(zvalPort); + port = (int)Z_LVAL_P(zvalPort); + break; + default: + port = 0; + } + + /* Check the port value */ + if (port <= 0 || port > 65535) { + zend_throw_exception(amqp_connection_exception_class_entry, "Invalid port given. Value must be between 1 and 65535.", 0 TSRMLS_CC); + return; + } + + zend_update_property_long(this_ce, getThis(), ZEND_STRL("port"), port TSRMLS_CC); + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto amqp::getVhost() +get the vhost */ +static PHP_METHOD(amqp_connection_class, getVhost) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + PHP_AMQP_RETURN_THIS_PROP("vhost"); +} +/* }}} */ + + +/* {{{ proto amqp::setVhost(string vhost) +set the vhost */ +static PHP_METHOD(amqp_connection_class, setVhost) +{ + char *vhost = NULL; PHP5to7_param_str_len_type_t vhost_len = 0; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &vhost, &vhost_len) == FAILURE) { + return; + } + + /* Validate vhost length */ + if (vhost_len > 128) { + zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'vhost' exceeds 128 characters limit.", 0 TSRMLS_CC); + return; + } + + zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("vhost"), vhost, vhost_len TSRMLS_CC); + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto amqp::getTimeout() +@deprecated +get the timeout */ +static PHP_METHOD(amqp_connection_class, getTimeout) +{ + php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "AMQPConnection::getTimeout() method is deprecated; use AMQPConnection::getReadTimeout() instead"); + + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + PHP_AMQP_RETURN_THIS_PROP("read_timeout"); +} +/* }}} */ + +/* {{{ proto amqp::setTimeout(double timeout) +@deprecated +set the timeout */ +static PHP_METHOD(amqp_connection_class, setTimeout) +{ + amqp_connection_object *connection; + double read_timeout; + + php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "AMQPConnection::setTimeout($timeout) method is deprecated; use AMQPConnection::setReadTimeout($timeout) instead"); + + /* Get the timeout from the method params */ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &read_timeout) == FAILURE) { + return; + } + + /* Validate timeout */ + if (read_timeout < 0) { + zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'timeout' must be greater than or equal to zero.", 0 TSRMLS_CC); + return; + } + + /* Get the connection object out of the store */ + connection = PHP_AMQP_GET_CONNECTION(getThis()); + + zend_update_property_double(this_ce, getThis(), ZEND_STRL("read_timeout"), read_timeout TSRMLS_CC); + + if (connection->connection_resource && connection->connection_resource->is_connected) { + if (php_amqp_set_resource_read_timeout(connection->connection_resource, read_timeout TSRMLS_CC) == 0) { + + php_amqp_disconnect_force(connection->connection_resource TSRMLS_CC); + + RETURN_FALSE; + } + } + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto amqp::getReadTimeout() +get the read timeout */ +static PHP_METHOD(amqp_connection_class, getReadTimeout) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + PHP_AMQP_RETURN_THIS_PROP("read_timeout"); +} +/* }}} */ + +/* {{{ proto amqp::setReadTimeout(double timeout) +set read timeout */ +static PHP_METHOD(amqp_connection_class, setReadTimeout) +{ + amqp_connection_object *connection; + double read_timeout; + + /* Get the timeout from the method params */ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &read_timeout) == FAILURE) { + return; + } + + /* Validate timeout */ + if (read_timeout < 0) { + zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'read_timeout' must be greater than or equal to zero.", 0 TSRMLS_CC); + return; + } + + /* Get the connection object out of the store */ + connection = PHP_AMQP_GET_CONNECTION(getThis()); + + zend_update_property_double(this_ce, getThis(), ZEND_STRL("read_timeout"), read_timeout TSRMLS_CC); + + if (connection->connection_resource && connection->connection_resource->is_connected) { + if (php_amqp_set_resource_read_timeout(connection->connection_resource, read_timeout TSRMLS_CC) == 0) { + + php_amqp_disconnect_force(connection->connection_resource TSRMLS_CC); + + RETURN_FALSE; + } + } + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto amqp::getWriteTimeout() +get write timeout */ +static PHP_METHOD(amqp_connection_class, getWriteTimeout) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + PHP_AMQP_RETURN_THIS_PROP("write_timeout"); +} +/* }}} */ + +/* {{{ proto amqp::setWriteTimeout(double timeout) +set write timeout */ +static PHP_METHOD(amqp_connection_class, setWriteTimeout) +{ + amqp_connection_object *connection; + double write_timeout; + + /* Get the timeout from the method params */ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &write_timeout) == FAILURE) { + return; + } + + /* Validate timeout */ + if (write_timeout < 0) { + zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'write_timeout' must be greater than or equal to zero.", 0 TSRMLS_CC); + return; + } + + /* Get the connection object out of the store */ + connection = PHP_AMQP_GET_CONNECTION(getThis()); + + zend_update_property_double(this_ce, getThis(), ZEND_STRL("write_timeout"), write_timeout TSRMLS_CC); + + if (connection->connection_resource && connection->connection_resource->is_connected) { + if (php_amqp_set_resource_write_timeout(connection->connection_resource, write_timeout TSRMLS_CC) == 0) { + + php_amqp_disconnect_force(connection->connection_resource TSRMLS_CC); + + RETURN_FALSE; + } + } + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto amqp::getUsedChannels() +Get max used channels number */ +static PHP_METHOD(amqp_connection_class, getUsedChannels) +{ + amqp_connection_object *connection; + + /* Get the timeout from the method params */ + PHP_AMQP_NOPARAMS(); + + /* Get the connection object out of the store */ + connection = PHP_AMQP_GET_CONNECTION(getThis()); + + if (!connection->connection_resource || !connection->connection_resource->is_connected) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Connection is not connected."); + + RETURN_LONG(0); + } + + RETURN_LONG(connection->connection_resource->used_slots); +} +/* }}} */ + +/* {{{ proto amqp::getMaxChannels() +Get max supported channels number per connection */ +PHP_METHOD(amqp_connection_class, getMaxChannels) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + amqp_connection_object *connection; + + PHP_AMQP_NOPARAMS(); + + /* Get the connection object out of the store */ + connection = PHP_AMQP_GET_CONNECTION(getThis()); + + if (connection->connection_resource && connection->connection_resource->is_connected) { + RETURN_LONG(connection->connection_resource->max_slots); + } + + PHP_AMQP_RETURN_THIS_PROP("channel_max"); +} +/* }}} */ + +/* {{{ proto amqp::getMaxFrameSize() +Get max supported frame size per connection in bytes */ +static PHP_METHOD(amqp_connection_class, getMaxFrameSize) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + amqp_connection_object *connection; + + PHP_AMQP_NOPARAMS(); + + /* Get the connection object out of the store */ + connection = PHP_AMQP_GET_CONNECTION(getThis()); + +#if AMQP_VERSION_MAJOR * 100 + AMQP_VERSION_MINOR * 10 + AMQP_VERSION_PATCH > 52 + if (connection->connection_resource && connection->connection_resource->is_connected) { + RETURN_LONG(amqp_get_frame_max(connection->connection_resource->connection_state)); + } +#endif + + PHP_AMQP_RETURN_THIS_PROP("frame_max"); +} +/* }}} */ + +/* {{{ proto amqp::getHeartbeatInterval() +Get number of seconds between heartbeats of the connection in seconds */ +static PHP_METHOD(amqp_connection_class, getHeartbeatInterval) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + amqp_connection_object *connection; + + PHP_AMQP_NOPARAMS(); + + /* Get the connection object out of the store */ + connection = PHP_AMQP_GET_CONNECTION(getThis()); + +#if AMQP_VERSION_MAJOR * 100 + AMQP_VERSION_MINOR * 10 + AMQP_VERSION_PATCH > 52 + if (connection->connection_resource != NULL + && connection->connection_resource->is_connected != '\0') { + RETURN_LONG(amqp_get_heartbeat(connection->connection_resource->connection_state)); + } +#endif + + PHP_AMQP_RETURN_THIS_PROP("heartbeat"); +} +/* }}} */ + +/* {{{ proto amqp::isPersistent() +check whether amqp connection is persistent */ +static PHP_METHOD(amqp_connection_class, isPersistent) +{ + amqp_connection_object *connection; + + PHP_AMQP_NOPARAMS(); + + connection = PHP_AMQP_GET_CONNECTION(getThis()); + + RETURN_BOOL(connection->connection_resource && connection->connection_resource->is_persistent); +} +/* }}} */ + + +/* {{{ proto amqp::getCACert() */ +static PHP_METHOD(amqp_connection_class, getCACert) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + PHP_AMQP_RETURN_THIS_PROP("cacert"); +} +/* }}} */ + +/* {{{ proto amqp::setCACert(string cacert) */ +static PHP_METHOD(amqp_connection_class, setCACert) +{ + char *str = NULL; PHP5to7_param_str_len_type_t str_len = 0; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) { + return; + } + + zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("cacert"), str, str_len TSRMLS_CC); + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto amqp::getCert() */ +static PHP_METHOD(amqp_connection_class, getCert) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + PHP_AMQP_RETURN_THIS_PROP("cert"); +} +/* }}} */ + +/* {{{ proto amqp::setCert(string cert) */ +static PHP_METHOD(amqp_connection_class, setCert) +{ + char *str = NULL; PHP5to7_param_str_len_type_t str_len = 0; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) { + return; + } + + zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("cert"), str, str_len TSRMLS_CC); + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto amqp::getKey() */ +static PHP_METHOD(amqp_connection_class, getKey) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + PHP_AMQP_RETURN_THIS_PROP("key"); +} +/* }}} */ + +/* {{{ proto amqp::setKey(string key) */ +static PHP_METHOD(amqp_connection_class, setKey) +{ + char *str = NULL; PHP5to7_param_str_len_type_t str_len = 0; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) { + return; + } + + zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("key"), str, str_len TSRMLS_CC); + + RETURN_TRUE; +} +/* }}} */ + + +/* {{{ proto amqp::getVerify() */ +static PHP_METHOD(amqp_connection_class, getVerify) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + PHP_AMQP_RETURN_THIS_PROP("verify"); +} +/* }}} */ + +/* {{{ proto amqp::setVerify(bool verify) */ +static PHP_METHOD(amqp_connection_class, setVerify) +{ + zend_bool verify = 1; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &verify) == FAILURE) { + return; + } + + zend_update_property_bool(this_ce, getThis(), ZEND_STRL("verify"), verify TSRMLS_CC); + + RETURN_TRUE; +} +/* }}} */ + +/* amqp_connection_class ARG_INFO definition */ +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class__construct, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) + ZEND_ARG_ARRAY_INFO(0, credentials, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_isConnected, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_connect, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_pconnect, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_pdisconnect, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_disconnect, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_reconnect, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_preconnect, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getLogin, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_setLogin, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) + ZEND_ARG_INFO(0, login) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getPassword, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_setPassword, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) + ZEND_ARG_INFO(0, password) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getHost, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_setHost, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) + ZEND_ARG_INFO(0, host) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getPort, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_setPort, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) + ZEND_ARG_INFO(0, port) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getVhost, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_setVhost, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) + ZEND_ARG_INFO(0, vhost) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getTimeout, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_setTimeout, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) + ZEND_ARG_INFO(0, timeout) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getReadTimeout, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_setReadTimeout, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) + ZEND_ARG_INFO(0, timeout) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getWriteTimeout, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_setWriteTimeout, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) + ZEND_ARG_INFO(0, timeout) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getUsedChannels, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getMaxChannels, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getMaxFrameSize, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getHeartbeatInterval, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_isPersistent, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getCACert, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_setCACert, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) + ZEND_ARG_INFO(0, cacert) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getCert, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_setCert, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) + ZEND_ARG_INFO(0, cert) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getKey, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_setKey, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) + ZEND_ARG_INFO(0, key) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getVerify, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_setVerify, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) + ZEND_ARG_INFO(0, verify) +ZEND_END_ARG_INFO() + + +zend_function_entry amqp_connection_class_functions[] = { + PHP_ME(amqp_connection_class, __construct, arginfo_amqp_connection_class__construct, ZEND_ACC_PUBLIC) + PHP_ME(amqp_connection_class, isConnected, arginfo_amqp_connection_class_isConnected, ZEND_ACC_PUBLIC) + PHP_ME(amqp_connection_class, connect, arginfo_amqp_connection_class_connect, ZEND_ACC_PUBLIC) + PHP_ME(amqp_connection_class, pconnect, arginfo_amqp_connection_class_pconnect, ZEND_ACC_PUBLIC) + PHP_ME(amqp_connection_class, pdisconnect, arginfo_amqp_connection_class_pdisconnect, ZEND_ACC_PUBLIC) + PHP_ME(amqp_connection_class, disconnect, arginfo_amqp_connection_class_disconnect, ZEND_ACC_PUBLIC) + PHP_ME(amqp_connection_class, reconnect, arginfo_amqp_connection_class_reconnect, ZEND_ACC_PUBLIC) + PHP_ME(amqp_connection_class, preconnect, arginfo_amqp_connection_class_preconnect, ZEND_ACC_PUBLIC) + + PHP_ME(amqp_connection_class, getLogin, arginfo_amqp_connection_class_getLogin, ZEND_ACC_PUBLIC) + PHP_ME(amqp_connection_class, setLogin, arginfo_amqp_connection_class_setLogin, ZEND_ACC_PUBLIC) + + PHP_ME(amqp_connection_class, getPassword, arginfo_amqp_connection_class_getPassword, ZEND_ACC_PUBLIC) + PHP_ME(amqp_connection_class, setPassword, arginfo_amqp_connection_class_setPassword, ZEND_ACC_PUBLIC) + + PHP_ME(amqp_connection_class, getHost, arginfo_amqp_connection_class_getHost, ZEND_ACC_PUBLIC) + PHP_ME(amqp_connection_class, setHost, arginfo_amqp_connection_class_setHost, ZEND_ACC_PUBLIC) + + PHP_ME(amqp_connection_class, getPort, arginfo_amqp_connection_class_getPort, ZEND_ACC_PUBLIC) + PHP_ME(amqp_connection_class, setPort, arginfo_amqp_connection_class_setPort, ZEND_ACC_PUBLIC) + + PHP_ME(amqp_connection_class, getVhost, arginfo_amqp_connection_class_getVhost, ZEND_ACC_PUBLIC) + PHP_ME(amqp_connection_class, setVhost, arginfo_amqp_connection_class_setVhost, ZEND_ACC_PUBLIC) + + PHP_ME(amqp_connection_class, getTimeout, arginfo_amqp_connection_class_getTimeout, ZEND_ACC_PUBLIC) + PHP_ME(amqp_connection_class, setTimeout, arginfo_amqp_connection_class_setTimeout, ZEND_ACC_PUBLIC) + + PHP_ME(amqp_connection_class, getReadTimeout, arginfo_amqp_connection_class_getReadTimeout, ZEND_ACC_PUBLIC) + PHP_ME(amqp_connection_class, setReadTimeout, arginfo_amqp_connection_class_setReadTimeout, ZEND_ACC_PUBLIC) + + PHP_ME(amqp_connection_class, getWriteTimeout, arginfo_amqp_connection_class_getWriteTimeout, ZEND_ACC_PUBLIC) + PHP_ME(amqp_connection_class, setWriteTimeout, arginfo_amqp_connection_class_setWriteTimeout, ZEND_ACC_PUBLIC) + + PHP_ME(amqp_connection_class, getUsedChannels, arginfo_amqp_connection_class_getUsedChannels, ZEND_ACC_PUBLIC) + PHP_ME(amqp_connection_class, getMaxChannels, arginfo_amqp_connection_class_getMaxChannels, ZEND_ACC_PUBLIC) + PHP_ME(amqp_connection_class, isPersistent, arginfo_amqp_connection_class_isPersistent, ZEND_ACC_PUBLIC) + PHP_ME(amqp_connection_class, getHeartbeatInterval, arginfo_amqp_connection_class_getHeartbeatInterval, ZEND_ACC_PUBLIC) + PHP_ME(amqp_connection_class, getMaxFrameSize, arginfo_amqp_connection_class_getMaxFrameSize, ZEND_ACC_PUBLIC) + + PHP_ME(amqp_connection_class, getCACert, arginfo_amqp_connection_class_getCACert, ZEND_ACC_PUBLIC) + PHP_ME(amqp_connection_class, setCACert, arginfo_amqp_connection_class_setCACert, ZEND_ACC_PUBLIC) + + PHP_ME(amqp_connection_class, getCert, arginfo_amqp_connection_class_getCert, ZEND_ACC_PUBLIC) + PHP_ME(amqp_connection_class, setCert, arginfo_amqp_connection_class_setCert, ZEND_ACC_PUBLIC) + + PHP_ME(amqp_connection_class, getKey, arginfo_amqp_connection_class_getKey, ZEND_ACC_PUBLIC) + PHP_ME(amqp_connection_class, setKey, arginfo_amqp_connection_class_setKey, ZEND_ACC_PUBLIC) + + PHP_ME(amqp_connection_class, getVerify, arginfo_amqp_connection_class_getVerify, ZEND_ACC_PUBLIC) + PHP_ME(amqp_connection_class, setVerify, arginfo_amqp_connection_class_setVerify, ZEND_ACC_PUBLIC) + + {NULL, NULL, NULL} +}; + + +PHP_MINIT_FUNCTION(amqp_connection) +{ + zend_class_entry ce; + + INIT_CLASS_ENTRY(ce, "AMQPConnection", amqp_connection_class_functions); + ce.create_object = amqp_connection_ctor; + this_ce = zend_register_internal_class(&ce TSRMLS_CC); + + zend_declare_property_null(this_ce, ZEND_STRL("login"), ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(this_ce, ZEND_STRL("password"), ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(this_ce, ZEND_STRL("host"), ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(this_ce, ZEND_STRL("vhost"), ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(this_ce, ZEND_STRL("port"), ZEND_ACC_PRIVATE TSRMLS_CC); + + zend_declare_property_null(this_ce, ZEND_STRL("read_timeout"), ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(this_ce, ZEND_STRL("write_timeout"), ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(this_ce, ZEND_STRL("connect_timeout"), ZEND_ACC_PRIVATE TSRMLS_CC); + + zend_declare_property_null(this_ce, ZEND_STRL("channel_max"), ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(this_ce, ZEND_STRL("frame_max"), ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(this_ce, ZEND_STRL("heartbeat"), ZEND_ACC_PRIVATE TSRMLS_CC); + + zend_declare_property_null(this_ce, ZEND_STRL("cacert"), ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(this_ce, ZEND_STRL("key"), ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(this_ce, ZEND_STRL("cert"), ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(this_ce, ZEND_STRL("verify"), ZEND_ACC_PRIVATE TSRMLS_CC); + +#if PHP_MAJOR_VERSION >=7 + memcpy(&amqp_connection_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); + + amqp_connection_object_handlers.offset = XtOffsetOf(amqp_connection_object, zo); + amqp_connection_object_handlers.free_obj = amqp_connection_free; +#endif + + return SUCCESS; +} + +/* +*Local variables: +*tab-width: 4 +*c-basic-offset: 4 +*End: +*vim600: noet sw=4 ts=4 fdm=marker +*vim<6 +*/ diff -Nru php-amqp-1.7.1/amqp-1.9.3/amqp_connection.h php-amqp-1.9.3/amqp-1.9.3/amqp_connection.h --- php-amqp-1.7.1/amqp-1.9.3/amqp_connection.h 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/amqp_connection.h 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,40 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2007 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 | + | Lead: | + | - Pieter de Zwart | + | Maintainers: | + | - Brad Rodriguez | + | - Jonathan Tansavatdi | + +----------------------------------------------------------------------+ +*/ +#include "php.h" + +extern zend_class_entry *amqp_connection_class_entry; + +int php_amqp_connect(amqp_connection_object *amqp_connection, zend_bool persistent, INTERNAL_FUNCTION_PARAMETERS); +void php_amqp_disconnect_force(amqp_connection_resource *resource TSRMLS_DC); + + +PHP_MINIT_FUNCTION(amqp_connection); + +/* +*Local variables: +*tab-width: 4 +*c-basic-offset: 4 +*End: +*vim600: noet sw=4 ts=4 fdm=marker +*vim<600: noet sw=4 ts=4 +*/ diff -Nru php-amqp-1.7.1/amqp-1.9.3/amqp_connection_resource.c php-amqp-1.9.3/amqp-1.9.3/amqp_connection_resource.c --- php-amqp-1.7.1/amqp-1.9.3/amqp_connection_resource.c 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/amqp_connection_resource.c 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,646 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2007 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 | + | Lead: | + | - Pieter de Zwart | + | Maintainers: | + | - Brad Rodriguez | + | - Jonathan Tansavatdi | + +----------------------------------------------------------------------+ +*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "php.h" +#include "php_ini.h" +#include "ext/standard/info.h" +#include "ext/standard/datetime.h" +#include "zend_exceptions.h" + +#ifdef PHP_WIN32 +# include "win32/php_stdint.h" +# include "win32/signal.h" +#else +# include +# include +#endif + +#include +#include +#include +#include + +#ifdef PHP_WIN32 +# include "win32/unistd.h" +#else +# include +#endif + +//#include "amqp_basic_properties.h" +#include "amqp_methods_handling.h" +#include "amqp_connection_resource.h" +#include "amqp_channel.h" +#include "php_amqp.h" + +#ifndef E_DEPRECATED +#define E_DEPRECATED E_WARNING +#endif + +int le_amqp_connection_resource; +int le_amqp_connection_resource_persistent; + +static void connection_resource_destructor(amqp_connection_resource *resource, int persistent TSRMLS_DC); +static void php_amqp_close_connection_from_server(amqp_rpc_reply_t reply, char **message, amqp_connection_resource *resource TSRMLS_DC); +static void php_amqp_close_channel_from_server(amqp_rpc_reply_t reply, char **message, amqp_connection_resource *resource, amqp_channel_t channel_id TSRMLS_DC); + + +/* Figure out what's going on connection and handle protocol exceptions, if any */ +int php_amqp_connection_resource_error(amqp_rpc_reply_t reply, char **message, amqp_connection_resource *resource, amqp_channel_t channel_id TSRMLS_DC) +{ + assert (resource != NULL); + + switch (reply.reply_type) { + case AMQP_RESPONSE_NORMAL: + return PHP_AMQP_RESOURCE_RESPONSE_OK; + + case AMQP_RESPONSE_NONE: + spprintf(message, 0, "Missing RPC reply type."); + return PHP_AMQP_RESOURCE_RESPONSE_ERROR; + + case AMQP_RESPONSE_LIBRARY_EXCEPTION: + + spprintf(message, 0, "Library error: %s", amqp_error_string2(reply.library_error)); + return PHP_AMQP_RESOURCE_RESPONSE_ERROR; + + case AMQP_RESPONSE_SERVER_EXCEPTION: + switch (reply.reply.id) { + case AMQP_CONNECTION_CLOSE_METHOD: { + php_amqp_close_connection_from_server(reply, message, resource TSRMLS_CC); + return PHP_AMQP_RESOURCE_RESPONSE_ERROR_CONNECTION_CLOSED; + } + case AMQP_CHANNEL_CLOSE_METHOD: { + php_amqp_close_channel_from_server(reply, message, resource, channel_id TSRMLS_CC); + return PHP_AMQP_RESOURCE_RESPONSE_ERROR_CHANNEL_CLOSED; + } + } + /* Default for the above switch should be handled by the below default. */ + default: + spprintf(message, 0, "Unknown server error, method id 0x%08X", reply.reply.id); + return PHP_AMQP_RESOURCE_RESPONSE_ERROR; + } + + /* Should not never get here*/ +} + +static void php_amqp_close_connection_from_server(amqp_rpc_reply_t reply, char **message, amqp_connection_resource *resource TSRMLS_DC) { + amqp_connection_close_t *m = (amqp_connection_close_t *)reply.reply.decoded; + int result; + + if (!reply.reply.id) { + PHP_AMQP_G(error_code) = -1; + spprintf(message, 0, "Server connection error: %d, message: %s", + PHP_AMQP_G(error_code), + "unexpected response" + ); + } else { + PHP_AMQP_G(error_code) = m->reply_code; + spprintf(message, 0, "Server connection error: %d, message: %.*s", + m->reply_code, + (PHP5to7_param_str_len_type_t) m->reply_text.len, + (char *) m->reply_text.bytes + ); + } + + /* + * - If r.reply.id == AMQP_CONNECTION_CLOSE_METHOD a connection exception + * occurred, cast r.reply.decoded to amqp_connection_close_t* to see + * details of the exception. The client amqp_send_method() a + * amqp_connection_close_ok_t and disconnect from the broker. + */ + + amqp_connection_close_ok_t *decoded = (amqp_connection_close_ok_t *) NULL; + + result = amqp_send_method( + resource->connection_state, + 0, /* NOTE: 0-channel is reserved for things like this */ + AMQP_CONNECTION_CLOSE_OK_METHOD, + &decoded + ); + + if (result != AMQP_STATUS_OK) { + zend_throw_exception(amqp_channel_exception_class_entry, "An error occurred while closing the connection.", 0 TSRMLS_CC); + } + + /* Prevent finishing AMQP connection in connection resource destructor */ + resource->is_connected = '\0'; +} + +static void php_amqp_close_channel_from_server(amqp_rpc_reply_t reply, char **message, amqp_connection_resource *resource, amqp_channel_t channel_id TSRMLS_DC) { + assert(channel_id > 0 && channel_id <= resource->max_slots); + + amqp_channel_close_t *m = (amqp_channel_close_t *) reply.reply.decoded; + + if (!reply.reply.id) { + PHP_AMQP_G(error_code) = -1; + spprintf(message, 0, "Server channel error: %d, message: %s", + PHP_AMQP_G(error_code), + "unexpected response" + ); + } else { + PHP_AMQP_G(error_code) = m->reply_code; + spprintf(message, 0, "Server channel error: %d, message: %.*s", + m->reply_code, + (PHP5to7_param_str_len_type_t) m->reply_text.len, + (char *)m->reply_text.bytes + ); + } + + /* + * - If r.reply.id == AMQP_CHANNEL_CLOSE_METHOD a channel exception + * occurred, cast r.reply.decoded to amqp_channel_close_t* to see details + * of the exception. The client should amqp_send_method() a + * amqp_channel_close_ok_t. The channel must be re-opened before it + * can be used again. Any resources associated with the channel + * (auto-delete exchanges, auto-delete queues, consumers) are invalid + * and must be recreated before attempting to use them again. + */ + + if (resource) { + int result; + amqp_channel_close_ok_t *decoded = (amqp_channel_close_ok_t *) NULL; + + result = amqp_send_method( + resource->connection_state, + channel_id, + AMQP_CHANNEL_CLOSE_OK_METHOD, + &decoded + ); + if (result != AMQP_STATUS_OK) { + zend_throw_exception(amqp_channel_exception_class_entry, "An error occurred while closing channel.", 0 TSRMLS_CC); + } + } +} + + +int php_amqp_connection_resource_error_advanced(amqp_rpc_reply_t reply, char **message, amqp_connection_resource *resource, amqp_channel_t channel_id, amqp_channel_object *channel TSRMLS_DC) +{ + assert(resource != NULL); + + amqp_frame_t frame; + + assert(AMQP_RESPONSE_LIBRARY_EXCEPTION == reply.reply_type); + assert(AMQP_STATUS_UNEXPECTED_STATE == reply.library_error); + + if (channel_id < 0 || AMQP_STATUS_OK != amqp_simple_wait_frame(resource->connection_state, &frame)) { + if (*message != NULL) { + efree(*message); + } + + spprintf(message, 0, "Library error: %s", amqp_error_string2(reply.library_error)); + return PHP_AMQP_RESOURCE_RESPONSE_ERROR; + } + + if (channel_id != frame.channel) { + spprintf(message, 0, "Library error: channel mismatch"); + return PHP_AMQP_RESOURCE_RESPONSE_ERROR; + } + + if (AMQP_FRAME_METHOD == frame.frame_type) { + switch (frame.payload.method.id) { + case AMQP_CONNECTION_CLOSE_METHOD: { + php_amqp_close_connection_from_server(reply, message, resource TSRMLS_CC); + return PHP_AMQP_RESOURCE_RESPONSE_ERROR_CONNECTION_CLOSED; + } + case AMQP_CHANNEL_CLOSE_METHOD: { + php_amqp_close_channel_from_server(reply, message, resource, channel_id TSRMLS_CC); + return PHP_AMQP_RESOURCE_RESPONSE_ERROR_CHANNEL_CLOSED; + } + + case AMQP_BASIC_ACK_METHOD: + /* if we've turned publisher confirms on, and we've published a message + * here is a message being confirmed + */ + + return php_amqp_handle_basic_ack(message, resource, channel_id, channel, &frame.payload.method TSRMLS_CC); + case AMQP_BASIC_NACK_METHOD: + /* if we've turned publisher confirms on, and we've published a message + * here is a message being confirmed + */ + + return php_amqp_handle_basic_nack(message, resource, channel_id, channel, &frame.payload.method TSRMLS_CC); + case AMQP_BASIC_RETURN_METHOD: + /* if a published message couldn't be routed and the mandatory flag was set + * this is what would be returned. The message then needs to be read. + */ + + return php_amqp_handle_basic_return(message, resource, channel_id, channel, &frame.payload.method TSRMLS_CC); + default: + if (*message != NULL) { + efree(*message); + } + + spprintf(message, 0, "Library error: An unexpected method was received 0x%08X\n", frame.payload.method.id); + return PHP_AMQP_RESOURCE_RESPONSE_ERROR; + } + } + + if (*message != NULL) { + efree(*message); + } + + spprintf(message, 0, "Library error: %s", amqp_error_string2(reply.library_error)); + return PHP_AMQP_RESOURCE_RESPONSE_ERROR; +} + +/* Socket-related functions */ +int php_amqp_set_resource_read_timeout(amqp_connection_resource *resource, double timeout TSRMLS_DC) +{ + assert(timeout >= 0.0); + +#ifdef PHP_WIN32 + DWORD read_timeout; + /* + In Windows, setsockopt with SO_RCVTIMEO sets actual timeout + to a value that's 500ms greater than specified value. + Also, it's not possible to set timeout to any value below 500ms. + Zero timeout works like it should, however. + */ + if (timeout == 0.) { + read_timeout = 0; + } else { + read_timeout = (int) (max(timeout * 1.e+3 - .5e+3, 1.)); + } +#else + struct timeval read_timeout; + read_timeout.tv_sec = (int) floor(timeout); + read_timeout.tv_usec = (int) ((timeout - floor(timeout)) * 1.e+6); +#endif + + if (0 != setsockopt(amqp_get_sockfd(resource->connection_state), SOL_SOCKET, SO_RCVTIMEO, (char *)&read_timeout, sizeof(read_timeout))) { + zend_throw_exception(amqp_connection_exception_class_entry, "Socket error: cannot setsockopt SO_RCVTIMEO", 0 TSRMLS_CC); + return 0; + } + + return 1; +} + +int php_amqp_set_resource_write_timeout(amqp_connection_resource *resource, double timeout TSRMLS_DC) +{ + assert(timeout >= 0.0); + +#ifdef PHP_WIN32 + DWORD write_timeout; + + if (timeout == 0.) { + write_timeout = 0; + } else { + write_timeout = (int) (max(timeout * 1.e+3 - .5e+3, 1.)); + } +#else + struct timeval write_timeout; + write_timeout.tv_sec = (int) floor(timeout); + write_timeout.tv_usec = (int) ((timeout - floor(timeout)) * 1.e+6); +#endif + + if (0 != setsockopt(amqp_get_sockfd(resource->connection_state), SOL_SOCKET, SO_SNDTIMEO, (char *)&write_timeout, sizeof(write_timeout))) { + zend_throw_exception(amqp_connection_exception_class_entry, "Socket error: cannot setsockopt SO_SNDTIMEO", 0 TSRMLS_CC); + return 0; + } + + return 1; +} + + +/* Channel-related functions */ + +amqp_channel_t php_amqp_connection_resource_get_available_channel_id(amqp_connection_resource *resource) +{ + assert(resource != NULL); + assert(resource->slots != NULL); + + /* Check if there are any open slots */ + if (resource->used_slots >= resource->max_slots) { + return 0; + } + + amqp_channel_t slot; + + for (slot = 0; slot < resource->max_slots; slot++) { + if (resource->slots[slot] == 0) { + return (amqp_channel_t) (slot + 1); + } + } + + return 0; +} + +int php_amqp_connection_resource_register_channel(amqp_connection_resource *resource, amqp_channel_resource *channel_resource, amqp_channel_t channel_id) +{ + assert(resource != NULL); + assert(resource->slots != NULL); + assert(channel_id > 0 && channel_id <= resource->max_slots); + + if (resource->slots[channel_id - 1] != 0) { + return FAILURE; + } + + resource->slots[channel_id - 1] = channel_resource; + channel_resource->connection_resource = resource; + resource->used_slots++; + + return SUCCESS; +} + +int php_amqp_connection_resource_unregister_channel(amqp_connection_resource *resource, amqp_channel_t channel_id) +{ + assert(resource != NULL); + assert(resource->slots != NULL); + assert(channel_id > 0 && channel_id <= resource->max_slots); + + if (resource->slots[channel_id - 1] != 0) { + resource->slots[channel_id - 1]->connection_resource = NULL; + + resource->slots[channel_id - 1] = 0; + resource->used_slots--; + } + + return SUCCESS; +} + + +/* Creating and destroying resource */ + +amqp_connection_resource *connection_resource_constructor(amqp_connection_params *params, zend_bool persistent TSRMLS_DC) +{ + struct timeval tv = {0}; + struct timeval *tv_ptr = &tv; + + char *std_datetime; + amqp_table_entry_t client_properties_entries[5]; + amqp_table_t client_properties_table; + + amqp_table_entry_t custom_properties_entries[1]; + amqp_table_t custom_properties_table; + + amqp_connection_resource *resource; + + /* Allocate space for the connection resource */ + resource = (amqp_connection_resource *)pecalloc(1, sizeof(amqp_connection_resource), persistent); + + /* Create the connection */ + resource->connection_state = amqp_new_connection(); + + /* Create socket object */ + if (params->cacert) { + resource->socket = amqp_ssl_socket_new(resource->connection_state); + + if (!resource->socket) { + zend_throw_exception(amqp_connection_exception_class_entry, "Socket error: could not create SSL socket.", 0 TSRMLS_CC); + + return NULL; + } + } else { + resource->socket = amqp_tcp_socket_new(resource->connection_state); + + if (!resource->socket) { + zend_throw_exception(amqp_connection_exception_class_entry, "Socket error: could not create socket.", 0 TSRMLS_CC); + + return NULL; + } + } + + if (params->cacert && amqp_ssl_socket_set_cacert(resource->socket, params->cacert)) { + zend_throw_exception(amqp_connection_exception_class_entry, "Socket error: could not set CA certificate.", 0 TSRMLS_CC); + + return NULL; + } + + if (params->cacert) { +#if AMQP_VERSION_MAJOR * 100 + AMQP_VERSION_MINOR * 10 + AMQP_VERSION_PATCH >= 80 + amqp_ssl_socket_set_verify_peer(resource->socket, params->verify); + amqp_ssl_socket_set_verify_hostname(resource->socket, params->verify); +#else + amqp_ssl_socket_set_verify(resource->socket, params->verify); +#endif + } + + if (params->cert && params->key && amqp_ssl_socket_set_key(resource->socket, params->cert, params->key)) { + zend_throw_exception(amqp_connection_exception_class_entry, "Socket error: could not setting client cert.", 0 TSRMLS_CC); + + return NULL; + } + + if (params->connect_timeout > 0) { + tv.tv_sec = (long int) params->connect_timeout; + tv.tv_usec = (long int) ((params->connect_timeout - tv.tv_sec) * 1000000); + } else { + tv_ptr = NULL; + } + + /* Try to connect and verify that no error occurred */ + if (amqp_socket_open_noblock(resource->socket, params->host, params->port, tv_ptr)) { + + zend_throw_exception(amqp_connection_exception_class_entry, "Socket error: could not connect to host.", 0 TSRMLS_CC); + + connection_resource_destructor(resource, persistent TSRMLS_CC); + + return NULL; + } + + if (!php_amqp_set_resource_read_timeout(resource, params->read_timeout TSRMLS_CC)) { + connection_resource_destructor(resource, persistent TSRMLS_CC); + return NULL; + } + + if (!php_amqp_set_resource_write_timeout(resource, params->write_timeout TSRMLS_CC)) { + connection_resource_destructor(resource, persistent TSRMLS_CC); + return NULL; + } + + std_datetime = php_std_date(time(NULL) TSRMLS_CC); + + client_properties_entries[0].key = amqp_cstring_bytes("type"); + client_properties_entries[0].value.kind = AMQP_FIELD_KIND_UTF8; + client_properties_entries[0].value.value.bytes = amqp_cstring_bytes("php-amqp extension"); + + client_properties_entries[1].key = amqp_cstring_bytes("version"); + client_properties_entries[1].value.kind = AMQP_FIELD_KIND_UTF8; + client_properties_entries[1].value.value.bytes = amqp_cstring_bytes(PHP_AMQP_VERSION); + + client_properties_entries[2].key = amqp_cstring_bytes("revision"); + client_properties_entries[2].value.kind = AMQP_FIELD_KIND_UTF8; + client_properties_entries[2].value.value.bytes = amqp_cstring_bytes(PHP_AMQP_REVISION); + + client_properties_entries[3].key = amqp_cstring_bytes("connection type"); + client_properties_entries[3].value.kind = AMQP_FIELD_KIND_UTF8; + client_properties_entries[3].value.value.bytes = amqp_cstring_bytes(persistent ? "persistent" : "transient"); + + client_properties_entries[4].key = amqp_cstring_bytes("connection started"); + client_properties_entries[4].value.kind = AMQP_FIELD_KIND_UTF8; + client_properties_entries[4].value.value.bytes = amqp_cstring_bytes(std_datetime); + + client_properties_table.entries = client_properties_entries; + client_properties_table.num_entries = sizeof(client_properties_entries) / sizeof(amqp_table_entry_t); + + custom_properties_entries[0].key = amqp_cstring_bytes("client"); + custom_properties_entries[0].value.kind = AMQP_FIELD_KIND_TABLE; + custom_properties_entries[0].value.value.table = client_properties_table; + + custom_properties_table.entries = custom_properties_entries; + custom_properties_table.num_entries = sizeof(custom_properties_entries) / sizeof(amqp_table_entry_t); + + /* We can assume that connection established here but it is not true, real handshake goes during login */ + + assert(params->frame_max > 0); + + amqp_rpc_reply_t res = amqp_login_with_properties( + resource->connection_state, + params->vhost, + params->channel_max, + params->frame_max, + params->heartbeat, + &custom_properties_table, + AMQP_SASL_METHOD_PLAIN, + params->login, + params->password + ); + + efree(std_datetime); + + if (AMQP_RESPONSE_NORMAL != res.reply_type) { + char *message = NULL, *long_message = NULL; + + php_amqp_connection_resource_error(res, &message, resource, 0 TSRMLS_CC); + + spprintf(&long_message, 0, "%s - Potential login failure.", message); + zend_throw_exception(amqp_connection_exception_class_entry, long_message, PHP_AMQP_G(error_code) TSRMLS_CC); + + efree(message); + efree(long_message); + + /* https://www.rabbitmq.com/resources/specs/amqp0-9-1.pdf + * + * 2.2.4 The Connection Class: + * ... a peer that detects an error MUST close the socket without sending any further data. + * + * 4.10.2 Denial of Service Attacks: + * ... The general response to any exceptional condition in the connection negotiation is to pause that connection + * (presumably a thread) for a period of several seconds and then to close the network connection. This + * includes syntax errors, over-sized data, and failed attempts to authenticate. + */ + connection_resource_destructor(resource, persistent TSRMLS_CC); + return NULL; + } + + /* Allocate space for the channel slots in the ring buffer */ + resource->max_slots = (amqp_channel_t) amqp_get_channel_max(resource->connection_state); + assert(resource->max_slots > 0); + + resource->slots = (amqp_channel_resource **)pecalloc(resource->max_slots + 1, sizeof(amqp_channel_object*), persistent); + + resource->is_connected = '\1'; + + return resource; +} + +ZEND_RSRC_DTOR_FUNC(amqp_connection_resource_dtor_persistent) +{ + amqp_connection_resource *resource = (amqp_connection_resource *)PHP5to7_ZEND_RESOURCE_DTOR_ARG->ptr; + + connection_resource_destructor(resource, 1 TSRMLS_CC); +} + +ZEND_RSRC_DTOR_FUNC(amqp_connection_resource_dtor) +{ + amqp_connection_resource *resource = (amqp_connection_resource *)PHP5to7_ZEND_RESOURCE_DTOR_ARG->ptr; + + connection_resource_destructor(resource, 0 TSRMLS_CC); +} + +static void connection_resource_destructor(amqp_connection_resource *resource, int persistent TSRMLS_DC) +{ + assert(resource != NULL); + +#ifndef PHP_WIN32 + void * old_handler; + + /* + If we are trying to close the connection and the connection already closed, it will throw + SIGPIPE, which is fine, so ignore all SIGPIPES + */ + + /* Start ignoring SIGPIPE */ + old_handler = signal(SIGPIPE, SIG_IGN); +#endif + + if (resource->parent) { + resource->parent->connection_resource = NULL; + } + + if (resource->slots) { + php_amqp_prepare_for_disconnect(resource TSRMLS_CC); + + pefree(resource->slots, persistent); + resource->slots = NULL; + } + + /* connection may be closed in case of previous failure */ + if (resource->is_connected) { + amqp_connection_close(resource->connection_state, AMQP_REPLY_SUCCESS); + } + + amqp_destroy_connection(resource->connection_state); + +#ifndef PHP_WIN32 + /* End ignoring of SIGPIPEs */ + signal(SIGPIPE, old_handler); +#endif + + pefree(resource, persistent); +} + +void php_amqp_prepare_for_disconnect(amqp_connection_resource *resource TSRMLS_DC) +{ + if (resource == NULL) { + return; + } + + if(resource->slots != NULL) { + /* NOTE: when we have persistent connection we do not move channels between php requests + * due to current php-amqp extension limitation in AMQPChannel where __construct == channel.open AMQP method call + * and __destruct = channel.close AMQP method call + */ + + /* Clean up old memory allocations which are now invalid (new connection) */ + amqp_channel_t slot; + + for (slot = 0; slot < resource->max_slots; slot++) { + if (resource->slots[slot] != 0) { + php_amqp_close_channel(resource->slots[slot], 0 TSRMLS_CC); + } + } + } + + /* If it's persistent connection do not destroy connection resource (this keep connection alive) */ + if (resource->is_persistent) { + /* Cleanup buffers to reduce memory usage in idle mode */ + amqp_maybe_release_buffers(resource->connection_state); + } + + return; +} + diff -Nru php-amqp-1.7.1/amqp-1.9.3/amqp_connection_resource.h php-amqp-1.9.3/amqp-1.9.3/amqp_connection_resource.h --- php-amqp-1.7.1/amqp-1.9.3/amqp_connection_resource.h 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/amqp_connection_resource.h 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,84 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2007 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 | + | Lead: | + | - Pieter de Zwart | + | Maintainers: | + | - Brad Rodriguez | + | - Jonathan Tansavatdi | + +----------------------------------------------------------------------+ +*/ +#ifndef PHP_AMQP_CONNECTION_RESOURCE_H +#define PHP_AMQP_CONNECTION_RESOURCE_H + +#define PHP_AMQP_RESOURCE_RESPONSE_BREAK 1 +#define PHP_AMQP_RESOURCE_RESPONSE_OK 0 +#define PHP_AMQP_RESOURCE_RESPONSE_ERROR -1 +#define PHP_AMQP_RESOURCE_RESPONSE_ERROR_CHANNEL_CLOSED -2 +#define PHP_AMQP_RESOURCE_RESPONSE_ERROR_CONNECTION_CLOSED -3 + +extern int le_amqp_connection_resource; +extern int le_amqp_connection_resource_persistent; + +#include "php_amqp.h" +#include "amqp.h" + +void php_amqp_prepare_for_disconnect(amqp_connection_resource *resource TSRMLS_DC); + +typedef struct _amqp_connection_params { + char *login; + char *password; + char *host; + char *vhost; + int port; + int channel_max; + int frame_max; + int heartbeat; + double read_timeout; + double write_timeout; + double connect_timeout; + char *cacert; + char *cert; + char *key; + int verify; +} amqp_connection_params; + +/* Figure out what's going on connection and handle protocol exceptions, if any */ +int php_amqp_connection_resource_error(amqp_rpc_reply_t reply, char **message, amqp_connection_resource *resource, amqp_channel_t channel_id TSRMLS_DC); +int php_amqp_connection_resource_error_advanced(amqp_rpc_reply_t reply, char **message, amqp_connection_resource *resource, amqp_channel_t channel_id, amqp_channel_object *channel TSRMLS_DC); + +/* Socket-related functions */ +int php_amqp_set_resource_read_timeout(amqp_connection_resource *resource, double read_timeout TSRMLS_DC); +int php_amqp_set_resource_write_timeout(amqp_connection_resource *resource, double write_timeout TSRMLS_DC); + +/* Channel-related functions */ +amqp_channel_t php_amqp_connection_resource_get_available_channel_id(amqp_connection_resource *resource); +int php_amqp_connection_resource_unregister_channel(amqp_connection_resource *resource, amqp_channel_t channel_id); +int php_amqp_connection_resource_register_channel(amqp_connection_resource *resource, amqp_channel_resource *channel_resource, amqp_channel_t channel_id); + +/* Creating and destroying resource */ +amqp_connection_resource *connection_resource_constructor(amqp_connection_params *params, zend_bool persistent TSRMLS_DC); +ZEND_RSRC_DTOR_FUNC(amqp_connection_resource_dtor_persistent); +ZEND_RSRC_DTOR_FUNC(amqp_connection_resource_dtor); + +#endif +/* +*Local variables: +*tab-width: 4 +*c-basic-offset: 4 +*End: +*vim600: noet sw=4 ts=4 fdm=marker +*vim<600: noet sw=4 ts=4 +*/ diff -Nru php-amqp-1.7.1/amqp-1.9.3/amqp_decimal.c php-amqp-1.9.3/amqp-1.9.3/amqp_decimal.c --- php-amqp-1.7.1/amqp-1.9.3/amqp_decimal.c 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/amqp_decimal.c 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,144 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2007 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 | + | Lead: | + | - Pieter de Zwart | + | Maintainers: | + | - Brad Rodriguez | + | - Jonathan Tansavatdi | + +----------------------------------------------------------------------+ +*/ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "php.h" +#include "zend_exceptions.h" +#include "php_amqp.h" + +zend_class_entry *amqp_decimal_class_entry; +#define this_ce amqp_decimal_class_entry + +static const PHP5to7_param_long_type_t AMQP_DECIMAL_EXPONENT_MIN = 0; +static const PHP5to7_param_long_type_t AMQP_DECIMAL_EXPONENT_MAX = UINT8_MAX; +static const PHP5to7_param_long_type_t AMQP_DECIMAL_SIGNIFICAND_MIN = 0; +static const PHP5to7_param_long_type_t AMQP_DECIMAL_SIGNIFICAND_MAX = UINT32_MAX; + + +/* {{{ proto AMQPDecimal::__construct(int $e, int $n) + */ +static PHP_METHOD(amqp_decimal_class, __construct) +{ + PHP5to7_param_long_type_t exponent, significand; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &exponent, &significand) == FAILURE) { + return; + } + + if (exponent < AMQP_DECIMAL_EXPONENT_MIN) { + zend_throw_exception_ex(amqp_value_exception_class_entry, 0 TSRMLS_CC, "Decimal exponent value must be unsigned."); + return; + } + + if (exponent > AMQP_DECIMAL_EXPONENT_MAX) { + zend_throw_exception_ex(amqp_value_exception_class_entry, 0 TSRMLS_CC, "Decimal exponent value must be less than %u.", AMQP_DECIMAL_EXPONENT_MAX); + return; + } + if (significand < AMQP_DECIMAL_SIGNIFICAND_MIN) { + zend_throw_exception_ex(amqp_value_exception_class_entry, 0 TSRMLS_CC, "Decimal significand value must be unsigned."); + return; + } + + if (significand > AMQP_DECIMAL_SIGNIFICAND_MAX) { + zend_throw_exception_ex(amqp_value_exception_class_entry, 0 TSRMLS_CC, "Decimal significand value must be less than %u.", AMQP_DECIMAL_SIGNIFICAND_MAX); + return; + } + + zend_update_property_long(this_ce, getThis(), ZEND_STRL("exponent"), exponent TSRMLS_CC); + zend_update_property_long(this_ce, getThis(), ZEND_STRL("significand"), significand TSRMLS_CC); +} +/* }}} */ + +/* {{{ proto int AMQPDecimal::getExponent() +Get exponent */ +static PHP_METHOD(amqp_decimal_class, getExponent) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + + PHP_AMQP_RETURN_THIS_PROP("exponent"); +} +/* }}} */ + +/* {{{ proto int AMQPDecimal::getSignificand() +Get E */ +static PHP_METHOD(amqp_decimal_class, getSignificand) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + + PHP_AMQP_RETURN_THIS_PROP("significand"); +} +/* }}} */ + + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_decimal_class_construct, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 2) + ZEND_ARG_INFO(0, exponent) + ZEND_ARG_INFO(0, significand) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_decimal_class_getExponent, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_decimal_class_getSignificand, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + + +zend_function_entry amqp_decimal_class_functions[] = { + PHP_ME(amqp_decimal_class, __construct, arginfo_amqp_decimal_class_construct, ZEND_ACC_PUBLIC) + PHP_ME(amqp_decimal_class, getExponent, arginfo_amqp_decimal_class_getExponent, ZEND_ACC_PUBLIC) + PHP_ME(amqp_decimal_class, getSignificand, arginfo_amqp_decimal_class_getSignificand, ZEND_ACC_PUBLIC) + + {NULL, NULL, NULL} +}; + + +PHP_MINIT_FUNCTION(amqp_decimal) +{ + zend_class_entry ce; + + INIT_CLASS_ENTRY(ce, "AMQPDecimal", amqp_decimal_class_functions); + this_ce = zend_register_internal_class(&ce TSRMLS_CC); + this_ce->ce_flags = this_ce->ce_flags | PHP5to7_ZEND_ACC_FINAL_CLASS; + + zend_declare_class_constant_long(this_ce, ZEND_STRL("EXPONENT_MIN"), AMQP_DECIMAL_EXPONENT_MIN TSRMLS_CC); + zend_declare_class_constant_long(this_ce, ZEND_STRL("EXPONENT_MAX"), AMQP_DECIMAL_EXPONENT_MAX TSRMLS_CC); + zend_declare_class_constant_long(this_ce, ZEND_STRL("SIGNIFICAND_MIN"), AMQP_DECIMAL_SIGNIFICAND_MIN TSRMLS_CC); + zend_declare_class_constant_long(this_ce, ZEND_STRL("SIGNIFICAND_MAX"), AMQP_DECIMAL_SIGNIFICAND_MAX TSRMLS_CC); + + zend_declare_property_long(this_ce, ZEND_STRL("exponent"), 0, ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_long(this_ce, ZEND_STRL("significand"), 0, ZEND_ACC_PRIVATE TSRMLS_CC); + + return SUCCESS; +} + +/* +*Local variables: +*tab-width: 4 +*c-basic-offset: 4 +*End: +*vim600: noet sw=4 ts=4 fdm=marker +*vim<6 +*/ diff -Nru php-amqp-1.7.1/amqp-1.9.3/amqp_decimal.h php-amqp-1.9.3/amqp-1.9.3/amqp_decimal.h --- php-amqp-1.7.1/amqp-1.9.3/amqp_decimal.h 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/amqp_decimal.h 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,36 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2007 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 | + | Lead: | + | - Pieter de Zwart | + | Maintainers: | + | - Brad Rodriguez | + | - Jonathan Tansavatdi | + +----------------------------------------------------------------------+ +*/ +#include "php.h" + +extern zend_class_entry *amqp_decimal_class_entry; + +PHP_MINIT_FUNCTION(amqp_decimal); + +/* +*Local variables: +*tab-width: 4 +*c-basic-offset: 4 +*End: +*vim600: noet sw=4 ts=4 fdm=marker +*vim<600: noet sw=4 ts=4 +*/ diff -Nru php-amqp-1.7.1/amqp-1.9.3/amqp_envelope.c php-amqp-1.9.3/amqp-1.9.3/amqp_envelope.c --- php-amqp-1.7.1/amqp-1.9.3/amqp_envelope.c 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/amqp_envelope.c 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,271 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2007 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 | + | Lead: | + | - Pieter de Zwart | + | Maintainers: | + | - Brad Rodriguez | + | - Jonathan Tansavatdi | + +----------------------------------------------------------------------+ +*/ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "php.h" +#include "php_ini.h" +#include "ext/standard/info.h" +#include "zend_exceptions.h" + +#ifdef PHP_WIN32 +# include "win32/php_stdint.h" +# include "win32/signal.h" +#else + +# include +# include + +#endif + +#include +#include + +#ifdef PHP_WIN32 +# include "win32/unistd.h" +#else + +# include + +#endif + +#include "amqp_envelope.h" +#include "amqp_basic_properties.h" +#include "php_amqp.h" + +zend_class_entry *amqp_envelope_class_entry; +#define this_ce amqp_envelope_class_entry + + +void convert_amqp_envelope_to_zval(amqp_envelope_t *amqp_envelope, zval *envelope TSRMLS_DC) +{ + /* Build the envelope */ + object_init_ex(envelope, this_ce); + + + amqp_basic_properties_t *p = &amqp_envelope->message.properties; + amqp_message_t *message = &amqp_envelope->message; + + zend_update_property_stringl(this_ce, envelope, ZEND_STRL("body"), (const char *) message->body.bytes, (PHP5to7_param_str_len_type_t) message->body.len TSRMLS_CC); + + zend_update_property_stringl(this_ce, envelope, ZEND_STRL("consumer_tag"), (const char *) amqp_envelope->consumer_tag.bytes, (PHP5to7_param_str_len_type_t) amqp_envelope->consumer_tag.len TSRMLS_CC); + zend_update_property_long(this_ce, envelope, ZEND_STRL("delivery_tag"), (PHP5to7_param_long_type_t) amqp_envelope->delivery_tag TSRMLS_CC); + zend_update_property_bool(this_ce, envelope, ZEND_STRL("is_redelivery"), (PHP5to7_param_long_type_t) amqp_envelope->redelivered TSRMLS_CC); + zend_update_property_stringl(this_ce, envelope, ZEND_STRL("exchange_name"), (const char *) amqp_envelope->exchange.bytes, (PHP5to7_param_str_len_type_t) amqp_envelope->exchange.len TSRMLS_CC); + zend_update_property_stringl(this_ce, envelope, ZEND_STRL("routing_key"), (const char *) amqp_envelope->routing_key.bytes, (PHP5to7_param_str_len_type_t) amqp_envelope->routing_key.len TSRMLS_CC); + + php_amqp_basic_properties_extract(p, envelope TSRMLS_CC); +} + +/* {{{ proto AMQPEnvelope::__construct() */ +static PHP_METHOD(amqp_envelope_class, __construct) { + PHP_AMQP_NOPARAMS(); + + /* BC */ + php_amqp_basic_properties_set_empty_headers(getThis() TSRMLS_CC); +} +/* }}} */ + + +/* {{{ proto AMQPEnvelope::getBody()*/ +static PHP_METHOD(amqp_envelope_class, getBody) { + PHP5to7_READ_PROP_RV_PARAM_DECL; + + PHP_AMQP_NOPARAMS(); + + zval* zv = PHP_AMQP_READ_THIS_PROP("body"); + + if (Z_STRLEN_P(zv) == 0) { + /* BC */ + RETURN_FALSE; + } + + RETURN_ZVAL(zv, 1, 0); +} +/* }}} */ + +/* {{{ proto AMQPEnvelope::getRoutingKey() */ +static PHP_METHOD(amqp_envelope_class, getRoutingKey) { + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + PHP_AMQP_RETURN_THIS_PROP("routing_key"); +} +/* }}} */ + +/* {{{ proto AMQPEnvelope::getDeliveryTag() */ +static PHP_METHOD(amqp_envelope_class, getDeliveryTag) { + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + PHP_AMQP_RETURN_THIS_PROP("delivery_tag"); +} +/* }}} */ + +/* {{{ proto AMQPEnvelope::getConsumerTag() */ +static PHP_METHOD(amqp_envelope_class, getConsumerTag) { + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + PHP_AMQP_RETURN_THIS_PROP("consumer_tag"); +} +/* }}} */ + +/* {{{ proto AMQPEnvelope::getExchangeName() */ +static PHP_METHOD(amqp_envelope_class, getExchangeName) { + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + PHP_AMQP_RETURN_THIS_PROP("exchange_name"); +} +/* }}} */ + +/* {{{ proto AMQPEnvelope::isRedelivery() */ +static PHP_METHOD(amqp_envelope_class, isRedelivery) { + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + PHP_AMQP_RETURN_THIS_PROP("is_redelivery"); +} +/* }}} */ + + +/* {{{ proto AMQPEnvelope::getHeader(string name) */ +static PHP_METHOD(amqp_envelope_class, getHeader) { + PHP5to7_READ_PROP_RV_PARAM_DECL; + + char *key; PHP5to7_param_str_len_type_t key_len; + PHP5to7_zval_t *tmp = NULL; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &key, &key_len) == FAILURE) { + return; + } + + zval* zv = PHP_AMQP_READ_THIS_PROP_CE("headers", amqp_basic_properties_class_entry); + //zval* zv = PHP_AMQP_READ_THIS_PROP("headers"); + + /* Look for the hash key */ + if (!PHP5to7_ZEND_HASH_FIND(HASH_OF(zv), key, key_len + 1, tmp)) { + RETURN_FALSE; + } + + RETURN_ZVAL(PHP5to7_MAYBE_DEREF(tmp), 1, 0); +} +/* }}} */ + + +/* {{{ proto AMQPEnvelope::hasHeader(string name) */ +static PHP_METHOD(amqp_envelope_class, hasHeader) { + PHP5to7_READ_PROP_RV_PARAM_DECL; + + char *key; PHP5to7_param_str_len_type_t key_len; + PHP5to7_zval_t *tmp = NULL; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &key, &key_len) == FAILURE) { + return; + } + + zval* zv = PHP_AMQP_READ_THIS_PROP_CE("headers", amqp_basic_properties_class_entry); + //zval* zv = PHP_AMQP_READ_THIS_PROP("headers"); + + /* Look for the hash key */ + if (!PHP5to7_ZEND_HASH_FIND(HASH_OF(zv), key, key_len + 1, tmp)) { + RETURN_FALSE; + } + + RETURN_TRUE; +} +/* }}} */ + + +/* amqp_envelope_class ARG_INFO definition */ +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class__construct, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getBody, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getRoutingKey, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getConsumerTag, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getDeliveryTag, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getExchangeName, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_isRedelivery, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getHeader, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) + ZEND_ARG_INFO(0, name) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_hasHeader, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) + ZEND_ARG_INFO(0, name) +ZEND_END_ARG_INFO() + + +zend_function_entry amqp_envelope_class_functions[] = { + PHP_ME(amqp_envelope_class, __construct, arginfo_amqp_envelope_class__construct, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR) + + PHP_ME(amqp_envelope_class, getBody, arginfo_amqp_envelope_class_getBody, ZEND_ACC_PUBLIC) + + PHP_ME(amqp_envelope_class, getRoutingKey, arginfo_amqp_envelope_class_getRoutingKey, ZEND_ACC_PUBLIC) + PHP_ME(amqp_envelope_class, getConsumerTag, arginfo_amqp_envelope_class_getConsumerTag, ZEND_ACC_PUBLIC) + PHP_ME(amqp_envelope_class, getDeliveryTag, arginfo_amqp_envelope_class_getDeliveryTag, ZEND_ACC_PUBLIC) + PHP_ME(amqp_envelope_class, getExchangeName, arginfo_amqp_envelope_class_getExchangeName, ZEND_ACC_PUBLIC) + PHP_ME(amqp_envelope_class, isRedelivery, arginfo_amqp_envelope_class_isRedelivery, ZEND_ACC_PUBLIC) + + PHP_ME(amqp_envelope_class, getHeader, arginfo_amqp_envelope_class_getHeader, ZEND_ACC_PUBLIC) + PHP_ME(amqp_envelope_class, hasHeader, arginfo_amqp_envelope_class_hasHeader, ZEND_ACC_PUBLIC) + + {NULL, NULL, NULL} +}; + + +PHP_MINIT_FUNCTION (amqp_envelope) { + zend_class_entry ce; + + INIT_CLASS_ENTRY(ce, "AMQPEnvelope", amqp_envelope_class_functions); + this_ce = zend_register_internal_class_ex(&ce, amqp_basic_properties_class_entry PHP5to7_PARENT_CLASS_NAME_C(NULL) TSRMLS_CC); + + zend_declare_property_null(this_ce, ZEND_STRL("body"), ZEND_ACC_PRIVATE TSRMLS_CC); + + zend_declare_property_null(this_ce, ZEND_STRL("consumer_tag"), ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(this_ce, ZEND_STRL("delivery_tag"), ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(this_ce, ZEND_STRL("is_redelivery"), ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(this_ce, ZEND_STRL("exchange_name"), ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(this_ce, ZEND_STRL("routing_key"), ZEND_ACC_PRIVATE TSRMLS_CC); + + return SUCCESS; +} + + +/* +*Local variables: +*tab-width: 4 +*c-basic-offset: 4 +*End: +*vim600: noet sw=4 ts=4 fdm=marker +*vim<600: noet sw=4 ts=4 +*/ diff -Nru php-amqp-1.7.1/amqp-1.9.3/amqp_envelope.h php-amqp-1.9.3/amqp-1.9.3/amqp_envelope.h --- php-amqp-1.7.1/amqp-1.9.3/amqp_envelope.h 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/amqp_envelope.h 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,37 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2007 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 | + | Lead: | + | - Pieter de Zwart | + | Maintainers: | + | - Brad Rodriguez | + | - Jonathan Tansavatdi | + +----------------------------------------------------------------------+ +*/ +extern zend_class_entry *amqp_envelope_class_entry; + +void convert_amqp_envelope_to_zval(amqp_envelope_t *amqp_envelope, zval *envelope TSRMLS_DC); + +PHP_MINIT_FUNCTION(amqp_envelope); + + +/* +*Local variables: +*tab-width: 4 +*c-basic-offset: 4 +*End: +*vim600: noet sw=4 ts=4 fdm=marker +*vim<600: noet sw=4 ts=4 +*/ diff -Nru php-amqp-1.7.1/amqp-1.9.3/amqp_exchange.c php-amqp-1.9.3/amqp-1.9.3/amqp_exchange.c --- php-amqp-1.7.1/amqp-1.9.3/amqp_exchange.c 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/amqp_exchange.c 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,917 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2007 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 | + | Lead: | + | - Pieter de Zwart | + | Maintainers: | + | - Brad Rodriguez | + | - Jonathan Tansavatdi | + +----------------------------------------------------------------------+ +*/ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "php.h" +#include "php_ini.h" +#include "ext/standard/info.h" +#include "zend_exceptions.h" + +#ifdef PHP_WIN32 +# include "win32/php_stdint.h" +# include "win32/signal.h" +#else +# include +# include +#endif +#include +#include + +#ifdef PHP_WIN32 +# include "win32/unistd.h" +#else +# include +#endif + +#include "php_amqp.h" +#include "amqp_connection.h" +#include "amqp_channel.h" +#include "amqp_exchange.h" +#include "amqp_type.h" + +zend_class_entry *amqp_exchange_class_entry; +#define this_ce amqp_exchange_class_entry + +/* {{{ proto AMQPExchange::__construct(AMQPChannel channel); +create Exchange */ +static PHP_METHOD(amqp_exchange_class, __construct) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + + PHP5to7_zval_t arguments PHP5to7_MAYBE_SET_TO_NULL; + + zval *channelObj; + amqp_channel_resource *channel_resource; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &channelObj) == FAILURE) { + return; + } + + PHP5to7_MAYBE_INIT(arguments); + PHP5to7_ARRAY_INIT(arguments); + zend_update_property(this_ce, getThis(), ZEND_STRL("arguments"), PHP5to7_MAYBE_PTR(arguments) TSRMLS_CC); + PHP5to7_MAYBE_DESTROY(arguments); + + channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(channelObj); + PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not create exchange."); + + zend_update_property(this_ce, getThis(), ZEND_STRL("channel"), channelObj TSRMLS_CC); + zend_update_property(this_ce, getThis(), ZEND_STRL("connection"), PHP_AMQP_READ_OBJ_PROP(amqp_channel_class_entry, channelObj, "connection") TSRMLS_CC); +} +/* }}} */ + + +/* {{{ proto AMQPExchange::getName() +Get the exchange name */ +static PHP_METHOD(amqp_exchange_class, getName) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + + PHP_AMQP_NOPARAMS(); + + if (PHP_AMQP_READ_THIS_PROP_STRLEN("name") > 0) { + PHP_AMQP_RETURN_THIS_PROP("name"); + } else { + /* BC */ + RETURN_FALSE; + } +} +/* }}} */ + + +/* {{{ proto AMQPExchange::setName(string name) +Set the exchange name */ +static PHP_METHOD(amqp_exchange_class, setName) +{ + char *name = NULL; + PHP5to7_param_str_len_type_t name_len = 0; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) { + return; + } + + /* Verify that the name is not null and not an empty string */ + if (name_len > 255) { + zend_throw_exception(amqp_exchange_exception_class_entry, "Invalid exchange name given, must be less than 255 characters long.", 0 TSRMLS_CC); + return; + } + + /* Set the exchange name */ + zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("name"), name, name_len TSRMLS_CC); +} +/* }}} */ + + +/* {{{ proto AMQPExchange::getFlags() +Get the exchange parameters */ +static PHP_METHOD(amqp_exchange_class, getFlags) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + + PHP5to7_param_long_type_t flagBitmask = 0; + + PHP_AMQP_NOPARAMS(); + + if (PHP_AMQP_READ_THIS_PROP_BOOL("passive")) { + flagBitmask |= AMQP_PASSIVE; + } + + if (PHP_AMQP_READ_THIS_PROP_BOOL("durable")) { + flagBitmask |= AMQP_DURABLE; + } + + if (PHP_AMQP_READ_THIS_PROP_BOOL("auto_delete")) { + flagBitmask |= AMQP_AUTODELETE; + } + + if (PHP_AMQP_READ_THIS_PROP_BOOL("internal")) { + flagBitmask |= AMQP_INTERNAL; + } + + RETURN_LONG(flagBitmask); +} +/* }}} */ + + +/* {{{ proto AMQPExchange::setFlags(long bitmask) +Set the exchange parameters */ +static PHP_METHOD(amqp_exchange_class, setFlags) +{ + PHP5to7_param_long_type_t flagBitmask; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &flagBitmask) == FAILURE) { + return; + } + + /* Set the flags based on the bitmask we were given */ + flagBitmask = flagBitmask ? flagBitmask & PHP_AMQP_EXCHANGE_FLAGS : flagBitmask; + + zend_update_property_bool(this_ce, getThis(), ZEND_STRL("passive"), IS_PASSIVE(flagBitmask) TSRMLS_CC); + zend_update_property_bool(this_ce, getThis(), ZEND_STRL("durable"), IS_DURABLE(flagBitmask) TSRMLS_CC); + zend_update_property_bool(this_ce, getThis(), ZEND_STRL("auto_delete"), IS_AUTODELETE(flagBitmask) TSRMLS_CC); + zend_update_property_bool(this_ce, getThis(), ZEND_STRL("internal"), IS_INTERNAL(flagBitmask) TSRMLS_CC); +} +/* }}} */ + + +/* {{{ proto AMQPExchange::getType() +Get the exchange type */ +static PHP_METHOD(amqp_exchange_class, getType) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + + PHP_AMQP_NOPARAMS(); + + if (PHP_AMQP_READ_THIS_PROP_STRLEN("type") > 0) { + PHP_AMQP_RETURN_THIS_PROP("type"); + } else { + /* BC */ + RETURN_FALSE; + } +} +/* }}} */ + + +/* {{{ proto AMQPExchange::setType(string type) +Set the exchange type */ +static PHP_METHOD(amqp_exchange_class, setType) +{ + char *type = NULL; PHP5to7_param_str_len_type_t type_len = 0; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &type, &type_len) == FAILURE) { + return; + } + + zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("type"), type, type_len TSRMLS_CC); +} +/* }}} */ + + +/* {{{ proto AMQPExchange::getArgument(string key) +Get the exchange argument referenced by key */ +static PHP_METHOD(amqp_exchange_class, getArgument) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + + PHP5to7_zval_t *tmp = NULL; + + char *key; PHP5to7_param_str_len_type_t key_len; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &key, &key_len) == FAILURE) { + return; + } + + if (!PHP5to7_ZEND_HASH_FIND(PHP_AMQP_READ_THIS_PROP_ARR("arguments"), key, key_len + 1, tmp)) { + RETURN_FALSE; + } + + RETURN_ZVAL(PHP5to7_MAYBE_DEREF(tmp), 1, 0); +} +/* }}} */ + +/* {{{ proto AMQPExchange::hasArgument(string key) */ +static PHP_METHOD(amqp_exchange_class, hasArgument) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + + PHP5to7_zval_t *tmp = NULL; + + char *key; PHP5to7_param_str_len_type_t key_len; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &key, &key_len) == FAILURE) { + return; + } + + if (!PHP5to7_ZEND_HASH_FIND(PHP_AMQP_READ_THIS_PROP_ARR("arguments"), key, (uint)(key_len + 1), tmp)) { + RETURN_FALSE; + } + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto AMQPExchange::getArguments +Get the exchange arguments */ +static PHP_METHOD(amqp_exchange_class, getArguments) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + PHP_AMQP_RETURN_THIS_PROP("arguments"); +} +/* }}} */ + + +/* {{{ proto AMQPExchange::setArguments(array args) +Overwrite all exchange arguments with given args */ +static PHP_METHOD(amqp_exchange_class, setArguments) +{ + zval *zvalArguments; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/", &zvalArguments) == FAILURE) { + return; + } + + zend_update_property(this_ce, getThis(), ZEND_STRL("arguments"), zvalArguments TSRMLS_CC); + + RETURN_TRUE; +} +/* }}} */ + + +/* {{{ proto AMQPExchange::setArgument(key, value) */ +static PHP_METHOD(amqp_exchange_class, setArgument) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + + char *key= NULL; PHP5to7_param_str_len_type_t key_len = 0; + zval *value = NULL; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz", + &key, &key_len, + &value) == FAILURE) { + return; + } + + switch (Z_TYPE_P(value)) { + case IS_NULL: + PHP5to7_ZEND_HASH_DEL(PHP_AMQP_READ_THIS_PROP_ARR("arguments"), key, (uint) (key_len + 1)); + break; + PHP5to7_CASE_IS_BOOL: + case IS_LONG: + case IS_DOUBLE: + case IS_STRING: + PHP5to7_ZEND_HASH_ADD(PHP_AMQP_READ_THIS_PROP_ARR("arguments"), key, (uint) (key_len + 1), value, sizeof(zval *)); + Z_TRY_ADDREF_P(value); + break; + default: + zend_throw_exception(amqp_exchange_exception_class_entry, "The value parameter must be of type NULL, int, double or string.", 0 TSRMLS_CC); + return; + } + + RETURN_TRUE; +} +/* }}} */ + + +/* {{{ proto AMQPExchange::declareExchange(); +declare Exchange +*/ +static PHP_METHOD(amqp_exchange_class, declareExchange) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + + amqp_channel_resource *channel_resource; + amqp_table_t *arguments; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + + channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel")); + PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not declare exchange."); + + /* Check that the exchange has a name */ + if (PHP_AMQP_READ_THIS_PROP_STRLEN("name") < 1) { + zend_throw_exception(amqp_exchange_exception_class_entry, "Could not declare exchange. Exchanges must have a name.", 0 TSRMLS_CC); + return; + } + + /* Check that the exchange has a name */ + if (PHP_AMQP_READ_THIS_PROP_STRLEN("type") < 1) { + zend_throw_exception(amqp_exchange_exception_class_entry, "Could not declare exchange. Exchanges must have a type.", 0 TSRMLS_CC); + return; + } + + arguments = php_amqp_type_convert_zval_to_amqp_table(PHP_AMQP_READ_THIS_PROP("arguments") TSRMLS_CC); + +#if AMQP_VERSION_MAJOR * 100 + AMQP_VERSION_MINOR * 10 + AMQP_VERSION_PATCH > 52 + amqp_exchange_declare( + channel_resource->connection_resource->connection_state, + channel_resource->channel_id, + amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STR("name")), + amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STR("type")), + PHP_AMQP_READ_THIS_PROP_BOOL("passive"), + PHP_AMQP_READ_THIS_PROP_BOOL("durable"), + PHP_AMQP_READ_THIS_PROP_BOOL("auto_delete"), + PHP_AMQP_READ_THIS_PROP_BOOL("internal"), + *arguments + ); +#else + amqp_exchange_declare( + channel_resource->connection_resource->connection_state, + channel_resource->channel_id, + amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STR("name")), + amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STR("type")), + PHP_AMQP_READ_THIS_PROP_BOOL("passive"), + PHP_AMQP_READ_THIS_PROP_BOOL("durable"), + *arguments + ); +#endif + + amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state); + + php_amqp_type_free_amqp_table(arguments); + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + + if (PHP_AMQP_MAYBE_ERROR(res, channel_resource)) { + php_amqp_zend_throw_exception_short(res, amqp_exchange_exception_class_entry TSRMLS_CC); + return; + } + + RETURN_TRUE; +} +/* }}} */ + + +/* {{{ proto AMQPExchange::delete([string name[, long params]]); +delete Exchange +*/ +static PHP_METHOD(amqp_exchange_class, delete) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + + amqp_channel_resource *channel_resource; + + char *name = NULL; PHP5to7_param_str_len_type_t name_len = 0; + PHP5to7_param_long_type_t flags = 0; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sl", + &name, &name_len, + &flags) == FAILURE) { + return; + } + + channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel")); + PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not delete exchange."); + + amqp_exchange_delete( + channel_resource->connection_resource->connection_state, + channel_resource->channel_id, + amqp_cstring_bytes(name_len ? name : PHP_AMQP_READ_THIS_PROP_STR("name")), + (AMQP_IFUNUSED & flags) ? 1 : 0 + ); + + amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state); + + if (PHP_AMQP_MAYBE_ERROR(res, channel_resource)) { + php_amqp_zend_throw_exception_short(res, amqp_exchange_exception_class_entry TSRMLS_CC); + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + return; + } + + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + + RETURN_TRUE; +} +/* }}} */ + + +/* {{{ proto AMQPExchange::publish(string msg, [string key, [int flags, [array headers]]]); +publish into Exchange +*/ +static PHP_METHOD(amqp_exchange_class, publish) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + + zval *ini_arr = NULL; + PHP5to7_zval_t *tmp = NULL; + + amqp_channel_resource *channel_resource; + + char *key_name = NULL; PHP5to7_param_str_len_type_t key_len = 0; + char *msg = NULL; PHP5to7_param_str_len_type_t msg_len = 0; + PHP5to7_param_long_type_t flags = AMQP_NOPARAM; + +#ifndef PHP_WIN32 + /* Storage for previous signal handler during SIGPIPE override */ + void * old_handler; +#endif + + amqp_basic_properties_t props; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|sla/", + &msg, &msg_len, + &key_name, &key_len, + &flags, + &ini_arr) == FAILURE) { + return; + } + + /* By default (and for BC) content type is text/plain (may be skipped at all, then set props._flags to 0) */ + props.content_type = amqp_cstring_bytes("text/plain"); + props._flags = AMQP_BASIC_CONTENT_TYPE_FLAG; + + props.headers.entries = 0; + + { + if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF (ini_arr), "content_type", sizeof("content_type"), tmp)) { + SEPARATE_ZVAL(tmp); + convert_to_string(PHP5to7_MAYBE_DEREF(tmp)); + + if (Z_STRLEN_P(PHP5to7_MAYBE_DEREF(tmp)) > 0) { + props.content_type = amqp_cstring_bytes(Z_STRVAL_P(PHP5to7_MAYBE_DEREF(tmp))); + props._flags |= AMQP_BASIC_CONTENT_TYPE_FLAG; + } + } + + if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF (ini_arr), "content_encoding", sizeof("content_encoding"), tmp)) { + SEPARATE_ZVAL(tmp); + convert_to_string(PHP5to7_MAYBE_DEREF(tmp)); + + if (Z_STRLEN_P(PHP5to7_MAYBE_DEREF(tmp)) > 0) { + props.content_encoding = amqp_cstring_bytes(Z_STRVAL_P(PHP5to7_MAYBE_DEREF(tmp))); + props._flags |= AMQP_BASIC_CONTENT_ENCODING_FLAG; + } + } + + if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF (ini_arr), "message_id", sizeof("message_id"), tmp)) { + SEPARATE_ZVAL(tmp); + convert_to_string(PHP5to7_MAYBE_DEREF(tmp)); + + if (Z_STRLEN_P(PHP5to7_MAYBE_DEREF(tmp)) > 0) { + props.message_id = amqp_cstring_bytes(Z_STRVAL_P(PHP5to7_MAYBE_DEREF(tmp))); + props._flags |= AMQP_BASIC_MESSAGE_ID_FLAG; + } + } + + if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF (ini_arr), "user_id", sizeof("user_id"), tmp)) { + SEPARATE_ZVAL(tmp); + convert_to_string(PHP5to7_MAYBE_DEREF(tmp)); + + if (Z_STRLEN_P(PHP5to7_MAYBE_DEREF(tmp)) > 0) { + props.user_id = amqp_cstring_bytes(Z_STRVAL_P(PHP5to7_MAYBE_DEREF(tmp))); + props._flags |= AMQP_BASIC_USER_ID_FLAG; + } + } + + if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF (ini_arr), "app_id", sizeof("app_id"), tmp)) { + SEPARATE_ZVAL(tmp); + convert_to_string(PHP5to7_MAYBE_DEREF(tmp)); + + if (Z_STRLEN_P(PHP5to7_MAYBE_DEREF(tmp)) > 0) { + props.app_id = amqp_cstring_bytes(Z_STRVAL_P(PHP5to7_MAYBE_DEREF(tmp))); + props._flags |= AMQP_BASIC_APP_ID_FLAG; + } + } + + if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF (ini_arr), "delivery_mode", sizeof("delivery_mode"), tmp)) { + SEPARATE_ZVAL(tmp); + convert_to_long(PHP5to7_MAYBE_DEREF(tmp)); + + props.delivery_mode = (uint8_t)Z_LVAL_P(PHP5to7_MAYBE_DEREF(tmp)); + props._flags |= AMQP_BASIC_DELIVERY_MODE_FLAG; + } + + if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF (ini_arr), "priority", sizeof("priority"), tmp)) { + SEPARATE_ZVAL(tmp); + convert_to_long(PHP5to7_MAYBE_DEREF(tmp)); + + props.priority = (uint8_t)Z_LVAL_P(PHP5to7_MAYBE_DEREF(tmp)); + props._flags |= AMQP_BASIC_PRIORITY_FLAG; + } + + if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF (ini_arr), "timestamp", sizeof("timestamp"), tmp)) { + SEPARATE_ZVAL(tmp); + convert_to_long(PHP5to7_MAYBE_DEREF(tmp)); + + props.timestamp = (uint64_t)Z_LVAL_P(PHP5to7_MAYBE_DEREF(tmp)); + props._flags |= AMQP_BASIC_TIMESTAMP_FLAG; + } + + if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF (ini_arr), "expiration", sizeof("expiration"), tmp)) { + SEPARATE_ZVAL(tmp); + convert_to_string(PHP5to7_MAYBE_DEREF(tmp)); + + if (Z_STRLEN_P(PHP5to7_MAYBE_DEREF(tmp)) > 0) { + props.expiration = amqp_cstring_bytes(Z_STRVAL_P(PHP5to7_MAYBE_DEREF(tmp))); + props._flags |= AMQP_BASIC_EXPIRATION_FLAG; + } + } + + if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF (ini_arr), "type", sizeof("type"), tmp)) { + SEPARATE_ZVAL(tmp); + convert_to_string(PHP5to7_MAYBE_DEREF(tmp)); + + if (Z_STRLEN_P(PHP5to7_MAYBE_DEREF(tmp)) > 0) { + props.type = amqp_cstring_bytes(Z_STRVAL_P(PHP5to7_MAYBE_DEREF(tmp))); + props._flags |= AMQP_BASIC_TYPE_FLAG; + } + } + + if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF (ini_arr), "reply_to", sizeof("reply_to"), tmp)) { + SEPARATE_ZVAL(tmp); + convert_to_string(PHP5to7_MAYBE_DEREF(tmp)); + + if (Z_STRLEN_P(PHP5to7_MAYBE_DEREF(tmp)) > 0) { + props.reply_to = amqp_cstring_bytes(Z_STRVAL_P(PHP5to7_MAYBE_DEREF(tmp))); + props._flags |= AMQP_BASIC_REPLY_TO_FLAG; + } + } + if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF (ini_arr), "correlation_id", sizeof("correlation_id"), tmp)) { + SEPARATE_ZVAL(tmp); + convert_to_string(PHP5to7_MAYBE_DEREF(tmp)); + + if (Z_STRLEN_P(PHP5to7_MAYBE_DEREF(tmp)) > 0) { + props.correlation_id = amqp_cstring_bytes(Z_STRVAL_P(PHP5to7_MAYBE_DEREF(tmp))); + props._flags |= AMQP_BASIC_CORRELATION_ID_FLAG; + } + } + + } + + amqp_table_t *headers = NULL; + + if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "headers", sizeof("headers"), tmp)) { + SEPARATE_ZVAL(tmp); + convert_to_array(PHP5to7_MAYBE_DEREF(tmp)); + + headers = php_amqp_type_convert_zval_to_amqp_table(PHP5to7_MAYBE_DEREF(tmp) TSRMLS_CC); + + props._flags |= AMQP_BASIC_HEADERS_FLAG; + props.headers = *headers; + } + + channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel")); + PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not publish to exchange."); + +#ifndef PHP_WIN32 + /* Start ignoring SIGPIPE */ + old_handler = signal(SIGPIPE, SIG_IGN); +#endif + + zval *exchange_name = PHP_AMQP_READ_THIS_PROP("name"); + + /* NOTE: basic.publish is asynchronous and thus will not indicate failure if something goes wrong on the broker */ + int status = amqp_basic_publish( + channel_resource->connection_resource->connection_state, + channel_resource->channel_id, + (Z_TYPE_P(exchange_name) == IS_STRING && Z_STRLEN_P(exchange_name) > 0 ? amqp_cstring_bytes(Z_STRVAL_P(exchange_name)) : amqp_empty_bytes), /* exchange */ + (key_len > 0 ? amqp_cstring_bytes(key_name) : amqp_empty_bytes), /* routing key */ + (AMQP_MANDATORY & flags) ? 1 : 0, /* mandatory */ + (AMQP_IMMEDIATE & flags) ? 1 : 0, /* immediate */ + &props, + php_amqp_type_char_to_amqp_long(msg, msg_len) /* message body */ + ); + + if (headers) { + php_amqp_type_free_amqp_table(headers); + } + +#ifndef PHP_WIN32 + /* End ignoring of SIGPIPEs */ + signal(SIGPIPE, old_handler); +#endif + + if (status != AMQP_STATUS_OK) { + /* Emulate library error */ + amqp_rpc_reply_t res; + res.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION; + res.library_error = status; + + php_amqp_error(res, &PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource TSRMLS_CC); + + php_amqp_zend_throw_exception(res, amqp_exchange_exception_class_entry, PHP_AMQP_G(error_message), PHP_AMQP_G(error_code) TSRMLS_CC); + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + return; + } + + RETURN_TRUE; +} +/* }}} */ + + +/* {{{ proto int exchange::bind(string srcExchangeName[, string routingKey, array arguments]); +bind exchange to exchange by routing key +*/ +static PHP_METHOD(amqp_exchange_class, bind) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + + zval *zvalArguments = NULL; + + amqp_channel_resource *channel_resource; + + char *src_name; PHP5to7_param_str_len_type_t src_name_len = 0; + char *keyname; PHP5to7_param_str_len_type_t keyname_len = 0; + + amqp_table_t *arguments = NULL; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|sa", + &src_name, &src_name_len, + &keyname, &keyname_len, + &zvalArguments) == FAILURE) { + return; + } + + channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel")); + PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not bind to exchange."); + + if (zvalArguments) { + arguments = php_amqp_type_convert_zval_to_amqp_table(zvalArguments TSRMLS_CC); + } + + amqp_exchange_bind( + channel_resource->connection_resource->connection_state, + channel_resource->channel_id, + amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STR("name")), + (src_name_len > 0 ? amqp_cstring_bytes(src_name) : amqp_empty_bytes), + (keyname_len > 0 ? amqp_cstring_bytes(keyname) : amqp_empty_bytes), + (arguments ? *arguments : amqp_empty_table) + ); + + if (arguments) { + php_amqp_type_free_amqp_table(arguments); + } + + amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state); + + if (PHP_AMQP_MAYBE_ERROR(res, channel_resource)) { + php_amqp_zend_throw_exception_short(res, amqp_exchange_exception_class_entry TSRMLS_CC); + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + return; + } + + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto int exchange::unbind(string srcExchangeName[, string routingKey, array arguments]); +remove exchange to exchange binding by routing key +*/ +static PHP_METHOD(amqp_exchange_class, unbind) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + + zval *zvalArguments = NULL; + + amqp_channel_resource *channel_resource; + + char *src_name; PHP5to7_param_str_len_type_t src_name_len = 0; + char *keyname; PHP5to7_param_str_len_type_t keyname_len = 0; + + amqp_table_t *arguments = NULL; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|sa", + &src_name, &src_name_len, + &keyname, &keyname_len, + &zvalArguments) == FAILURE) { + return; + } + + channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel")); + PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not unbind from exchange."); + + if (zvalArguments) { + arguments = php_amqp_type_convert_zval_to_amqp_table(zvalArguments TSRMLS_CC); + } + + amqp_exchange_unbind( + channel_resource->connection_resource->connection_state, + channel_resource->channel_id, + amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STR("name")), + (src_name_len > 0 ? amqp_cstring_bytes(src_name) : amqp_empty_bytes), + (keyname_len > 0 ? amqp_cstring_bytes(keyname) : amqp_empty_bytes), + (arguments ? *arguments : amqp_empty_table) + ); + + if (arguments) { + php_amqp_type_free_amqp_table(arguments); + } + + amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state); + + if (PHP_AMQP_MAYBE_ERROR(res, channel_resource)) { + php_amqp_zend_throw_exception_short(res, amqp_exchange_exception_class_entry TSRMLS_CC); + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + return; + } + + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto AMQPExchange::getChannel() +Get the AMQPChannel object in use */ +static PHP_METHOD(amqp_exchange_class, getChannel) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + PHP_AMQP_RETURN_THIS_PROP("channel"); +} +/* }}} */ + +/* {{{ proto AMQPExchange::getConnection() +Get the AMQPConnection object in use */ +static PHP_METHOD(amqp_exchange_class, getConnection) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + PHP_AMQP_RETURN_THIS_PROP("connection"); +} +/* }}} */ + +/* amqp_exchange ARG_INFO definition */ +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class__construct, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) + ZEND_ARG_OBJ_INFO(0, amqp_channel, AMQPChannel, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_getName, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_setName, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) + ZEND_ARG_INFO(0, exchange_name) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_getFlags, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_setFlags, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) + ZEND_ARG_INFO(0, flags) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_getType, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_setType, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) + ZEND_ARG_INFO(0, exchange_type) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_getArgument, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) + ZEND_ARG_INFO(0, argument) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_hasArgument, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) + ZEND_ARG_INFO(0, argument) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_getArguments, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_setArgument, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 2) + ZEND_ARG_INFO(0, key) + ZEND_ARG_INFO(0, value) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_setArguments, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) + ZEND_ARG_ARRAY_INFO(0, arguments, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_declareExchange, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_bind, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 2) + ZEND_ARG_INFO(0, exchange_name) + ZEND_ARG_INFO(0, routing_key) + ZEND_ARG_INFO(0, flags) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_unbind, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 2) + ZEND_ARG_INFO(0, exchange_name) + ZEND_ARG_INFO(0, routing_key) + ZEND_ARG_INFO(0, flags) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_delete, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) + ZEND_ARG_INFO(0, exchange_name) + ZEND_ARG_INFO(0, flags) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_publish, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) + ZEND_ARG_INFO(0, message) + ZEND_ARG_INFO(0, routing_key) + ZEND_ARG_INFO(0, flags) + ZEND_ARG_ARRAY_INFO(0, headers, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_getChannel, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_getConnection, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +zend_function_entry amqp_exchange_class_functions[] = { + PHP_ME(amqp_exchange_class, __construct, arginfo_amqp_exchange_class__construct, ZEND_ACC_PUBLIC) + + PHP_ME(amqp_exchange_class, getName, arginfo_amqp_exchange_class_getName, ZEND_ACC_PUBLIC) + PHP_ME(amqp_exchange_class, setName, arginfo_amqp_exchange_class_setName, ZEND_ACC_PUBLIC) + + PHP_ME(amqp_exchange_class, getFlags, arginfo_amqp_exchange_class_getFlags, ZEND_ACC_PUBLIC) + PHP_ME(amqp_exchange_class, setFlags, arginfo_amqp_exchange_class_setFlags, ZEND_ACC_PUBLIC) + + PHP_ME(amqp_exchange_class, getType, arginfo_amqp_exchange_class_getType, ZEND_ACC_PUBLIC) + PHP_ME(amqp_exchange_class, setType, arginfo_amqp_exchange_class_setType, ZEND_ACC_PUBLIC) + + PHP_ME(amqp_exchange_class, getArgument, arginfo_amqp_exchange_class_getArgument, ZEND_ACC_PUBLIC) + PHP_ME(amqp_exchange_class, getArguments, arginfo_amqp_exchange_class_getArguments, ZEND_ACC_PUBLIC) + PHP_ME(amqp_exchange_class, setArgument, arginfo_amqp_exchange_class_setArgument, ZEND_ACC_PUBLIC) + PHP_ME(amqp_exchange_class, setArguments, arginfo_amqp_exchange_class_setArguments, ZEND_ACC_PUBLIC) + PHP_ME(amqp_exchange_class, hasArgument, arginfo_amqp_exchange_class_hasArgument, ZEND_ACC_PUBLIC) + + PHP_ME(amqp_exchange_class, declareExchange,arginfo_amqp_exchange_class_declareExchange,ZEND_ACC_PUBLIC) + PHP_ME(amqp_exchange_class, bind, arginfo_amqp_exchange_class_bind, ZEND_ACC_PUBLIC) + PHP_ME(amqp_exchange_class, unbind, arginfo_amqp_exchange_class_unbind, ZEND_ACC_PUBLIC) + PHP_ME(amqp_exchange_class, delete, arginfo_amqp_exchange_class_delete, ZEND_ACC_PUBLIC) + PHP_ME(amqp_exchange_class, publish, arginfo_amqp_exchange_class_publish, ZEND_ACC_PUBLIC) + + PHP_ME(amqp_exchange_class, getChannel, arginfo_amqp_exchange_class_getChannel, ZEND_ACC_PUBLIC) + PHP_ME(amqp_exchange_class, getConnection, arginfo_amqp_exchange_class_getConnection, ZEND_ACC_PUBLIC) + + PHP_MALIAS(amqp_exchange_class, declare, declareExchange, arginfo_amqp_exchange_class_declareExchange, ZEND_ACC_PUBLIC | ZEND_ACC_DEPRECATED) + + {NULL, NULL, NULL} +}; + +PHP_MINIT_FUNCTION(amqp_exchange) +{ + zend_class_entry ce; + + INIT_CLASS_ENTRY(ce, "AMQPExchange", amqp_exchange_class_functions); + this_ce = zend_register_internal_class(&ce TSRMLS_CC); + + zend_declare_property_null(this_ce, ZEND_STRL("connection"), ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(this_ce, ZEND_STRL("channel"), ZEND_ACC_PRIVATE TSRMLS_CC); + + zend_declare_property_stringl(this_ce, ZEND_STRL("name"), "", 0, ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(this_ce, ZEND_STRL("type"), ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_bool(this_ce, ZEND_STRL("passive"), 0, ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_bool(this_ce, ZEND_STRL("durable"), 0, ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_bool(this_ce, ZEND_STRL("auto_delete"), 0, ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_bool(this_ce, ZEND_STRL("internal"), 0, ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(this_ce, ZEND_STRL("arguments"), ZEND_ACC_PRIVATE TSRMLS_CC); + + return SUCCESS; +} +/* +*Local variables: +*tab-width: 4 +*c-basic-offset: 4 +*End: +*vim600: noet sw=4 ts=4 fdm=marker +*vim<600: noet sw=4 ts=4 +*/ diff -Nru php-amqp-1.7.1/amqp-1.9.3/amqp_exchange.h php-amqp-1.9.3/amqp-1.9.3/amqp_exchange.h --- php-amqp-1.7.1/amqp-1.9.3/amqp_exchange.h 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/amqp_exchange.h 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,35 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2007 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 | + | Lead: | + | - Pieter de Zwart | + | Maintainers: | + | - Brad Rodriguez | + | - Jonathan Tansavatdi | + +----------------------------------------------------------------------+ +*/ +extern zend_class_entry *amqp_exchange_class_entry; + + +PHP_MINIT_FUNCTION(amqp_exchange); + +/* +*Local variables: +*tab-width: 4 +*c-basic-offset: 4 +*End: +*vim600: noet sw=4 ts=4 fdm=marker +*vim<600: noet sw=4 ts=4 +*/ diff -Nru php-amqp-1.7.1/amqp-1.9.3/amqp_methods_handling.c php-amqp-1.9.3/amqp-1.9.3/amqp_methods_handling.c --- php-amqp-1.7.1/amqp-1.9.3/amqp_methods_handling.c 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/amqp_methods_handling.c 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,265 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2007 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 | + | Lead: | + | - Pieter de Zwart | + | Maintainers: | + | - Brad Rodriguez | + | - Jonathan Tansavatdi | + +----------------------------------------------------------------------+ +*/ + +#include "amqp_basic_properties.h" +#include "amqp_methods_handling.h" + +/* taken from rabbbitmq-c */ +static int amqp_id_in_reply_list(amqp_method_number_t expected, amqp_method_number_t *list) { + while (*list != 0) { + if (*list == expected) { + return 1; + } + list++; + } + + return 0; +} + +/* taken from rabbbitmq-c */ +static int amqp_simple_wait_method_list(amqp_connection_state_t state, + amqp_channel_t expected_channel, + amqp_method_number_t *expected_methods, + amqp_method_t *output) { + amqp_frame_t frame; + int res = amqp_simple_wait_frame(state, &frame); + + if (AMQP_STATUS_OK != res) { + return res; + } + + if (AMQP_FRAME_METHOD != frame.frame_type || + expected_channel != frame.channel || + !amqp_id_in_reply_list(frame.payload.method.id, expected_methods)) { + return AMQP_STATUS_WRONG_METHOD; + } + + *output = frame.payload.method; + return AMQP_STATUS_OK; +} + +/* taken from rabbbitmq-c */ +int amqp_simple_wait_method_list_noblock(amqp_connection_state_t state, + amqp_channel_t expected_channel, + amqp_method_number_t *expected_methods, + amqp_method_t *output, + struct timeval *timeout) { + amqp_frame_t frame; + int res = amqp_simple_wait_frame_noblock(state, &frame, timeout); + + if (AMQP_STATUS_OK != res) { + return res; + } + + if (AMQP_FRAME_METHOD != frame.frame_type || + expected_channel != frame.channel || + !amqp_id_in_reply_list(frame.payload.method.id, expected_methods)) { + + if (AMQP_CHANNEL_CLOSE_METHOD == frame.payload.method.id || AMQP_CONNECTION_CLOSE_METHOD == frame.payload.method.id) { + + *output = frame.payload.method; + + return AMQP_RESPONSE_SERVER_EXCEPTION; + } + + return AMQP_STATUS_WRONG_METHOD; + } + + *output = frame.payload.method; + return AMQP_STATUS_OK; +} + +/* taken from rabbbitmq-c */ +int amqp_simple_wait_method_noblock(amqp_connection_state_t state, + amqp_channel_t expected_channel, + amqp_method_number_t expected_method, + amqp_method_t *output, + struct timeval *timeout) +{ + amqp_method_number_t expected_methods[] = { 0, 0 }; + expected_methods[0] = expected_method; + + return amqp_simple_wait_method_list_noblock(state, expected_channel, expected_methods, output, timeout); +} + + +int php_amqp_handle_basic_return(char **message, amqp_connection_resource *resource, amqp_channel_t channel_id, amqp_channel_object *channel, amqp_method_t *method TSRMLS_DC) { + amqp_rpc_reply_t ret; + amqp_message_t msg; + int status = PHP_AMQP_RESOURCE_RESPONSE_OK; + + assert(AMQP_BASIC_RETURN_METHOD == method->id); + + amqp_basic_return_t *m = (amqp_basic_return_t *) method->decoded; + + ret = amqp_read_message(resource->connection_state, channel_id, &msg, 0); + + if (AMQP_RESPONSE_NORMAL != ret.reply_type) { + return php_amqp_connection_resource_error(ret, message, resource, channel_id TSRMLS_CC); + } + + if (channel->callbacks.basic_return.fci.size > 0) { + status = php_amqp_call_basic_return_callback(m, &msg, &channel->callbacks.basic_return TSRMLS_CC); + } else { + zend_error(E_NOTICE, "Unhandled basic.return method from server received. Use AMQPChannel::setBasicReturnCallback() to process it."); + status = PHP_AMQP_RESOURCE_RESPONSE_BREAK; + } + + amqp_destroy_message(&msg); + + return status; +} + +int php_amqp_call_basic_return_callback(amqp_basic_return_t *m, amqp_message_t *msg, amqp_callback_bucket *cb TSRMLS_DC) { + PHP5to7_zval_t params PHP5to7_MAYBE_SET_TO_NULL; + PHP5to7_zval_t basic_properties PHP5to7_MAYBE_SET_TO_NULL; + + int status = PHP_AMQP_RESOURCE_RESPONSE_OK; + + PHP5to7_MAYBE_INIT(params); + PHP5to7_ARRAY_INIT(params); + + PHP5to7_MAYBE_INIT(basic_properties); + + /* callback(int $reply_code, string $reply_text, string $exchange, string $routing_key, AMQPBasicProperties $properties, string $body); */ + + add_next_index_long(PHP5to7_MAYBE_PTR(params), (PHP5to7_param_long_type_t) m->reply_code); + PHP5to7_ADD_NEXT_INDEX_STRINGL_DUP(PHP5to7_MAYBE_PTR(params), (const char *) m->reply_text.bytes, (PHP5to7_param_str_len_type_t) m->reply_text.len); + PHP5to7_ADD_NEXT_INDEX_STRINGL_DUP(PHP5to7_MAYBE_PTR(params), (const char *) m->exchange.bytes, (PHP5to7_param_str_len_type_t) m->exchange.len); + PHP5to7_ADD_NEXT_INDEX_STRINGL_DUP(PHP5to7_MAYBE_PTR(params), (const char *) m->routing_key.bytes, (PHP5to7_param_str_len_type_t) m->routing_key.len); + + php_amqp_basic_properties_convert_to_zval(&msg->properties, PHP5to7_MAYBE_PTR(basic_properties) TSRMLS_CC); + add_next_index_zval(PHP5to7_MAYBE_PTR(params), PHP5to7_MAYBE_PTR(basic_properties)); + Z_ADDREF_P(PHP5to7_MAYBE_PTR(basic_properties)); + + PHP5to7_ADD_NEXT_INDEX_STRINGL_DUP(PHP5to7_MAYBE_PTR(params), (const char *) msg->body.bytes, (PHP5to7_param_str_len_type_t) msg->body.len); + + status = php_amqp_call_callback_with_params(params, cb TSRMLS_CC); + + PHP5to7_MAYBE_DESTROY(basic_properties); + + return status; +} + +int php_amqp_handle_basic_ack(char **message, amqp_connection_resource *resource, amqp_channel_t channel_id, amqp_channel_object *channel, amqp_method_t *method TSRMLS_DC) { + amqp_rpc_reply_t ret; + int status = PHP_AMQP_RESOURCE_RESPONSE_OK; + + assert(AMQP_BASIC_ACK_METHOD == method->id); + + amqp_basic_ack_t *m = (amqp_basic_ack_t *) method->decoded; + + if (channel->callbacks.basic_ack.fci.size > 0) { + status = php_amqp_call_basic_ack_callback(m, &channel->callbacks.basic_ack TSRMLS_CC); + } else { + zend_error(E_NOTICE, "Unhandled basic.ack method from server received. Use AMQPChannel::setConfirmCallback() to process it."); + status = PHP_AMQP_RESOURCE_RESPONSE_BREAK; + } + + return status; +} + +int php_amqp_call_basic_ack_callback(amqp_basic_ack_t *m, amqp_callback_bucket *cb TSRMLS_DC) { + PHP5to7_zval_t params PHP5to7_MAYBE_SET_TO_NULL; + + PHP5to7_MAYBE_INIT(params); + PHP5to7_ARRAY_INIT(params); + + /* callback(int $delivery_tag, bool $multiple); */ + add_next_index_long(PHP5to7_MAYBE_PTR(params), (PHP5to7_param_long_type_t) m->delivery_tag); + add_next_index_bool(PHP5to7_MAYBE_PTR(params), m->multiple); + + return php_amqp_call_callback_with_params(params, cb TSRMLS_CC); +} + +int php_amqp_handle_basic_nack(char **message, amqp_connection_resource *resource, amqp_channel_t channel_id, amqp_channel_object *channel, amqp_method_t *method TSRMLS_DC) { + amqp_rpc_reply_t ret; + int status = PHP_AMQP_RESOURCE_RESPONSE_OK; + + assert(AMQP_BASIC_NACK_METHOD == method->id); + + amqp_basic_nack_t *m = (amqp_basic_nack_t *) method->decoded; + + if (channel->callbacks.basic_nack.fci.size > 0) { + status = php_amqp_call_basic_nack_callback(m, &channel->callbacks.basic_nack TSRMLS_CC); + } else { + zend_error(E_NOTICE, "Unhandled basic.nack method from server received. Use AMQPChannel::setConfirmCallback() to process it."); + status = PHP_AMQP_RESOURCE_RESPONSE_BREAK; + } + + return status; +} + +int php_amqp_call_basic_nack_callback(amqp_basic_nack_t *m, amqp_callback_bucket *cb TSRMLS_DC) { + PHP5to7_zval_t params PHP5to7_MAYBE_SET_TO_NULL; + + PHP5to7_MAYBE_INIT(params); + PHP5to7_ARRAY_INIT(params); + + /* callback(int $delivery_tag, bool $multiple, bool $requeue); */ + add_next_index_long(PHP5to7_MAYBE_PTR(params), (PHP5to7_param_long_type_t) m->delivery_tag); + add_next_index_bool(PHP5to7_MAYBE_PTR(params), m->multiple); + add_next_index_bool(PHP5to7_MAYBE_PTR(params), m->requeue); + + return php_amqp_call_callback_with_params(params, cb TSRMLS_CC); +} + +int php_amqp_call_callback_with_params(PHP5to7_zval_t params, amqp_callback_bucket *cb TSRMLS_DC) +{ + zval retval; + zval *retval_ptr = &retval; + + int status = PHP_AMQP_RESOURCE_RESPONSE_OK; + + ZVAL_NULL(&retval); + + /* Convert everything to be callable */ + zend_fcall_info_args(&cb->fci, PHP5to7_MAYBE_PTR(params) TSRMLS_CC); + + /* Initialize the return value pointer */ + PHP5to7_SET_FCI_RETVAL_PTR(cb->fci, retval_ptr); + + zend_call_function(&cb->fci, &cb->fcc TSRMLS_CC); + + /* Check if user land function wants to bail */ + if (EG(exception) || PHP5to7_IS_FALSE_P(retval_ptr)) { + status = PHP_AMQP_RESOURCE_RESPONSE_BREAK; + } + + /* Clean up our mess */ + zend_fcall_info_args_clear(&cb->fci, 1); + PHP5to7_MAYBE_DESTROY(params); + PHP5to7_MAYBE_DESTROY2(retval, retval_ptr); + + return status; +} + + +/* +*Local variables: +*tab-width: 4 +*c-basic-offset: 4 +*End: +*vim600: noet sw=4 ts=4 fdm=marker +*vim<600: noet sw=4 ts=4 +*/ diff -Nru php-amqp-1.7.1/amqp-1.9.3/amqp_methods_handling.h php-amqp-1.9.3/amqp-1.9.3/amqp_methods_handling.h --- php-amqp-1.7.1/amqp-1.9.3/amqp_methods_handling.h 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/amqp_methods_handling.h 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,62 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2007 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 | + | Lead: | + | - Pieter de Zwart | + | Maintainers: | + | - Brad Rodriguez | + | - Jonathan Tansavatdi | + +----------------------------------------------------------------------+ +*/ +#ifndef PHP_AMQP_METHODS_HANDLING_H +#define PHP_AMQP_METHODS_HANDLING_H + +#include "php_amqp.h" +#include "amqp.h" +#include "php.h" + +int amqp_simple_wait_method_list_noblock(amqp_connection_state_t state, + amqp_channel_t expected_channel, + amqp_method_number_t *expected_methods, + amqp_method_t *output, + struct timeval *timeout); + +int amqp_simple_wait_method_noblock(amqp_connection_state_t state, + amqp_channel_t expected_channel, + amqp_method_number_t expected_method, + amqp_method_t *output, + struct timeval *timeout); + +int php_amqp_call_callback_with_params(PHP5to7_zval_t params, amqp_callback_bucket *cb TSRMLS_DC); + +int php_amqp_call_basic_return_callback(amqp_basic_return_t *m, amqp_message_t *msg, amqp_callback_bucket *cb TSRMLS_DC); +int php_amqp_handle_basic_return(char **message, amqp_connection_resource *resource, amqp_channel_t channel_id, amqp_channel_object *channel, amqp_method_t *method TSRMLS_DC); + +int php_amqp_call_basic_ack_callback(amqp_basic_ack_t *m, amqp_callback_bucket *cb TSRMLS_DC); +int php_amqp_handle_basic_ack(char **message, amqp_connection_resource *resource, amqp_channel_t channel_id, amqp_channel_object *channel, amqp_method_t *method TSRMLS_DC); + +int php_amqp_call_basic_nack_callback(amqp_basic_nack_t *m, amqp_callback_bucket *cb TSRMLS_DC); +int php_amqp_handle_basic_nack(char **message, amqp_connection_resource *resource, amqp_channel_t channel_id, amqp_channel_object *channel, amqp_method_t *method TSRMLS_DC); + +#endif + +/* +*Local variables: +*tab-width: 4 +*c-basic-offset: 4 +*End: +*vim600: noet sw=4 ts=4 fdm=marker +*vim<600: noet sw=4 ts=4 +*/ diff -Nru php-amqp-1.7.1/amqp-1.9.3/amqp_queue.c php-amqp-1.9.3/amqp-1.9.3/amqp_queue.c --- php-amqp-1.7.1/amqp-1.9.3/amqp_queue.c 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/amqp_queue.c 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,1299 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2007 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 | + | Lead: | + | - Pieter de Zwart | + | Maintainers: | + | - Brad Rodriguez | + | - Jonathan Tansavatdi | + +----------------------------------------------------------------------+ +*/ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "php.h" +#include "php_ini.h" +#include "ext/standard/info.h" +#include "zend_exceptions.h" + +#ifdef PHP_WIN32 +# include "win32/php_stdint.h" +# include "win32/signal.h" +#else +# include +# include +#endif +#include +#include + +#ifdef PHP_WIN32 +# include "win32/unistd.h" +#else +# include +#endif + +#include "php_amqp.h" +#include "amqp_envelope.h" +#include "amqp_connection.h" +#include "amqp_channel.h" +#include "amqp_queue.h" +#include "amqp_type.h" + +zend_class_entry *amqp_queue_class_entry; +#define this_ce amqp_queue_class_entry + + +/* {{{ proto AMQPQueue::__construct(AMQPChannel channel) +AMQPQueue constructor +*/ +static PHP_METHOD(amqp_queue_class, __construct) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + + PHP5to7_zval_t arguments PHP5to7_MAYBE_SET_TO_NULL; + + zval *channelObj; + amqp_channel_resource *channel_resource; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &channelObj) == FAILURE) { + return; + } + + PHP5to7_MAYBE_INIT(arguments); + PHP5to7_ARRAY_INIT(arguments); + zend_update_property(this_ce, getThis(), ZEND_STRL("arguments"), PHP5to7_MAYBE_PTR(arguments) TSRMLS_CC); + PHP5to7_MAYBE_DESTROY(arguments); + + channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(channelObj); + PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not create queue."); + + zend_update_property(this_ce, getThis(), ZEND_STRL("channel"), channelObj TSRMLS_CC); + zend_update_property(this_ce, getThis(), ZEND_STRL("connection"), PHP_AMQP_READ_OBJ_PROP(amqp_channel_class_entry, channelObj, "connection") TSRMLS_CC); + +} +/* }}} */ + + +/* {{{ proto AMQPQueue::getName() +Get the queue name */ +static PHP_METHOD(amqp_queue_class, getName) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + + PHP_AMQP_NOPARAMS(); + + if (PHP_AMQP_READ_THIS_PROP_STRLEN("name") > 0) { + PHP_AMQP_RETURN_THIS_PROP("name"); + } else { + /* BC */ + RETURN_FALSE; + } +} +/* }}} */ + + +/* {{{ proto AMQPQueue::setName(string name) +Set the queue name */ +static PHP_METHOD(amqp_queue_class, setName) +{ + char *name = NULL; PHP5to7_param_str_len_type_t name_len = 0; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) { + return; + } + + if (name_len < 1 || name_len > 255) { + /* Verify that the name is not null and not an empty string */ + zend_throw_exception(amqp_queue_exception_class_entry, "Invalid queue name given, must be between 1 and 255 characters long.", 0 TSRMLS_CC); + return; + } + + /* Set the queue name */ + zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("name"), name, name_len TSRMLS_CC); + + /* BC */ + RETURN_TRUE; +} +/* }}} */ + + + +/* {{{ proto AMQPQueue::getFlags() +Get the queue parameters */ +static PHP_METHOD(amqp_queue_class, getFlags) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + + PHP5to7_param_long_type_t flagBitmask = 0; + + PHP_AMQP_NOPARAMS(); + + if (PHP_AMQP_READ_THIS_PROP_BOOL("passive")) { + flagBitmask |= AMQP_PASSIVE; + } + + if (PHP_AMQP_READ_THIS_PROP_BOOL("durable")) { + flagBitmask |= AMQP_DURABLE; + } + + if (PHP_AMQP_READ_THIS_PROP_BOOL("exclusive")) { + flagBitmask |= AMQP_EXCLUSIVE; + } + + if (PHP_AMQP_READ_THIS_PROP_BOOL("auto_delete")) { + flagBitmask |= AMQP_AUTODELETE; + } + + RETURN_LONG(flagBitmask); +} +/* }}} */ + + +/* {{{ proto AMQPQueue::setFlags(long bitmask) +Set the queue parameters */ +static PHP_METHOD(amqp_queue_class, setFlags) +{ + PHP5to7_param_long_type_t flagBitmask; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &flagBitmask) == FAILURE) { + return; + } + + /* Set the flags based on the bitmask we were given */ + flagBitmask = flagBitmask ? flagBitmask & PHP_AMQP_QUEUE_FLAGS : flagBitmask; + + zend_update_property_bool(this_ce, getThis(), ZEND_STRL("passive"), IS_PASSIVE(flagBitmask) TSRMLS_CC); + zend_update_property_bool(this_ce, getThis(), ZEND_STRL("durable"), IS_DURABLE(flagBitmask) TSRMLS_CC); + zend_update_property_bool(this_ce, getThis(), ZEND_STRL("exclusive"), IS_EXCLUSIVE(flagBitmask) TSRMLS_CC); + zend_update_property_bool(this_ce, getThis(), ZEND_STRL("auto_delete"), IS_AUTODELETE(flagBitmask) TSRMLS_CC); + + /* BC */ + RETURN_TRUE; +} +/* }}} */ + + +/* {{{ proto AMQPQueue::getArgument(string key) +Get the queue argument referenced by key */ +static PHP_METHOD(amqp_queue_class, getArgument) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + + PHP5to7_zval_t *tmp = NULL; + + char *key; PHP5to7_param_str_len_type_t key_len; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &key, &key_len) == FAILURE) { + return; + } + + if (!PHP5to7_ZEND_HASH_FIND(PHP_AMQP_READ_THIS_PROP_ARR("arguments"), key, (uint)(key_len + 1), tmp)) { + RETURN_FALSE; + } + + RETURN_ZVAL(PHP5to7_MAYBE_DEREF(tmp), 1, 0); +} +/* }}} */ + +/* {{{ proto AMQPQueue::hasArgument(string key) */ +static PHP_METHOD(amqp_queue_class, hasArgument) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + + PHP5to7_zval_t *tmp = NULL; + + char *key; PHP5to7_param_str_len_type_t key_len; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &key, &key_len) == FAILURE) { + return; + } + + if (!PHP5to7_ZEND_HASH_FIND(PHP_AMQP_READ_THIS_PROP_ARR("arguments"), key, (uint)(key_len + 1), tmp)) { + RETURN_FALSE; + } + + RETURN_TRUE; +} +/* }}} */ + + +/* {{{ proto AMQPQueue::getArguments +Get the queue arguments */ +static PHP_METHOD(amqp_queue_class, getArguments) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + PHP_AMQP_RETURN_THIS_PROP("arguments"); +} +/* }}} */ + +/* {{{ proto AMQPQueue::setArguments(array args) +Overwrite all queue arguments with given args */ +static PHP_METHOD(amqp_queue_class, setArguments) +{ + zval *zvalArguments; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/", &zvalArguments) == FAILURE) { + return; + } + + zend_update_property(this_ce, getThis(), ZEND_STRL("arguments"), zvalArguments TSRMLS_CC); + + RETURN_TRUE; +} +/* }}} */ + + +/* {{{ proto AMQPQueue::setArgument(key, value) +Get the queue name */ +static PHP_METHOD(amqp_queue_class, setArgument) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + + char *key= NULL; PHP5to7_param_str_len_type_t key_len = 0; + zval *value = NULL; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz", + &key, &key_len, + &value) == FAILURE) { + return; + } + + switch (Z_TYPE_P(value)) { + case IS_NULL: + PHP5to7_ZEND_HASH_DEL(PHP_AMQP_READ_THIS_PROP_ARR("arguments"), key, (uint) (key_len + 1)); + break; + PHP5to7_CASE_IS_BOOL: + case IS_LONG: + case IS_DOUBLE: + case IS_STRING: + PHP5to7_ZEND_HASH_ADD(PHP_AMQP_READ_THIS_PROP_ARR("arguments"), key, (uint) (key_len + 1), value, sizeof(zval *)); + Z_TRY_ADDREF_P(value); + break; + default: + zend_throw_exception(amqp_exchange_exception_class_entry, "The value parameter must be of type NULL, int, double or string.", 0 TSRMLS_CC); + return; + } + + RETURN_TRUE; +} +/* }}} */ + + +/* {{{ proto int AMQPQueue::declareQueue(); +declare queue +*/ +static PHP_METHOD(amqp_queue_class, declareQueue) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + + amqp_channel_resource *channel_resource; + + char *name; + amqp_table_t *arguments; + PHP5to7_param_long_type_t message_count; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + + channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel")); + PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not declare queue."); + + arguments = php_amqp_type_convert_zval_to_amqp_table(PHP_AMQP_READ_THIS_PROP("arguments") TSRMLS_CC); + + amqp_queue_declare_ok_t *r = amqp_queue_declare( + channel_resource->connection_resource->connection_state, + channel_resource->channel_id, + amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STR("name")), + PHP_AMQP_READ_THIS_PROP_BOOL("passive"), + PHP_AMQP_READ_THIS_PROP_BOOL("durable"), + PHP_AMQP_READ_THIS_PROP_BOOL("exclusive"), + PHP_AMQP_READ_THIS_PROP_BOOL("auto_delete"), + *arguments + ); + + php_amqp_type_free_amqp_table(arguments); + + if (!r) { + amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state); + + php_amqp_error(res, &PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource TSRMLS_CC); + + php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, PHP_AMQP_G(error_message), PHP_AMQP_G(error_code) TSRMLS_CC); + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + return; + } + + message_count = r->message_count; + + /* Set the queue name, in case it is an autogenerated queue name */ + name = php_amqp_type_amqp_bytes_to_char(r->queue); + zend_update_property_string(this_ce, getThis(), ZEND_STRL("name"), name TSRMLS_CC); + efree(name); + + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + + RETURN_LONG(message_count); +} +/* }}} */ + + +/* {{{ proto int AMQPQueue::bind(string exchangeName, [string routingKey, array arguments]); +bind queue to exchange by routing key +*/ +static PHP_METHOD(amqp_queue_class, bind) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + + zval *zvalArguments = NULL; + + amqp_channel_resource *channel_resource; + + char *exchange_name; PHP5to7_param_str_len_type_t exchange_name_len; + char *keyname = NULL; PHP5to7_param_str_len_type_t keyname_len = 0; + + amqp_table_t *arguments = NULL; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|sa", + &exchange_name, &exchange_name_len, + &keyname, &keyname_len, + &zvalArguments) == FAILURE) { + return; + } + + channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel")); + PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not bind queue."); + + if (zvalArguments) { + arguments = php_amqp_type_convert_zval_to_amqp_table(zvalArguments TSRMLS_CC); + } + + amqp_queue_bind( + channel_resource->connection_resource->connection_state, + channel_resource->channel_id, + amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STR("name")), + (exchange_name_len > 0 ? amqp_cstring_bytes(exchange_name) : amqp_empty_bytes), + (keyname_len > 0 ? amqp_cstring_bytes(keyname) : amqp_empty_bytes), + (arguments ? *arguments : amqp_empty_table) + ); + + if (arguments) { + php_amqp_type_free_amqp_table(arguments); + } + + amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state); + + if (PHP_AMQP_MAYBE_ERROR(res, channel_resource)) { + php_amqp_zend_throw_exception_short(res, amqp_queue_exception_class_entry TSRMLS_CC); + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + return; + } + + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + + RETURN_TRUE; +} +/* }}} */ + + +/* {{{ proto int AMQPQueue::get([bit flags=AMQP_NOPARAM]); +read messages from queue +return array (messages) +*/ +static PHP_METHOD(amqp_queue_class, get) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + + amqp_channel_resource *channel_resource; + + PHP5to7_zval_t message PHP5to7_MAYBE_SET_TO_NULL; + PHP5to7_zval_t retval PHP5to7_MAYBE_SET_TO_NULL; + + PHP5to7_param_long_type_t flags = INI_INT("amqp.auto_ack") ? AMQP_AUTOACK : AMQP_NOPARAM; + + /* Parse out the method parameters */ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &flags) == FAILURE) { + return; + } + + channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel")); + PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not get messages from queue."); + + amqp_rpc_reply_t res = amqp_basic_get( + channel_resource->connection_resource->connection_state, + channel_resource->channel_id, + amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STR("name")), + (AMQP_AUTOACK & flags) ? 1 : 0 + ); + + if (PHP_AMQP_MAYBE_ERROR(res, channel_resource)) { + php_amqp_zend_throw_exception_short(res, amqp_queue_exception_class_entry TSRMLS_CC); + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + return; + } + + if (AMQP_BASIC_GET_EMPTY_METHOD == res.reply.id) { + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + RETURN_FALSE; + } + + assert(AMQP_BASIC_GET_OK_METHOD == res.reply.id); + + /* Fill the envelope from response */ + amqp_basic_get_ok_t *get_ok_method = res.reply.decoded; + + amqp_envelope_t envelope; + + envelope.channel = channel_resource->channel_id; + envelope.consumer_tag = amqp_empty_bytes; + envelope.delivery_tag = get_ok_method->delivery_tag; + envelope.redelivered = get_ok_method->redelivered; + envelope.exchange = amqp_bytes_malloc_dup(get_ok_method->exchange); + envelope.routing_key = amqp_bytes_malloc_dup(get_ok_method->routing_key); + + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + + res = amqp_read_message( + channel_resource->connection_resource->connection_state, + channel_resource->channel_id, + &envelope.message, + 0 + ); + + if (PHP_AMQP_MAYBE_ERROR(res, channel_resource)) { + php_amqp_zend_throw_exception_short(res, amqp_queue_exception_class_entry TSRMLS_CC); + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + amqp_destroy_envelope(&envelope); + return; + } + + PHP5to7_MAYBE_INIT(message); + + convert_amqp_envelope_to_zval(&envelope, PHP5to7_MAYBE_PTR(message) TSRMLS_CC); + + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + amqp_destroy_envelope(&envelope); + + RETVAL_ZVAL(PHP5to7_MAYBE_PTR(message), 1, 0); + PHP5to7_MAYBE_DESTROY(message); +} +/* }}} */ + + +/* {{{ proto array AMQPQueue::consume([callback, flags = , consumer_tag]); +consume the message +*/ +static PHP_METHOD(amqp_queue_class, consume) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + + PHP5to7_zval_t *consumer_tag_zv = NULL; + PHP5to7_zval_t current_channel_zv PHP5to7_MAYBE_SET_TO_NULL; + + PHP5to7_zval_t *current_queue_zv = NULL; + + amqp_channel_resource *channel_resource; + amqp_channel_resource *current_channel_resource; + + zend_fcall_info fci = empty_fcall_info; + zend_fcall_info_cache fci_cache = empty_fcall_info_cache; + + amqp_table_t *arguments; + + char *consumer_tag = NULL; PHP5to7_param_str_len_type_t consumer_tag_len = 0; + PHP5to7_param_long_type_t flags = INI_INT("amqp.auto_ack") ? AMQP_AUTOACK : AMQP_NOPARAM; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|f!ls", + &fci, &fci_cache, + &flags, + &consumer_tag, &consumer_tag_len) == FAILURE) { + return; + } + + zval *channel_zv = PHP_AMQP_READ_THIS_PROP("channel"); + zval *consumers = zend_read_property(amqp_channel_class_entry, channel_zv, ZEND_STRL("consumers"), 0 PHP5to7_READ_PROP_RV_PARAM_CC TSRMLS_CC); + + if (IS_ARRAY != Z_TYPE_P(consumers)) { + zend_throw_exception(amqp_queue_exception_class_entry, "Invalid channel consumers, forgot to call channel constructor?", 0 TSRMLS_CC); + return; + } + + amqp_channel_object *channel = PHP_AMQP_GET_CHANNEL(channel_zv); + + channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(channel_zv); + PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not get channel."); + + if (!(AMQP_JUST_CONSUME & flags)) { + /* Setup the consume */ + arguments = php_amqp_type_convert_zval_to_amqp_table(PHP_AMQP_READ_THIS_PROP("arguments") TSRMLS_CC); + + amqp_basic_consume_ok_t *r = amqp_basic_consume( + channel_resource->connection_resource->connection_state, + channel_resource->channel_id, + amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STR("name")), + (consumer_tag_len > 0 ? amqp_cstring_bytes(consumer_tag) : amqp_empty_bytes), /* Consumer tag */ + (AMQP_NOLOCAL & flags) ? 1 : 0, /* No local */ + (AMQP_AUTOACK & flags) ? 1 : 0, /* no_ack, aka AUTOACK */ + PHP_AMQP_READ_THIS_PROP_BOOL("exclusive"), + *arguments + ); + + php_amqp_type_free_amqp_table(arguments); + + if (!r) { + amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state); + + php_amqp_error(res, &PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource TSRMLS_CC); + + zend_throw_exception(amqp_queue_exception_class_entry, PHP_AMQP_G(error_message), PHP_AMQP_G(error_code) TSRMLS_CC); + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + return; + } + + char *key; + key = estrndup((char *) r->consumer_tag.bytes, (uint) r->consumer_tag.len); + + if (PHP5to7_ZEND_HASH_FIND(Z_ARRVAL_P(consumers), (const char *) key, PHP5to7_ZEND_HASH_STRLEN(r->consumer_tag.len), consumer_tag_zv)) { + // This should never happen as AMQP server guarantees that consumer tag is unique within channel + zend_throw_exception(amqp_exception_class_entry, "Duplicate consumer tag", 0 TSRMLS_CC); + efree(key); + return; + } + + PHP5to7_zval_t tmp PHP5to7_MAYBE_SET_TO_NULL; + +#if PHP_MAJOR_VERSION >= 7 + PHP5to7_MAYBE_INIT(tmp); + ZVAL_COPY(PHP5to7_MAYBE_PTR(tmp), getThis()); +#else + tmp = getThis(); + Z_ADDREF_P(tmp); +#endif + + PHP5to7_ZEND_HASH_ADD(Z_ARRVAL_P(consumers), + (const char *) key, + PHP5to7_ZEND_HASH_STRLEN(r->consumer_tag.len), + PHP5to7_MAYBE_PTR(tmp), + sizeof(PHP5to7_MAYBE_PTR_TYPE) + ); + + efree(key); + + /* Set the consumer tag name, in case it is an autogenerated consumer tag name */ + zend_update_property_stringl(this_ce, getThis(), ZEND_STRL("consumer_tag"), (const char *) r->consumer_tag.bytes, (PHP5to7_param_str_len_type_t) r->consumer_tag.len TSRMLS_CC); + } + + if (!ZEND_FCI_INITIALIZED(fci)) { + /* Callback not set, we have nothing to do - real consuming may happens later */ + return; + } + + struct timeval tv = {0}; + struct timeval *tv_ptr = &tv; + + double read_timeout = PHP_AMQP_READ_OBJ_PROP_DOUBLE(amqp_connection_class_entry, PHP_AMQP_READ_THIS_PROP("connection"), "read_timeout"); + + if (read_timeout > 0) { + tv.tv_sec = (long int) read_timeout; + tv.tv_usec = (long int) ((read_timeout - tv.tv_sec) * 1000000); + } else { + tv_ptr = NULL; + } + + while(1) { + /* Initialize the message */ + PHP5to7_zval_t message PHP5to7_MAYBE_SET_TO_NULL; + + amqp_envelope_t envelope; + + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + + amqp_rpc_reply_t res = amqp_consume_message(channel_resource->connection_resource->connection_state, &envelope, tv_ptr, 0); + + if (AMQP_RESPONSE_LIBRARY_EXCEPTION == res.reply_type && AMQP_STATUS_TIMEOUT == res.library_error) { + zend_throw_exception(amqp_queue_exception_class_entry, "Consumer timeout exceed", 0 TSRMLS_CC); + + amqp_destroy_envelope(&envelope); + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + return; + } + + if (PHP_AMQP_MAYBE_ERROR_RECOVERABLE(res, channel_resource)) { + + if (PHP_AMQP_IS_ERROR_RECOVERABLE(res, channel_resource, channel)) { + /* In case no message was received, continue the loop */ + amqp_destroy_envelope(&envelope); + + continue; + } else { + /* Mark connection resource as closed to prevent sending any further requests */ + channel_resource->connection_resource->is_connected = '\0'; + + /* Close connection with all its channels */ + php_amqp_disconnect_force(channel_resource->connection_resource TSRMLS_CC); + } + + php_amqp_zend_throw_exception_short(res, amqp_queue_exception_class_entry TSRMLS_CC); + + amqp_destroy_envelope(&envelope); + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + + return; + } + + PHP5to7_MAYBE_INIT(message); + convert_amqp_envelope_to_zval(&envelope, PHP5to7_MAYBE_PTR(message) TSRMLS_CC); + + current_channel_resource = channel_resource->connection_resource->slots[envelope.channel - 1]; + + if (!current_channel_resource) { + // This should never happen, but just in case + php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, "Orphaned channel. Please, report a bug.", 0 TSRMLS_CC); + amqp_destroy_envelope(&envelope); + break; + } + +#if PHP_MAJOR_VERSION >= 7 + PHP5to7_MAYBE_INIT(current_channel_zv); + ZVAL_OBJ(¤t_channel_zv, ¤t_channel_resource->parent->zo); +#else + current_channel_zv = current_channel_resource->parent->this_ptr; +#endif + + consumers = zend_read_property(amqp_channel_class_entry, PHP5to7_MAYBE_PTR(current_channel_zv), ZEND_STRL("consumers"), 0 PHP5to7_READ_PROP_RV_PARAM_CC TSRMLS_CC); + + if (IS_ARRAY != Z_TYPE_P(consumers)) { + zend_throw_exception(amqp_queue_exception_class_entry, "Invalid channel consumers, forgot to call channel constructor?", 0 TSRMLS_CC); + amqp_destroy_envelope(&envelope); + break; + } + + char *key; + key = estrndup((char *)envelope.consumer_tag.bytes, (uint) envelope.consumer_tag.len); + + if (!PHP5to7_ZEND_HASH_FIND(Z_ARRVAL_P(consumers), key, PHP5to7_ZEND_HASH_STRLEN(envelope.consumer_tag.len), current_queue_zv)) { + PHP5to7_zval_t exception PHP5to7_MAYBE_SET_TO_NULL; + PHP5to7_MAYBE_INIT(exception); + object_init_ex(PHP5to7_MAYBE_PTR(exception), amqp_envelope_exception_class_entry); + zend_update_property_string(zend_exception_get_default(TSRMLS_C), PHP5to7_MAYBE_PTR(exception), ZEND_STRL("message"), "Orphaned envelope" TSRMLS_CC); + zend_update_property(amqp_envelope_exception_class_entry, PHP5to7_MAYBE_PTR(exception), ZEND_STRL("envelope"), PHP5to7_MAYBE_PTR(message) TSRMLS_CC); + + zend_throw_exception_object(PHP5to7_MAYBE_PTR(exception) TSRMLS_CC); + + PHP5to7_MAYBE_DESTROY(message); + + amqp_destroy_envelope(&envelope); + efree(key); + break; + } + + efree(key); + amqp_destroy_envelope(&envelope); + + /* Make the callback */ + PHP5to7_zval_t params PHP5to7_MAYBE_SET_TO_NULL; + PHP5to7_zval_t retval PHP5to7_MAYBE_SET_TO_NULL; + + /* Build the parameter array */ + PHP5to7_MAYBE_INIT(params); + PHP5to7_ARRAY_INIT(params); + + /* Dump it into the params array */ + add_index_zval(PHP5to7_MAYBE_PTR(params), 0, PHP5to7_MAYBE_PTR(message)); + Z_ADDREF_P( PHP5to7_MAYBE_PTR(message)); + + /* Add a pointer to the queue: */ + add_index_zval(PHP5to7_MAYBE_PTR(params), 1, PHP5to7_MAYBE_DEREF(current_queue_zv)); + Z_ADDREF_P(PHP5to7_MAYBE_DEREF(current_queue_zv)); + + + /* Convert everything to be callable */ + zend_fcall_info_args(&fci, PHP5to7_MAYBE_PTR(params) TSRMLS_CC); + /* Initialize the return value pointer */ + + PHP5to7_SET_FCI_RETVAL_PTR(fci, PHP5to7_MAYBE_PTR(retval)); + + /* Call the function, and track the return value */ + if (zend_call_function(&fci, &fci_cache TSRMLS_CC) == SUCCESS && PHP5to7_CHECK_FCI_RETVAL_PTR(fci)) { + RETVAL_ZVAL(PHP5to7_MAYBE_PTR(retval), 1, 1); + } + + /* Clean up our mess */ + zend_fcall_info_args_clear(&fci, 1); + PHP5to7_MAYBE_DESTROY(params); + PHP5to7_MAYBE_DESTROY(message); + + /* Check if user land function wants to bail */ + if (EG(exception) || PHP5to7_IS_FALSE_P(return_value)) { + break; + } + } + + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + return; +} +/* }}} */ + + +/* {{{ proto int AMQPQueue::ack(long deliveryTag, [bit flags=AMQP_NOPARAM]); + acknowledge the message +*/ +static PHP_METHOD(amqp_queue_class, ack) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + + amqp_channel_resource *channel_resource; + + PHP5to7_param_long_type_t deliveryTag = 0; + PHP5to7_param_long_type_t flags = AMQP_NOPARAM; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|l", &deliveryTag, &flags ) == FAILURE) { + return; + } + + channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel")); + PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not ack message."); + + /* NOTE: basic.ack is asynchronous and thus will not indicate failure if something goes wrong on the broker */ + int status = amqp_basic_ack( + channel_resource->connection_resource->connection_state, + channel_resource->channel_id, + (uint64_t) deliveryTag, + (AMQP_MULTIPLE & flags) ? 1 : 0 + ); + + if (status != AMQP_STATUS_OK) { + /* Emulate library error */ + amqp_rpc_reply_t res; + res.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION; + res.library_error = status; + + php_amqp_error(res, &PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource TSRMLS_CC); + + php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, PHP_AMQP_G(error_message), PHP_AMQP_G(error_code) TSRMLS_CC); + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + return; + } + + RETURN_TRUE; +} +/* }}} */ + + +/* {{{ proto int AMQPQueue::nack(long deliveryTag, [bit flags=AMQP_NOPARAM]); + acknowledge the message +*/ +static PHP_METHOD(amqp_queue_class, nack) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + + amqp_channel_resource *channel_resource; + + PHP5to7_param_long_type_t deliveryTag = 0; + PHP5to7_param_long_type_t flags = AMQP_NOPARAM; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|l", &deliveryTag, &flags ) == FAILURE) { + return; + } + + channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel")); + PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not nack message."); + + /* NOTE: basic.nack is asynchronous and thus will not indicate failure if something goes wrong on the broker */ + int status = amqp_basic_nack( + channel_resource->connection_resource->connection_state, + channel_resource->channel_id, + (uint64_t) deliveryTag, + (AMQP_MULTIPLE & flags) ? 1 : 0, + (AMQP_REQUEUE & flags) ? 1 : 0 + ); + + if (status != AMQP_STATUS_OK) { + /* Emulate library error */ + amqp_rpc_reply_t res; + res.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION; + res.library_error = status; + + php_amqp_error(res, &PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource TSRMLS_CC); + + php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, PHP_AMQP_G(error_message), PHP_AMQP_G(error_code) TSRMLS_CC); + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + return; + } + + RETURN_TRUE; +} +/* }}} */ + + +/* {{{ proto int AMQPQueue::reject(long deliveryTag, [bit flags=AMQP_NOPARAM]); + acknowledge the message +*/ +static PHP_METHOD(amqp_queue_class, reject) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + + amqp_channel_resource *channel_resource; + + PHP5to7_param_long_type_t deliveryTag = 0; + PHP5to7_param_long_type_t flags = AMQP_NOPARAM; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|l", &deliveryTag, &flags) == FAILURE) { + return; + } + + channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel")); + PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not reject message."); + + /* NOTE: basic.reject is asynchronous and thus will not indicate failure if something goes wrong on the broker */ + int status = amqp_basic_reject( + channel_resource->connection_resource->connection_state, + channel_resource->channel_id, + (uint64_t) deliveryTag, + (AMQP_REQUEUE & flags) ? 1 : 0 + ); + + if (status != AMQP_STATUS_OK) { + /* Emulate library error */ + amqp_rpc_reply_t res; + res.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION; + res.library_error = status; + + php_amqp_error(res, &PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource TSRMLS_CC); + + php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, PHP_AMQP_G(error_message), PHP_AMQP_G(error_code) TSRMLS_CC); + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + return; + } + + RETURN_TRUE; +} +/* }}} */ + + +/* {{{ proto int AMQPQueue::purge(); +purge queue +*/ +static PHP_METHOD(amqp_queue_class, purge) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + + amqp_channel_resource *channel_resource; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + + channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel")); + PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not purge queue."); + + amqp_queue_purge_ok_t *r = amqp_queue_purge( + channel_resource->connection_resource->connection_state, + channel_resource->channel_id, + amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STR("name")) + ); + + if (!r) { + amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state); + + php_amqp_error(res, &PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource TSRMLS_CC); + + php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, PHP_AMQP_G(error_message), PHP_AMQP_G(error_code) TSRMLS_CC); + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + return; + } + + /* long message_count = r->message_count; */ + + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + + /* RETURN_LONG(message_count) */; + + /* BC */ + RETURN_TRUE; +} +/* }}} */ + + +/* {{{ proto int AMQPQueue::cancel([string consumer_tag]); +cancel queue to consumer +*/ +static PHP_METHOD(amqp_queue_class, cancel) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + + amqp_channel_resource *channel_resource; + PHP5to7_zval_t *tmp = NULL; + + char *consumer_tag = NULL; PHP5to7_param_str_len_type_t consumer_tag_len = 0; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &consumer_tag, &consumer_tag_len) == FAILURE) { + return; + } + + zval *channel_zv = PHP_AMQP_READ_THIS_PROP("channel"); + zval *consumers = zend_read_property(amqp_channel_class_entry, channel_zv, ZEND_STRL("consumers"), 0 PHP5to7_READ_PROP_RV_PARAM_CC TSRMLS_CC); + + if (IS_ARRAY != Z_TYPE_P(consumers)) { + zend_throw_exception(amqp_queue_exception_class_entry, "Invalid channel consumers, forgot to call channel constructor?", 0 TSRMLS_CC); + return; + } + + channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(channel_zv); + PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not cancel queue."); + + if (!consumer_tag_len && !PHP_AMQP_READ_THIS_PROP_STRLEN("consumer_tag")) { + return; + } + + amqp_basic_cancel_ok_t *r = amqp_basic_cancel( + channel_resource->connection_resource->connection_state, + channel_resource->channel_id, + consumer_tag_len > 0 ? amqp_cstring_bytes(consumer_tag) : amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STR("consumer_tag")) + ); + + if (!r) { + amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state); + + php_amqp_error(res, &PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource TSRMLS_CC); + + php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, PHP_AMQP_G(error_message), PHP_AMQP_G(error_code) TSRMLS_CC); + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + return; + } + + if (!consumer_tag_len || strcmp(consumer_tag, PHP_AMQP_READ_THIS_PROP_STR("consumer_tag")) != 0) { + zend_update_property_null(this_ce, getThis(), ZEND_STRL("consumer_tag") TSRMLS_CC); + } + + char *key; + key = estrndup((char *)r->consumer_tag.bytes, (uint) r->consumer_tag.len); + PHP5to7_ZEND_HASH_DEL(Z_ARRVAL_P(consumers), (const char *) key, PHP5to7_ZEND_HASH_STRLEN(r->consumer_tag.len)); + efree(key); + + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + + RETURN_TRUE; +} +/* }}} */ + + +/* {{{ proto int AMQPQueue::unbind(string exchangeName, [string routingKey, array arguments]); +unbind queue from exchange +*/ +static PHP_METHOD(amqp_queue_class, unbind) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + + zval *zvalArguments = NULL; + amqp_channel_resource *channel_resource; + + char *exchange_name; PHP5to7_param_str_len_type_t exchange_name_len; + char *keyname = NULL; PHP5to7_param_str_len_type_t keyname_len = 0; + + amqp_table_t *arguments = NULL; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|sa", + &exchange_name, &exchange_name_len, + &keyname, &keyname_len, + &zvalArguments) == FAILURE) { + return; + } + + channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel")); + PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not unbind queue."); + + if (zvalArguments) { + arguments = php_amqp_type_convert_zval_to_amqp_table(zvalArguments TSRMLS_CC); + } + + amqp_queue_unbind( + channel_resource->connection_resource->connection_state, + channel_resource->channel_id, + amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STR("name")), + (exchange_name_len > 0 ? amqp_cstring_bytes(exchange_name) : amqp_empty_bytes), + (keyname_len > 0 ? amqp_cstring_bytes(keyname) : amqp_empty_bytes), + (arguments ? *arguments : amqp_empty_table) + ); + + if (arguments) { + php_amqp_type_free_amqp_table(arguments); + } + + amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state); + + if (PHP_AMQP_MAYBE_ERROR(res, channel_resource)) { + php_amqp_zend_throw_exception_short(res, amqp_queue_exception_class_entry TSRMLS_CC); + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + return; + } + + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + + RETURN_TRUE; +} +/* }}} */ + + +/* {{{ proto int AMQPQueue::delete([long flags = AMQP_NOPARAM]]); +delete queue and return the number of messages deleted in it +*/ +static PHP_METHOD(amqp_queue_class, delete) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + + amqp_channel_resource *channel_resource; + + PHP5to7_param_long_type_t flags = AMQP_NOPARAM; + + PHP5to7_param_long_type_t message_count; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &flags) == FAILURE) { + return; + } + + channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel")); + PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not delete queue."); + + amqp_queue_delete_ok_t * r = amqp_queue_delete( + channel_resource->connection_resource->connection_state, + channel_resource->channel_id, + amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STR("name")), + (AMQP_IFUNUSED & flags) ? 1 : 0, + (AMQP_IFEMPTY & flags) ? 1 : 0 + ); + + if (!r) { + amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state); + + php_amqp_error(res, &PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource TSRMLS_CC); + + php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, PHP_AMQP_G(error_message), PHP_AMQP_G(error_code) TSRMLS_CC); + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + return; + } + + message_count = r->message_count; + + php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource); + + RETURN_LONG(message_count); +} +/* }}} */ + +/* {{{ proto AMQPChannel::getChannel() +Get the AMQPChannel object in use */ +static PHP_METHOD(amqp_queue_class, getChannel) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + PHP_AMQP_RETURN_THIS_PROP("channel"); +} +/* }}} */ + +/* {{{ proto AMQPChannel::getConnection() +Get the AMQPConnection object in use */ +static PHP_METHOD(amqp_queue_class, getConnection) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + PHP_AMQP_RETURN_THIS_PROP("connection"); +} +/* }}} */ + +/* {{{ proto string AMQPChannel::getConsumerTag() +Get latest consumer tag*/ +static PHP_METHOD(amqp_queue_class, getConsumerTag) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + PHP_AMQP_RETURN_THIS_PROP("consumer_tag"); +} + +/* }}} */ +/* amqp_queue_class ARG_INFO definition */ +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class__construct, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) + ZEND_ARG_OBJ_INFO(0, amqp_channel, AMQPChannel, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_getName, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_setName, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) + ZEND_ARG_INFO(0, queue_name) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_getFlags, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_setFlags, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) + ZEND_ARG_INFO(0, flags) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_getArgument, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) + ZEND_ARG_INFO(0, argument) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_getArguments, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_setArgument, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 2) + ZEND_ARG_INFO(0, key) + ZEND_ARG_INFO(0, value) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_hasArgument, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) + ZEND_ARG_INFO(0, key) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_setArguments, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) + ZEND_ARG_ARRAY_INFO(0, arguments, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_declareQueue, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_bind, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) + ZEND_ARG_INFO(0, exchange_name) + ZEND_ARG_INFO(0, routing_key) + ZEND_ARG_INFO(0, arguments) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_get, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) + ZEND_ARG_INFO(0, flags) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_consume, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) + ZEND_ARG_INFO(0, callback) + ZEND_ARG_INFO(0, flags) + ZEND_ARG_INFO(0, consumer_tag) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_ack, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) + ZEND_ARG_INFO(0, delivery_tag) + ZEND_ARG_INFO(0, flags) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_nack, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) + ZEND_ARG_INFO(0, delivery_tag) + ZEND_ARG_INFO(0, flags) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_reject, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) + ZEND_ARG_INFO(0, delivery_tag) + ZEND_ARG_INFO(0, flags) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_purge, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_cancel, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) + ZEND_ARG_INFO(0, consumer_tag) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_unbind, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) + ZEND_ARG_INFO(0, exchange_name) + ZEND_ARG_INFO(0, routing_key) + ZEND_ARG_INFO(0, arguments) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_delete, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) + ZEND_ARG_INFO(0, flags) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_getChannel, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_getConnection, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_getConsumerTag, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +zend_function_entry amqp_queue_class_functions[] = { + PHP_ME(amqp_queue_class, __construct, arginfo_amqp_queue_class__construct, ZEND_ACC_PUBLIC) + + PHP_ME(amqp_queue_class, getName, arginfo_amqp_queue_class_getName, ZEND_ACC_PUBLIC) + PHP_ME(amqp_queue_class, setName, arginfo_amqp_queue_class_setName, ZEND_ACC_PUBLIC) + + PHP_ME(amqp_queue_class, getFlags, arginfo_amqp_queue_class_getFlags, ZEND_ACC_PUBLIC) + PHP_ME(amqp_queue_class, setFlags, arginfo_amqp_queue_class_setFlags, ZEND_ACC_PUBLIC) + + PHP_ME(amqp_queue_class, getArgument, arginfo_amqp_queue_class_getArgument, ZEND_ACC_PUBLIC) + PHP_ME(amqp_queue_class, getArguments, arginfo_amqp_queue_class_getArguments, ZEND_ACC_PUBLIC) + PHP_ME(amqp_queue_class, setArgument, arginfo_amqp_queue_class_setArgument, ZEND_ACC_PUBLIC) + PHP_ME(amqp_queue_class, setArguments, arginfo_amqp_queue_class_setArguments, ZEND_ACC_PUBLIC) + PHP_ME(amqp_queue_class, hasArgument, arginfo_amqp_queue_class_hasArgument, ZEND_ACC_PUBLIC) + + PHP_ME(amqp_queue_class, declareQueue, arginfo_amqp_queue_class_declareQueue, ZEND_ACC_PUBLIC) + PHP_ME(amqp_queue_class, bind, arginfo_amqp_queue_class_bind, ZEND_ACC_PUBLIC) + + PHP_ME(amqp_queue_class, get, arginfo_amqp_queue_class_get, ZEND_ACC_PUBLIC) + PHP_ME(amqp_queue_class, consume, arginfo_amqp_queue_class_consume, ZEND_ACC_PUBLIC) + PHP_ME(amqp_queue_class, ack, arginfo_amqp_queue_class_ack, ZEND_ACC_PUBLIC) + PHP_ME(amqp_queue_class, nack, arginfo_amqp_queue_class_nack, ZEND_ACC_PUBLIC) + PHP_ME(amqp_queue_class, reject, arginfo_amqp_queue_class_reject, ZEND_ACC_PUBLIC) + PHP_ME(amqp_queue_class, purge, arginfo_amqp_queue_class_purge, ZEND_ACC_PUBLIC) + + PHP_ME(amqp_queue_class, cancel, arginfo_amqp_queue_class_cancel, ZEND_ACC_PUBLIC) + PHP_ME(amqp_queue_class, delete, arginfo_amqp_queue_class_delete, ZEND_ACC_PUBLIC) + PHP_ME(amqp_queue_class, unbind, arginfo_amqp_queue_class_unbind, ZEND_ACC_PUBLIC) + + PHP_ME(amqp_queue_class, getChannel, arginfo_amqp_queue_class_getChannel, ZEND_ACC_PUBLIC) + PHP_ME(amqp_queue_class, getConnection, arginfo_amqp_queue_class_getConnection, ZEND_ACC_PUBLIC) + PHP_ME(amqp_queue_class, getConsumerTag, arginfo_amqp_queue_class_getConsumerTag, ZEND_ACC_PUBLIC) + + PHP_MALIAS(amqp_queue_class, declare, declareQueue, arginfo_amqp_queue_class_declareQueue, ZEND_ACC_PUBLIC | ZEND_ACC_DEPRECATED) + + {NULL, NULL, NULL} +}; + +PHP_MINIT_FUNCTION(amqp_queue) +{ + zend_class_entry ce; + + INIT_CLASS_ENTRY(ce, "AMQPQueue", amqp_queue_class_functions); + this_ce = zend_register_internal_class(&ce TSRMLS_CC); + + zend_declare_property_null(this_ce, ZEND_STRL("connection"), ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(this_ce, ZEND_STRL("channel"), ZEND_ACC_PRIVATE TSRMLS_CC); + + zend_declare_property_stringl(this_ce, ZEND_STRL("name"), "", 0, ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(this_ce, ZEND_STRL("consumer_tag"), ZEND_ACC_PRIVATE TSRMLS_CC); + + zend_declare_property_bool(this_ce, ZEND_STRL("passive"), 0, ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_bool(this_ce, ZEND_STRL("durable"), 0, ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_bool(this_ce, ZEND_STRL("exclusive"), 0, ZEND_ACC_PRIVATE TSRMLS_CC); + /* By default, the auto_delete flag should be set */ + zend_declare_property_bool(this_ce, ZEND_STRL("auto_delete"), 1, ZEND_ACC_PRIVATE TSRMLS_CC); + + + + zend_declare_property_null(this_ce, ZEND_STRL("arguments"), ZEND_ACC_PRIVATE TSRMLS_CC); + + return SUCCESS; +} + +/* +*Local variables: +*tab-width: 4 +*tabstop: 4 +*c-basic-offset: 4 +*End: +*vim600: noet sw=4 ts=4 fdm=marker +*vim<600: noet sw=4 ts=4 +*/ diff -Nru php-amqp-1.7.1/amqp-1.9.3/amqp_queue.h php-amqp-1.9.3/amqp-1.9.3/amqp_queue.h --- php-amqp-1.7.1/amqp-1.9.3/amqp_queue.h 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/amqp_queue.h 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,35 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2007 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 | + | Lead: | + | - Pieter de Zwart | + | Maintainers: | + | - Brad Rodriguez | + | - Jonathan Tansavatdi | + +----------------------------------------------------------------------+ +*/ +extern zend_class_entry *amqp_queue_class_entry; + + +PHP_MINIT_FUNCTION(amqp_queue); + +/* +*Local variables: +*tab-width: 4 +*c-basic-offset: 4 +*End: +*vim600: noet sw=4 ts=4 fdm=marker +*vim<600: noet sw=4 ts=4 +*/ diff -Nru php-amqp-1.7.1/amqp-1.9.3/amqp_timestamp.c php-amqp-1.9.3/amqp-1.9.3/amqp_timestamp.c --- php-amqp-1.7.1/amqp-1.9.3/amqp_timestamp.c 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/amqp_timestamp.c 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,147 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2007 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 | + | Lead: | + | - Pieter de Zwart | + | Maintainers: | + | - Brad Rodriguez | + | - Jonathan Tansavatdi | + +----------------------------------------------------------------------+ +*/ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "php.h" +#include "php_ini.h" +#include "zend_exceptions.h" +#include "php_amqp.h" +#include "ext/standard/php_math.h" + +zend_class_entry *amqp_timestamp_class_entry; +#define this_ce amqp_timestamp_class_entry + +static const double AMQP_TIMESTAMP_MAX = 0xFFFFFFFFFFFFFFFF; +static const double AMQP_TIMESTAMP_MIN = 0; + +/* {{{ proto AMQPTimestamp::__construct(string $timestamp) + */ +static PHP_METHOD(amqp_timestamp_class, __construct) +{ + double timestamp; + zval *timestamp_value; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", ×tamp) == FAILURE) { + return; + } + + if (timestamp < AMQP_TIMESTAMP_MIN) { + zend_throw_exception_ex(amqp_value_exception_class_entry, 0 TSRMLS_CC, "The timestamp parameter must be greater than %0.f.", AMQP_TIMESTAMP_MIN); + return; + } + + if (timestamp > AMQP_TIMESTAMP_MAX) { + zend_throw_exception_ex(amqp_value_exception_class_entry, 0 TSRMLS_CC, "The timestamp parameter must be less than %0.f.", AMQP_TIMESTAMP_MAX); + return; + } + + { + #if PHP_MAJOR_VERSION >= 7 + zend_string *str; + str = _php_math_number_format_ex(timestamp, 0, "", 0, "", 0); + zend_update_property_str(this_ce, getThis(), ZEND_STRL("timestamp"), str); + zend_string_delref(str); + #else + char *str; + str = _php_math_number_format_ex(timestamp, 0, "", 0, "", 0); + zend_update_property_string(this_ce, getThis(), ZEND_STRL("timestamp"), str TSRMLS_CC); + efree(str); + #endif + } +} +/* }}} */ + + +/* {{{ proto int AMQPTimestamp::getTimestamp() +Get timestamp */ +static PHP_METHOD(amqp_timestamp_class, getTimestamp) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + + PHP_AMQP_RETURN_THIS_PROP("timestamp"); +} +/* }}} */ + + +/* {{{ proto string AMQPTimestamp::__toString() +Return timestamp as string */ +static PHP_METHOD(amqp_timestamp_class, __toString) +{ + PHP5to7_READ_PROP_RV_PARAM_DECL; + PHP_AMQP_NOPARAMS(); + + PHP_AMQP_RETURN_THIS_PROP("timestamp"); +} +/* }}} */ + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_timestamp_class_construct, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) + ZEND_ARG_INFO(0, timestamp) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_timestamp_class_getTimestamp, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_timestamp_class_toString, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO() + +zend_function_entry amqp_timestamp_class_functions[] = { + PHP_ME(amqp_timestamp_class, __construct, arginfo_amqp_timestamp_class_construct, ZEND_ACC_PUBLIC) + PHP_ME(amqp_timestamp_class, getTimestamp, arginfo_amqp_timestamp_class_getTimestamp, ZEND_ACC_PUBLIC) + PHP_ME(amqp_timestamp_class, __toString, arginfo_amqp_timestamp_class_toString, ZEND_ACC_PUBLIC) + + {NULL, NULL, NULL} +}; + + +PHP_MINIT_FUNCTION(amqp_timestamp) +{ + zend_class_entry ce; + char min[21], max[21]; + int min_len, max_len; + + INIT_CLASS_ENTRY(ce, "AMQPTimestamp", amqp_timestamp_class_functions); + this_ce = zend_register_internal_class(&ce TSRMLS_CC); + this_ce->ce_flags = this_ce->ce_flags | PHP5to7_ZEND_ACC_FINAL_CLASS; + + zend_declare_property_null(this_ce, ZEND_STRL("timestamp"), ZEND_ACC_PRIVATE TSRMLS_CC); + + max_len = snprintf(max, sizeof(max), "%.0f", AMQP_TIMESTAMP_MAX); + zend_declare_class_constant_stringl(this_ce, ZEND_STRL("MAX"), max, max_len TSRMLS_CC); + + min_len = snprintf(min, sizeof(min), "%.0f", AMQP_TIMESTAMP_MIN); + zend_declare_class_constant_stringl(this_ce, ZEND_STRL("MIN"), min, min_len TSRMLS_CC); + + return SUCCESS; +} + +/* +*Local variables: +*tab-width: 4 +*c-basic-offset: 4 +*End: +*vim600: noet sw=4 ts=4 fdm=marker +*vim<6 +*/ diff -Nru php-amqp-1.7.1/amqp-1.9.3/amqp_timestamp.h php-amqp-1.9.3/amqp-1.9.3/amqp_timestamp.h --- php-amqp-1.7.1/amqp-1.9.3/amqp_timestamp.h 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/amqp_timestamp.h 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,36 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2007 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 | + | Lead: | + | - Pieter de Zwart | + | Maintainers: | + | - Brad Rodriguez | + | - Jonathan Tansavatdi | + +----------------------------------------------------------------------+ +*/ +#include "php.h" + +extern zend_class_entry *amqp_timestamp_class_entry; + +PHP_MINIT_FUNCTION(amqp_timestamp); + +/* +*Local variables: +*tab-width: 4 +*c-basic-offset: 4 +*End: +*vim600: noet sw=4 ts=4 fdm=marker +*vim<600: noet sw=4 ts=4 +*/ diff -Nru php-amqp-1.7.1/amqp-1.9.3/amqp_type.c php-amqp-1.9.3/amqp-1.9.3/amqp_type.c --- php-amqp-1.7.1/amqp-1.9.3/amqp_type.c 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/amqp_type.c 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,382 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2007 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 | + | Lead: | + | - Pieter de Zwart | + | Maintainers: | + | - Brad Rodriguez | + | - Jonathan Tansavatdi | + +----------------------------------------------------------------------+ +*/ +#include +#include +#include "Zend/zend_interfaces.h" +#include "amqp_type.h" +#include "amqp_timestamp.h" +#include "amqp_decimal.h" + +#ifdef PHP_WIN32 +# define strtoimax _strtoi64 +#endif + +static void php_amqp_type_internal_free_amqp_array(amqp_array_t *array); +static void php_amqp_type_internal_free_amqp_table(amqp_table_t *object, zend_bool clear_root); + +amqp_bytes_t php_amqp_type_char_to_amqp_long(char const *cstr, PHP5to7_param_str_len_type_t len) +{ + amqp_bytes_t result; + + if (len < 1) { + return amqp_empty_bytes; + } + + result.len = (size_t)len; + result.bytes = (void *) cstr; + + return result; +} + +char *php_amqp_type_amqp_bytes_to_char(amqp_bytes_t bytes) +{ +/* We will need up to 4 chars per byte, plus the terminating 0 */ + char *res = emalloc(bytes.len * 4 + 1); + uint8_t *data = bytes.bytes; + char *p = res; + size_t i; + + for (i = 0; i < bytes.len; i++) { + if (data[i] >= 32 && data[i] != 127) { + *p++ = data[i]; + } else { + *p++ = '\\'; + *p++ = '0' + (data[i] >> 6); + *p++ = '0' + (data[i] >> 3 & 0x7); + *p++ = '0' + (data[i] & 0x7); + } + } + + *p = 0; + return res; +} + +void php_amqp_type_internal_convert_zval_array(zval *php_array, amqp_field_value_t **field, zend_bool allow_int_keys TSRMLS_DC) +{ + HashTable *ht; + HashPosition pos; + + zval *value; + zval **data; + + PHP5to7_ZEND_REAL_HASH_KEY_T *real_key; + + char *key; + uint key_len; + + ulong index; + ht = Z_ARRVAL_P(php_array); + + zend_bool is_amqp_array = 1; + + PHP5to7_ZEND_HASH_FOREACH_KEY_VAL(ht, index, real_key, key, key_len, data, value, pos) { + if (PHP5to7_ZEND_HASH_KEY_IS_STRING(ht, real_key, key, key_len, index, pos)) { + is_amqp_array = 0; + break; + } + + } PHP5to7_ZEND_HASH_FOREACH_END(); + + if (is_amqp_array) { + (*field)->kind = AMQP_FIELD_KIND_ARRAY; + php_amqp_type_internal_convert_zval_to_amqp_array(php_array, &(*field)->value.array TSRMLS_CC); + } else { + (*field)->kind = AMQP_FIELD_KIND_TABLE; + php_amqp_type_internal_convert_zval_to_amqp_table(php_array, &(*field)->value.table, allow_int_keys TSRMLS_CC); + } +} + +void php_amqp_type_internal_convert_zval_to_amqp_table(zval *php_array, amqp_table_t *amqp_table, zend_bool allow_int_keys TSRMLS_DC) +{ + HashTable *ht; + HashPosition pos; + + zval *value; + zval **data; + + PHP5to7_ZEND_REAL_HASH_KEY_T *real_key; + + char *key; + uint key_len; + + ulong index; + + + ht = Z_ARRVAL_P(php_array); + + amqp_table->entries = (amqp_table_entry_t *)ecalloc((size_t)zend_hash_num_elements(ht), sizeof(amqp_table_entry_t)); + amqp_table->num_entries = 0; + + PHP5to7_ZEND_HASH_FOREACH_KEY_VAL(ht, index, real_key, key, key_len, data, value, pos) { + char *string_key; + amqp_table_entry_t *table_entry; + amqp_field_value_t *field; + + + /* Now pull the key */ + + if (!PHP5to7_ZEND_HASH_KEY_IS_STRING(ht, real_key, key, key_len, index, pos)) { + if (allow_int_keys) { + /* Convert to strings non-string keys */ + char str[32]; + + key_len = sprintf(str, "%lu", index); + key = str; + } else { + /* Skip things that are not strings */ + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Ignoring non-string header field '%lu'", index); + + continue; + } + } else { + PHP5to7_ZEND_HASH_KEY_MAYBE_UNPACK(real_key, key, key_len); + } + + /* Build the value */ + table_entry = &amqp_table->entries[amqp_table->num_entries++]; + field = &table_entry->value; + + if (!php_amqp_type_internal_convert_php_to_amqp_field_value(value, &field, key TSRMLS_CC)) { + /* Reset entries counter back */ + amqp_table->num_entries --; + + continue; + } + + string_key = estrndup(key, key_len); + table_entry->key = amqp_cstring_bytes(string_key); + + } PHP5to7_ZEND_HASH_FOREACH_END(); +} + +void php_amqp_type_internal_convert_zval_to_amqp_array(zval *zvalArguments, amqp_array_t *arguments TSRMLS_DC) +{ + HashTable *ht; + HashPosition pos; + + zval *value; + zval **data; + + PHP5to7_ZEND_REAL_HASH_KEY_T *real_key; + + char *key; + uint key_len; + + ulong index; + + char type[16]; + + ht = Z_ARRVAL_P(zvalArguments); + + /* Allocate all the memory necessary for storing the arguments */ + arguments->entries = (amqp_field_value_t *)ecalloc((size_t)zend_hash_num_elements(ht), sizeof(amqp_field_value_t)); + arguments->num_entries = 0; + + PHP5to7_ZEND_HASH_FOREACH_KEY_VAL(ht, index, real_key, key, key_len, data, value, pos) { + amqp_field_value_t *field = &arguments->entries[arguments->num_entries++]; + + if (!php_amqp_type_internal_convert_php_to_amqp_field_value(value, &field, key TSRMLS_CC)) { + /* Reset entries counter back */ + arguments->num_entries --; + + continue; + } + } PHP5to7_ZEND_HASH_FOREACH_END(); +} + +zend_bool php_amqp_type_internal_convert_php_to_amqp_field_value(zval *value, amqp_field_value_t **fieldPtr, char *key TSRMLS_DC) +{ + zend_bool result; + char type[16]; + amqp_field_value_t *field; + + result = 1; + field = *fieldPtr; + + switch (Z_TYPE_P(value)) { + PHP5to7_CASE_IS_BOOL: + field->kind = AMQP_FIELD_KIND_BOOLEAN; + field->value.boolean = (amqp_boolean_t) !PHP5to7_IS_FALSE_P(value); + break; + case IS_DOUBLE: + field->kind = AMQP_FIELD_KIND_F64; + field->value.f64 = Z_DVAL_P(value); + break; + case IS_LONG: + field->kind = AMQP_FIELD_KIND_I64; + field->value.i64 = Z_LVAL_P(value); + break; + case IS_STRING: + field->kind = AMQP_FIELD_KIND_UTF8; + + if (Z_STRLEN_P(value)) { + amqp_bytes_t bytes; + bytes.len = (size_t) Z_STRLEN_P(value); + bytes.bytes = estrndup(Z_STRVAL_P(value), (uint) Z_STRLEN_P(value)); + + field->value.bytes = bytes; + } else { + field->value.bytes = amqp_empty_bytes; + } + + break; + case IS_ARRAY: + php_amqp_type_internal_convert_zval_array(value, &field, 1 TSRMLS_CC); + break; + case IS_NULL: + field->kind = AMQP_FIELD_KIND_VOID; + break; + case IS_OBJECT: + if (instanceof_function(Z_OBJCE_P(value), amqp_timestamp_class_entry TSRMLS_CC)) { + PHP5to7_zval_t result_zv PHP5to7_MAYBE_SET_TO_NULL; + + zend_call_method_with_0_params(PHP5to7_MAYBE_PARAM_PTR(value), amqp_timestamp_class_entry, NULL, "gettimestamp", &result_zv); + + field->kind = AMQP_FIELD_KIND_TIMESTAMP; + field->value.u64 = strtoimax(Z_STRVAL(PHP5to7_MAYBE_DEREF(result_zv)), NULL, 10); + + PHP5to7_MAYBE_DESTROY(result_zv); + + break; + } else if (instanceof_function(Z_OBJCE_P(value), amqp_decimal_class_entry TSRMLS_CC)) { + field->kind = AMQP_FIELD_KIND_DECIMAL; + PHP5to7_zval_t result_zv PHP5to7_MAYBE_SET_TO_NULL; + + zend_call_method_with_0_params(PHP5to7_MAYBE_PARAM_PTR(value), amqp_decimal_class_entry, NULL, "getexponent", &result_zv); + field->value.decimal.decimals = (uint8_t)Z_LVAL(PHP5to7_MAYBE_DEREF(result_zv)); + PHP5to7_MAYBE_DESTROY(result_zv); + + zend_call_method_with_0_params(PHP5to7_MAYBE_PARAM_PTR(value), amqp_decimal_class_entry, NULL, "getsignificand", &result_zv); + field->value.decimal.value = (uint32_t)Z_LVAL(PHP5to7_MAYBE_DEREF(result_zv)); + + PHP5to7_MAYBE_DESTROY(result_zv); + + break; + } + default: + switch(Z_TYPE_P(value)) { + case IS_OBJECT: + strcpy(type, "object"); + break; + case IS_RESOURCE: + strcpy(type, "resource"); + break; + default: + strcpy(type, "unknown"); + break; + } + + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Ignoring field '%s' due to unsupported value type (%s)", key, type); + result = 0; + break; + } + + return result; +} + +amqp_table_t *php_amqp_type_convert_zval_to_amqp_table(zval *php_array TSRMLS_DC) +{ + amqp_table_t *amqp_table; + /* In setArguments, we are overwriting all the existing values */ + amqp_table = (amqp_table_t *)emalloc(sizeof(amqp_table_t)); + + php_amqp_type_internal_convert_zval_to_amqp_table(php_array, amqp_table, 0 TSRMLS_CC); + + return amqp_table; +} + + +static void php_amqp_type_internal_free_amqp_array(amqp_array_t *array) { + if (!array) { + return; + } + + int macroEntryCounter; + for (macroEntryCounter = 0; macroEntryCounter < array->num_entries; macroEntryCounter++) { + + amqp_field_value_t *entry = &array->entries[macroEntryCounter]; + + switch (entry->kind) { + case AMQP_FIELD_KIND_TABLE: + php_amqp_type_internal_free_amqp_table(&entry->value.table, 0); + break; + case AMQP_FIELD_KIND_ARRAY: + php_amqp_type_internal_free_amqp_array(&entry->value.array); + break; + case AMQP_FIELD_KIND_UTF8: + if (entry->value.bytes.bytes) { + efree(entry->value.bytes.bytes); + } + break; + // + default: + break; + } + } + + if (array->entries) { + efree(array->entries); + } +} + +static void php_amqp_type_internal_free_amqp_table(amqp_table_t *object, zend_bool clear_root) +{ + if (!object) { + return; + } + + if (object->entries) { + int macroEntryCounter; + for (macroEntryCounter = 0; macroEntryCounter < object->num_entries; macroEntryCounter++) { + + amqp_table_entry_t *entry = &object->entries[macroEntryCounter]; + efree(entry->key.bytes); + + switch (entry->value.kind) { + case AMQP_FIELD_KIND_TABLE: + php_amqp_type_internal_free_amqp_table(&entry->value.value.table, 0); + break; + case AMQP_FIELD_KIND_ARRAY: + php_amqp_type_internal_free_amqp_array(&entry->value.value.array); + break; + case AMQP_FIELD_KIND_UTF8: + if (entry->value.value.bytes.bytes) { + efree(entry->value.value.bytes.bytes); + } + break; + default: + break; + } + } + efree(object->entries); + } + + if (clear_root) { + efree(object); + } +} + +void php_amqp_type_free_amqp_table(amqp_table_t *object) +{ + php_amqp_type_internal_free_amqp_table(object, 1); +} diff -Nru php-amqp-1.7.1/amqp-1.9.3/amqp_type.h php-amqp-1.9.3/amqp-1.9.3/amqp_type.h --- php-amqp-1.7.1/amqp-1.9.3/amqp_type.h 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/amqp_type.h 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,48 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2007 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 | + | Lead: | + | - Pieter de Zwart | + | Maintainers: | + | - Brad Rodriguez | + | - Jonathan Tansavatdi | + +----------------------------------------------------------------------+ +*/ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "php.h" + +#include +#if PHP_MAJOR_VERSION >= 7 + #include "php7_support.h" +#else + #include "php5_support.h" +#endif + +PHP_MINIT_FUNCTION(amqp_type); + +char *php_amqp_type_amqp_bytes_to_char(amqp_bytes_t bytes); +amqp_bytes_t php_amqp_type_char_to_amqp_long(char const *cstr, PHP5to7_param_str_len_type_t len); + +amqp_table_t *php_amqp_type_convert_zval_to_amqp_table(zval *php_array TSRMLS_DC); +void php_amqp_type_free_amqp_table(amqp_table_t *object); + +/** Internal functions */ +zend_bool php_amqp_type_internal_convert_php_to_amqp_field_value(zval *value, amqp_field_value_t **fieldPtr, char *key TSRMLS_DC); +void php_amqp_type_internal_convert_zval_array(zval *php_array, amqp_field_value_t **field, zend_bool allow_int_keys TSRMLS_DC); +void php_amqp_type_internal_convert_zval_to_amqp_table(zval *php_array, amqp_table_t *amqp_table, zend_bool allow_int_keys TSRMLS_DC); +void php_amqp_type_internal_convert_zval_to_amqp_array(zval *php_array, amqp_array_t *amqp_array TSRMLS_DC); \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.9.3/benchmark.php php-amqp-1.9.3/amqp-1.9.3/benchmark.php --- php-amqp-1.7.1/amqp-1.9.3/benchmark.php 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/benchmark.php 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,102 @@ +getVersion().')'; +} catch (Exception $e) { + $xdebug = '(without xdebug)'; +} + +$ext = new ReflectionExtension('amqp'); +$srcVersion = $ext->getVersion(); + +echo 'Running benchmark for php-amqp ', $srcVersion, ' on PHP ', PHP_VERSION, ' ', $xdebug, PHP_EOL; + +$iterations = 10000; + +if (isset($argv[1])) { + $iterations = max((int) $argv[1], 0) ?: $iterations; +} +echo ' running ', $iterations, ' iterations:', PHP_EOL, PHP_EOL; + + +$conn = new AMQPConnection(); +$conn->connect(); + +$ch = new AMQPChannel($conn); + +$exchange = new AMQPExchange($ch); +$exchange->setType(AMQP_EX_TYPE_FANOUT); +$exchange->setFlags(AMQP_AUTODELETE); +$exchange->setName('benchmark_exchange_' . microtime(true)); +$exchange->declareExchange(); + +$q = new AMQPQueue($ch); +$q->setFlags(AMQP_AUTODELETE); +$q->declareQueue(); +$q->bind($exchange->getName()); + + +$message = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."; + +$timer = microtime(true); +for ($i = 0; $i < $iterations; $i++) { + $exchange->publish($message); +} +$timer = microtime(true) - $timer; + +echo 'Publish: ', $iterations, ' iterations took ', $timer, 'sec', PHP_EOL; + + +$timer = microtime(true); +for ($i = 0; $i < $iterations; $i++) { + if (!$q->get(AMQP_AUTOACK)) { + echo 'GET failed', PHP_EOL; + } +} +$timer = microtime(true) - $timer; + +echo ' Get: ', $iterations, ' iterations took ', $timer, 'sec', PHP_EOL; + +$q->delete(); +$exchange->delete(); + +echo PHP_EOL; +// ================================== + + +$exchange = new AMQPExchange($ch); +$exchange->setType(AMQP_EX_TYPE_FANOUT); +$exchange->setFlags(AMQP_AUTODELETE); +$exchange->setName('benchmark_exchange_' . microtime(true)); +$exchange->declareExchange(); + +$q = new AMQPQueue($ch); +$q->setFlags(AMQP_AUTODELETE); +$q->declareQueue(); +$q->bind($exchange->getName()); + +$timer = microtime(true); +for ($i = 0; $i < $iterations; $i++) { + $exchange->publish($message); +} +$timer = microtime(true) - $timer; + +echo 'Publish: ', $iterations, ' iterations took ', $timer, 'sec', PHP_EOL; + +$consumer_iterations = $iterations; + +$timer = microtime(true); +$q->consume( + function () use (&$consumer_iterations) { + return (--$consumer_iterations > 0); + }, + AMQP_AUTOACK); +$timer = microtime(true) - $timer; + +echo 'Consume: ', $iterations, ' iterations took ', $timer, 'sec', PHP_EOL; + +$q->delete(); +$exchange->delete(); diff -Nru php-amqp-1.7.1/amqp-1.9.3/config.m4 php-amqp-1.9.3/amqp-1.9.3/config.m4 --- php-amqp-1.7.1/amqp-1.9.3/config.m4 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/config.m4 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,137 @@ +dnl $Id: config.m4 322428 2012-01-17 21:42:40Z pdezwart $ +dnl config.m4 for extension amqp + +dnl Comments in this file start with the string 'dnl'. +dnl Remove where necessary. This file will not work +dnl without editing. +dnl amqp +dnl If your extension references something external, use with: + + +dnl Make sure that the comment is aligned: +PHP_ARG_WITH(amqp, for amqp support, +[ --with-amqp Include amqp support]) + +PHP_ARG_WITH(librabbitmq-dir, for amqp, +[ --with-librabbitmq-dir[=DIR] Set the path to librabbitmq install prefix.], yes) + + +if test "$PHP_AMQP" != "no"; then + dnl Write more examples of tests here... + + AC_MSG_RESULT($PHP_AMQP) + + dnl # --with-amqp -> check with-path + + SEARCH_FOR="amqp_framing.h" + AC_PATH_PROG(PKG_CONFIG, pkg-config, no) + + if test "$PHP_LIBRABBITMQ_DIR" = "yes" -a -x $PKG_CONFIG; then + AC_MSG_CHECKING([for amqp using pkg-config]) + + if ! $PKG_CONFIG --exists librabbitmq ; then + AC_MSG_ERROR([librabbitmq not found]) + fi + + PHP_AMQP_VERSION=`$PKG_CONFIG librabbitmq --modversion` + AC_MSG_RESULT([found version $PHP_AMQP_VERSION]) + + if ! $PKG_CONFIG librabbitmq --atleast-version 0.5.2 ; then + AC_MSG_ERROR([librabbitmq must be version 0.5.2 or greater]) + fi + if ! $PKG_CONFIG librabbitmq --atleast-version 0.6.0 ; then + AC_MSG_WARN([librabbitmq 0.6.0 or greater recommended]) + fi + + PHP_AMQP_LIBS=`$PKG_CONFIG librabbitmq --libs` + PHP_AMQP_INCS=`$PKG_CONFIG librabbitmq --cflags` + + PHP_EVAL_LIBLINE($PHP_AMQP_LIBS, AMQP_SHARED_LIBADD) + PHP_EVAL_INCLINE($PHP_AMQP_INCS) + + else + AC_MSG_CHECKING([for amqp files in default path]) + if test "$PHP_LIBRABBITMQ_DIR" != "no" && test "$PHP_LIBRABBITMQ_DIR" != "yes"; then + for i in $PHP_LIBRABBITMQ_DIR; do + if test -r $i/include/$SEARCH_FOR; + then + AMQP_DIR=$i + AC_MSG_RESULT(found in $i) + break + fi + done + else + for i in $PHP_AMQP /usr/local /usr ; do + if test -r $i/include/$SEARCH_FOR; + then + AMQP_DIR=$i + AC_MSG_RESULT(found in $i) + break + fi + done + fi + + if test -z "$AMQP_DIR"; then + AC_MSG_RESULT([not found]) + AC_MSG_ERROR([Please reinstall the librabbitmq distribution itself or (re)install librabbitmq development package if it available in your system]) + fi + + dnl # --with-amqp -> add include path + PHP_ADD_INCLUDE($AMQP_DIR/include) + + old_CFLAGS=$CFLAGS + CFLAGS="$CFLAGS -I$AMQP_DIR/include" + + AC_CACHE_CHECK(for librabbitmq version, ac_cv_librabbitmq_version, [ + AC_TRY_RUN([ + #include "amqp.h" + #include + + int main () + { + FILE *testfile = fopen("conftestval", "w"); + + if (NULL == testfile) { + return 1; + } + + fprintf(testfile, "%s\n", AMQ_VERSION_STRING); + fclose(testfile); + + return 0; + } + ], [ac_cv_librabbitmq_version=`cat ./conftestval`], [ac_cv_librabbitmq_version=NONE], [ac_cv_librabbitmq_version=NONE]) + ]) + + CFLAGS=$old_CFLAGS + + if test "$ac_cv_librabbitmq_version" != "NONE"; then + ac_IFS=$IFS + IFS=. + set $ac_cv_librabbitmq_version + IFS=$ac_IFS + LIBRABBITMQ_API_VERSION=`expr [$]1 \* 1000000 + [$]2 \* 1000 + [$]3` + + if test "$LIBRABBITMQ_API_VERSION" -lt 5001 ; then + AC_MSG_ERROR([librabbitmq must be version 0.5.2 or greater, $ac_cv_librabbitmq_version version given instead]) + fi + + if test "$LIBRABBITMQ_API_VERSION" -lt 6000 ; then + AC_MSG_WARN([librabbitmq 0.6.0 or greater recommended, current version is $ac_cv_librabbitmq_version]) + fi + else + AC_MSG_ERROR([could not determine librabbitmq version]) + fi + + dnl # --with-amqp -> check for lib and symbol presence + LIBNAME=rabbitmq + LIBSYMBOL=rabbitmq + + PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $AMQP_DIR/$PHP_LIBDIR, AMQP_SHARED_LIBADD) + fi + PHP_SUBST(AMQP_SHARED_LIBADD) + + AMQP_SOURCES="amqp.c amqp_type.c amqp_exchange.c amqp_queue.c amqp_connection.c amqp_connection_resource.c amqp_channel.c amqp_envelope.c amqp_basic_properties.c amqp_methods_handling.c amqp_timestamp.c amqp_decimal.c" + + PHP_NEW_EXTENSION(amqp, $AMQP_SOURCES, $ext_shared) +fi diff -Nru php-amqp-1.7.1/amqp-1.9.3/config.w32 php-amqp-1.9.3/amqp-1.9.3/config.w32 --- php-amqp-1.7.1/amqp-1.9.3/config.w32 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/config.w32 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,12 @@ +ARG_WITH("amqp", "AMQP support", "no"); + +if (PHP_AMQP != "no") { + if (CHECK_HEADER_ADD_INCLUDE("amqp.h", "CFLAGS_AMQP", PHP_PHP_BUILD + "\\include;" + PHP_AMQP) && + CHECK_LIB("rabbitmq.4.lib", "amqp", PHP_PHP_BUILD + "\\lib;" + PHP_AMQP)) { +// ADD_FLAG("CFLAGS_AMQP", "/D HAVE_AMQP_GETSOCKOPT"); + EXTENSION('amqp', 'amqp.c amqp_type.c amqp_exchange.c amqp_queue.c amqp_connection.c amqp_connection_resource.c amqp_channel.c amqp_envelope.c amqp_basic_properties.c amqp_methods_handling.c amqp_timestamp.c amqp_decimal.c'); + AC_DEFINE('HAVE_AMQP', 1); + } else { + WARNING("amqp not enabled; libraries and headers not found"); + } +} diff -Nru php-amqp-1.7.1/amqp-1.9.3/CREDITS php-amqp-1.9.3/amqp-1.9.3/CREDITS --- php-amqp-1.7.1/amqp-1.9.3/CREDITS 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/CREDITS 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,20 @@ +AMQP bindings for PHP +All who contributed to php-amqp project +Alexandre Kalendarev (original author) +Pieter de Zwart (lead) +Andrey Hristov (contributor) +Brad Rodriguez (contributor) +John Skopis (contributor - PHP < 5.3 compatibility) +Andy Wick (contributor - bug fixes, custom headers support) +Jonathan Tansavatdi (contributor) +Bernhard Weisshuhn (maintainer) +Lars Strojny (maintainer) +Anatoliy Belsky (contributor) +Alex Sladkov (contributor) +Vladimir Kartaviy (contributor) +Florin Patan (reported) +Ilya a.k.a. coodix (contributor) +Bogdan Padalko (contributor) +Dmitry Vinogradov (contributor) +Peter Hansen (contributor) +Michael K. Squires (contributor) \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.9.3/LICENSE php-amqp-1.9.3/amqp-1.9.3/LICENSE --- php-amqp-1.7.1/amqp-1.9.3/LICENSE 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/LICENSE 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,68 @@ +-------------------------------------------------------------------- + The PHP License, version 3.01 +Copyright (c) 1999 - 2012 The PHP Group. All rights reserved. +-------------------------------------------------------------------- + +Redistribution and use in source and binary forms, with or without +modification, is permitted provided that the following conditions +are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + 3. The name "PHP" must not be used to endorse or promote products + derived from this software without prior written permission. For + written permission, please contact group@php.net. + + 4. Products derived from this software may not be called "PHP", nor + may "PHP" appear in their name, without prior written permission + from group@php.net. You may indicate that your software works in + conjunction with PHP by saying "Foo for PHP" instead of calling + it "PHP Foo" or "phpfoo" + + 5. The PHP Group may publish revised and/or new versions of the + license from time to time. Each version will be given a + distinguishing version number. + Once covered code has been published under a particular version + of the license, you may always continue to use it under the terms + of that version. You may also choose to use such covered code + under the terms of any subsequent version of the license + published by the PHP Group. No one other than the PHP Group has + the right to modify the terms applicable to covered code created + under this License. + + 6. Redistributions of any form whatsoever must retain the following + acknowledgment: + "This product includes PHP software, freely available from + ". + +THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND +ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP +DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED +OF THE POSSIBILITY OF SUCH DAMAGE. + +-------------------------------------------------------------------- + +This software consists of voluntary contributions made by many +individuals on behalf of the PHP Group. + +The PHP Group can be contacted via Email at group@php.net. + +For more information on the PHP Group and the PHP project, +please see . + +PHP includes the Zend Engine, freely available at +. diff -Nru php-amqp-1.7.1/amqp-1.9.3/php5_support.h php-amqp-1.9.3/amqp-1.9.3/php5_support.h --- php-amqp-1.7.1/amqp-1.9.3/php5_support.h 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/php5_support.h 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,121 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2007 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 | + | Lead: | + | - Pieter de Zwart | + | Maintainers: | + | - Brad Rodriguez | + | - Jonathan Tansavatdi | + +----------------------------------------------------------------------+ +*/ + +#ifndef PHP_AMQP_PHP5_SUPPORT_H +#define PHP_AMQP_PHP5_SUPPORT_H + +typedef int PHP5to7_param_str_len_type_t; +typedef long PHP5to7_param_long_type_t; +typedef zval* PHP5to7_zval_t; + +#define PHP5to7_MAYBE_SET_TO_NULL = NULL + +#define PHP5to7_MAYBE_DEREF(zv) (*(zv)) +#define PHP5to7_MAYBE_PTR(zv) (zv) +#define PHP5to7_MAYBE_PTR_TYPE PHP5to7_zval_t +#define PHP5to7_MAYBE_PARAM_PTR(zv) (&(zv)) + +#define PHP5to7_MAYBE_INIT(zv) MAKE_STD_ZVAL(zv); +#define PHP5to7_ARRAY_INIT(zv) array_init(zv); +#define PHP5to7_MAYBE_DESTROY(zv) zval_ptr_dtor(&(zv)); +#define PHP5to7_MAYBE_DESTROY2(zv, pzv) zval_ptr_dtor(&pzv); + +#define PHP5to7_ZVAL_STRINGL_DUP(z, s, l) ZVAL_STRINGL((z), (s), (l), 1) + +#define PHP5to7_ADD_NEXT_INDEX_STRINGL_DUP(arg, str, length) add_next_index_stringl((arg), (str), (uint)(length), 1) + +#define PHP5to7_ZEND_HASH_FIND(ht, str, len, res) \ + (zend_hash_find((ht), (str), (uint)(len), (void **) &(res)) != FAILURE) + +#define PHP5to7_ZEND_HASH_STRLEN(len) (uint)((len) + 1) +#define PHP5to7_ZEND_HASH_DEL(ht, key, len) zend_hash_del_key_or_index((ht), (key), (uint)(len), 0, HASH_DEL_KEY); +#define PHP5to7_ZEND_HASH_ADD(ht, key, len, pData, nDataSize) (zend_hash_add((ht), (key), (uint)(len), &(pData), nDataSize, NULL) != FAILURE) +#define PHP5to7_ZEND_HASH_STR_UPD_MEM(ht, key, len, pData, nDataSize) PHP5to7_ZEND_HASH_ADD((ht), (key), (len), (pData), (nDataSize)) +#define PHP5to7_ZEND_HASH_STR_FIND_PTR(ht, key, len, res) PHP5to7_ZEND_HASH_FIND((ht), (key), (len), (res)) +#define PHP5to7_ZEND_HASH_STR_DEL(ht, key, len) PHP5to7_ZEND_HASH_DEL((ht), (key), (len)) + +#define PHP5to7_SET_FCI_RETVAL_PTR(fci, pzv) (fci).retval_ptr_ptr = &(pzv); +#define PHP5to7_CHECK_FCI_RETVAL_PTR(fci) ((fci).retval_ptr_ptr && *(fci).retval_ptr_ptr) + +#define PHP5to7_IS_FALSE_P(pzv) ((Z_TYPE_P(pzv) == IS_BOOL && !Z_BVAL_P(pzv))) + +#define PHP5to7_obj_free_zend_object void +#define PHP5to7_zend_object_value zend_object_value +#define PHP5to7_zend_register_internal_class_ex(ce, parent_ce) zend_register_internal_class_ex((ce), (parent_ce), NULL TSRMLS_CC) + +#define PHP5to7_ECALLOC_CONNECTION_OBJECT(ce) (amqp_connection_object*)ecalloc(1, sizeof(amqp_connection_object)) +#define PHP5to7_ECALLOC_CHANNEL_OBJECT(ce) (amqp_channel_object*)ecalloc(1, sizeof(amqp_channel_object)) + +#define PHP5to7_CASE_IS_BOOL case IS_BOOL + +#define PHP5to7_READ_PROP_RV_PARAM_DECL +#define PHP5to7_READ_PROP_RV_PARAM_CC + + +#define PHP5to7_ZEND_REAL_HASH_KEY_T void + +#define PHP5to7_ZEND_HASH_FOREACH_KEY_VAL(ht, num_key, real_key, key, key_len, data, val, pos) \ + for ( \ + zend_hash_internal_pointer_reset_ex((ht), &(pos)); \ + zend_hash_get_current_data_ex((ht), (void**) &(data), &(pos)) == SUCCESS && ((value) = *(data)); \ + zend_hash_move_forward_ex((ht), &(pos)) \ + ) + +#define PHP5to7_ZEND_HASH_KEY_IS_STRING(ht, real_key, key, key_len, num_key, pos) \ + (zend_hash_get_current_key_ex((ht), &(key), &(key_len), &(num_key), 0, &(pos)) == HASH_KEY_IS_STRING) + +#define PHP5to7_ZEND_HASH_KEY_MAYBE_UNPACK(real_key, key, key_len) + +#define PHP5to7_ZEND_HASH_FOREACH_END() + +#define Z_TRY_ADDREF_P(pz) Z_ADDREF_P(pz) + +/* Resources stuff */ + +typedef int PHP5to7_zend_resource_t; +typedef zend_rsrc_list_entry PHP5to7_zend_resource_store_t; +typedef zend_rsrc_list_entry PHP5to7_zend_resource_le_t; + +#define PHP5to7_ZEND_RESOURCE_DTOR_ARG rsrc +#define Z_RES_P(le) (le) + +#define PHP5to7_ZEND_RESOURCE_EMPTY 0 +#define PHP5to7_ZEND_RESOURCE_LE_EMPTY NULL +#define PHP5to7_ZEND_RSRC_TYPE_P(le) Z_TYPE_P(le) +#define PHP5to7_ZEND_REGISTER_RESOURCE(rsrc_pointer, rsrc_type) ZEND_REGISTER_RESOURCE(NULL, (rsrc_pointer), (rsrc_type)) + +#define PHP5to7_PARENT_CLASS_NAME_C(name) , (name) + +#define ZEND_ULONG_FMT "%" PRIu64 +#define PHP5to7_ZEND_ACC_FINAL_CLASS ZEND_ACC_FINAL_CLASS + +#endif //PHP_AMQP_PHP5_SUPPORT_H + +/* +*Local variables: +*tab-width: 4 +*c-basic-offset: 4 +*End: +*vim600: noet sw=4 ts=4 fdm=marker +*vim<600: noet sw=4 ts=4 +*/ diff -Nru php-amqp-1.7.1/amqp-1.9.3/php7_support.h php-amqp-1.9.3/amqp-1.9.3/php7_support.h --- php-amqp-1.7.1/amqp-1.9.3/php7_support.h 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/php7_support.h 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,113 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2007 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 | + | Lead: | + | - Pieter de Zwart | + | Maintainers: | + | - Brad Rodriguez | + | - Jonathan Tansavatdi | + +----------------------------------------------------------------------+ +*/ + +#ifndef PHP_AMQP_PHP7_SUPPORT_H +#define PHP_AMQP_PHP7_SUPPORT_H + +typedef size_t PHP5to7_param_str_len_type_t; +typedef zend_long PHP5to7_param_long_type_t; +typedef zval PHP5to7_zval_t; + +#define PHP5to7_MAYBE_SET_TO_NULL + +#define PHP5to7_MAYBE_DEREF(zv) (zv) +#define PHP5to7_MAYBE_PTR(zv) (&(zv)) +#define PHP5to7_MAYBE_PTR_TYPE PHP5to7_zval_t * +#define PHP5to7_MAYBE_PARAM_PTR(zv) (zv) + +#define PHP5to7_MAYBE_INIT(zv) ZVAL_UNDEF(&(zv)) +#define PHP5to7_ARRAY_INIT(zv) array_init(&(zv)); +#define PHP5to7_MAYBE_DESTROY(zv) if (!Z_ISUNDEF(zv)) { zval_ptr_dtor(&(zv)); } +#define PHP5to7_MAYBE_DESTROY2(zv, pzv) if (!Z_ISUNDEF(zv)) { zval_ptr_dtor(pzv); } + +#define PHP5to7_ZVAL_STRINGL_DUP(z, s, l) ZVAL_STRINGL((z), (s), (l)) +#define PHP5to7_ADD_NEXT_INDEX_STRINGL_DUP(arg, str, length) add_next_index_stringl((arg), (str), (size_t)(length)) + +#define PHP5to7_ZEND_HASH_FIND(ht, str, len, res) \ + ((res = zend_hash_str_find((ht), (str), (size_t)(len - 1))) != NULL) + +#define PHP5to7_ZEND_HASH_STRLEN(len) (PHP5to7_param_str_len_type_t)((len) + 1) +#define PHP5to7_ZEND_HASH_DEL(ht, key, len) zend_hash_str_del_ind((ht), (key), (uint)(len - 1)) +#define PHP5to7_ZEND_HASH_ADD(ht, key, len, pData, nDataSize) zend_hash_str_add((ht), (key), (uint)(len - 1), (pData)) +#define PHP5to7_ZEND_HASH_STR_UPD_MEM(ht, key, len, pData, nDataSize) zend_hash_str_update_mem((ht), (key), (size_t)(len), &(pData), (nDataSize)) +#define PHP5to7_ZEND_HASH_STR_FIND_PTR(ht, key, len, res) ((res = zend_hash_str_find_ptr((ht), (key), (size_t)(len))) != NULL) +#define PHP5to7_ZEND_HASH_STR_DEL(ht, key, len) zend_hash_str_del_ind((ht), (key), (uint)(len)) + +#define PHP5to7_SET_FCI_RETVAL_PTR(fci, pzv) (fci).retval = (pzv); +#define PHP5to7_CHECK_FCI_RETVAL_PTR(fci) ((fci).retval) + +#define PHP5to7_IS_FALSE_P(pzv) (Z_TYPE_P(pzv) == IS_FALSE) + +#define PHP5to7_obj_free_zend_object zend_object +#define PHP5to7_zend_object_value zend_object * +#define PHP5to7_zend_register_internal_class_ex(ce, parent_ce) zend_register_internal_class_ex((ce), (parent_ce) TSRMLS_CC) + +#define PHP5to7_ECALLOC_CONNECTION_OBJECT(ce) (amqp_connection_object*)ecalloc(1, sizeof(amqp_connection_object) + zend_object_properties_size(ce)) +#define PHP5to7_ECALLOC_CHANNEL_OBJECT(ce) (amqp_channel_object*)ecalloc(1, sizeof(amqp_channel_object) + zend_object_properties_size(ce)) + +#define PHP5to7_CASE_IS_BOOL case IS_TRUE: case IS_FALSE + +#define PHP5to7_READ_PROP_RV_PARAM_DECL zval rv; +#define PHP5to7_READ_PROP_RV_PARAM_CC , (&rv) + +#define Z_BVAL_P(zval_p) (Z_TYPE_P(zval_p) == IS_TRUE) + +#define PHP5to7_ZEND_REAL_HASH_KEY_T zend_string + +#define PHP5to7_ZEND_HASH_FOREACH_KEY_VAL(ht, num_key, real_key, key, key_len, data, val, pos) \ + ZEND_HASH_FOREACH_KEY_VAL((ht), (num_key), (real_key), (val)) + +#define PHP5to7_ZEND_HASH_KEY_IS_STRING(ht, real_key, key, key_len, num_key, pos) \ + (real_key) + +#define PHP5to7_ZEND_HASH_KEY_MAYBE_UNPACK(real_key, key, key_len) \ + (key_len) = ZSTR_LEN(real_key); \ + (key) = ZSTR_VAL(real_key); + +#define PHP5to7_ZEND_HASH_FOREACH_END() ZEND_HASH_FOREACH_END(); + +/* Resources stuff */ +typedef zend_resource* PHP5to7_zend_resource_t; +typedef zend_resource PHP5to7_zend_resource_store_t; +typedef zval PHP5to7_zend_resource_le_t; + +#define PHP5to7_ZEND_RESOURCE_DTOR_ARG res +#define PHP5to7_ZEND_RESOURCE_EMPTY NULL +#define PHP5to7_ZEND_RESOURCE_LE_EMPTY NULL +#define PHP5to7_ZEND_RSRC_TYPE_P(le) (le)->type +#define PHP5to7_ZEND_REGISTER_RESOURCE(rsrc_pointer, rsrc_type) zend_register_resource((rsrc_pointer), (rsrc_type)) + +#define PHP5to7_PARENT_CLASS_NAME_C(name) + +#define PHP5to7_ZEND_ACC_FINAL_CLASS ZEND_ACC_FINAL + +#endif //PHP_AMQP_PHP7_SUPPORT_H + +/* +*Local variables: +*tab-width: 4 +*c-basic-offset: 4 +*End: +*vim600: noet sw=4 ts=4 fdm=marker +*vim<600: noet sw=4 ts=4 +*/ diff -Nru php-amqp-1.7.1/amqp-1.9.3/php_amqp.h php-amqp-1.9.3/amqp-1.9.3/php_amqp.h --- php-amqp-1.7.1/amqp-1.9.3/php_amqp.h 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/php_amqp.h 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,388 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2007 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 | + | Lead: | + | - Pieter de Zwart | + | Maintainers: | + | - Brad Rodriguez | + | - Jonathan Tansavatdi | + +----------------------------------------------------------------------+ +*/ +#ifndef PHP_AMQP_H +#define PHP_AMQP_H + +/* True global resources - no need for thread safety here */ +extern zend_class_entry *amqp_exception_class_entry, + *amqp_connection_exception_class_entry, + *amqp_channel_exception_class_entry, + *amqp_exchange_exception_class_entry, + *amqp_queue_exception_class_entry, + *amqp_envelope_exception_class_entry, + *amqp_value_exception_class_entry; + + +typedef struct _amqp_connection_resource amqp_connection_resource; +typedef struct _amqp_connection_object amqp_connection_object; +typedef struct _amqp_channel_object amqp_channel_object; +typedef struct _amqp_channel_resource amqp_channel_resource; +typedef struct _amqp_channel_callbacks amqp_channel_callbacks; +typedef struct _amqp_callback_bucket amqp_callback_bucket; + +#if PHP_MAJOR_VERSION >= 7 + #include "php7_support.h" +#else + #include "php5_support.h" +#endif + +#include "amqp_connection_resource.h" + +#include + +extern zend_module_entry amqp_module_entry; +#define phpext_amqp_ptr &amqp_module_entry + +#ifdef PHP_WIN32 +#define PHP_AMQP_API __declspec(dllexport) +#else +#define PHP_AMQP_API +#endif + +#ifdef ZTS +#include "TSRM.h" +#endif + +#define AMQP_NOPARAM 0 +/* Where is 1?*/ +#define AMQP_JUST_CONSUME 1 +#define AMQP_DURABLE 2 +#define AMQP_PASSIVE 4 +#define AMQP_EXCLUSIVE 8 +#define AMQP_AUTODELETE 16 +#define AMQP_INTERNAL 32 +#define AMQP_NOLOCAL 64 +#define AMQP_AUTOACK 128 +#define AMQP_IFEMPTY 256 +#define AMQP_IFUNUSED 512 +#define AMQP_MANDATORY 1024 +#define AMQP_IMMEDIATE 2048 +#define AMQP_MULTIPLE 4096 +#define AMQP_NOWAIT 8192 +#define AMQP_REQUEUE 16384 + +/* passive, durable, auto-delete, internal, no-wait (see https://www.rabbitmq.com/amqp-0-9-1-reference.html#exchange.declare) */ +#define PHP_AMQP_EXCHANGE_FLAGS (AMQP_PASSIVE | AMQP_DURABLE | AMQP_AUTODELETE | AMQP_INTERNAL) + +/* passive, durable, exclusive, auto-delete, no-wait (see https://www.rabbitmq.com/amqp-0-9-1-reference.html#queue.declare) */ +/* We don't support no-wait flag */ +#define PHP_AMQP_QUEUE_FLAGS (AMQP_PASSIVE | AMQP_DURABLE | AMQP_EXCLUSIVE | AMQP_AUTODELETE) + +#define AMQP_EX_TYPE_DIRECT "direct" +#define AMQP_EX_TYPE_FANOUT "fanout" +#define AMQP_EX_TYPE_TOPIC "topic" +#define AMQP_EX_TYPE_HEADERS "headers" + +#define PHP_AMQP_CONNECTION_RES_NAME "AMQP Connection Resource" + +struct _amqp_channel_resource { + char is_connected; + amqp_channel_t channel_id; + amqp_connection_resource *connection_resource; + amqp_channel_object *parent; +}; + +struct _amqp_callback_bucket { + zend_fcall_info fci; + zend_fcall_info_cache fcc; +}; + +struct _amqp_channel_callbacks { + amqp_callback_bucket basic_return; + amqp_callback_bucket basic_ack; + amqp_callback_bucket basic_nack; +}; + + +/* NOTE: due to how internally PHP works with custom object, zend_object position in structure matters */ +struct _amqp_channel_object { +#if PHP_MAJOR_VERSION >= 7 + amqp_channel_callbacks callbacks; + zval *gc_data; + int gc_data_count; + amqp_channel_resource *channel_resource; + zend_object zo; +#else + zend_object zo; + zval *this_ptr; + amqp_channel_resource *channel_resource; + amqp_channel_callbacks callbacks; + zval **gc_data; + long gc_data_count; +#endif +}; + +struct _amqp_connection_resource { + zend_bool is_connected; + zend_bool is_persistent; + zend_bool is_dirty; + PHP5to7_zend_resource_t resource; + amqp_connection_object *parent; + amqp_channel_t max_slots; + amqp_channel_t used_slots; + amqp_channel_resource **slots; + amqp_connection_state_t connection_state; + amqp_socket_t *socket; +}; + +struct _amqp_connection_object { +#if PHP_MAJOR_VERSION >= 7 + amqp_connection_resource *connection_resource; + zend_object zo; +#else + zend_object zo; + amqp_connection_resource *connection_resource; +#endif +}; + +#define DEFAULT_PORT "5672" /* default AMQP port */ +#define DEFAULT_HOST "localhost" +#define DEFAULT_TIMEOUT "" +#define DEFAULT_READ_TIMEOUT "0" +#define DEFAULT_WRITE_TIMEOUT "0" +#define DEFAULT_CONNECT_TIMEOUT "0" +#define DEFAULT_VHOST "/" +#define DEFAULT_LOGIN "guest" +#define DEFAULT_PASSWORD "guest" +#define DEFAULT_AUTOACK "0" /* These are all strings to facilitate setting default ini values */ +#define DEFAULT_PREFETCH_COUNT "3" + +/* Usually, default is 0 which means 65535, but underlying rabbitmq-c library pool allocates minimal pool for each channel, + * so it takes a lot of memory to keep all that channels. Even after channel closing that buffer still keep memory allocation. + */ +/* #define DEFAULT_CHANNELS_PER_CONNECTION AMQP_DEFAULT_MAX_CHANNELS */ +#define PHP_AMQP_PROTOCOL_MAX_CHANNELS 256 + +/* AMQP_DEFAULT_FRAME_SIZE 131072 */ + +#if PHP_AMQP_PROTOCOL_MAX_CHANNELS > 0 + #define PHP_AMQP_MAX_CHANNELS PHP_AMQP_PROTOCOL_MAX_CHANNELS +#else + #define PHP_AMQP_MAX_CHANNELS 65535 // Note that the maximum number of channels the protocol supports is 65535 (2^16, with the 0-channel reserved) +#endif + +#define PHP_AMQP_MAX_FRAME INT_MAX +#define PHP_AMQP_MAX_HEARTBEAT INT_MAX + +#define PHP_AMQP_DEFAULT_CHANNEL_MAX PHP_AMQP_MAX_CHANNELS +#define PHP_AMQP_DEFAULT_FRAME_MAX AMQP_DEFAULT_FRAME_SIZE +#define PHP_AMQP_DEFAULT_HEARTBEAT AMQP_DEFAULT_HEARTBEAT + +#define PHP_AMQP_STRINGIFY(value) PHP_AMQP_TO_STRING(value) +#define PHP_AMQP_TO_STRING(value) #value + + +#define DEFAULT_CHANNEL_MAX PHP_AMQP_STRINGIFY(PHP_AMQP_MAX_CHANNELS) +#define DEFAULT_FRAME_MAX PHP_AMQP_STRINGIFY(PHP_AMQP_DEFAULT_FRAME_MAX) +#define DEFAULT_HEARTBEAT PHP_AMQP_STRINGIFY(PHP_AMQP_DEFAULT_HEARTBEAT) +#define DEFAULT_CACERT "" +#define DEFAULT_CERT "" +#define DEFAULT_KEY "" +#define DEFAULT_VERIFY "1" + + +#define IS_PASSIVE(bitmask) (AMQP_PASSIVE & (bitmask)) ? 1 : 0 +#define IS_DURABLE(bitmask) (AMQP_DURABLE & (bitmask)) ? 1 : 0 +#define IS_EXCLUSIVE(bitmask) (AMQP_EXCLUSIVE & (bitmask)) ? 1 : 0 +#define IS_AUTODELETE(bitmask) (AMQP_AUTODELETE & (bitmask)) ? 1 : 0 +#define IS_INTERNAL(bitmask) (AMQP_INTERNAL & (bitmask)) ? 1 : 0 +#define IS_NOWAIT(bitmask) (AMQP_NOWAIT & (bitmask)) ? 1 : 0 /* NOTE: always 0 in rabbitmq-c internals, so don't use it unless you are clearly understand aftermath*/ + +#define PHP_AMQP_NOPARAMS() if (zend_parse_parameters_none() == FAILURE) { return; } + +#define PHP_AMQP_RETURN_THIS_PROP(prop_name) \ + zval * _zv = zend_read_property(this_ce, getThis(), ZEND_STRL(prop_name), 0 PHP5to7_READ_PROP_RV_PARAM_CC TSRMLS_CC); \ + RETURN_ZVAL(_zv, 1, 0); + +#define PHP_AMQP_READ_OBJ_PROP(cls, obj, name) zend_read_property((cls), (obj), ZEND_STRL(name), 0 PHP5to7_READ_PROP_RV_PARAM_CC TSRMLS_CC) +#define PHP_AMQP_READ_OBJ_PROP_DOUBLE(cls, obj, name) Z_DVAL_P(PHP_AMQP_READ_OBJ_PROP((cls), (obj), (name))) + +#define PHP_AMQP_READ_THIS_PROP_CE(name, ce) zend_read_property((ce), getThis(), ZEND_STRL(name), 0 PHP5to7_READ_PROP_RV_PARAM_CC TSRMLS_CC) +#define PHP_AMQP_READ_THIS_PROP(name) zend_read_property(this_ce, getThis(), ZEND_STRL(name), 0 PHP5to7_READ_PROP_RV_PARAM_CC TSRMLS_CC) +#define PHP_AMQP_READ_THIS_PROP_BOOL(name) Z_BVAL_P(PHP_AMQP_READ_THIS_PROP(name)) +#define PHP_AMQP_READ_THIS_PROP_STR(name) Z_STRVAL_P(PHP_AMQP_READ_THIS_PROP(name)) +#define PHP_AMQP_READ_THIS_PROP_STRLEN(name) (Z_TYPE_P(PHP_AMQP_READ_THIS_PROP(name)) == IS_STRING ? Z_STRLEN_P(PHP_AMQP_READ_THIS_PROP(name)) : 0) +#define PHP_AMQP_READ_THIS_PROP_ARR(name) Z_ARRVAL_P(PHP_AMQP_READ_THIS_PROP(name)) +#define PHP_AMQP_READ_THIS_PROP_LONG(name) Z_LVAL_P(PHP_AMQP_READ_THIS_PROP(name)) +#define PHP_AMQP_READ_THIS_PROP_DOUBLE(name) Z_DVAL_P(PHP_AMQP_READ_THIS_PROP(name)) + + +#if PHP_MAJOR_VERSION >= 7 + static inline amqp_connection_object *php_amqp_connection_object_fetch(zend_object *obj) { + return (amqp_connection_object *)((char *)obj - XtOffsetOf(amqp_connection_object, zo)); + } + + static inline amqp_channel_object *php_amqp_channel_object_fetch(zend_object *obj) { + return (amqp_channel_object *)((char *)obj - XtOffsetOf(amqp_channel_object, zo)); + } + + #define PHP_AMQP_GET_CONNECTION(obj) php_amqp_connection_object_fetch(Z_OBJ_P(obj)) + #define PHP_AMQP_GET_CHANNEL(obj) php_amqp_channel_object_fetch(Z_OBJ_P(obj)) + + #define PHP_AMQP_FETCH_CONNECTION(obj) php_amqp_connection_object_fetch(obj) + #define PHP_AMQP_FETCH_CHANNEL(obj) php_amqp_channel_object_fetch(obj) + +#else + #define PHP_AMQP_GET_CONNECTION(obj) (amqp_connection_object *)zend_object_store_get_object((obj) TSRMLS_CC) + #define PHP_AMQP_GET_CHANNEL(obj) (amqp_channel_object *)zend_object_store_get_object((obj) TSRMLS_CC) + + #define PHP_AMQP_FETCH_CONNECTION(obj) (amqp_connection_object*)(obj) + #define PHP_AMQP_FETCH_CHANNEL(obj) (amqp_channel_object*)(obj) +#endif + + +#define PHP_AMQP_GET_CHANNEL_RESOURCE(obj) (IS_OBJECT == Z_TYPE_P(obj) ? (PHP_AMQP_GET_CHANNEL(obj))->channel_resource : NULL) + +#define PHP_AMQP_VERIFY_CONNECTION_ERROR(error, reason) \ + char verify_connection_error_tmp[255]; \ + snprintf(verify_connection_error_tmp, 255, "%s %s", error, reason); \ + zend_throw_exception(amqp_connection_exception_class_entry, verify_connection_error_tmp, 0 TSRMLS_CC); \ + return; \ + +#define PHP_AMQP_VERIFY_CONNECTION(connection, error) \ + if (!connection) { \ + PHP_AMQP_VERIFY_CONNECTION_ERROR(error, "Stale reference to the connection object.") \ + } \ + if (!(connection)->connection_resource || !(connection)->connection_resource->is_connected) { \ + PHP_AMQP_VERIFY_CONNECTION_ERROR(error, "No connection available.") \ + } \ + +#define PHP_AMQP_VERIFY_CHANNEL_ERROR(error, reason) \ + char verify_channel_error_tmp[255]; \ + snprintf(verify_channel_error_tmp, 255, "%s %s", error, reason); \ + zend_throw_exception(amqp_channel_exception_class_entry, verify_channel_error_tmp, 0 TSRMLS_CC); \ + return; \ + +#define PHP_AMQP_VERIFY_CHANNEL_RESOURCE(resource, error) \ + if (!resource) { \ + PHP_AMQP_VERIFY_CHANNEL_ERROR(error, "Stale reference to the channel object.") \ + } \ + if (!(resource)->is_connected) { \ + PHP_AMQP_VERIFY_CHANNEL_ERROR(error, "No channel available.") \ + } \ + if (!(resource)->connection_resource) { \ + PHP_AMQP_VERIFY_CONNECTION_ERROR(error, "Stale reference to the connection object.") \ + } \ + if (!(resource)->connection_resource->is_connected) { \ + PHP_AMQP_VERIFY_CONNECTION_ERROR(error, "No connection available.") \ + } \ + +#define PHP_AMQP_VERIFY_CHANNEL_CONNECTION_RESOURCE(resource, error) \ + if (!resource) { \ + PHP_AMQP_VERIFY_CHANNEL_ERROR(error, "Stale reference to the channel object.") \ + } \ + if (!(resource)->connection_resource) { \ + PHP_AMQP_VERIFY_CONNECTION_ERROR(error, "Stale reference to the connection object.") \ + } \ + if (!(resource)->connection_resource->is_connected) { \ + PHP_AMQP_VERIFY_CONNECTION_ERROR(error, "No connection available.") \ + } \ + +#define PHP_AMQP_MAYBE_ERROR(res, channel_resource) (\ + (AMQP_RESPONSE_NORMAL != (res).reply_type) \ + && \ + PHP_AMQP_RESOURCE_RESPONSE_OK != php_amqp_error(res, &PHP_AMQP_G(error_message), (channel_resource)->connection_resource, (channel_resource) TSRMLS_CC) \ + ) + +#define PHP_AMQP_MAYBE_ERROR_RECOVERABLE(res, channel_resource) (\ + (AMQP_RESPONSE_NORMAL != (res).reply_type) \ + && \ + PHP_AMQP_RESOURCE_RESPONSE_OK != php_amqp_error_advanced(res, &PHP_AMQP_G(error_message), (channel_resource)->connection_resource, (channel_resource), 0 TSRMLS_CC) \ + ) + +#define PHP_AMQP_IS_ERROR_RECOVERABLE(res, channel_resource, channel_object) ( \ + AMQP_RESPONSE_LIBRARY_EXCEPTION == (res).reply_type && AMQP_STATUS_UNEXPECTED_STATE == (res).library_error \ + && (0 <= php_amqp_connection_resource_error_advanced(res, &PHP_AMQP_G(error_message), (channel_resource)->connection_resource, (amqp_channel_t)(channel_resource ? (channel_resource)->channel_id : 0), (channel_object) TSRMLS_CC)) \ +) + + +#if ZEND_MODULE_API_NO >= 20100000 + #define AMQP_OBJECT_PROPERTIES_INIT(obj, ce) object_properties_init(&(obj), ce); +#else + #define AMQP_OBJECT_PROPERTIES_INIT(obj, ce) \ + do { \ + zval *tmp; \ + zend_hash_copy((obj).properties, &(ce)->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); \ + } while (0); +#endif + + +#define AMQP_ERROR_CATEGORY_MASK (1 << 29) + + +#ifdef PHP_WIN32 +# define AMQP_OS_SOCKET_TIMEOUT_ERRNO AMQP_ERROR_CATEGORY_MASK | WSAETIMEDOUT +#else +# define AMQP_OS_SOCKET_TIMEOUT_ERRNO AMQP_ERROR_CATEGORY_MASK | EAGAIN +#endif + +ZEND_BEGIN_MODULE_GLOBALS(amqp) + char *error_message; + PHP5to7_param_long_type_t error_code; +ZEND_END_MODULE_GLOBALS(amqp) + +ZEND_EXTERN_MODULE_GLOBALS(amqp); + +#ifdef ZEND_MODULE_GLOBALS_ACCESSOR + #define PHP_AMQP_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(amqp, v) + + #if defined(ZTS) && defined(COMPILE_DL_WEAK) + ZEND_TSRMLS_CACHE_EXTERN(); + #endif +#else + #ifdef ZTS + #define PHP_AMQP_G(v) TSRMG(amqp_globals_id, zend_amqp_globals *, v) + #else + #define PHP_AMQP_G(v) (amqp_globals.v) + #endif +#endif + +#ifndef PHP_AMQP_VERSION +#define PHP_AMQP_VERSION "1.9.3" +#endif + +#ifndef PHP_AMQP_REVISION +#define PHP_AMQP_REVISION "release" +#endif + +int php_amqp_error(amqp_rpc_reply_t reply, char **message, amqp_connection_resource *connection_resource, amqp_channel_resource *channel_resource TSRMLS_DC); +int php_amqp_error_advanced(amqp_rpc_reply_t reply, char **message, amqp_connection_resource *connection_resource, amqp_channel_resource *channel_resource, int fail_on_errors TSRMLS_DC); + +/** + * @deprecated + */ +void php_amqp_zend_throw_exception(amqp_rpc_reply_t reply, zend_class_entry *exception_ce, const char *message, PHP5to7_param_long_type_t code TSRMLS_DC); +void php_amqp_zend_throw_exception_short(amqp_rpc_reply_t reply, zend_class_entry *exception_ce TSRMLS_DC); +void php_amqp_maybe_release_buffers_on_channel(amqp_connection_resource *connection_resource, amqp_channel_resource *channel_resource); + +#endif /* PHP_AMQP_H */ + + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: noet sw=4 ts=4 fdm=marker + * vim<600: noet sw=4 ts=4 + */ diff -Nru php-amqp-1.7.1/amqp-1.9.3/stubs/AMQPBasicProperties.php php-amqp-1.9.3/amqp-1.9.3/stubs/AMQPBasicProperties.php --- php-amqp-1.7.1/amqp-1.9.3/stubs/AMQPBasicProperties.php 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/stubs/AMQPBasicProperties.php 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,167 @@ + amqp.host The host to connect too. Note: Max 1024 characters. + * 'port' => amqp.port Port on the host. + * 'vhost' => amqp.vhost The virtual host on the host. Note: Max 128 characters. + * 'login' => amqp.login The login name to use. Note: Max 128 characters. + * 'password' => amqp.password Password. Note: Max 128 characters. + * 'read_timeout' => Timeout in for income activity. Note: 0 or greater seconds. May be fractional. + * 'write_timeout' => Timeout in for outcome activity. Note: 0 or greater seconds. May be fractional. + * 'connect_timeout' => Connection timeout. Note: 0 or greater seconds. May be fractional. + * + * Connection tuning options (see http://www.rabbitmq.com/amqp-0-9-1-reference.html#connection.tune for details): + * 'channel_max' => Specifies highest channel number that the server permits. 0 means standard extension limit + * (see PHP_AMQP_MAX_CHANNELS constant) + * 'frame_max' => The largest frame size that the server proposes for the connection, including frame header + * and end-byte. 0 means standard extension limit (depends on librabbimq default frame size limit) + * 'heartbeat' => The delay, in seconds, of the connection heartbeat that the server wants. + * 0 means the server does not want a heartbeat. Note, librabbitmq has limited heartbeat support, + * which means heartbeats checked only during blocking calls. + * + * TLS support (see https://www.rabbitmq.com/ssl.html for details): + * 'cacert' => Path to the CA cert file in PEM format.. + * 'cert' => Path to the client certificate in PEM foramt. + * 'key' => Path to the client key in PEM format. + * 'verify' => Enable or disable peer verification. If peer verification is enabled then the common name in the + * server certificate must match the server name. Peer verification is enabled by default. + * ) + * + * @param array $credentials Optional array of credential information for + * connecting to the AMQP broker. + */ + public function __construct(array $credentials = array()) + { + } + + /** + * Closes the transient connection with the AMQP broker. + * + * This method will close an open connection with the AMQP broker. + * + * @return boolean true if connection was successfully closed, false otherwise. + */ + public function disconnect() + { + } + + /** + * Get the configured host. + * + * @return string The configured hostname of the broker + */ + public function getHost() + { + } + + /** + * Get the configured login. + * + * @return string The configured login as a string. + */ + public function getLogin() + { + } + + /** + * Get the configured password. + * + * @return string The configured password as a string. + */ + public function getPassword() + { + } + + /** + * Get the configured port. + * + * @return int The configured port as an integer. + */ + public function getPort() + { + } + + /** + * Get the configured vhost. + * + * @return string The configured virtual host as a string. + */ + public function getVhost() + { + } + + /** + * Check whether the connection to the AMQP broker is still valid. + * + * It does so by checking the return status of the last connect-command. + * + * @return boolean True if connected, false otherwise. + */ + public function isConnected() + { + } + + /** + * Establish a persistent connection with the AMQP broker. + * + * This method will initiate a connection with the AMQP broker + * or reuse an existing one if present. + * + * @throws AMQPConnectionException + * @return boolean TRUE on success or throws an exception on failure. + */ + public function pconnect() + { + } + + /** + * Closes a persistent connection with the AMQP broker. + * + * This method will close an open persistent connection with the AMQP + * broker. + * + * @return boolean true if connection was found and closed, + * false if no persistent connection with this host, + * port, vhost and login could be found, + */ + public function pdisconnect() + { + } + + /** + * Close any open transient connections and initiate a new one with the AMQP broker. + * + * @return boolean TRUE on success or FALSE on failure. + */ + public function reconnect() + { + } + + /** + * Close any open persistent connections and initiate a new one with the AMQP broker. + * + * @return boolean TRUE on success or FALSE on failure. + */ + public function preconnect() + { + } + + + /** + * Set the hostname used to connect to the AMQP broker. + * + * @param string $host The hostname of the AMQP broker. + * + * @throws AMQPConnectionException If host is longer then 1024 characters. + * + * @return boolean TRUE on success or FALSE on failure. + */ + public function setHost($host) + { + } + + /** + * Set the login string used to connect to the AMQP broker. + * + * @param string $login The login string used to authenticate + * with the AMQP broker. + * + * @throws AMQPConnectionException If login is longer then 32 characters. + * + * @return boolean TRUE on success or FALSE on failure. + */ + public function setLogin($login) + { + } + + /** + * Set the password string used to connect to the AMQP broker. + * + * @param string $password The password string used to authenticate + * with the AMQP broker. + * + * @throws AMQPConnectionException If password is longer then 32characters. + * + * @return boolean TRUE on success or FALSE on failure. + */ + public function setPassword($password) + { + } + + /** + * Set the port used to connect to the AMQP broker. + * + * @param integer $port The port used to connect to the AMQP broker. + * + * @throws AMQPConnectionException If port is longer not between + * 1 and 65535. + * + * @return boolean TRUE on success or FALSE on failure. + */ + public function setPort($port) + { + } + + /** + * Sets the virtual host to which to connect on the AMQP broker. + * + * @param string $vhost The virtual host to use on the AMQP + * broker. + * + * @throws AMQPConnectionException If host is longer then 32 characters. + * + * @return boolean true on success or false on failure. + */ + public function setVhost($vhost) + { + } + + /** + * Sets the interval of time to wait for income activity from AMQP broker + * + * @deprecated use AMQPConnection::setReadTimout($timeout) instead + * + * @param int $timeout + * + * @return bool + */ + public function setTimeout($timeout) + { + } + + /** + * Get the configured interval of time to wait for income activity + * from AMQP broker + * + * @deprecated use AMQPConnection::getReadTimout() instead + * + * @return float + */ + public function getTimeout() + { + } + + /** + * Sets the interval of time to wait for income activity from AMQP broker + * + * @param int $timeout + * + * @return bool + */ + public function setReadTimeout($timeout) + { + } + + /** + * Get the configured interval of time to wait for income activity + * from AMQP broker + * + * @return float + */ + public function getReadTimeout() + { + } + + /** + * Sets the interval of time to wait for outcome activity to AMQP broker + * + * @param int $timeout + * + * @return bool + */ + public function setWriteTimeout($timeout) + { + } + + /** + * Get the configured interval of time to wait for outcome activity + * to AMQP broker + * + * @return float + */ + public function getWriteTimeout() + { + } + + /** + * Return last used channel id during current connection session. + * + * @return int + */ + public function getUsedChannels() + { + } + + /** + * Get the maximum number of channels the connection can handle. + * + * When connection is connected, effective connection value returned, which is normally the same as original + * correspondent value passed to constructor, otherwise original value passed to constructor returned. + * + * @return int + */ + public function getMaxChannels() + { + } + + /** + * Get max supported frame size per connection in bytes. + * + * When connection is connected, effective connection value returned, which is normally the same as original + * correspondent value passed to constructor, otherwise original value passed to constructor returned. + * + * @return int + */ + public function getMaxFrameSize() + { + } + + /** + * Get number of seconds between heartbeats of the connection in seconds. + * + * When connection is connected, effective connection value returned, which is normally the same as original + * correspondent value passed to constructor, otherwise original value passed to constructor returned. + * + * @return int + */ + public function getHeartbeatInterval() + { + } + + /** + * Whether connection persistent. + * + * When connection is not connected, boolean false always returned + * + * @return bool + */ + public function isPersistent() + { + } + + /** + * Get path to the CA cert file in PEM format + * + * @return string + */ + public function getCACert() + { + } + + /** + * Set path to the CA cert file in PEM format + * + * @param string $cacert + */ + public function setCACert($cacert) + { + } + + /** + * Get path to the client certificate in PEM format + * + * @return string + */ + public function getCert() + { + } + + /** + * Set path to the client certificate in PEM format + * + * @param string $cert + */ + public function setCert($cert) + { + } + + /** + * Get path to the client key in PEM format + * + * @return string + */ + public function getKey() + { + } + + /** + * Set path to the client key in PEM format + * + * @param string $key + */ + public function setKey($key) + { + } + + /** + * Get whether peer verification enabled or disabled + * + * @return bool + */ + public function getVerify() + { + } + + /** + * Enable or disable peer verification + * + * @param bool $verify + */ + public function setVerify($verify) + { + } +} diff -Nru php-amqp-1.7.1/amqp-1.9.3/stubs/AMQPDecimal.php php-amqp-1.9.3/amqp-1.9.3/stubs/AMQPDecimal.php --- php-amqp-1.7.1/amqp-1.9.3/stubs/AMQPDecimal.php 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/stubs/AMQPDecimal.php 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,32 @@ += 0.5.3) + * + * @return void + */ + public function setFlags($flags) + { + } + + /** + * Set the name of the exchange. + * + * @param string $exchange_name The name of the exchange to set as string. + * + * @return void + */ + public function setName($exchange_name) + { + } + + /** + * Set the type of the exchange. + * + * Set the type of the exchange. This can be any of AMQP_EX_TYPE_DIRECT, + * AMQP_EX_TYPE_FANOUT, AMQP_EX_TYPE_HEADERS or AMQP_EX_TYPE_TOPIC. + * + * @param string $exchange_type The type of exchange as a string. + * + * @return void + */ + public function setType($exchange_type) + { + } + + /** + * Get the AMQPChannel object in use + * + * @return AMQPChannel + */ + public function getChannel() + { + } + + /** + * Get the AMQPConnection object in use + * + * @return AMQPConnection + */ + public function getConnection() + { + } +} diff -Nru php-amqp-1.7.1/amqp-1.9.3/stubs/AMQP.php php-amqp-1.9.3/amqp-1.9.3/stubs/AMQP.php --- php-amqp-1.7.1/amqp-1.9.3/stubs/AMQP.php 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/stubs/AMQP.php 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,125 @@ + +--FILE-- +connect(); + +$channel1 = new AMQPChannel($connection); + +$q1 = new AMQPQueue($channel1); +$q1->setName('q1-' . microtime(true)); +$q1->declareQueue(); + + +$channel2 = new AMQPChannel($connection); + +$q2_0 = new AMQPQueue($channel2); +$q2_0->setName('q2.0-' . microtime(true)); +$q2_0->declareQueue(); + +$q2_1 = new AMQPQueue($channel2); +$q2_1->setName('q2.1-' . microtime(true)); +$q2_1->declareQueue(); + + +echo "Channels should have no consumers: c1: ", count($channel1->getConsumers()), ', c2: ', count($channel2->getConsumers()), PHP_EOL; + +$q1->consume(null, AMQP_NOPARAM, 'test-consumer-0'); + +echo "Channel holds consumer: c1: ", count($channel1->getConsumers()), ', c2: ', count($channel2->getConsumers()), PHP_EOL; +$q2_0->consume(null, AMQP_NOPARAM, 'test-consumer-2-0'); +$q2_1->consume(null, AMQP_NOPARAM, 'test-consumer-2-1'); + +echo "Channel holds consumer: c1: ", count($channel1->getConsumers()), ', c2: ', count($channel2->getConsumers()), PHP_EOL; + +echo PHP_EOL; + +echo "Consumers belongs to their channels:", PHP_EOL; +echo "c1:", PHP_EOL; +foreach ($channel1->getConsumers() as $tag => $queue) { + echo ' ', $tag, ': ', $queue->getName(), PHP_EOL; +} +echo "c2:", PHP_EOL; +foreach ($channel2->getConsumers() as $tag => $queue) { + echo ' ', $tag, ': ', $queue->getName(), PHP_EOL; +} + +echo PHP_EOL; + +$q1->cancel(); +echo "Consumer removed after canceling: c1: ", count($channel1->getConsumers()), ', c2: ', count($channel2->getConsumers()), PHP_EOL; + + +$q2_0 = null; +$q2_1 = null; +echo "Consumer still stored after source variable been destroyed: c1: ", count($channel1->getConsumers()), ', c2: ', count($channel2->getConsumers()), PHP_EOL; +foreach ($channel2->getConsumers() as $tag => $queue) { + $queue->cancel(); +} +echo "Consumer removed after canceling: c1: ", count($channel1->getConsumers()), ', c2: ', count($channel2->getConsumers()), PHP_EOL; + + +?> +--EXPECTF-- +Channels should have no consumers: c1: 0, c2: 0 +Channel holds consumer: c1: 1, c2: 0 +Channel holds consumer: c1: 1, c2: 2 + +Consumers belongs to their channels: +c1: + test-consumer-0: q1-%f +c2: + test-consumer-2-0: q2.0-%f + test-consumer-2-1: q2.1-%f + +Consumer removed after canceling: c1: 0, c2: 2 +Consumer still stored after source variable been destroyed: c1: 0, c2: 2 +Consumer removed after canceling: c1: 0, c2: 0 diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/004-queue-consume-nested.phpt php-amqp-1.9.3/amqp-1.9.3/tests/004-queue-consume-nested.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/004-queue-consume-nested.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/004-queue-consume-nested.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,107 @@ +--TEST-- +AMQPQueue - nested consumers +--SKIPIF-- + +--FILE-- +setName('ex1-' . microtime(true)); + $ex1->setType(AMQP_EX_TYPE_FANOUT); + $ex1->declareExchange(); + + $q1 = new AMQPQueue($channel1); + $q1->setName('q1-' . microtime(true)); + $q1->declareQueue(); + $q1->bind($ex1->getName()); + + $cnt1 = 4; + $cnt2 = 4; + $nested_publish = true; + + for($i=0; $i < $cnt1; $i++) { + $ex1->publish("message 1 - {$i}"); + } + + $q1->consume(function (\AMQPEnvelope $message, \AMQPQueue $queue) use (&$cnt1, &$cnt2, &$nested_publish) { + + $queue->ack($message->getDeliveryTag()); + + printf("1: %s [%s] %s - %s (%s): %s queue\n", $message->getExchangeName(), $message->getBody(), $message->getConsumerTag(), $queue->getConsumerTag(), $queue->getName(), $message->getConsumerTag() == $queue->getConsumerTag() ? 'valid' : 'not valid'); + + $channel2 = new \AMQPChannel($queue->getConnection()); + + $ex2 = new AMQPExchange($channel2); + $ex2->setName('ex2-' . microtime(true)); + $ex2->setType(AMQP_EX_TYPE_FANOUT); + $ex2->declareExchange(); + + $q2 = new AMQPQueue($channel2); + $q2->setName('q2-' . microtime(true)); + $q2->declareQueue(); + $q2->bind($ex2->getName()); + + if ($nested_publish) { + for($i=0; $i < $cnt2; $i++) { + $ex2->publish("message 2 - {$i}"); + } + $nested_publish = false; + } + + $q2->consume(function (AMQPEnvelope $message, AMQPQueue $queue) use (&$cnt2) { + printf("2: %s [%s] %s - %s (%s): %s queue\n", $message->getExchangeName(), $message->getBody(), $message->getConsumerTag(), $queue->getConsumerTag(), $queue->getName(), $message->getConsumerTag() == $queue->getConsumerTag() ? 'valid' : 'not valid'); + $queue->ack($message->getDeliveryTag()); + + return --$cnt2 > 1; + }); + + return --$cnt1 > 1; + }); +} + +$connection1 = new AMQPConnection(); +$connection1->connect(); +$channel1 = new AMQPChannel($connection1); +echo 'With default prefetch = 3', PHP_EOL; +test($channel1); + +$channel1->close(); +$channel1 = null; +$connection1->disconnect(); +$connection1 = null; + +// var_dump($channel1); +$connection2 = new AMQPConnection(); +$connection2->connect(); + +$channel2 = new AMQPChannel($connection2); +$channel2->setPrefetchCount(1); +echo 'With prefetch = 1', PHP_EOL; +test($channel2); + + + +?> +--EXPECTF-- +With default prefetch = 3 +1: ex1-%f [message 1 - 0] amq.ctag-%s - amq.ctag-%s (q1-%f): valid queue +2: ex1-%f [message 1 - 1] amq.ctag-%s - amq.ctag-%s (q1-%f): valid queue +2: ex1-%f [message 1 - 2] amq.ctag-%s - amq.ctag-%s (q1-%f): valid queue +2: ex1-%f [message 1 - 3] amq.ctag-%s - amq.ctag-%s (q1-%f): valid queue +1: ex2-%f [message 2 - 0] amq.ctag-%s - amq.ctag-%s (q2-%f): valid queue +2: ex2-%f [message 2 - 1] amq.ctag-%s - amq.ctag-%s (q2-%f): valid queue +1: ex2-%f [message 2 - 2] amq.ctag-%s - amq.ctag-%s (q2-%f): valid queue +2: ex2-%f [message 2 - 3] amq.ctag-%s - amq.ctag-%s (q2-%f): valid queue +With prefetch = 1 +1: ex1-%f [message 1 - 0] amq.ctag-%s - amq.ctag-%s (q1-%f): valid queue +2: ex1-%f [message 1 - 1] amq.ctag-%s - amq.ctag-%s (q1-%f): valid queue +2: ex2-%f [message 2 - 0] amq.ctag-%s - amq.ctag-%s (q2-%f): valid queue +2: ex2-%f [message 2 - 1] amq.ctag-%s - amq.ctag-%s (q2-%f): valid queue +1: ex2-%f [message 2 - 2] amq.ctag-%s - amq.ctag-%s (q2-%f): valid queue +2: ex1-%f [message 1 - 2] amq.ctag-%s - amq.ctag-%s (q1-%f): valid queue +1: ex2-%f [message 2 - 3] amq.ctag-%s - amq.ctag-%s (q2-%f): valid queue +2: ex1-%f [message 1 - 3] amq.ctag-%s - amq.ctag-%s (q1-%f): valid queue diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/004-queue-consume-orphaned.phpt php-amqp-1.9.3/amqp-1.9.3/tests/004-queue-consume-orphaned.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/004-queue-consume-orphaned.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/004-queue-consume-orphaned.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,99 @@ +--TEST-- +AMQPQueue - orphaned envelope +--SKIPIF-- + +--FILE-- +connect(); + +$channel1 = new AMQPChannel($connection); + +$ex1 = new AMQPExchange($channel1); +$ex1->setName('ex1-' . microtime(true)); +$ex1->setType(AMQP_EX_TYPE_FANOUT); +$ex1->declareExchange(); + +$q1 = new AMQPQueue($channel1); +$q1->setName('q1-' . microtime(true)); +$q1->declareQueue(); +$q1->bind($ex1->getName()); + +$ex1->publish("test passed"); +$ex1->publish("test orphaned"); + +$q1->consume(function (AMQPEnvelope $message, AMQPQueue $queue) { + $queue->ack($message->getDeliveryTag()); + return false; +}); + +$q1->cancel(); + +$q1 = null; + +$q2 = new AMQPQueue($channel1); +$q2->setName('q1-' . microtime(true)); +$q2->declareQueue(); +$q2->bind($ex1->getName()); + + +try { + $q2->consume(function (AMQPEnvelope $message, AMQPQueue $queue) { + $queue->ack($message->getDeliveryTag()); + return false; + }); + +} catch (AMQPEnvelopeException $e) { + echo get_class($e), ': ', $e->getMessage(), ':', PHP_EOL, PHP_EOL; + var_dump($e->envelope); +} + +?> +--EXPECTF-- +AMQPEnvelopeException: Orphaned envelope: + +object(AMQPEnvelope)#6 (20) { + ["content_type":"AMQPBasicProperties":private]=> + string(10) "text/plain" + ["content_encoding":"AMQPBasicProperties":private]=> + string(0) "" + ["headers":"AMQPBasicProperties":private]=> + array(0) { + } + ["delivery_mode":"AMQPBasicProperties":private]=> + int(1) + ["priority":"AMQPBasicProperties":private]=> + int(0) + ["correlation_id":"AMQPBasicProperties":private]=> + string(0) "" + ["reply_to":"AMQPBasicProperties":private]=> + string(0) "" + ["expiration":"AMQPBasicProperties":private]=> + string(0) "" + ["message_id":"AMQPBasicProperties":private]=> + string(0) "" + ["timestamp":"AMQPBasicProperties":private]=> + int(0) + ["type":"AMQPBasicProperties":private]=> + string(0) "" + ["user_id":"AMQPBasicProperties":private]=> + string(0) "" + ["app_id":"AMQPBasicProperties":private]=> + string(0) "" + ["cluster_id":"AMQPBasicProperties":private]=> + string(0) "" + ["body":"AMQPEnvelope":private]=> + string(13) "test orphaned" + ["consumer_tag":"AMQPEnvelope":private]=> + string(31) "amq.ctag-%s" + ["delivery_tag":"AMQPEnvelope":private]=> + int(2) + ["is_redelivery":"AMQPEnvelope":private]=> + bool(false) + ["exchange_name":"AMQPEnvelope":private]=> + string(%d) "ex1-%f" + ["routing_key":"AMQPEnvelope":private]=> + string(0) "" +} diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpbasicproperties.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpbasicproperties.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpbasicproperties.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpbasicproperties.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,163 @@ +--TEST-- +AMQPBasicProperties +--SKIPIF-- + +--FILE-- + 'headers'), + 42, + 24, + "correlation_id", + "reply_to", + "expiration", + "message_id", + 99999, + "type", + "user_id", + "app_id", + "cluster_id" +); +var_dump($props); +dump_methods($props); + + +?> +--EXPECT-- +object(AMQPBasicProperties)#1 (14) { + ["content_type":"AMQPBasicProperties":private]=> + string(0) "" + ["content_encoding":"AMQPBasicProperties":private]=> + string(0) "" + ["headers":"AMQPBasicProperties":private]=> + array(0) { + } + ["delivery_mode":"AMQPBasicProperties":private]=> + int(1) + ["priority":"AMQPBasicProperties":private]=> + int(0) + ["correlation_id":"AMQPBasicProperties":private]=> + string(0) "" + ["reply_to":"AMQPBasicProperties":private]=> + string(0) "" + ["expiration":"AMQPBasicProperties":private]=> + string(0) "" + ["message_id":"AMQPBasicProperties":private]=> + string(0) "" + ["timestamp":"AMQPBasicProperties":private]=> + int(0) + ["type":"AMQPBasicProperties":private]=> + string(0) "" + ["user_id":"AMQPBasicProperties":private]=> + string(0) "" + ["app_id":"AMQPBasicProperties":private]=> + string(0) "" + ["cluster_id":"AMQPBasicProperties":private]=> + string(0) "" +} +AMQPBasicProperties + getContentType(): + string(0) "" + getContentEncoding(): + string(0) "" + getHeaders(): + array(0) { +} + getDeliveryMode(): + int(1) + getPriority(): + int(0) + getCorrelationId(): + string(0) "" + getReplyTo(): + string(0) "" + getExpiration(): + string(0) "" + getMessageId(): + string(0) "" + getTimestamp(): + int(0) + getType(): + string(0) "" + getUserId(): + string(0) "" + getAppId(): + string(0) "" + getClusterId(): + string(0) "" + +object(AMQPBasicProperties)#2 (14) { + ["content_type":"AMQPBasicProperties":private]=> + string(12) "content_type" + ["content_encoding":"AMQPBasicProperties":private]=> + string(16) "content_encoding" + ["headers":"AMQPBasicProperties":private]=> + array(1) { + ["test"]=> + string(7) "headers" + } + ["delivery_mode":"AMQPBasicProperties":private]=> + int(42) + ["priority":"AMQPBasicProperties":private]=> + int(24) + ["correlation_id":"AMQPBasicProperties":private]=> + string(14) "correlation_id" + ["reply_to":"AMQPBasicProperties":private]=> + string(8) "reply_to" + ["expiration":"AMQPBasicProperties":private]=> + string(10) "expiration" + ["message_id":"AMQPBasicProperties":private]=> + string(10) "message_id" + ["timestamp":"AMQPBasicProperties":private]=> + int(99999) + ["type":"AMQPBasicProperties":private]=> + string(4) "type" + ["user_id":"AMQPBasicProperties":private]=> + string(7) "user_id" + ["app_id":"AMQPBasicProperties":private]=> + string(6) "app_id" + ["cluster_id":"AMQPBasicProperties":private]=> + string(10) "cluster_id" +} +AMQPBasicProperties + getContentType(): + string(12) "content_type" + getContentEncoding(): + string(16) "content_encoding" + getHeaders(): + array(1) { + ["test"]=> + string(7) "headers" +} + getDeliveryMode(): + int(42) + getPriority(): + int(24) + getCorrelationId(): + string(14) "correlation_id" + getReplyTo(): + string(8) "reply_to" + getExpiration(): + string(10) "expiration" + getMessageId(): + string(10) "message_id" + getTimestamp(): + int(99999) + getType(): + string(4) "type" + getUserId(): + string(7) "user_id" + getAppId(): + string(6) "app_id" + getClusterId(): + string(10) "cluster_id" diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpchannel_basicRecover.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpchannel_basicRecover.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpchannel_basicRecover.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpchannel_basicRecover.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,112 @@ +--TEST-- +AMQPChannel::basicRecover +--SKIPIF-- + +--FILE-- +connect(); + +$channel_1 = new AMQPChannel($connection_1); +$channel_1->setPrefetchCount(5); + +$exchange_1 = new AMQPExchange($channel_1); +$exchange_1->setType(AMQP_EX_TYPE_TOPIC); +$exchange_1->setName('test_' . $time); +$exchange_1->setFlags(AMQP_AUTODELETE); +$exchange_1->declareExchange(); + +$queue_1 = new AMQPQueue($channel_1); +$queue_1->setName('test_' . $time); +$queue_1->setFlags(AMQP_DURABLE); +$queue_1->declareQueue(); + +$queue_1->bind($exchange_1->getName(), 'test'); + +$messages_count = 0; +while ($messages_count++ < 10) { + $exchange_1->publish('test message #' . $messages_count, 'test'); + //echo 'published test message #' . $messages_count, PHP_EOL; +} + +$consume = 2; // NOTE: by default prefetch-count=3, so in consumer below we will ignore prefetched messages 3-5, + // and they will not seen by other consumers until we redeliver it. +$queue_1->consume(function(AMQPEnvelope $e, AMQPQueue $q) use (&$consume) { + echo 'consumed ', $e->getBody(), ' ', ($e->isRedelivery() ? '(redelivered)' : '(original)'), PHP_EOL; + $q->ack($e->getDeliveryTag()); + + return (-- $consume > 0); +}); +$queue_1->cancel(); // we have to do that to prevent redelivering to the same consumer + +$connection_2 = new AMQPConnection(); +$connection_2->setReadTimeout(1); + +$connection_2->connect(); +$channel_2 = new AMQPChannel($connection_2); +$channel_2->setPrefetchCount(8); + + +$queue_2 = new AMQPQueue($channel_2); +$queue_2->setName('test_' . $time); + +$consume = 10; +try { + + $queue_2->consume(function (AMQPEnvelope $e, AMQPQueue $q) use (&$consume) { + echo 'consumed ' . $e->getBody(), ' ', ($e->isRedelivery() ? '(redelivered)' : '(original)'), PHP_EOL; + $q->ack($e->getDeliveryTag()); + + return (--$consume > 0); + }); + +} catch (AMQPException $e) { + echo get_class($e), "({$e->getCode()}): ", $e->getMessage(), PHP_EOL; +} +$queue_2->cancel(); +//var_dump($connection_2, $channel_2);die; + + +// yes, we do it repeatedly, basic.recover works in a slightly different way than it looks like. As it said, +// it "asks the server to redeliver all unacknowledged messages on a specified channel. +// ZERO OR MORE messages MAY BE redelivered" +$channel_1->basicRecover(); + +echo 'redelivered', PHP_EOL; + +$consume = 10; +try { + + $queue_2->consume(function (AMQPEnvelope $e, AMQPQueue $q) use (&$consume) { + echo 'consumed ' . $e->getBody(), ' ', ($e->isRedelivery() ? '(redelivered)' : '(original)'), PHP_EOL; + $q->ack($e->getDeliveryTag()); + + return (--$consume > 0); + }); + +} catch (AMQPException $e) { + echo get_class($e), "({$e->getCode()}): ", $e->getMessage(), PHP_EOL; +} + + +?> +--EXPECT-- +consumed test message #1 (original) +consumed test message #2 (original) +consumed test message #8 (original) +consumed test message #9 (original) +consumed test message #10 (original) +AMQPQueueException(0): Consumer timeout exceed +redelivered +consumed test message #3 (redelivered) +consumed test message #4 (redelivered) +consumed test message #5 (redelivered) +consumed test message #6 (redelivered) +consumed test message #7 (redelivered) +AMQPQueueException(0): Consumer timeout exceed diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpchannel_close.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpchannel_close.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpchannel_close.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpchannel_close.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,60 @@ +--TEST-- +AMQPChannel::close +--SKIPIF-- + +--FILE-- +connect(); + +$channel_1 = new AMQPChannel($connection_1); +$channel_1->setPrefetchCount(5); + +$exchange_1 = new AMQPExchange($channel_1); +$exchange_1->setType(AMQP_EX_TYPE_TOPIC); +$exchange_1->setName('test_' . $time); +$exchange_1->setFlags(AMQP_AUTODELETE); +$exchange_1->declareExchange(); + +$queue_1 = new AMQPQueue($channel_1); +$queue_1->setName('test_' . $time); +$queue_1->setFlags(AMQP_DURABLE); +$queue_1->declareQueue(); + +$queue_1->bind($exchange_1->getName(), 'test'); + +$messages_count = 0; + +while ($messages_count++ < 3) { + $exchange_1->publish('test message #' . $messages_count, 'test'); +} + +$msg = $queue_1->get(); +echo $msg->getBody(), PHP_EOL; + +echo 'connected: ', var_export($channel_1->isConnected(), true), PHP_EOL; +$channel_1->close(); +echo 'connected: ', var_export($channel_1->isConnected(), true), PHP_EOL; + +try { + $queue_1->get(); +} catch (AMQPChannelException $e) { + echo get_class($e), "({$e->getCode()}): " . $e->getMessage(), PHP_EOL; +} + +$channel_1->close(); +echo 'connected: ', var_export($channel_1->isConnected(), true), PHP_EOL; + +?> +--EXPECT-- +test message #1 +connected: true +connected: false +AMQPChannelException(0): Could not get messages from queue. No channel available. +connected: false diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpchannel_confirmSelect.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpchannel_confirmSelect.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpchannel_confirmSelect.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpchannel_confirmSelect.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,41 @@ +--TEST-- +AMQPChannel::confirmSelect() +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +$ch->confirmSelect(); +echo 'confirm.select: OK', PHP_EOL; + +try { + $ch->startTransaction(); +} catch (Exception $e) { + echo get_class($e), "({$e->getCode()}): " . $e->getMessage(), PHP_EOL; +} + +$ch = new AMQPChannel($cnn); +$ch->startTransaction(); +echo 'transaction.start: OK', PHP_EOL; + +try { + $ch->confirmSelect(); +} catch (Exception $e) { + echo get_class($e), "({$e->getCode()}): " . $e->getMessage(), PHP_EOL; +} + + +?> +--EXPECT-- +confirm.select: OK +AMQPChannelException(406): Server channel error: 406, message: PRECONDITION_FAILED - cannot switch from confirm to tx mode +transaction.start: OK +AMQPChannelException(406): Server channel error: 406, message: PRECONDITION_FAILED - cannot switch from tx to confirm mode diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpchannel_construct_basic.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpchannel_construct_basic.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpchannel_construct_basic.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpchannel_construct_basic.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,15 @@ +--TEST-- +AMQPChannel constructor +--SKIPIF-- + +--FILE-- +connect(); +$ch = new AMQPChannel($cnn); +echo get_class($ch) . "\n"; +echo $ch->isConnected() ? 'true' : 'false'; +?> +--EXPECT-- +AMQPChannel +true \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpchannel_getChannelId.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpchannel_getChannelId.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpchannel_getChannelId.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpchannel_getChannelId.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,23 @@ +--TEST-- +AMQPChannel::getChannelId +--SKIPIF-- + +--FILE-- +connect(); +$ch = new AMQPChannel($cnn); + +var_dump($ch->getChannelId()); + +$cnn->disconnect(); +var_dump($ch->getChannelId()); + +?> +--EXPECT-- +int(1) +int(1) \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpchannel_get_connection.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpchannel_get_connection.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpchannel_get_connection.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpchannel_get_connection.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,32 @@ +--TEST-- +AMQPChannel getConnection test +--SKIPIF-- + +--FILE-- +connect(); +$ch = new AMQPChannel($cnn); + +$cnn2 = new AMQPConnection(); + +echo $cnn === $ch->getConnection() ? 'same' : 'not same', PHP_EOL; +echo $cnn2 === $ch->getConnection() ? 'same' : 'not same', PHP_EOL; + +$old_host = $cnn->getHost(); +$new_host = 'test'; + +$ch->getConnection()->setHost($new_host); + +echo $cnn->getHost() == $new_host ? 'by ref' : 'copy', PHP_EOL; + +?> +--EXPECT-- +same +not same +by ref diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpchannel_multi_channel_connection.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpchannel_multi_channel_connection.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpchannel_multi_channel_connection.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpchannel_multi_channel_connection.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,27 @@ +--TEST-- +AMQPConnection - multiple AMQPChannels per AMQPConnection +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); +echo get_class($ch) . "\n"; +echo $ch->isConnected() ? 'true' : 'false'; +echo "\n"; +$ch2 = new AMQPChannel($cnn); +echo get_class($ch) . "\n"; +echo $ch->isConnected() ? 'true' : 'false'; + +unset($ch2); + +$ch->setPrefetchCount(10); + +?> +--EXPECT-- +AMQPChannel +true +AMQPChannel +true diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpchannel_slots_usage.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpchannel_slots_usage.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpchannel_slots_usage.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpchannel_slots_usage.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,29 @@ +--TEST-- +AMQPChannel slots usage +--SKIPIF-- + +--FILE-- +connect(); + +echo 'Used channels: ', $cnn->getUsedChannels(), PHP_EOL; + +$ch = new AMQPChannel($cnn); +echo 'Used channels: ', $cnn->getUsedChannels(), PHP_EOL; + +$ch = new AMQPChannel($cnn); +echo 'Used channels: ', $cnn->getUsedChannels(), PHP_EOL; + +$ch = null; +echo 'Used channels: ', $cnn->getUsedChannels(), PHP_EOL; +?> +--EXPECT-- +Used channels: 0 +Used channels: 1 +Used channels: 1 +Used channels: 0 diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpchannel_var_dump.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpchannel_var_dump.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpchannel_var_dump.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpchannel_var_dump.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,104 @@ +--TEST-- +AMQPChannel var_dump +--SKIPIF-- + +--FILE-- +connect(); +$ch = new AMQPChannel($cnn); + +var_dump($ch); +$cnn->disconnect(); +var_dump($ch); + +?> +--EXPECT-- +object(AMQPChannel)#2 (4) { + ["connection":"AMQPChannel":private]=> + object(AMQPConnection)#1 (15) { + ["login":"AMQPConnection":private]=> + string(5) "guest" + ["password":"AMQPConnection":private]=> + string(5) "guest" + ["host":"AMQPConnection":private]=> + string(9) "localhost" + ["vhost":"AMQPConnection":private]=> + string(1) "/" + ["port":"AMQPConnection":private]=> + int(5672) + ["read_timeout":"AMQPConnection":private]=> + float(0) + ["write_timeout":"AMQPConnection":private]=> + float(0) + ["connect_timeout":"AMQPConnection":private]=> + float(0) + ["channel_max":"AMQPConnection":private]=> + int(256) + ["frame_max":"AMQPConnection":private]=> + int(131072) + ["heartbeat":"AMQPConnection":private]=> + int(0) + ["cacert":"AMQPConnection":private]=> + string(0) "" + ["key":"AMQPConnection":private]=> + string(0) "" + ["cert":"AMQPConnection":private]=> + string(0) "" + ["verify":"AMQPConnection":private]=> + bool(true) + } + ["prefetch_count":"AMQPChannel":private]=> + int(3) + ["prefetch_size":"AMQPChannel":private]=> + int(0) + ["consumers":"AMQPChannel":private]=> + array(0) { + } +} +object(AMQPChannel)#2 (4) { + ["connection":"AMQPChannel":private]=> + object(AMQPConnection)#1 (15) { + ["login":"AMQPConnection":private]=> + string(5) "guest" + ["password":"AMQPConnection":private]=> + string(5) "guest" + ["host":"AMQPConnection":private]=> + string(9) "localhost" + ["vhost":"AMQPConnection":private]=> + string(1) "/" + ["port":"AMQPConnection":private]=> + int(5672) + ["read_timeout":"AMQPConnection":private]=> + float(0) + ["write_timeout":"AMQPConnection":private]=> + float(0) + ["connect_timeout":"AMQPConnection":private]=> + float(0) + ["channel_max":"AMQPConnection":private]=> + int(256) + ["frame_max":"AMQPConnection":private]=> + int(131072) + ["heartbeat":"AMQPConnection":private]=> + int(0) + ["cacert":"AMQPConnection":private]=> + string(0) "" + ["key":"AMQPConnection":private]=> + string(0) "" + ["cert":"AMQPConnection":private]=> + string(0) "" + ["verify":"AMQPConnection":private]=> + bool(true) + } + ["prefetch_count":"AMQPChannel":private]=> + int(3) + ["prefetch_size":"AMQPChannel":private]=> + int(0) + ["consumers":"AMQPChannel":private]=> + array(0) { + } +} diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_connection_getters.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_connection_getters.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_connection_getters.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_connection_getters.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,89 @@ +--TEST-- +AMQPConnection - connection-specific getters +--SKIPIF-- + +--FILE-- +isConnected(), true), PHP_EOL; +echo 'channel_max: ', var_export($cnn->getMaxChannels(), true), PHP_EOL; +echo 'frame_max: ', var_export($cnn->getMaxFrameSize(), true), PHP_EOL; +echo 'heartbeat: ', var_export($cnn->getHeartbeatInterval(), true), PHP_EOL; +echo PHP_EOL; + +$cnn->connect(); + +echo 'connected: ', var_export($cnn->isConnected(), true), PHP_EOL; +echo 'channel_max: ', var_export($cnn->getMaxChannels(), true), PHP_EOL; +echo 'frame_max: ', var_export($cnn->getMaxFrameSize(), true), PHP_EOL; +echo 'heartbeat: ', var_export($cnn->getHeartbeatInterval(), true), PHP_EOL; +echo PHP_EOL; + +$cnn->disconnect(); + +echo 'connected: ', var_export($cnn->isConnected(), true), PHP_EOL; +echo 'channel_max: ', var_export($cnn->getMaxChannels(), true), PHP_EOL; +echo 'frame_max: ', var_export($cnn->getMaxFrameSize(), true), PHP_EOL; +echo 'heartbeat: ', var_export($cnn->getHeartbeatInterval(), true), PHP_EOL; +echo PHP_EOL; + + +$cnn = new AMQPConnection(array('channel_max' => '10', 'frame_max' => 10240, 'heartbeat' => 10)); + +echo 'connected: ', var_export($cnn->isConnected(), true), PHP_EOL; +echo 'channel_max: ', var_export($cnn->getMaxChannels(), true), PHP_EOL; +echo 'frame_max: ', var_export($cnn->getMaxFrameSize(), true), PHP_EOL; +echo 'heartbeat: ', var_export($cnn->getHeartbeatInterval(), true), PHP_EOL; +echo PHP_EOL; + +$cnn->connect(); + +echo 'connected: ', var_export($cnn->isConnected(), true), PHP_EOL; +echo 'channel_max: ', var_export($cnn->getMaxChannels(), true), PHP_EOL; +echo 'frame_max: ', var_export($cnn->getMaxFrameSize(), true), PHP_EOL; +echo 'heartbeat: ', var_export($cnn->getHeartbeatInterval(), true), PHP_EOL; +echo PHP_EOL; + +$cnn->disconnect(); + +echo 'connected: ', var_export($cnn->isConnected(), true), PHP_EOL; +echo 'channel_max: ', var_export($cnn->getMaxChannels(), true), PHP_EOL; +echo 'frame_max: ', var_export($cnn->getMaxFrameSize(), true), PHP_EOL; +echo 'heartbeat: ', var_export($cnn->getHeartbeatInterval(), true), PHP_EOL; +echo PHP_EOL; +?> +--EXPECT-- +connected: false +channel_max: 256 +frame_max: 131072 +heartbeat: 0 + +connected: true +channel_max: 256 +frame_max: 131072 +heartbeat: 0 + +connected: false +channel_max: 256 +frame_max: 131072 +heartbeat: 0 + +connected: false +channel_max: 10 +frame_max: 10240 +heartbeat: 10 + +connected: true +channel_max: 10 +frame_max: 10240 +heartbeat: 10 + +connected: false +channel_max: 10 +frame_max: 10240 +heartbeat: 10 diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_connect_login_failure.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_connect_login_failure.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_connect_login_failure.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_connect_login_failure.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,33 @@ +--TEST-- +AMQPConnection connect login failure +--SKIPIF-- + +--FILE-- +setLogin('nonexistent-login-'.microtime(true)); +$cnn->setPassword('nonexistent-password-'.microtime(true)); + +//var_dump($cnn); + +echo ($cnn->isConnected() ? 'connected' : 'disconnected'), PHP_EOL; +// +try { + $cnn->connect(); + echo 'Connected', PHP_EOL; +} catch (AMQPException $e) { + echo get_class($e), "({$e->getCode()}): ", $e->getMessage(), PHP_EOL; +} +// +echo ($cnn->isConnected() ? 'connected' : 'disconnected'), PHP_EOL; + +// NOTE: in real-world environment (incl. travis ci) "a socket error occurred" happens, but in vagrant environment "connection closed unexpectedly" happens. WTF? +?> +--EXPECTF-- +disconnected +AMQPConnectionException(%d): %s error: %s - Potential login failure. +disconnected \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_construct_basic.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_construct_basic.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_construct_basic.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_construct_basic.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,16 @@ +--TEST-- +AMQPConnection constructor +--SKIPIF-- + +--FILE-- +connect(); +echo get_class($cnn) . "\n"; +echo $cnn->isConnected() ? 'true' : 'false', PHP_EOL; +echo $cnn->isPersistent() ? 'true' : 'false', PHP_EOL; +?> +--EXPECT-- +AMQPConnection +true +false \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_construct_ini_read_timeout.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_construct_ini_read_timeout.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_construct_ini_read_timeout.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_construct_ini_read_timeout.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,13 @@ +--TEST-- +AMQPConnection constructor with amqp.read_timeout ini value set +--SKIPIF-- + +--INI-- +amqp.read_timeout=202.202 +--FILE-- +getReadTimeout()); +?> +--EXPECTF-- +float(202.202) diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_construct_ini_timeout_and_read_timeout.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_construct_ini_timeout_and_read_timeout.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_construct_ini_timeout_and_read_timeout.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_construct_ini_timeout_and_read_timeout.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,17 @@ +--TEST-- +AMQPConnection constructor with both amqp.timeout and amqp.read_timeout ini values set +--SKIPIF-- + +--INI-- +amqp.timeout = 101.101 +amqp.read_timeout = 202.202 +--FILE-- +getReadTimeout()); +?> +--EXPECTF-- +%s: AMQPConnection::__construct(): INI setting 'amqp.timeout' is deprecated; use 'amqp.read_timeout' instead in %s on line 2 + +Notice: AMQPConnection::__construct(): INI setting 'amqp.read_timeout' will be used instead of 'amqp.timeout' in %s on line 2 +float(202.202) diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_construct_ini_timeout_default.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_construct_ini_timeout_default.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_construct_ini_timeout_default.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_construct_ini_timeout_default.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,13 @@ +--TEST-- +AMQPConnection constructor with amqp.timeout ini value set in code to it default value +--SKIPIF-- + +--FILE-- +getReadTimeout()); +?> +--EXPECTF-- +float(0) diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_construct_ini_timeout.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_construct_ini_timeout.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_construct_ini_timeout.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_construct_ini_timeout.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,14 @@ +--TEST-- +AMQPConnection constructor with amqp.timeout ini value set +--SKIPIF-- + +--INI-- +amqp.timeout=101.101 +--FILE-- +getReadTimeout()); +?> +--EXPECTF-- +%s: AMQPConnection::__construct(): INI setting 'amqp.timeout' is deprecated; use 'amqp.read_timeout' instead in %s on line 2 +float(101.101) diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_construct_with_connect_timeout.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_construct_with_connect_timeout.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_construct_with_connect_timeout.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_construct_with_connect_timeout.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,43 @@ +--TEST-- +AMQPConnection constructor with timeout parameter in credentials +--SKIPIF-- + +--FILE-- + -1.5)); +} catch (AMQPConnectionException $e) { + echo $e->getMessage(), PHP_EOL; +} + +$timeout = 10.5; + +// resolve hostname to don't waste time on resolve inside library while resolve operations are not under timings limit (yet) +$credentials = array('host' => gethostbyname('google.com'), 'connect_timeout' => $timeout); +//$credentials = array('host' => 'google.com', 'connect_timeout' => $timeout); +$cnn = new AMQPConnection($credentials); + +$start = microtime(true); + +try { + $cnn->connect(); +} catch (AMQPConnectionException $e) { + echo $e->getMessage(), PHP_EOL; + $end = microtime(true); + + $error = $end - $start - $timeout; + + $limit = abs(log10($timeout)); // empirical value + + echo 'error: ', $error, PHP_EOL; + echo 'limit: ', $limit, PHP_EOL; + + echo abs($error) <= $limit ? 'timings OK' : 'timings failed'; // error should be less than 5% of timeout value +} +?> +--EXPECTF-- +Parameter 'connect_timeout' must be greater than or equal to zero. +Socket error: could not connect to host. +error: %f +limit: %f +timings OK diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_construct_with_limits.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_construct_with_limits.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_construct_with_limits.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_construct_with_limits.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,49 @@ +--TEST-- +AMQPConnection constructor with channel_max, frame_max and heartbeat limits +--SKIPIF-- + +--FILE-- + 10, + 'frame_max' => 10240, + 'heartbeat' => 5, +); +$cnn = new AMQPConnection($credentials); +$cnn->connect(); + +var_dump($cnn); +?> +--EXPECT-- +object(AMQPConnection)#1 (15) { + ["login":"AMQPConnection":private]=> + string(5) "guest" + ["password":"AMQPConnection":private]=> + string(5) "guest" + ["host":"AMQPConnection":private]=> + string(9) "localhost" + ["vhost":"AMQPConnection":private]=> + string(1) "/" + ["port":"AMQPConnection":private]=> + int(5672) + ["read_timeout":"AMQPConnection":private]=> + float(0) + ["write_timeout":"AMQPConnection":private]=> + float(0) + ["connect_timeout":"AMQPConnection":private]=> + float(0) + ["channel_max":"AMQPConnection":private]=> + int(10) + ["frame_max":"AMQPConnection":private]=> + int(10240) + ["heartbeat":"AMQPConnection":private]=> + int(5) + ["cacert":"AMQPConnection":private]=> + string(0) "" + ["key":"AMQPConnection":private]=> + string(0) "" + ["cert":"AMQPConnection":private]=> + string(0) "" + ["verify":"AMQPConnection":private]=> + bool(true) +} diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_construct_with_timeout_and_read_timeout.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_construct_with_timeout_and_read_timeout.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_construct_with_timeout_and_read_timeout.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_construct_with_timeout_and_read_timeout.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,13 @@ +--TEST-- +AMQPConnection constructor with both timeout and read_timeout parameters in credentials +--SKIPIF-- + +--FILE-- + 101.101, 'read_timeout' => 202.202); +$cnn = new AMQPConnection($credentials); +var_dump($cnn->getReadTimeout()); +?> +--EXPECTF-- +Notice: AMQPConnection::__construct(): Parameter 'timeout' is deprecated, 'read_timeout' used instead in %s on line 3 +float(202.202) diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_construct_with_timeout.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_construct_with_timeout.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_construct_with_timeout.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_construct_with_timeout.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,13 @@ +--TEST-- +AMQPConnection constructor with timeout parameter in credentials +--SKIPIF-- + +--FILE-- + 101.101); +$cnn = new AMQPConnection($credentials); +var_dump($cnn->getReadTimeout()); +?> +--EXPECTF-- +%s: AMQPConnection::__construct(): Parameter 'timeout' is deprecated; use 'read_timeout' instead in %s on line 3 +float(101.101) diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_construct_with_write_timeout.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_construct_with_write_timeout.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_construct_with_write_timeout.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_construct_with_write_timeout.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,12 @@ +--TEST-- +AMQPConnection constructor with write_timeout parameter in creadentials +--SKIPIF-- + +--FILE-- + 303.303); +$cnn = new AMQPConnection($credentials); +var_dump($cnn->getWriteTimeout()); +?> +--EXPECT-- +float(303.303) diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_getUsedChannels.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_getUsedChannels.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_getUsedChannels.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_getUsedChannels.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,25 @@ +--TEST-- +AMQPConnection::getUsedChannels() +--SKIPIF-- + +--FILE-- +getUsedChannels(), PHP_EOL; +$cnn->connect(); +echo get_class($cnn), '::getUsedChannels():', $cnn->getUsedChannels(), PHP_EOL; + +$ch = new AMQPChannel($cnn); +echo get_class($cnn), '::getUsedChannels():', $cnn->getUsedChannels(), PHP_EOL; + +$ch = null; +echo get_class($cnn), '::getUsedChannels():', $cnn->getUsedChannels(), PHP_EOL; + +?> +--EXPECTF-- +AMQPConnection::getUsedChannels(): +Warning: AMQPConnection::getUsedChannels(): Connection is not connected. in %s on line %d +0 +AMQPConnection::getUsedChannels():0 +AMQPConnection::getUsedChannels():1 +AMQPConnection::getUsedChannels():0 diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_heartbeat.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_heartbeat.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_heartbeat.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_heartbeat.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,37 @@ +--TEST-- +AMQPConnection - heartbeats support +--SKIPIF-- + +--FILE-- + $heartbeat); +$cnn = new AMQPConnection($credentials); +$cnn->connect(); + +echo 'heartbeat: ', var_export($cnn->getHeartbeatInterval(), true), PHP_EOL; +echo 'connected: ', var_export($cnn->isConnected(), true), PHP_EOL; +echo 'persistent: ', var_export($cnn->isPersistent(), true), PHP_EOL; + +sleep($heartbeat*5); + +try { + $ch = new AMQPChannel($cnn); + echo 'channel created', PHP_EOL; +} catch (AMQPException $e) { + echo get_class($e), "({$e->getCode()}): ", $e->getMessage(), PHP_EOL; +} + +echo 'heartbeat: ', var_export($cnn->getHeartbeatInterval(), true), PHP_EOL; +echo 'connected: ', var_export($cnn->isConnected(), true), PHP_EOL; +echo 'persistent: ', var_export($cnn->isPersistent(), true), PHP_EOL; + +?> +--EXPECTF-- +heartbeat: 2 +connected: true +persistent: false +AMQPException(0): Library error: a socket error occurred +heartbeat: 2 +connected: false +persistent: false diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_heartbeat_with_consumer.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_heartbeat_with_consumer.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_heartbeat_with_consumer.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_heartbeat_with_consumer.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,98 @@ +--TEST-- +AMQPConnection heartbeats support (with active consumer) +--SKIPIF-- + +--FILE-- + $heartbeat, 'read_timeout' => $heartbeat * 20); +$cnn = new AMQPConnection($credentials); +$cnn->connect(); + +var_dump($cnn); + +$ch = new AMQPChannel($cnn); + +$q_dead_name = 'test.queue.dead.' . microtime(true); +$q_name = 'test.queue.' . microtime(true); + +$e = new AMQPExchange($ch); + +$q = new AMQPQueue($ch); +$q->setName($q_name); +$q->declareQueue(); + + +$q_dead = new AMQPQueue($ch); +$q_dead->setName($q_dead_name); +$q_dead->setArgument('x-dead-letter-exchange', ''); +$q_dead->setArgument('x-dead-letter-routing-key', $q_name); +$q_dead->setArgument('x-message-ttl', $heartbeat * 10 * 1000); +$q_dead->declareQueue(); + +$e->publish('test message 1 (should be dead lettered)', $q_dead_name); + +$t = microtime(true); +$q->consume(function (AMQPEnvelope $envelope) { + echo 'Consumed: ', $envelope->getBody(), PHP_EOL; + return false; +}); +$t = microtime(true) - $t; + +echo 'Consuming took: ', (float) round($t, 4), 'sec', PHP_EOL; + +$t_min = (float)round($heartbeat * 9.5, 4); +$t_max = (float)round($heartbeat * 10.5, 4); + +if ($t > $t_min && $t < $t_max) { + echo "Timing OK ($t_min < $t < $t_max)", PHP_EOL; +} else { + echo "Timing ERROR ($t_min < $t < $t_max)", PHP_EOL; +} + +$ch2 = new AMQPChannel($cnn); + +sleep($heartbeat/2); + +$ch3 = new AMQPChannel($cnn); + +echo 'Done', PHP_EOL + +?> +--EXPECTF-- +object(AMQPConnection)#1 (15) { + ["login":"AMQPConnection":private]=> + string(5) "guest" + ["password":"AMQPConnection":private]=> + string(5) "guest" + ["host":"AMQPConnection":private]=> + string(9) "localhost" + ["vhost":"AMQPConnection":private]=> + string(1) "/" + ["port":"AMQPConnection":private]=> + int(5672) + ["read_timeout":"AMQPConnection":private]=> + float(40) + ["write_timeout":"AMQPConnection":private]=> + float(0) + ["connect_timeout":"AMQPConnection":private]=> + float(0) + ["channel_max":"AMQPConnection":private]=> + int(256) + ["frame_max":"AMQPConnection":private]=> + int(131072) + ["heartbeat":"AMQPConnection":private]=> + int(2) + ["cacert":"AMQPConnection":private]=> + string(0) "" + ["key":"AMQPConnection":private]=> + string(0) "" + ["cert":"AMQPConnection":private]=> + string(0) "" + ["verify":"AMQPConnection":private]=> + bool(true) +} +Consumed: test message 1 (should be dead lettered) +Consuming took: %fsec +Timing OK (%f < %f < %f) +Done diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_heartbeat_with_persistent.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_heartbeat_with_persistent.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_heartbeat_with_persistent.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_heartbeat_with_persistent.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,92 @@ +--TEST-- +AMQPConnection - heartbeats support with persistent connections +--SKIPIF-- + +--FILE-- + $heartbeat); + +$cnn = new AMQPConnection($credentials); + +echo 'heartbeat: ', var_export($cnn->getHeartbeatInterval(), true), PHP_EOL; +echo 'connected: ', var_export($cnn->isConnected(), true), PHP_EOL; +echo 'persistent: ', var_export($cnn->isPersistent(), true), PHP_EOL; +echo PHP_EOL; + +$cnn->pconnect(); + +echo 'heartbeat: ', var_export($cnn->getHeartbeatInterval(), true), PHP_EOL; +echo 'connected: ', var_export($cnn->isConnected(), true), PHP_EOL; +echo 'persistent: ', var_export($cnn->isPersistent(), true), PHP_EOL; +echo PHP_EOL; + +sleep($heartbeat*5); + +try { + $ch = new AMQPChannel($cnn); + echo 'channel created', PHP_EOL; +} catch (AMQPException $e) { + echo get_class($e), "({$e->getCode()}): ", $e->getMessage(), PHP_EOL; +} + +echo PHP_EOL; +echo 'heartbeat: ', var_export($cnn->getHeartbeatInterval(), true), PHP_EOL; +echo 'connected: ', var_export($cnn->isConnected(), true), PHP_EOL; +echo 'persistent: ', var_export($cnn->isPersistent(), true), PHP_EOL; +echo PHP_EOL; + +$cnn = new AMQPConnection($credentials); +$cnn->pconnect(); + +echo 'heartbeat: ', var_export($cnn->getHeartbeatInterval(), true), PHP_EOL; +echo 'connected: ', var_export($cnn->isConnected(), true), PHP_EOL; +echo 'persistent: ', var_export($cnn->isPersistent(), true), PHP_EOL; +echo PHP_EOL; + + +$ch = new AMQPChannel($cnn); +echo 'channel created', PHP_EOL; +echo PHP_EOL; + +echo 'heartbeat: ', var_export($cnn->getHeartbeatInterval(), true), PHP_EOL; +echo 'connected: ', var_export($cnn->isConnected(), true), PHP_EOL; +echo 'persistent: ', var_export($cnn->isPersistent(), true), PHP_EOL; +echo PHP_EOL; + +$cnn->pdisconnect(); + +echo 'heartbeat: ', var_export($cnn->getHeartbeatInterval(), true), PHP_EOL; +echo 'connected: ', var_export($cnn->isConnected(), true), PHP_EOL; +echo 'persistent: ', var_export($cnn->isPersistent(), true), PHP_EOL; +echo PHP_EOL; + +?> +--EXPECTF-- +heartbeat: 2 +connected: false +persistent: false + +heartbeat: 2 +connected: true +persistent: true + +AMQPException(0): Library error: a socket error occurred + +heartbeat: 2 +connected: false +persistent: false + +heartbeat: 2 +connected: true +persistent: true + +channel created + +heartbeat: 2 +connected: true +persistent: true + +heartbeat: 2 +connected: false +persistent: false diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_persistent_construct_basic.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_persistent_construct_basic.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_persistent_construct_basic.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_persistent_construct_basic.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,16 @@ +--TEST-- +AMQPConnection persitent constructor +--SKIPIF-- + +--FILE-- +pconnect(); +echo get_class($cnn) . "\n"; +echo $cnn->isConnected() ? 'true' : 'false', PHP_EOL; +echo $cnn->isPersistent() ? 'true' : 'false', PHP_EOL; +?> +--EXPECT-- +AMQPConnection +true +true \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_persistent_in_use.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_persistent_in_use.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_persistent_in_use.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_persistent_in_use.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,32 @@ +--TEST-- +AMQPConnection persitent connection resource can't be used by multiple connection +--SKIPIF-- + +--FILE-- +pconnect(); +echo $cnn->isConnected() ? 'true' : 'false', PHP_EOL; + +echo PHP_EOL; + +$cnn2 = new AMQPConnection(); +echo get_class($cnn), PHP_EOL; + +try { + $cnn2->pconnect(); + echo 'reused', PHP_EOL; +} catch (AMQPException $e) { + echo get_class($e), "({$e->getCode()}): ", $e->getMessage(), PHP_EOL; +} +echo $cnn->isConnected() ? 'true' : 'false', PHP_EOL; + +?> +--EXPECT-- +AMQPConnection +true + +AMQPConnection +AMQPConnectionException(0): There are already established persistent connection to the same resource. +true \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_persistent_reusable.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_persistent_reusable.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_persistent_reusable.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_persistent_reusable.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,46 @@ +--TEST-- +AMQPConnection persistent connection are reusable +--SKIPIF-- + +--FILE-- +pconnect(); +echo get_class($cnn), PHP_EOL; +echo $cnn->isConnected() ? 'true' : 'false', PHP_EOL; + +if ($manual) { + $ch = new AMQPChannel($cnn); + sleep(10); + $ch = null; +} + +$cnn = null; +echo PHP_EOL; + +if ($manual) { + sleep(10); +} + +$cnn = new AMQPConnection(); +$cnn->pconnect(); +echo get_class($cnn), PHP_EOL; +echo $cnn->isConnected() ? 'true' : 'false', PHP_EOL; + +if ($manual) { + $ch = new AMQPChannel($cnn); + sleep(10); + $ch = null; +} + +$cnn->pdisconnect(); + +?> +--EXPECT-- +AMQPConnection +true + +AMQPConnection +true diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_setHost.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_setHost.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_setHost.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_setHost.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,13 @@ +--TEST-- +AMQPConnection setHost +--SKIPIF-- + +--FILE-- +getHost()); +$cnn->setHost('nonexistent'); +var_dump($cnn->getHost()); +--EXPECTF-- +string(9) "localhost" +string(11) "nonexistent" diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_setLogin.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_setLogin.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_setLogin.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_setLogin.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,13 @@ +--TEST-- +AMQPConnection setLogin +--SKIPIF-- + +--FILE-- +getLogin()); +$cnn->setLogin('nonexistent'); +var_dump($cnn->getLogin()); +--EXPECTF-- +string(5) "guest" +string(11) "nonexistent" diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_setPassword.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_setPassword.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_setPassword.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_setPassword.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,13 @@ +--TEST-- +AMQPConnection setPassword +--SKIPIF-- + +--FILE-- +getPassword()); +$cnn->setPassword('nonexistent'); +var_dump($cnn->getPassword()); +--EXPECTF-- +string(5) "guest" +string(11) "nonexistent" diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_setPort_int.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_setPort_int.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_setPort_int.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_setPort_int.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,13 @@ +--TEST-- +AMQPConnection constructor +--SKIPIF-- + +--FILE-- +setPort(12345), true), PHP_EOL; +echo $cnn->getPort(), PHP_EOL; +?> +--EXPECT-- +true +12345 diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_setPort_out_of_range.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_setPort_out_of_range.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_setPort_out_of_range.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_setPort_out_of_range.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,15 @@ +--TEST-- +AMQPConnection setPort with int out of range +--SKIPIF-- + +--FILE-- +setPort(1234567890); +} catch (Exception $e) { + echo $e->getMessage(); +} +?> +--EXPECT-- +Invalid port given. Value must be between 1 and 65535. \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_setPort_string.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_setPort_string.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_setPort_string.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_setPort_string.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,11 @@ +--TEST-- +AMQPConnection setPort with string +--SKIPIF-- + +--FILE-- +setPort('12345'); +?> +--EXPECT-- +1 \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_setReadTimeout_float.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_setReadTimeout_float.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_setReadTimeout_float.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_setReadTimeout_float.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,14 @@ +--TEST-- +AMQPConnection setReadTimeout float +--SKIPIF-- + +--FILE-- +setReadTimeout(.34); +var_dump($cnn->getReadTimeout()); +$cnn->setReadTimeout(4.7e-2); +var_dump($cnn->getReadTimeout());?> +--EXPECT-- +float(0.34) +float(0.047) diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_setReadTimeout_int.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_setReadTimeout_int.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_setReadTimeout_int.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_setReadTimeout_int.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,12 @@ +--TEST-- +AMQPConnection setReadTimeout int +--SKIPIF-- + +--FILE-- +setReadTimeout(3); +var_dump($cnn->getReadTimeout()); +?> +--EXPECT-- +float(3) diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_setReadTimeout_out_of_range.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_setReadTimeout_out_of_range.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_setReadTimeout_out_of_range.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_setReadTimeout_out_of_range.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,18 @@ +--TEST-- +AMQPConnection setReadTimeout out of range +--SKIPIF-- + +--FILE-- +setReadTimeout(-1); +} catch (Exception $e) { + echo get_class($e); + echo PHP_EOL; + echo $e->getMessage(); +} +?> +--EXPECT-- +AMQPConnectionException +Parameter 'read_timeout' must be greater than or equal to zero. diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_setReadTimeout_string.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_setReadTimeout_string.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_setReadTimeout_string.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_setReadTimeout_string.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,14 @@ +--TEST-- +AMQPConnection setReadTimeout string +--SKIPIF-- + +--FILE-- +setReadTimeout(".34"); +var_dump($cnn->getReadTimeout()); +$cnn->setReadTimeout("4.7e-2"); +var_dump($cnn->getReadTimeout());?> +--EXPECT-- +float(0.34) +float(0.047) diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_setTimeout_deprecated.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_setTimeout_deprecated.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_setTimeout_deprecated.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_setTimeout_deprecated.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,14 @@ +--TEST-- +AMQPConnection setTimeout deprecated +--SKIPIF-- + +--FILE-- +setTimeout(0); +$cnn->getTimeout(); +?> +--EXPECTF-- +%s: AMQPConnection::setTimeout(): AMQPConnection::setTimeout($timeout) method is deprecated; use AMQPConnection::setReadTimeout($timeout) instead in %s on line 3 + +%s: AMQPConnection::getTimeout(): AMQPConnection::getTimeout() method is deprecated; use AMQPConnection::getReadTimeout() instead in %s on line 4 diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_setTimeout_float.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_setTimeout_float.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_setTimeout_float.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_setTimeout_float.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,21 @@ +--TEST-- +AMQPConnection setTimeout float +--SKIPIF-- + +--FILE-- +setTimeout(.34); +var_dump($cnn->getTimeout()); +$cnn->setTimeout(4.7e-2); +var_dump($cnn->getTimeout());?> +--EXPECTF-- +%s: AMQPConnection::setTimeout(): AMQPConnection::setTimeout($timeout) method is deprecated; use AMQPConnection::setReadTimeout($timeout) instead in %s on line 3 + +%s: AMQPConnection::getTimeout(): AMQPConnection::getTimeout() method is deprecated; use AMQPConnection::getReadTimeout() instead in %s on line 4 +float(0.34) + +%s: AMQPConnection::setTimeout(): AMQPConnection::setTimeout($timeout) method is deprecated; use AMQPConnection::setReadTimeout($timeout) instead in %s on line 5 + +%s: AMQPConnection::getTimeout(): AMQPConnection::getTimeout() method is deprecated; use AMQPConnection::getReadTimeout() instead in %s on line 6 +float(0.047) diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_setTimeout_int.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_setTimeout_int.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_setTimeout_int.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_setTimeout_int.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,15 @@ +--TEST-- +AMQPConnection setTimeout int +--SKIPIF-- + +--FILE-- +setTimeout(3); +var_dump($cnn->getTimeout()); +?> +--EXPECTF-- +%s: AMQPConnection::setTimeout(): AMQPConnection::setTimeout($timeout) method is deprecated; use AMQPConnection::setReadTimeout($timeout) instead in %s on line 3 + +%s: AMQPConnection::getTimeout(): AMQPConnection::getTimeout() method is deprecated; use AMQPConnection::getReadTimeout() instead in %s on line 4 +float(3) diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_setTimeout_out_of_range.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_setTimeout_out_of_range.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_setTimeout_out_of_range.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_setTimeout_out_of_range.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,19 @@ +--TEST-- +AMQPConnection setTimeout out of range +--SKIPIF-- + +--FILE-- +setTimeout(-1); +} catch (Exception $e) { + echo get_class($e); + echo PHP_EOL; + echo $e->getMessage(); +} +?> +--EXPECTF-- +%s: AMQPConnection::setTimeout(): AMQPConnection::setTimeout($timeout) method is deprecated; use AMQPConnection::setReadTimeout($timeout) instead in %s on line 4 +AMQPConnectionException +Parameter 'timeout' must be greater than or equal to zero. diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_setTimeout_string.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_setTimeout_string.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_setTimeout_string.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_setTimeout_string.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,21 @@ +--TEST-- +AMQPConnection setTimeout string +--SKIPIF-- + +--FILE-- +setTimeout(".34"); +var_dump($cnn->getTimeout()); +$cnn->setTimeout("4.7e-2"); +var_dump($cnn->getTimeout());?> +--EXPECTF-- +%s: AMQPConnection::setTimeout(): AMQPConnection::setTimeout($timeout) method is deprecated; use AMQPConnection::setReadTimeout($timeout) instead in %s on line 3 + +%s: AMQPConnection::getTimeout(): AMQPConnection::getTimeout() method is deprecated; use AMQPConnection::getReadTimeout() instead in %s on line 4 +float(0.34) + +%s: AMQPConnection::setTimeout(): AMQPConnection::setTimeout($timeout) method is deprecated; use AMQPConnection::setReadTimeout($timeout) instead in %s on line 5 + +%s: AMQPConnection::getTimeout(): AMQPConnection::getTimeout() method is deprecated; use AMQPConnection::getReadTimeout() instead in %s on line 6 +float(0.047) diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_setVhost.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_setVhost.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_setVhost.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_setVhost.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,13 @@ +--TEST-- +AMQPConnection setVhost +--SKIPIF-- + +--FILE-- +getVhost()); +$cnn->setVhost('nonexistent'); +var_dump($cnn->getVhost()); +--EXPECTF-- +string(1) "/" +string(11) "nonexistent" diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_setWriteTimeout_float.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_setWriteTimeout_float.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_setWriteTimeout_float.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_setWriteTimeout_float.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,14 @@ +--TEST-- +AMQPConnection setWriteTimeout float +--SKIPIF-- + +--FILE-- +setWriteTimeout(.34); +var_dump($cnn->getWriteTimeout()); +$cnn->setWriteTimeout(4.7e-2); +var_dump($cnn->getWriteTimeout());?> +--EXPECT-- +float(0.34) +float(0.047) diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_setWriteTimeout_int.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_setWriteTimeout_int.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_setWriteTimeout_int.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_setWriteTimeout_int.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,12 @@ +--TEST-- +AMQPConnection setWriteTimeout int +--SKIPIF-- + +--FILE-- +setWriteTimeout(3); +var_dump($cnn->getWriteTimeout()); +?> +--EXPECT-- +float(3) diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_setWriteTimeout_out_of_range.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_setWriteTimeout_out_of_range.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_setWriteTimeout_out_of_range.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_setWriteTimeout_out_of_range.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,18 @@ +--TEST-- +AMQPConnection setWriteTimeout out of range +--SKIPIF-- + +--FILE-- +setWriteTimeout(-1); +} catch (Exception $e) { + echo get_class($e); + echo PHP_EOL; + echo $e->getMessage(); +} +?> +--EXPECT-- +AMQPConnectionException +Parameter 'write_timeout' must be greater than or equal to zero. diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_setWriteTimeout_string.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_setWriteTimeout_string.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_setWriteTimeout_string.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_setWriteTimeout_string.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,15 @@ +--TEST-- +AMQPConnection setWriteTimeout string +--SKIPIF-- + +--FILE-- +setWriteTimeout(".34"); +var_dump($cnn->getWriteTimeout()); +$cnn->setWriteTimeout("4.7e-2"); +var_dump($cnn->getWriteTimeout()); +?> +--EXPECT-- +float(0.34) +float(0.047) diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_ssl.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_ssl.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_ssl.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_ssl.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,129 @@ +--TEST-- +AMQPConnection - ssl support +--SKIPIF-- + + +--FILE-- + gethostname(), //'vagrant-ubuntu-wily-64', + 'port' => 5671, + + 'verify' => false, + + 'cacert' => "/home/vagrant/php-amqp/provision/test_certs/testca/cacert.pem", + 'cert' => "/home/vagrant/php-amqp/provision/test_certs/client/cert.pem", + 'key' => "/home/vagrant/php-amqp/provision/test_certs/client/key.pem", +); + +$cnn = new AMQPConnection($credentials); + +var_dump($cnn); + +$cnn->connect(); + +echo ($cnn->isConnected() ? 'connected' : 'disconnected'), PHP_EOL; + +echo PHP_EOL; + +$cnn = new AMQPConnection(); +$cnn->setPort(5671); +$cnn->setCACert("/home/vagrant/php-amqp/provision/test_certs/testca/cacert.pem"); +$cnn->setCert("/home/vagrant/php-amqp/provision/test_certs/client/cert.pem"); +$cnn->setKey("/home/vagrant/php-amqp/provision/test_certs/client/key.pem"); +$cnn->setVerify(false); +var_dump($cnn); + +$cnn->connect(); + +echo ($cnn->isConnected() ? 'connected' : 'disconnected'), PHP_EOL; + +//sleep(100); + +?> +--EXPECT-- +object(AMQPConnection)#1 (15) { + ["login":"AMQPConnection":private]=> + string(5) "guest" + ["password":"AMQPConnection":private]=> + string(5) "guest" + ["host":"AMQPConnection":private]=> + string(9) "localhost" + ["vhost":"AMQPConnection":private]=> + string(1) "/" + ["port":"AMQPConnection":private]=> + int(5671) + ["read_timeout":"AMQPConnection":private]=> + float(0) + ["write_timeout":"AMQPConnection":private]=> + float(0) + ["connect_timeout":"AMQPConnection":private]=> + float(0) + ["channel_max":"AMQPConnection":private]=> + int(256) + ["frame_max":"AMQPConnection":private]=> + int(131072) + ["heartbeat":"AMQPConnection":private]=> + int(0) + ["cacert":"AMQPConnection":private]=> + string(61) "/home/vagrant/php-amqp/provision/test_certs/testca/cacert.pem" + ["key":"AMQPConnection":private]=> + string(58) "/home/vagrant/php-amqp/provision/test_certs/client/key.pem" + ["cert":"AMQPConnection":private]=> + string(59) "/home/vagrant/php-amqp/provision/test_certs/client/cert.pem" + ["verify":"AMQPConnection":private]=> + bool(false) +} +connected + +object(AMQPConnection)#2 (15) { + ["login":"AMQPConnection":private]=> + string(5) "guest" + ["password":"AMQPConnection":private]=> + string(5) "guest" + ["host":"AMQPConnection":private]=> + string(9) "localhost" + ["vhost":"AMQPConnection":private]=> + string(1) "/" + ["port":"AMQPConnection":private]=> + int(5671) + ["read_timeout":"AMQPConnection":private]=> + float(0) + ["write_timeout":"AMQPConnection":private]=> + float(0) + ["connect_timeout":"AMQPConnection":private]=> + float(0) + ["channel_max":"AMQPConnection":private]=> + int(256) + ["frame_max":"AMQPConnection":private]=> + int(131072) + ["heartbeat":"AMQPConnection":private]=> + int(0) + ["cacert":"AMQPConnection":private]=> + string(61) "/home/vagrant/php-amqp/provision/test_certs/testca/cacert.pem" + ["key":"AMQPConnection":private]=> + string(58) "/home/vagrant/php-amqp/provision/test_certs/client/key.pem" + ["cert":"AMQPConnection":private]=> + string(59) "/home/vagrant/php-amqp/provision/test_certs/client/cert.pem" + ["verify":"AMQPConnection":private]=> + bool(false) +} +connected diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_toomanychannels.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_toomanychannels.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_toomanychannels.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_toomanychannels.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,29 @@ +--TEST-- +AMQPConnection too many channels on a connection +--SKIPIF-- + +--FILE-- +connect(); + +$channels = array(); + +for ($i = 0; $i < PHP_AMQP_MAX_CHANNELS; $i++) { + $channel = $channels[] = new AMQPChannel($cnn); + //echo '#', $channel->getChannelId(), ', used ', $cnn->getUsedChannels(), ' of ', $cnn->getMaxChannels(), PHP_EOL; +} + +echo "Good\n"; + +try { + new AMQPChannel($cnn); + echo "Bad\n"; +} catch(Exception $e) { + echo get_class($e), "({$e->getCode()}): ", $e->getMessage(), PHP_EOL; +} + +?> +--EXPECT-- +Good +AMQPChannelException(0): Could not create channel. Connection has no open channel slots remaining. \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_var_dump.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_var_dump.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpconnection_var_dump.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpconnection_var_dump.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,124 @@ +--TEST-- +AMQPConnection var_dump +--SKIPIF-- + +--FILE-- +isConnected()); +var_dump($cnn); +$cnn->connect(); +var_dump($cnn->isConnected()); +$cnn->connect(); +var_dump($cnn->isConnected()); +var_dump($cnn); + +$cnn->disconnect(); +var_dump($cnn->isConnected()); +var_dump($cnn); +?> +--EXPECT-- +bool(false) +object(AMQPConnection)#1 (15) { + ["login":"AMQPConnection":private]=> + string(5) "guest" + ["password":"AMQPConnection":private]=> + string(5) "guest" + ["host":"AMQPConnection":private]=> + string(9) "localhost" + ["vhost":"AMQPConnection":private]=> + string(1) "/" + ["port":"AMQPConnection":private]=> + int(5672) + ["read_timeout":"AMQPConnection":private]=> + float(0) + ["write_timeout":"AMQPConnection":private]=> + float(0) + ["connect_timeout":"AMQPConnection":private]=> + float(0) + ["channel_max":"AMQPConnection":private]=> + int(256) + ["frame_max":"AMQPConnection":private]=> + int(131072) + ["heartbeat":"AMQPConnection":private]=> + int(0) + ["cacert":"AMQPConnection":private]=> + string(0) "" + ["key":"AMQPConnection":private]=> + string(0) "" + ["cert":"AMQPConnection":private]=> + string(0) "" + ["verify":"AMQPConnection":private]=> + bool(true) +} +bool(true) +bool(true) +object(AMQPConnection)#1 (15) { + ["login":"AMQPConnection":private]=> + string(5) "guest" + ["password":"AMQPConnection":private]=> + string(5) "guest" + ["host":"AMQPConnection":private]=> + string(9) "localhost" + ["vhost":"AMQPConnection":private]=> + string(1) "/" + ["port":"AMQPConnection":private]=> + int(5672) + ["read_timeout":"AMQPConnection":private]=> + float(0) + ["write_timeout":"AMQPConnection":private]=> + float(0) + ["connect_timeout":"AMQPConnection":private]=> + float(0) + ["channel_max":"AMQPConnection":private]=> + int(256) + ["frame_max":"AMQPConnection":private]=> + int(131072) + ["heartbeat":"AMQPConnection":private]=> + int(0) + ["cacert":"AMQPConnection":private]=> + string(0) "" + ["key":"AMQPConnection":private]=> + string(0) "" + ["cert":"AMQPConnection":private]=> + string(0) "" + ["verify":"AMQPConnection":private]=> + bool(true) +} +bool(false) +object(AMQPConnection)#1 (15) { + ["login":"AMQPConnection":private]=> + string(5) "guest" + ["password":"AMQPConnection":private]=> + string(5) "guest" + ["host":"AMQPConnection":private]=> + string(9) "localhost" + ["vhost":"AMQPConnection":private]=> + string(1) "/" + ["port":"AMQPConnection":private]=> + int(5672) + ["read_timeout":"AMQPConnection":private]=> + float(0) + ["write_timeout":"AMQPConnection":private]=> + float(0) + ["connect_timeout":"AMQPConnection":private]=> + float(0) + ["channel_max":"AMQPConnection":private]=> + int(256) + ["frame_max":"AMQPConnection":private]=> + int(131072) + ["heartbeat":"AMQPConnection":private]=> + int(0) + ["cacert":"AMQPConnection":private]=> + string(0) "" + ["key":"AMQPConnection":private]=> + string(0) "" + ["cert":"AMQPConnection":private]=> + string(0) "" + ["verify":"AMQPConnection":private]=> + bool(true) +} diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpdecimal.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpdecimal.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpdecimal.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpdecimal.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,68 @@ +--TEST-- +AMQPDecimal +--SKIPIF-- +getExponent(), $decimal->getSignificand()); + +$decimal = new AMQPDecimal(1.1, 2.2); +var_dump($decimal->getExponent(), $decimal->getSignificand()); + + +try { + new AMQPDecimal(-1, 1); +} catch (AMQPValueException $e) { + echo $e->getMessage() . "\n"; +} + +try { + new AMQPDecimal(1, -1); +} catch (AMQPValueException $e) { + echo $e->getMessage() . "\n"; +} + + +try { + new AMQPDecimal(AMQPDecimal::EXPONENT_MAX+1, 1); +} catch (AMQPValueException $e) { + echo $e->getMessage() . "\n"; +} + +try { + new AMQPDecimal(1, AMQPDecimal::SIGNIFICAND_MAX+1); +} catch (AMQPValueException $e) { + echo $e->getMessage() . "\n"; +} + + +var_dump((new ReflectionClass("AMQPDecimal"))->isFinal()); + +var_dump(AMQPDecimal::EXPONENT_MIN); +var_dump(AMQPDecimal::EXPONENT_MAX); +var_dump(AMQPDecimal::SIGNIFICAND_MIN); +var_dump(AMQPDecimal::SIGNIFICAND_MAX); +?> + +==END== +--EXPECT-- +int(1) +int(2) +int(1) +int(2) +Decimal exponent value must be unsigned. +Decimal significand value must be unsigned. +Decimal exponent value must be less than 255. +Decimal significand value must be less than 4294967295. +bool(true) +int(0) +int(255) +int(0) +int(4294967295) + +==END== diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpenvelope_construct.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpenvelope_construct.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpenvelope_construct.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpenvelope_construct.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,55 @@ +--TEST-- +AMQPEnvelope construct +--SKIPIF-- + +--EXPECT-- +object(AMQPEnvelope)#1 (20) { + ["content_type":"AMQPBasicProperties":private]=> + string(0) "" + ["content_encoding":"AMQPBasicProperties":private]=> + string(0) "" + ["headers":"AMQPBasicProperties":private]=> + array(0) { + } + ["delivery_mode":"AMQPBasicProperties":private]=> + int(1) + ["priority":"AMQPBasicProperties":private]=> + int(0) + ["correlation_id":"AMQPBasicProperties":private]=> + string(0) "" + ["reply_to":"AMQPBasicProperties":private]=> + string(0) "" + ["expiration":"AMQPBasicProperties":private]=> + string(0) "" + ["message_id":"AMQPBasicProperties":private]=> + string(0) "" + ["timestamp":"AMQPBasicProperties":private]=> + int(0) + ["type":"AMQPBasicProperties":private]=> + string(0) "" + ["user_id":"AMQPBasicProperties":private]=> + string(0) "" + ["app_id":"AMQPBasicProperties":private]=> + string(0) "" + ["cluster_id":"AMQPBasicProperties":private]=> + string(0) "" + ["body":"AMQPEnvelope":private]=> + NULL + ["consumer_tag":"AMQPEnvelope":private]=> + NULL + ["delivery_tag":"AMQPEnvelope":private]=> + NULL + ["is_redelivery":"AMQPEnvelope":private]=> + NULL + ["exchange_name":"AMQPEnvelope":private]=> + NULL + ["routing_key":"AMQPEnvelope":private]=> + NULL +} diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpenvelope_get_accessors.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpenvelope_get_accessors.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpenvelope_get_accessors.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpenvelope_get_accessors.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,127 @@ +--TEST-- +AMQPEnvelope test get*() accessors +--SKIPIF-- + +--FILE-- +connect(); +$ch = new AMQPChannel($cnn); +// Declare a new exchange +$ex = new AMQPExchange($ch); +$ex->setName('exchange-'.microtime(true)); +$ex->setType(AMQP_EX_TYPE_FANOUT); +$ex->declareExchange(); +// Create a new queue +$q = new AMQPQueue($ch); +$q->setName('queue1' . microtime(true)); +$q->declareQueue(); +// Bind it on the exchange to routing.key +$q->bind($ex->getName(), 'routing.*'); +// Publish a message to the exchange with a routing key +$ex->publish('message', 'routing.1', AMQP_NOPARAM, array('headers' => array('foo' => 'bar'))); + +// Read from the queue +$msg = $q->get(); +var_dump($msg); +dump_message($msg); + +$header = $msg->getHeader('foo'); +var_dump($header); +$header = 'changed'; +$header = $msg->getHeader('foo'); +var_dump($header); + +?> +--EXPECTF-- +object(AMQPEnvelope)#5 (20) { + ["content_type":"AMQPBasicProperties":private]=> + string(10) "text/plain" + ["content_encoding":"AMQPBasicProperties":private]=> + string(0) "" + ["headers":"AMQPBasicProperties":private]=> + array(1) { + ["foo"]=> + string(3) "bar" + } + ["delivery_mode":"AMQPBasicProperties":private]=> + int(1) + ["priority":"AMQPBasicProperties":private]=> + int(0) + ["correlation_id":"AMQPBasicProperties":private]=> + string(0) "" + ["reply_to":"AMQPBasicProperties":private]=> + string(0) "" + ["expiration":"AMQPBasicProperties":private]=> + string(0) "" + ["message_id":"AMQPBasicProperties":private]=> + string(0) "" + ["timestamp":"AMQPBasicProperties":private]=> + int(0) + ["type":"AMQPBasicProperties":private]=> + string(0) "" + ["user_id":"AMQPBasicProperties":private]=> + string(0) "" + ["app_id":"AMQPBasicProperties":private]=> + string(0) "" + ["cluster_id":"AMQPBasicProperties":private]=> + string(0) "" + ["body":"AMQPEnvelope":private]=> + string(7) "message" + ["consumer_tag":"AMQPEnvelope":private]=> + string(0) "" + ["delivery_tag":"AMQPEnvelope":private]=> + int(1) + ["is_redelivery":"AMQPEnvelope":private]=> + bool(false) + ["exchange_name":"AMQPEnvelope":private]=> + string(%d) "exchange-%f" + ["routing_key":"AMQPEnvelope":private]=> + string(9) "routing.1" +} +AMQPEnvelope + getBody: + string(7) "message" + getContentType: + string(10) "text/plain" + getRoutingKey: + string(9) "routing.1" + getConsumerTag: + string(0) "" + getDeliveryTag: + int(1) + getDeliveryMode: + int(1) + getExchangeName: + string(%d) "exchange-%f" + isRedelivery: + bool(false) + getContentEncoding: + string(0) "" + getType: + string(0) "" + getTimeStamp: + int(0) + getPriority: + int(0) + getExpiration: + string(0) "" + getUserId: + string(0) "" + getAppId: + string(0) "" + getMessageId: + string(0) "" + getReplyTo: + string(0) "" + getCorrelationId: + string(0) "" + getHeaders: + array(1) { + ["foo"]=> + string(3) "bar" +} +string(3) "bar" +string(3) "bar" diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpenvelope_var_dump.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpenvelope_var_dump.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpenvelope_var_dump.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpenvelope_var_dump.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,122 @@ +--TEST-- +AMQPEnvelope var_dump +--SKIPIF-- +connect(); +$ch = new AMQPChannel($cnn); +// Declare a new exchange +$ex = new AMQPExchange($ch); +$ex->setName('exchange1'); +$ex->setType(AMQP_EX_TYPE_FANOUT); +$ex->declareExchange(); +// Create a new queue +$q = new AMQPQueue($ch); +$q->setName('queue1' . microtime(true)); +$q->declareQueue(); +// Bind it on the exchange to routing.key +$q->bind($ex->getName(), 'routing.*'); +// Publish a message to the exchange with a routing key +$ex->publish('message', 'routing.1'); +$ex->publish('message', 'routing.1', AMQP_NOPARAM, array("headers" => array("test" => "passed"))); + +// Read from the queue +$q->consume("consumeThings"); +$q->consume("consumeThings"); +?> +--EXPECTF-- +object(AMQPEnvelope)#5 (20) { + ["content_type":"AMQPBasicProperties":private]=> + string(10) "text/plain" + ["content_encoding":"AMQPBasicProperties":private]=> + string(0) "" + ["headers":"AMQPBasicProperties":private]=> + array(0) { + } + ["delivery_mode":"AMQPBasicProperties":private]=> + int(1) + ["priority":"AMQPBasicProperties":private]=> + int(0) + ["correlation_id":"AMQPBasicProperties":private]=> + string(0) "" + ["reply_to":"AMQPBasicProperties":private]=> + string(0) "" + ["expiration":"AMQPBasicProperties":private]=> + string(0) "" + ["message_id":"AMQPBasicProperties":private]=> + string(0) "" + ["timestamp":"AMQPBasicProperties":private]=> + int(0) + ["type":"AMQPBasicProperties":private]=> + string(0) "" + ["user_id":"AMQPBasicProperties":private]=> + string(0) "" + ["app_id":"AMQPBasicProperties":private]=> + string(0) "" + ["cluster_id":"AMQPBasicProperties":private]=> + string(0) "" + ["body":"AMQPEnvelope":private]=> + string(7) "message" + ["consumer_tag":"AMQPEnvelope":private]=> + string(31) "amq.ctag-%s" + ["delivery_tag":"AMQPEnvelope":private]=> + int(1) + ["is_redelivery":"AMQPEnvelope":private]=> + bool(false) + ["exchange_name":"AMQPEnvelope":private]=> + string(9) "exchange1" + ["routing_key":"AMQPEnvelope":private]=> + string(9) "routing.1" +} +object(AMQPEnvelope)#5 (20) { + ["content_type":"AMQPBasicProperties":private]=> + string(10) "text/plain" + ["content_encoding":"AMQPBasicProperties":private]=> + string(0) "" + ["headers":"AMQPBasicProperties":private]=> + array(1) { + ["test"]=> + string(6) "passed" + } + ["delivery_mode":"AMQPBasicProperties":private]=> + int(1) + ["priority":"AMQPBasicProperties":private]=> + int(0) + ["correlation_id":"AMQPBasicProperties":private]=> + string(0) "" + ["reply_to":"AMQPBasicProperties":private]=> + string(0) "" + ["expiration":"AMQPBasicProperties":private]=> + string(0) "" + ["message_id":"AMQPBasicProperties":private]=> + string(0) "" + ["timestamp":"AMQPBasicProperties":private]=> + int(0) + ["type":"AMQPBasicProperties":private]=> + string(0) "" + ["user_id":"AMQPBasicProperties":private]=> + string(0) "" + ["app_id":"AMQPBasicProperties":private]=> + string(0) "" + ["cluster_id":"AMQPBasicProperties":private]=> + string(0) "" + ["body":"AMQPEnvelope":private]=> + string(7) "message" + ["consumer_tag":"AMQPEnvelope":private]=> + string(31) "amq.ctag-%s" + ["delivery_tag":"AMQPEnvelope":private]=> + int(2) + ["is_redelivery":"AMQPEnvelope":private]=> + bool(false) + ["exchange_name":"AMQPEnvelope":private]=> + string(9) "exchange1" + ["routing_key":"AMQPEnvelope":private]=> + string(9) "routing.1" +} diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_attributes.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_attributes.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_attributes.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_attributes.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,34 @@ +--TEST-- +AMQPExchange attributes +--SKIPIF-- + +--FILE-- +connect(); +$ch = new AMQPChannel($cnn); + +$ex = new AMQPExchange($ch); + +$ex->setArguments($arr = array('existent' => 'value', 'false' => false)); + +echo 'Initial args: ', count($arr), ', exchange args: ', count($ex->getArguments()), PHP_EOL; +$ex->setArgument('foo', 'bar'); +echo 'Initial args: ', count($arr), ', exchange args: ', count($ex->getArguments()), PHP_EOL; + +foreach (array('existent', 'false', 'nonexistent') as $key) { + echo "$key: ", var_export($ex->hasArgument($key), true), ', ', var_export($ex->getArgument($key)), PHP_EOL; +} + +?> +--EXPECT-- +Initial args: 2, exchange args: 2 +Initial args: 2, exchange args: 3 +existent: true, 'value' +false: true, false +nonexistent: false, false diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_bind.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_bind.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_bind.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_bind.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,30 @@ +--TEST-- +AMQPExchange::bind +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +// Declare a new exchange +$ex = new AMQPExchange($ch); +$ex->setName('exchange-' . microtime(true)); +$ex->setType(AMQP_EX_TYPE_FANOUT); +$ex->declareExchange(); + +// Declare a new exchange +$ex2 = new AMQPExchange($ch); +$ex2->setName('exchange2-' . microtime(true)); +$ex2->setType(AMQP_EX_TYPE_FANOUT); +$ex2->declareExchange(); + +var_dump($ex->bind($ex2->getName(), 'test-key-1')); +var_dump($ex->bind($ex2->getName(), 'test-key-1')); + +?> +--EXPECT-- +bool(true) +bool(true) \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_bind_with_arguments.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_bind_with_arguments.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_bind_with_arguments.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_bind_with_arguments.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,32 @@ +--TEST-- +AMQPExchange::bind with arguments +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +// Declare a new exchange +$ex = new AMQPExchange($ch); +$ex->setName('exchange-' . microtime(true)); +$ex->setType(AMQP_EX_TYPE_FANOUT); +$ex->declareExchange(); + +// Declare a new exchange +$ex2 = new AMQPExchange($ch); +$ex2->setName('exchange2-' . microtime(true)); +$ex2->setType(AMQP_EX_TYPE_FANOUT); +$ex2->declareExchange(); + +$time = microtime(true); + +var_dump($ex->bind($ex2->getName(), 'test', array('test' => 'passed', 'at' => $time))); +var_dump($ex->bind($ex2->getName(), 'test', array('test' => 'passed', 'at' => $time))); + +?> +--EXPECT-- +bool(true) +bool(true) \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_bind_without_key.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_bind_without_key.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_bind_without_key.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_bind_without_key.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,32 @@ +--TEST-- +AMQPExchange::bind without key +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +// Declare a new exchange +$ex = new AMQPExchange($ch); +$ex->setName('exchange-' . microtime(true)); +$ex->setType(AMQP_EX_TYPE_FANOUT); +$ex->declareExchange(); + +// Declare a new exchange +$ex2 = new AMQPExchange($ch); +$ex2->setName('exchange2-' . microtime(true)); +$ex2->setType(AMQP_EX_TYPE_FANOUT); +$ex2->declareExchange(); + +var_dump($ex->bind($ex2->getName())); +var_dump($ex->bind($ex2->getName(), null)); +var_dump($ex->bind($ex2->getName(), '')); + +?> +--EXPECT-- +bool(true) +bool(true) +bool(true) \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_bind_without_key_with_arguments.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_bind_without_key_with_arguments.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_bind_without_key_with_arguments.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_bind_without_key_with_arguments.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,32 @@ +--TEST-- +AMQPExchange::bind without key with arguments +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +// Declare a new exchange +$ex = new AMQPExchange($ch); +$ex->setName('exchange-' . microtime(true)); +$ex->setType(AMQP_EX_TYPE_FANOUT); +$ex->declareExchange(); + +// Declare a new exchange +$ex2 = new AMQPExchange($ch); +$ex2->setName('exchange2-' . microtime(true)); +$ex2->setType(AMQP_EX_TYPE_FANOUT); +$ex2->declareExchange(); + +$time = microtime(true); + +var_dump($ex->bind($ex2->getName(), null, array('test' => 'passed', 'at' => $time, 'i am' => 'first'))); +var_dump($ex->bind($ex2->getName(), '', array('test' => 'passed', 'at' => $time, 'i am' => 'second'))); + +?> +--EXPECT-- +bool(true) +bool(true) \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_channel_refcount.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_channel_refcount.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_channel_refcount.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_channel_refcount.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,32 @@ +--TEST-- +AMQPExchange channel refcount +--SKIPIF-- + +--FILE-- +connect(); + + $ch = new AMQPChannel($cnn); + + $ex = new AMQPExchange($ch); + + $ex->setName("refcount-testing"); + + return $ex; +} + +$ex = buildExchange(); + +echo $ex->getName() . "\n"; + +$ex->setType(AMQP_EX_TYPE_FANOUT); + +$ex->declareExchange(); + +$ex->delete(); + +?> +--EXPECT-- +refcount-testing diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_construct_basic.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_construct_basic.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_construct_basic.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_construct_basic.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,16 @@ +--TEST-- +AMQPExchange constructor +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +$ex = new AMQPExchange($ch); +echo get_class($ex); +?> +--EXPECT-- +AMQPExchange \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_declare_basic.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_declare_basic.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_declare_basic.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_declare_basic.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,18 @@ +--TEST-- +AMQPExchange +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +$ex = new AMQPExchange($ch); +$ex->setName("exchange-" . microtime(true)); +$ex->setType(AMQP_EX_TYPE_FANOUT); +echo $ex->declareExchange() ? "true" : "false"; +?> +--EXPECT-- +true diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_declare_existent.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_declare_existent.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_declare_existent.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_declare_existent.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,47 @@ +--TEST-- +AMQPExchange +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +echo 'Channel id: ', $ch->getChannelId(), PHP_EOL; + +$exchangge_name = "exchange-" . microtime(true); + +$ex = new AMQPExchange($ch); +$ex->setName($exchangge_name); +$ex->setType(AMQP_EX_TYPE_FANOUT); +echo "Exchange declared: ", $ex->declareExchange() ? "true" : "false", PHP_EOL; + +try { + $ex = new AMQPExchange($ch); + $ex->setName($exchangge_name); + $ex->setType(AMQP_EX_TYPE_TOPIC); + $ex->declareExchange(); + echo 'exchange ', $ex->getName(), ' declared', PHP_EOL; +} catch (AMQPException $e) { + echo get_class($e), "({$e->getCode()}): ", $e->getMessage(), PHP_EOL; +} + +echo "Channel connected: ", $ch->isConnected() ? "true" : "false", PHP_EOL; +echo "Connection connected: ", $cnn->isConnected() ? "true" : "false", PHP_EOL; + +try { + $ex = new AMQPExchange($ch); + echo "New exchange class created", PHP_EOL; +} catch (AMQPException $e) { + echo get_class($e), "({$e->getCode()}): ", $e->getMessage(), PHP_EOL; +} +?> +--EXPECTF-- +Channel id: 1 +Exchange declared: true +AMQPExchangeException(406): Server channel error: 406, message: PRECONDITION_FAILED - %s exchange 'exchange-%f' in vhost '/'%s +Channel connected: false +Connection connected: true +AMQPChannelException(0): Could not create exchange. No channel available. \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange-declare-segfault.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange-declare-segfault.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange-declare-segfault.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange-declare-segfault.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,36 @@ +--TEST-- +AMQPExchange +--SKIPIF-- + +--FILE-- +connect(); + +$name = "exchange-" . microtime(true); + +$ex = new AMQPExchange(new AMQPChannel($cnn)); +$ex->setName($name); +$ex->setType(AMQP_EX_TYPE_FANOUT); +$ex->declareExchange(); + +$ex2 = new AMQPExchange(new AMQPChannel($cnn)); +$ex2->setName($name); +$ex2->setType(AMQP_EX_TYPE_DIRECT); + +try { + $ex2->declareExchange(); +} catch (AMQPExchangeException $e) { + echo get_class($e) . "\n"; + try { + $ex2->delete(); + } catch (AMQPChannelException $e) { + echo get_class($e) . "\n"; + } +} +?> +=DONE= +--EXPECT-- +AMQPExchangeException +AMQPChannelException +=DONE= \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_declare_without_name.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_declare_without_name.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_declare_without_name.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_declare_without_name.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,24 @@ +--TEST-- +AMQPExchange::declareExchange() without name set +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + + +$ex = new AMQPExchange($ch); +$ex->setType(AMQP_EX_TYPE_FANOUT); + +try { + $ex->declareExchange(); + echo 'Exchange declared', PHP_EOL; +} catch (AMQPException $e) { + echo get_class($e), "({$e->getCode()}): ", $e->getMessage(), PHP_EOL; +} +?> +--EXPECTF-- +AMQPExchangeException(0): Could not declare exchange. Exchanges must have a name. diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_declare_without_type.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_declare_without_type.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_declare_without_type.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_declare_without_type.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,25 @@ +--TEST-- +AMQPExchange::declareExchange() without type set +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +$exchangge_name = "exchange-" . microtime(true); + +$ex = new AMQPExchange($ch); +$ex->setName($exchangge_name); + +try { + $ex->declareExchange(); + echo 'Exchange declared', PHP_EOL; +} catch (AMQPException $e) { + echo get_class($e), "({$e->getCode()}): ", $e->getMessage(), PHP_EOL; +} +?> +--EXPECTF-- +AMQPExchangeException(0): Could not declare exchange. Exchanges must have a type. diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_declare_with_stalled_reference.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_declare_with_stalled_reference.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_declare_with_stalled_reference.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_declare_with_stalled_reference.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,40 @@ +--TEST-- +AMQPExchange - declare with stalled reference +--SKIPIF-- + +--FILE-- +declareExchange(); +} catch (\Exception $e) { + echo get_class($e), "({$e->getCode()}): ", $e->getMessage(), PHP_EOL; +} + +?> +--EXPECT-- +AMQPChannelException(0): Could not declare exchange. Stale reference to the channel object. diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_delete_default_exchange.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_delete_default_exchange.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_delete_default_exchange.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_delete_default_exchange.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,30 @@ +--TEST-- +AMQPExchange::delete() +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +echo 'Channel id: ', $ch->getChannelId(), PHP_EOL; + +$ch = new AMQPChannel($cnn); +$ex = new AMQPExchange($ch); + +try { + $ex->delete(); +} catch (AMQPExchangeException $e) { + echo get_class($e), "({$e->getCode()}): ", $e->getMessage(), PHP_EOL; +} + +echo "Channel connected: ", $ch->isConnected() ? "true" : "false", PHP_EOL; +echo "Connection connected: ", $cnn->isConnected() ? "true" : "false", PHP_EOL; +?> +--EXPECT-- +Channel id: 1 +AMQPExchangeException(403): Server channel error: 403, message: ACCESS_REFUSED - operation not permitted on the default exchange +Channel connected: false +Connection connected: true diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_get_channel.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_get_channel.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_get_channel.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_get_channel.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,30 @@ +--TEST-- +AMQPExchange getChannel() test +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); +$ch2 = new AMQPChannel($cnn); + +$ex = new AMQPExchange($ch); + + +echo $ch === $ex->getChannel() ? 'same' : 'not same', PHP_EOL; +echo $ch2 === $ex->getChannel() ? 'same' : 'not same', PHP_EOL; + +$old_prefetch = $ch->getPrefetchCount(); +$new_prefetch = 999; + +$ex->getChannel()->setPrefetchCount($new_prefetch); + +echo $ch->getPrefetchCount() == $new_prefetch ? 'by ref' : 'copy', PHP_EOL; + +?> +--EXPECT-- +same +not same +by ref diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_get_connection.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_get_connection.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_get_connection.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_get_connection.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,34 @@ +--TEST-- +AMQPExchange getConnection test +--SKIPIF-- + +--FILE-- +connect(); +$ch = new AMQPChannel($cnn); + +$ex = new AMQPExchange($ch); + +$cnn2 = new AMQPConnection(); + +echo $cnn === $ex->getConnection() ? 'same' : 'not same', PHP_EOL; +echo $cnn2 === $ex->getConnection() ? 'same' : 'not same', PHP_EOL; + +$old_host = $cnn->getHost(); +$new_host = 'test'; + +$ex->getConnection()->setHost($new_host); + +echo $cnn->getHost() == $new_host ? 'by ref' : 'copy', PHP_EOL; + +?> +--EXPECT-- +same +not same +by ref diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_invalid_type.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_invalid_type.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_invalid_type.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_invalid_type.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,34 @@ +--TEST-- +AMQPExchange +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +$ex = new AMQPExchange($ch); +$ex->setName("exchange-" . microtime(true)); +$ex->setType("invalid_exchange_type"); + +echo "Channel ", $ch->isConnected() ? 'connected' : 'disconnected', PHP_EOL; +echo "Connection ", $cnn->isConnected() ? 'connected' : 'disconnected', PHP_EOL; + +try { + $ex->declareExchange(); +} catch (AMQPException $e) { + echo get_class($e), "({$e->getCode()}): ", $e->getMessage(), PHP_EOL; +} + +echo "Channel ", $ch->isConnected() ? 'connected' : 'disconnected', PHP_EOL; +echo "Connection ", $cnn->isConnected() ? 'connected' : 'disconnected', PHP_EOL; + +?> +--EXPECT-- +Channel connected +Connection connected +AMQPConnectionException(503): Server connection error: 503, message: COMMAND_INVALID - unknown exchange type 'invalid_exchange_type' +Channel disconnected +Connection disconnected \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_publish_basic.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_publish_basic.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_publish_basic.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_publish_basic.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,20 @@ +--TEST-- +AMQPExchange +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +$ex = new AMQPExchange($ch); +$ex->setName("exchange-" . microtime(true)); +$ex->setType(AMQP_EX_TYPE_FANOUT); +$ex->declareExchange(); +echo $ex->publish('message', 'routing.key') ? 'true' : 'false'; +$ex->delete(); +?> +--EXPECT-- +true diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_publish_confirms_consume.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_publish_confirms_consume.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_publish_confirms_consume.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_publish_confirms_consume.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,97 @@ +--TEST-- +AMQPExchange::publish() - publish in conform mode and handle conforms with AMQPQueue::consume() method +--SKIPIF-- + +--FILE-- +setReadTimeout(2); + +$cnn->connect(); +$ch = new AMQPChannel($cnn); +$ch->confirmSelect(); + +$ex = new AMQPExchange($ch); +$ex->setName("exchange-" . microtime(true)); +$ex->setType(AMQP_EX_TYPE_FANOUT); +$ex->setFlags(AMQP_AUTODELETE); +$ex->declareExchange(); + +echo $ex->publish('message 1', 'routing.key', AMQP_MANDATORY) ? 'true' : 'false', PHP_EOL; + +// Create a new queue +$q = new AMQPQueue($ch); +$q->setName('queue-' . microtime(true)); +$q->setFlags(AMQP_AUTODELETE); +$q->declareQueue(); + +$msg = $q->get(); +var_dump($msg); + +try { + $q->consume(function() use ($q) { + echo 'Message returned', PHP_EOL; + var_dump(func_get_args()); + return false; + }); +} catch(Exception $e) { + echo get_class($e), "({$e->getCode()}): ", $e->getMessage(). PHP_EOL; +} + +echo $ex->publish('message 2', 'routing.key', AMQP_MANDATORY) ? 'true' : 'false', PHP_EOL; + +/* callback(int $reply_code, string $reply_text, string $exchange, string $routing_key, AMQPBasicProperties $properties, string $body); */ +$ch->setReturnCallback(function ($reply_code, $reply_text, $exchange, $routing_key, AMQPBasicProperties $properties, $body) { + echo 'Message returned: ', $reply_text, ', message body:', $body, PHP_EOL; +}); + +$cnt = 1; +$ch->setConfirmCallback(function ($delivery_tag, $multiple) use(&$cnt) { + echo 'Message acked', PHP_EOL; + var_dump(func_get_args()); + return --$cnt > 0; +}, function ($delivery_tag, $multiple, $requeue) { + echo 'Message nacked', PHP_EOL; + var_dump(func_get_args()); + return false; +}); + +try { + $q->consume(function() use ($q) { + echo 'Received message', PHP_EOL; + var_dump(func_get_args()); + return false; + }); +} catch(Exception $e) { + echo get_class($e), "({$e->getCode()}): ", $e->getMessage(). PHP_EOL; +} + + +$q->delete(); +$ex->delete(); +?> +--EXPECTF-- +true +bool(false) +Unhandled basic.return method from server received. Use AMQPChannel::setBasicReturnCallback() to process it. +Unhandled basic.ack method from server received. Use AMQPChannel::setConfirmCallback() to process it. +AMQPQueueException(0): Consumer timeout exceed +true +Message returned: NO_ROUTE, message body:message 2 +Message acked +array(2) { + [0]=> + int(2) + [1]=> + bool(false) +} +AMQPQueueException(0): Consumer timeout exceed diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_publish_confirms.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_publish_confirms.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_publish_confirms.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_publish_confirms.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,127 @@ +--TEST-- +AMQPExchange::publish() - publish with confirms +--SKIPIF-- + + +--FILE-- +setReadTimeout(2); +$cnn->connect(); + + +$ch = new AMQPChannel($cnn); +$ch->confirmSelect(); + +try { + $ch->waitForConfirm(1); +} catch(Exception $e) { + echo get_class($e), "({$e->getCode()}): ", $e->getMessage(). PHP_EOL; +} + + +$ex1 = new AMQPExchange($ch); +$ex1->setName("exchange-" . microtime(true)); +$ex1->setType(AMQP_EX_TYPE_FANOUT); +$ex1->setFlags(AMQP_AUTODELETE); +$ex1->declareExchange(); + + +echo $ex1->publish('message 1', 'routing.key') ? 'true' : 'false', PHP_EOL; +echo $ex1->publish('message 1', 'routing.key', AMQP_MANDATORY) ? 'true' : 'false', PHP_EOL; + +try { + $ch->waitForConfirm(); +} catch(Exception $e) { + echo get_class($e), "({$e->getCode()}): ", $e->getMessage(). PHP_EOL; +} + +try { + $ch->waitForConfirm(); +} catch(Exception $e) { + echo get_class($e), "({$e->getCode()}): ", $e->getMessage(). PHP_EOL; +} + +try { + $ch->waitForConfirm(1); +} catch(Exception $e) { + echo get_class($e), "({$e->getCode()}): ", $e->getMessage(). PHP_EOL; +} + + +echo $ex1->publish('message 1', 'routing.key') ? 'true' : 'false', PHP_EOL; +echo $ex1->publish('message 1', 'routing.key', AMQP_MANDATORY) ? 'true' : 'false', PHP_EOL; + +// ack_callback(int $delivery_tag, bool $multiple) : bool; +// nack_callback(int $delivery_tag, bool $multiple, bool $requeue) : bool; +// return_callback(int $reply_code, string $reply_text, string $exchange, string $routing_key, AMQPBasicProperties $properties, string $body); + +$ch->setReturnCallback(function ($reply_code, $reply_text, $exchange, $routing_key, AMQPBasicProperties $properties, $body) { + echo 'Message returned: ', $reply_text, ', message body:', $body, PHP_EOL; +}); + +$cnt = 2; +$ch->setConfirmCallback(function ($delivery_tag, $multiple) use(&$cnt) { + echo 'Message acked', PHP_EOL; + var_dump(func_get_args()); + return --$cnt > 0; +}, function ($delivery_tag, $multiple, $requeue) { + echo 'Message nacked', PHP_EOL; + var_dump(func_get_args()); + return false; +}); + +try { + $ch->waitForConfirm(); +} catch(Exception $e) { + echo get_class($e), "({$e->getCode()}): ", $e->getMessage(). PHP_EOL; +} + +$ex1->delete(); + +$ex2 = new AMQPExchange($ch); +$ex2->setName("exchange-nonexistent-" . microtime(true)); +echo $ex2->publish('message 2', 'routing.key') ? 'true' : 'false', PHP_EOL; + +try { + $ch->waitForConfirm(1); +} catch(Exception $e) { + echo get_class($e), "({$e->getCode()}): ", $e->getMessage(). PHP_EOL; +} + +?> +--EXPECTF-- +AMQPQueueException(0): Wait timeout exceed +true +true +Unhandled basic.ack method from server received. Use AMQPChannel::setConfirmCallback() to process it. +Unhandled basic.return method from server received. Use AMQPChannel::setBasicReturnCallback() to process it. +Unhandled basic.ack method from server received. Use AMQPChannel::setConfirmCallback() to process it. +true +true +Message acked +array(2) { + [0]=> + int(3) + [1]=> + bool(false) +} +Message returned: NO_ROUTE, message body:message 1 +Message acked +array(2) { + [0]=> + int(4) + [1]=> + bool(false) +} +true +AMQPChannelException(404): Server channel error: 404, message: NOT_FOUND - no exchange 'exchange-nonexistent-%f' in vhost '/' diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_publish_empty_routing_key.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_publish_empty_routing_key.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_publish_empty_routing_key.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_publish_empty_routing_key.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,20 @@ +--TEST-- +AMQPExchange publish with empty routing key +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +$ex = new AMQPExchange($ch); +$ex->setName("exchange-" . microtime(true)); +$ex->setType(AMQP_EX_TYPE_FANOUT); +$ex->declareExchange(); +echo $ex->publish('message') ? 'true' : 'false'; +$ex->delete(); +?> +--EXPECT-- +true diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_publish_mandatory_consume.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_publish_mandatory_consume.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_publish_mandatory_consume.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_publish_mandatory_consume.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,125 @@ +--TEST-- +AMQPExchange::publish() - publish unroutable with mandatory flag and handle them with AMQPQueue::consume() method +--SKIPIF-- + +--FILE-- +setReadTimeout(2); + +$cnn->connect(); + +$ch = new AMQPChannel($cnn); + +$ex = new AMQPExchange($ch); +$ex->setName("exchange-" . microtime(true)); +$ex->setType(AMQP_EX_TYPE_FANOUT); +$ex->setFlags(AMQP_AUTODELETE); +$ex->declareExchange(); + +echo $ex->publish('message 1', 'routing.key', AMQP_MANDATORY) ? 'true' : 'false', PHP_EOL; + +// Create a new queue +$q = new AMQPQueue($ch); +$q->setName('queue-' . microtime(true)); +$q->setFlags(AMQP_AUTODELETE); +$q->declareQueue(); + +$msg = $q->get(); +var_dump($msg); + +try { + $q->consume(function() use ($q) { + echo 'Message returned', PHP_EOL; + var_dump(func_get_args()); + return false; + }); +} catch(Exception $e) { + echo get_class($e), "({$e->getCode()}): ", $e->getMessage(). PHP_EOL; +} + +echo $ex->publish('message 2', 'routing.key', AMQP_MANDATORY) ? 'true' : 'false', PHP_EOL; + +/* callback(int $reply_code, string $reply_text, string $exchange, string $routing_key, AMQPBasicProperties $properties, string $body); */ +$ch->setReturnCallback(function ($reply_code, $reply_text, $exchange, $routing_key, AMQPBasicProperties $properties, $body) { + echo 'Message returned', PHP_EOL; + var_dump(func_get_args()); +}); + +try { + $q->consume(function() use ($q) { + echo 'Received message', PHP_EOL; + var_dump(func_get_args()); + return false; + }); +} catch(Exception $e) { + echo get_class($e), "({$e->getCode()}): ", $e->getMessage(). PHP_EOL; +} + + +$q->delete(); + + +$ex->delete(); +?> +--EXPECTF-- +true +bool(false) +Unhandled basic.return method from server received. Use AMQPChannel::setBasicReturnCallback() to process it. +AMQPQueueException(0): Consumer timeout exceed +true +Message returned +array(6) { + [0]=> + int(312) + [1]=> + string(8) "NO_ROUTE" + [2]=> + string(%d) "exchange-%f" + [3]=> + string(11) "routing.key" + [4]=> + object(AMQPBasicProperties)#9 (14) { + ["content_type":"AMQPBasicProperties":private]=> + string(10) "text/plain" + ["content_encoding":"AMQPBasicProperties":private]=> + string(0) "" + ["headers":"AMQPBasicProperties":private]=> + array(0) { + } + ["delivery_mode":"AMQPBasicProperties":private]=> + int(1) + ["priority":"AMQPBasicProperties":private]=> + int(0) + ["correlation_id":"AMQPBasicProperties":private]=> + string(0) "" + ["reply_to":"AMQPBasicProperties":private]=> + string(0) "" + ["expiration":"AMQPBasicProperties":private]=> + string(0) "" + ["message_id":"AMQPBasicProperties":private]=> + string(0) "" + ["timestamp":"AMQPBasicProperties":private]=> + int(0) + ["type":"AMQPBasicProperties":private]=> + string(0) "" + ["user_id":"AMQPBasicProperties":private]=> + string(0) "" + ["app_id":"AMQPBasicProperties":private]=> + string(0) "" + ["cluster_id":"AMQPBasicProperties":private]=> + string(0) "" + } + [5]=> + string(9) "message 2" +} +AMQPQueueException(0): Consumer timeout exceed diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_publish_mandatory_multiple_channels_pitfal.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_publish_mandatory_multiple_channels_pitfal.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_publish_mandatory_multiple_channels_pitfal.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_publish_mandatory_multiple_channels_pitfal.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,84 @@ +--TEST-- +AMQPExchange::publish() - publish unroutable mandatory on multiple channels pitfall +--SKIPIF-- + +--FILE-- +connect(); + + +$ch1 = new AMQPChannel($cnn); + +try { + $ch1->waitForBasicReturn(1); +} catch (Exception $e) { + echo get_class($e), "({$e->getCode()}): ", $e->getMessage() . PHP_EOL; +} + +$ch2 = new AMQPChannel($cnn); + +try { + $ch2->waitForBasicReturn(1); +} catch (Exception $e) { + echo get_class($e), "({$e->getCode()}): ", $e->getMessage() . PHP_EOL; +} + + +$exchange_name = "exchange-" . microtime(true); + +$ex1 = new AMQPExchange($ch1); +$ex1->setName($exchange_name); +$ex1->setType(AMQP_EX_TYPE_FANOUT); +$ex1->setFlags(AMQP_AUTODELETE); +$ex1->declareExchange(); + + +$ex2 = new AMQPExchange($ch2); +$ex2->setName($exchange_name); + +echo $ex2->publish('message 1-2', 'routing.key', AMQP_MANDATORY) ? 'true' : 'false', PHP_EOL; +echo $ex2->publish('message 2-2', 'routing.key', AMQP_MANDATORY) ? 'true' : 'false', PHP_EOL; + +//echo $ex1->publish('message 1-1', 'routing.key', AMQP_MANDATORY) ? 'true' : 'false', PHP_EOL; +//echo $ex1->publish('message 2-1', 'routing.key', AMQP_MANDATORY) ? 'true' : 'false', PHP_EOL; + +// Create a new queue +$q = new AMQPQueue($ch1); +$q->setName('queue-' . microtime(true)); +$q->setFlags(AMQP_AUTODELETE); +$q->declareQueue(); + +$msg = $q->get(); +var_dump($msg); + + +try { + $ch1->waitForBasicReturn(); +} catch (Exception $e) { + echo get_class($e), "({$e->getCode()}): ", $e->getMessage(), PHP_EOL; +} + +// This error happens because on a channel 1 we are expecting only messages withing channel 1, but inside current +// connection we already have pending message on channel 2 + +echo 'Connection active: ', ($cnn->isConnected() ? 'yes' : 'no'); + +?> +--EXPECTF-- +AMQPQueueException(0): Wait timeout exceed +AMQPQueueException(0): Wait timeout exceed +true +true +bool(false) +AMQPException(0): Library error: unexpected method received +Connection active: no diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_publish_mandatory.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_publish_mandatory.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_publish_mandatory.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_publish_mandatory.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,126 @@ +--TEST-- +AMQPExchange::publish() - publish unroutable mandatory +--SKIPIF-- + + +--FILE-- +setReadTimeout(2); + +$cnn->connect(); + + +$ch = new AMQPChannel($cnn); + + +try { + $ch->waitForBasicReturn(1); +} catch(Exception $e) { + echo get_class($e), "({$e->getCode()}): ", $e->getMessage(). PHP_EOL; +} + + +$ex = new AMQPExchange($ch); +$ex->setName("exchange-" . microtime(true)); +$ex->setType(AMQP_EX_TYPE_FANOUT); +$ex->setFlags(AMQP_AUTODELETE); +$ex->declareExchange(); + +echo $ex->publish('message 1', 'routing.key', AMQP_MANDATORY) ? 'true' : 'false', PHP_EOL; +echo $ex->publish('message 2', 'routing.key', AMQP_MANDATORY) ? 'true' : 'false', PHP_EOL; + +// Create a new queue +$q = new AMQPQueue($ch); +$q->setName('queue-' . microtime(true)); +$q->setFlags(AMQP_AUTODELETE); +$q->declareQueue(); + +$msg = $q->get(); +var_dump($msg); + +try { + $ch->waitForBasicReturn(); +} catch(Exception $e) { + echo get_class($e), "({$e->getCode()}): ", $e->getMessage(). PHP_EOL; +} + +/* callback(int $reply_code, string $reply_text, string $exchange, string $routing_key, AMQPBasicProperties $properties, string $body); */ +$ch->setReturnCallback(function ($reply_code, $reply_text, $exchange, $routing_key, AMQPBasicProperties $properties, $body) { + echo 'Message returned', PHP_EOL; + var_dump(func_get_args()); + return false; +}); + +try { + $ch->waitForBasicReturn(); +} catch(Exception $e) { + echo get_class($e), "({$e->getCode()}): ", $e->getMessage(). PHP_EOL; +} + + +$q->delete(); + + +$ex->delete(); +?> +--EXPECTF-- +AMQPQueueException(0): Wait timeout exceed +true +true +bool(false) +Unhandled basic.return method from server received. Use AMQPChannel::setBasicReturnCallback() to process it. +Message returned +array(6) { + [0]=> + int(312) + [1]=> + string(8) "NO_ROUTE" + [2]=> + string(%d) "exchange-%f" + [3]=> + string(11) "routing.key" + [4]=> + object(AMQPBasicProperties)#7 (14) { + ["content_type":"AMQPBasicProperties":private]=> + string(10) "text/plain" + ["content_encoding":"AMQPBasicProperties":private]=> + string(0) "" + ["headers":"AMQPBasicProperties":private]=> + array(0) { + } + ["delivery_mode":"AMQPBasicProperties":private]=> + int(1) + ["priority":"AMQPBasicProperties":private]=> + int(0) + ["correlation_id":"AMQPBasicProperties":private]=> + string(0) "" + ["reply_to":"AMQPBasicProperties":private]=> + string(0) "" + ["expiration":"AMQPBasicProperties":private]=> + string(0) "" + ["message_id":"AMQPBasicProperties":private]=> + string(0) "" + ["timestamp":"AMQPBasicProperties":private]=> + int(0) + ["type":"AMQPBasicProperties":private]=> + string(0) "" + ["user_id":"AMQPBasicProperties":private]=> + string(0) "" + ["app_id":"AMQPBasicProperties":private]=> + string(0) "" + ["cluster_id":"AMQPBasicProperties":private]=> + string(0) "" + } + [5]=> + string(9) "message 2" +} diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_publish_timeout.disabled php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_publish_timeout.disabled --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_publish_timeout.disabled 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_publish_timeout.disabled 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,57 @@ +--TEST-- +AMQPExchange +--SKIPIF-- + +--FILE-- + $timeout)); +$conn->connect(); + +$chan = new AMQPChannel($conn); + +$ex = new AMQPExchange($chan); +$ex->setName("exchange-pub-timeout-" . time()); +$ex->setType(AMQP_EX_TYPE_FANOUT); +$ex->declare(); + +$queue = new AMQPQueue($chan); +$queue->setName('queue-for-'.$ex->getName()); +$queue->setFlags(AMQP_EXCLUSIVE); +$queue->declare(); +$queue->bind($ex->getName(), 'ignored-for-fanout'); + +$message = str_repeat('d41d8cd98f00b204e9800998ecf8427e', 32); // 32768 - 1mb, 32 - 1Kb +$start = $end = 0; + +// try to exceed resources limit +try { + while(true) { + $start = microtime(true); + $ex->publish($message, 'ignored-for-fanout', AMQP_NOPARAM, array('expiration' => 5000)); + } +} catch (Exception $e) {} + +try { + while(true) { + $start = microtime(true); + // at this point publishing should be banned immediately + $ex->publish($message, 'ignored-for-fanout', AMQP_NOPARAM, array('expiration' => 5000)); + } +} catch (Exception $e) { + $end = microtime(true); + echo get_class($e); + echo PHP_EOL; + echo $e->getMessage(); + echo PHP_EOL; +} +//$delay = abs($end - $start - $timeout); +//echo $delay < 0.005 ? 'true' : 'false'; +?> +--EXPECT-- +AMQPExchangeException +Socket error: Resource temporarily unavailable diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_publish_with_decimal_header.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_publish_with_decimal_header.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_publish_with_decimal_header.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_publish_with_decimal_header.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,57 @@ +--TEST-- +AMQPExchange publish with decimal header +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +$ex = new AMQPExchange($ch); +$ex->setName("exchange-" . microtime(true)); +$ex->setType(AMQP_EX_TYPE_FANOUT); +$ex->declareExchange(); + +$q = new AMQPQueue($ch); +$q->setName('queue-' . microtime(true)); +$q->declareQueue(); +$q->bind($ex->getName()); + +$headers = ['headerName' => new AMQPDecimal(123, 456)]; + +$ex->publish('message', 'routing.key', AMQP_NOPARAM, array('headers' => $headers)); + +$message =$q->get(AMQP_AUTOACK); +var_dump($message->getHeaders()); +var_dump($headers); +echo $message->getHeaders() == $headers ? 'same' : 'differs'; +?> + + +==DONE== +--EXPECTF-- +array(1) { + ["headerName"]=> + object(AMQPDecimal)#7 (2) { + ["exponent":"AMQPDecimal":private]=> + int(123) + ["significand":"AMQPDecimal":private]=> + int(456) + } +} +array(1) { + ["headerName"]=> + object(AMQPDecimal)#5 (2) { + ["exponent":"AMQPDecimal":private]=> + int(123) + ["significand":"AMQPDecimal":private]=> + int(456) + } +} +same + +==DONE== Binary files /tmp/tmp16NgSN/W688uipSRy/php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_publish_with_null.phpt and /tmp/tmp16NgSN/uIFclp_y0o/php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_publish_with_null.phpt differ diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_publish_with_properties_ignore_num_header.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_publish_with_properties_ignore_num_header.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_publish_with_properties_ignore_num_header.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_publish_with_properties_ignore_num_header.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,30 @@ +--TEST-- +AMQPExchange publish with properties - ignore numeric keys in headers +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +$ex = new AMQPExchange($ch); +$ex->setName("exchange-" . microtime(true)); +$ex->setType(AMQP_EX_TYPE_FANOUT); +$ex->declareExchange(); + + +echo $ex->publish('message', 'routing.key', AMQP_NOPARAM, array('headers' => 'ignored')) ? 'true' : 'false', PHP_EOL; +echo $ex->publish('message', 'routing.key', AMQP_NOPARAM, array('headers' => array(2 => 'ignore_me'))) ? 'true' : 'false', PHP_EOL; + +$ex->delete(); + + +?> +--EXPECTF-- +Warning: AMQPExchange::publish(): Ignoring non-string header field '0' in %s on line %d +true + +Warning: AMQPExchange::publish(): Ignoring non-string header field '2' in %s on line %d +true diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_publish_with_properties_ignore_unsupported_header_values.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_publish_with_properties_ignore_unsupported_header_values.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_publish_with_properties_ignore_unsupported_header_values.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_publish_with_properties_ignore_unsupported_header_values.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,35 @@ +--TEST-- +AMQPExchange publish with properties - ignore unsupported header values (NULL, object, resources) +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +$ex = new AMQPExchange($ch); +$ex->setName("exchange-" . microtime(true)); +$ex->setType(AMQP_EX_TYPE_FANOUT); +$ex->declareExchange(); + +$attrs = array( + 'headers' => array( + 'null' => null, + 'object' => new stdClass(), + 'resource' => fopen(__FILE__, 'r'), + ), +); + +echo $ex->publish('message', 'routing.key', AMQP_NOPARAM, $attrs) ? 'true' : 'false'; + +$ex->delete(); + + +?> +--EXPECTF-- +Warning: AMQPExchange::publish(): Ignoring field 'object' due to unsupported value type (object) in %s on line %d + +Warning: AMQPExchange::publish(): Ignoring field 'resource' due to unsupported value type (resource) in %s on line %d +true diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_publish_with_properties_nested_header.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_publish_with_properties_nested_header.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_publish_with_properties_nested_header.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_publish_with_properties_nested_header.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,142 @@ +--TEST-- +AMQPExchange publish with properties - nested header values +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +$ex = new AMQPExchange($ch); +$ex->setName("exchange-" . microtime(true)); +$ex->setType(AMQP_EX_TYPE_FANOUT); +$ex->declareExchange(); + +$q = new AMQPQueue($ch); +$q->setName('queue-' . microtime(true)); +$q->declareQueue(); +$q->bind($ex->getName()); + +$headers = array( + 'nested' => array( + 'string' => 'passed', + 999 => 'numeric works', + 'sub-nested' => array( + 'should' => 'works', + 42 => 'too' + ), + ), +); + +$ex->publish('message', 'routing.key', AMQP_NOPARAM, array('headers' => $headers)); + +$message =$q->get(AMQP_AUTOACK); +var_dump($message->getHeaders()); +var_dump($headers); +echo $message->getHeaders() === $headers ? 'same' : 'differs'; +echo PHP_EOL, PHP_EOL; + + +$headers = array( + 'x-death' => array( + array ( + 'reason' => 'rejected', + 'queue' => 'my_queue', + 'time' => 1410527691, + 'exchange' => 'my_exchange', + 'routing-keys' => array ('my_routing_key') + ) + ) +); + +$ex->publish('message', 'routing.key', AMQP_NOPARAM, array('headers' => $headers)); + +$message =$q->get(AMQP_AUTOACK); +var_dump($message->getHeaders()); +var_dump($headers); +echo $message->getHeaders() === $headers ? 'same' : 'differs'; +echo PHP_EOL, PHP_EOL; + +?> +--EXPECT-- +array(1) { + ["nested"]=> + array(3) { + ["string"]=> + string(6) "passed" + [999]=> + string(13) "numeric works" + ["sub-nested"]=> + array(2) { + ["should"]=> + string(5) "works" + [42]=> + string(3) "too" + } + } +} +array(1) { + ["nested"]=> + array(3) { + ["string"]=> + string(6) "passed" + [999]=> + string(13) "numeric works" + ["sub-nested"]=> + array(2) { + ["should"]=> + string(5) "works" + [42]=> + string(3) "too" + } + } +} +same + +array(1) { + ["x-death"]=> + array(1) { + [0]=> + array(5) { + ["reason"]=> + string(8) "rejected" + ["queue"]=> + string(8) "my_queue" + ["time"]=> + int(1410527691) + ["exchange"]=> + string(11) "my_exchange" + ["routing-keys"]=> + array(1) { + [0]=> + string(14) "my_routing_key" + } + } + } +} +array(1) { + ["x-death"]=> + array(1) { + [0]=> + array(5) { + ["reason"]=> + string(8) "rejected" + ["queue"]=> + string(8) "my_queue" + ["time"]=> + int(1410527691) + ["exchange"]=> + string(11) "my_exchange" + ["routing-keys"]=> + array(1) { + [0]=> + string(14) "my_routing_key" + } + } + } +} +same \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_publish_with_properties.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_publish_with_properties.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_publish_with_properties.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_publish_with_properties.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,114 @@ +--TEST-- +AMQPExchange publish with properties +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +$ex = new AMQPExchange($ch); +$ex->setName("exchange-" . microtime(true)); +$ex->setType(AMQP_EX_TYPE_FANOUT); +$ex->declareExchange(); + +$q = new AMQPQueue($ch); +$q->declareQueue(); + +$q->bind($ex->getName()); + +$attrs = array( + 'content_type' => 1, // should be string + 'content_encoding' => 2, // should be string + 'message_id' => 3, // should be string + //'user_id' => 4, // should be string // NOTE: fail due to Validated User-ID https://www.rabbitmq.com/validated-user-id.html, @see tests/amqpexchange_publish_with_properties_user_id_failure.phpt test + 'app_id' => 5, // should be string + 'delivery_mode' => '1-non-persistent', // should be long + 'priority' => '2high', // should be long + 'timestamp' => '123now', // should be long + 'expiration' => 100000000, // should be string // NOTE: in fact it is milliseconds for how long to stay in queue, see https://www.rabbitmq.com/ttl.html#per-message-ttl for details + 'type' => 7, // should be string + 'reply_to' => 8, // should be string + 'correlation_id' => 9, // should be string + //'headers' => 'not array', // should be array // NOTE: covered in tests/amqpexchange_publish_with_properties_ignore_num_header.phpt +); + +$attrs_control = array( + 'content_type' => 1, // should be string + 'content_encoding' => 2, // should be string + 'message_id' => 3, // should be string + //'user_id' => 4, // should be string // NOTE: fail due to Validated User-ID https://www.rabbitmq.com/validated-user-id.html, @see tests/amqpexchange_publish_with_properties_user_id_failure.phpt test + 'app_id' => 5, // should be string + 'delivery_mode' => '1-non-persistent', // should be long + 'priority' => '2high', // should be long + 'timestamp' => '123now', // should be long + 'expiration' => 100000000, // should be string // NOTE: in fact it is milliseconds for how long to stay in queue, see https://www.rabbitmq.com/ttl.html#per-message-ttl for details + 'type' => 7, // should be string + 'reply_to' => 8, // should be string + 'correlation_id' => 9, // should be string + //'headers' => 'not array', // should be array // NOTE: covered in tests/amqpexchange_publish_with_properties_ignore_num_header.phpt +); + +echo $ex->publish('message', 'routing.key', AMQP_NOPARAM, $attrs) ? 'true' : 'false', PHP_EOL; + + +//var_dump($attrs, $attrs_control); +echo 'Message attributes are ', $attrs === $attrs_control ? 'the same' : 'not the same', PHP_EOL; + +$msg = $q->get(AMQP_AUTOACK); + + +dump_message($msg); + +$ex->delete(); +$q->delete(); + + +?> +--EXPECTF-- +true +Message attributes are the same +AMQPEnvelope + getBody: + string(7) "message" + getContentType: + string(1) "1" + getRoutingKey: + string(11) "routing.key" + getConsumerTag: + string(0) "" + getDeliveryTag: + int(1) + getDeliveryMode: + int(1) + getExchangeName: + string(%d) "exchange-%f" + isRedelivery: + bool(false) + getContentEncoding: + string(1) "2" + getType: + string(1) "7" + getTimeStamp: + int(123) + getPriority: + int(2) + getExpiration: + string(9) "100000000" + getUserId: + string(0) "" + getAppId: + string(1) "5" + getMessageId: + string(1) "3" + getReplyTo: + string(1) "8" + getCorrelationId: + string(1) "9" + getHeaders: + array(0) { +} diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_publish_with_properties_user_id_failure.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_publish_with_properties_user_id_failure.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_publish_with_properties_user_id_failure.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_publish_with_properties_user_id_failure.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,54 @@ +--TEST-- +AMQPExchange publish with properties - user_id failure +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +$ex = new AMQPExchange($ch); +$ex->setName("exchange-" . microtime(true)); +$ex->setType(AMQP_EX_TYPE_FANOUT); +$ex->declareExchange(); + +echo "Channel ", $ch->isConnected() ? 'connected' : 'disconnected', PHP_EOL; +echo "Connection ", $cnn->isConnected() ? 'connected' : 'disconnected', PHP_EOL; + +try { + // NOTE: basic.publish is asynchronous, so ... + echo $ex->publish('message', 'routing.key', AMQP_NOPARAM, array('user_id' => 'unknown-' . microtime(true))) ? 'true' : 'false', PHP_EOL; +} catch (AMQPException $e) { + echo get_class($e), "({$e->getCode()}): ", $e->getMessage(), PHP_EOL; +} + +echo "Channel ", $ch->isConnected() ? 'connected' : 'disconnected', PHP_EOL; +echo "Connection ", $cnn->isConnected() ? 'connected' : 'disconnected', PHP_EOL; + +try { + // NOTE: ... the next socket (not only channel) operation will fail, which may lead to very strange issues + // if we operate here,on different entity, for example on queue. + + $q = new AMQPQueue($ch); + $q->declareQueue(); + + echo "Queue declared", PHP_EOL; +} catch (AMQPException $e) { + echo get_class($e), "({$e->getCode()}): ", $e->getMessage(), PHP_EOL; +} + +echo "Channel ", $ch->isConnected() ? 'connected' : 'disconnected', PHP_EOL; +echo "Connection ", $cnn->isConnected() ? 'connected' : 'disconnected', PHP_EOL; + +?> +--EXPECTF-- +Channel connected +Connection connected +true +Channel connected +Connection connected +AMQPQueueException(406): Server channel error: 406, message: PRECONDITION_FAILED - user_id property set to 'unknown-%f' but authenticated user was 'guest' +Channel disconnected +Connection connected \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_publish_with_timestamp_header.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_publish_with_timestamp_header.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_publish_with_timestamp_header.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_publish_with_timestamp_header.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,53 @@ +--TEST-- +AMQPExchange publish with timestamp header +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +$ex = new AMQPExchange($ch); +$ex->setName("exchange-" . microtime(true)); +$ex->setType(AMQP_EX_TYPE_FANOUT); +$ex->declareExchange(); + +$q = new AMQPQueue($ch); +$q->setName('queue-' . microtime(true)); +$q->declareQueue(); +$q->bind($ex->getName()); + +$headers = ['headerName' => new AMQPTimestamp(1488578462)]; + +$ex->publish('message', 'routing.key', AMQP_NOPARAM, array('headers' => $headers)); + +$message =$q->get(AMQP_AUTOACK); +var_dump($message->getHeaders()); +var_dump($headers); +echo $message->getHeaders() == $headers ? 'same' : 'differs'; +?> + + +==DONE== +--EXPECTF-- +array(1) { + ["headerName"]=> + object(AMQPTimestamp)#%d (1) { + ["timestamp":"AMQPTimestamp":private]=> + string(10) "1488578462" + } +} +array(1) { + ["headerName"]=> + object(AMQPTimestamp)#%d (1) { + ["timestamp":"AMQPTimestamp":private]=> + string(10) "1488578462" + } +} +same + +==DONE== diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_publish_xdeath.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_publish_xdeath.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_publish_xdeath.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_publish_xdeath.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,156 @@ +--TEST-- +AMQPExchange publish with properties - nested header values +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +$suffix = sha1(microtime(true)); + +$dlx = new AMQPExchange($ch); +$dlx->setName('dlx-' . $suffix); +$dlx->setType(AMQP_EX_TYPE_TOPIC); +$dlx->setFlags(AMQP_DURABLE); +$dlx->declareExchange(); + +$dq = new AMQPQueue($ch); +$dq->setName('dlx-' . $suffix); +$dq->declareQueue(); +$dq->setFlags(AMQP_DURABLE); +$dq->bind($dlx->getName(), '#'); + +$ex = new AMQPExchange($ch); +$ex->setName("exchange-" . $suffix); +$ex->setType(AMQP_EX_TYPE_FANOUT); +$ex->setFlags(AMQP_DURABLE); +$ex->declareExchange(); + +$q = new AMQPQueue($ch); +$q->setName('dlx-test-queue-' . $suffix); +$q->setFlags(AMQP_DURABLE); +$q->setArgument('x-dead-letter-exchange', $dlx->getName()); +$q->declareQueue(); +$q->bind($ex->getName()); + +$ex->publish('message'); + +function assert_xdeath(AMQPEnvelope $envelope, $exchangeName, $queueName) { + if (!$envelope->hasHeader('x-death')) { + return 'header-missing'; + } + + $originalHeader = $envelope->getHeader('x-death'); + /** + * RabbitMQ 3.5.1 handles x-death headers differently: instead of growing the table x-death + * headers indefinitely it introduces a count field indexed by queue and reason. We normalize + * the headers to match the new format and to test against that + * + * https://github.com/rabbitmq/rabbitmq-server/releases/tag/rabbitmq_v3_5_1 + * https://github.com/rabbitmq/rabbitmq-server/issues/78 + * https://github.com/rabbitmq/rabbitmq-server/pull/79 + */ + $header = []; + foreach ($originalHeader as $death) { + $index = $death['queue'] . $death['reason']; + $count = isset($death['count']) ? $death['count'] : 1; + if (!isset($header[$index])) { + $header[$index] = array_merge($death, ['count' => $count]); + } else { + $header[$index]['count'] += $count; + } + } + $header = array_values($header); + + + if (count($header) !== 1) { + return 'unexpected-number-of-headers-' . count($header) . ': ' . json_encode($header); + } + + if (!isset($header[0]['reason']) || $header[0]['reason'] !== 'rejected') { + return 'unexpected-reason: ' . json_encode($header); + } + + if (!isset($header[0]['time']) || !$header[0]['time'] instanceof AMQPTimestamp) { + return 'unexpected-time: ' . json_encode($header); + } + + if (!isset($header[0]['exchange']) || $header[0]['exchange'] !== $exchangeName) { + return 'unexpected-exchange: ' . json_encode($header); + } + + if (!isset($header[0]['queue']) || $header[0]['queue'] !== $queueName) { + return 'unexpected-queue: ' . json_encode($header); + } + + if (!isset($header[0]['routing-keys']) || $header[0]['routing-keys'] !== ['']) { + return 'unexpected-routing-keys: ' . json_encode($header); + } + + if (!isset($header[0]['count'])) { + return 'count-missing: ' . json_encode($header); + } + + return $header[0]['count']; +} + +$envelope = $q->get(); +var_dump(assert_xdeath($envelope, $ex->getName(), $q->getName())); +$q->nack($envelope->getDeliveryTag()); + +usleep(20000); + +$failed = $dq->get(); +var_dump(assert_xdeath($failed, $ex->getName(), $q->getName())); +$dq->ack($failed->getDeliveryTag()); + +$ex->publish( + $failed->getBody(), + $failed->getRoutingKey(), + AMQP_NOPARAM, + [ + 'content_type' => $failed->getContentType(), + 'content_encoding' => $failed->getContentEncoding(), + 'message_id' => $failed->getMessageId(), + 'user_id' => $failed->getUserId(), + 'app_id' => $failed->getAppId(), + 'delivery_mode' => $failed->getDeliveryMode(), + 'priority' => $failed->getPriority(), + 'timestamp' => $failed->getTimeStamp(), + 'expiration' => $failed->getExpiration(), + 'type' => $failed->getType(), + 'reply_to' => $failed->getReplyTo(), + 'headers' => $failed->getHeaders(), + 'correlation_id' => $failed->getCorrelationId(), + ] +); + +usleep(20000); + + +$envelope = $q->get(); +var_dump(assert_xdeath($envelope, $ex->getName(), $q->getName())); +$q->nack($envelope->getDeliveryTag()); + + +usleep(20000); + +$failedTwice = $dq->get(); +var_dump(assert_xdeath($failedTwice, $ex->getName(), $q->getName())); +$dq->ack($failedTwice->getDeliveryTag()); + +?> + +==DONE== +--EXPECTF-- +string(14) "header-missing" +int(1) +int(1) +int(2) + +==DONE== \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_setArgument.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_setArgument.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_setArgument.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_setArgument.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,341 @@ +--TEST-- +AMQPExchange::setArgument() test +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +$heartbeat = 10; +$e_name_ae = 'test.exchange.ae.' . microtime(true); +$e_name = 'test.exchange.' . microtime(true); + +$ex_ae = new AMQPExchange($ch); +$ex_ae->setName($e_name_ae); +$ex_ae->setFlags(AMQP_AUTODELETE); +$ex_ae->setType(AMQP_EX_TYPE_FANOUT); +$ex_ae->declareExchange(); + +var_dump($ex_ae); + + +$ex = new AMQPExchange($ch); +$ex->setName($e_name); +$ex->setFlags(AMQP_AUTODELETE); +$ex->setType(AMQP_EX_TYPE_FANOUT); +// some real keys +$ex->setArgument("x-ha-policy", "all"); +$ex->setArgument("alternate-exchange", $e_name_ae); +// some custom keys to test various cases +$ex->setArgument('x-empty-string', ''); +$ex->setArgument('x-alternate-exchange-one-more-time', $e_name_ae); +$ex->setArgument('x-numeric-argument', $heartbeat * 10 * 1000); +$ex->declareExchange(); + +var_dump($ex); +$ex->setArgument('x-alternate-exchange-one-more-time', null); // remov key +var_dump($ex); +?> +--EXPECTF-- +object(AMQPExchange)#3 (9) { + ["connection":"AMQPExchange":private]=> + object(AMQPConnection)#1 (15) { + ["login":"AMQPConnection":private]=> + string(5) "guest" + ["password":"AMQPConnection":private]=> + string(5) "guest" + ["host":"AMQPConnection":private]=> + string(9) "localhost" + ["vhost":"AMQPConnection":private]=> + string(1) "/" + ["port":"AMQPConnection":private]=> + int(5672) + ["read_timeout":"AMQPConnection":private]=> + float(0) + ["write_timeout":"AMQPConnection":private]=> + float(0) + ["connect_timeout":"AMQPConnection":private]=> + float(0) + ["channel_max":"AMQPConnection":private]=> + int(256) + ["frame_max":"AMQPConnection":private]=> + int(131072) + ["heartbeat":"AMQPConnection":private]=> + int(0) + ["cacert":"AMQPConnection":private]=> + string(0) "" + ["key":"AMQPConnection":private]=> + string(0) "" + ["cert":"AMQPConnection":private]=> + string(0) "" + ["verify":"AMQPConnection":private]=> + bool(true) + } + ["channel":"AMQPExchange":private]=> + object(AMQPChannel)#2 (4) { + ["connection":"AMQPChannel":private]=> + object(AMQPConnection)#1 (15) { + ["login":"AMQPConnection":private]=> + string(5) "guest" + ["password":"AMQPConnection":private]=> + string(5) "guest" + ["host":"AMQPConnection":private]=> + string(9) "localhost" + ["vhost":"AMQPConnection":private]=> + string(1) "/" + ["port":"AMQPConnection":private]=> + int(5672) + ["read_timeout":"AMQPConnection":private]=> + float(0) + ["write_timeout":"AMQPConnection":private]=> + float(0) + ["connect_timeout":"AMQPConnection":private]=> + float(0) + ["channel_max":"AMQPConnection":private]=> + int(256) + ["frame_max":"AMQPConnection":private]=> + int(131072) + ["heartbeat":"AMQPConnection":private]=> + int(0) + ["cacert":"AMQPConnection":private]=> + string(0) "" + ["key":"AMQPConnection":private]=> + string(0) "" + ["cert":"AMQPConnection":private]=> + string(0) "" + ["verify":"AMQPConnection":private]=> + bool(true) + } + ["prefetch_count":"AMQPChannel":private]=> + int(3) + ["prefetch_size":"AMQPChannel":private]=> + int(0) + ["consumers":"AMQPChannel":private]=> + array(0) { + } + } + ["name":"AMQPExchange":private]=> + string(%d) "test.exchange.ae.%f" + ["type":"AMQPExchange":private]=> + string(6) "fanout" + ["passive":"AMQPExchange":private]=> + bool(false) + ["durable":"AMQPExchange":private]=> + bool(false) + ["auto_delete":"AMQPExchange":private]=> + bool(true) + ["internal":"AMQPExchange":private]=> + bool(false) + ["arguments":"AMQPExchange":private]=> + array(0) { + } +} +object(AMQPExchange)#4 (9) { + ["connection":"AMQPExchange":private]=> + object(AMQPConnection)#1 (15) { + ["login":"AMQPConnection":private]=> + string(5) "guest" + ["password":"AMQPConnection":private]=> + string(5) "guest" + ["host":"AMQPConnection":private]=> + string(9) "localhost" + ["vhost":"AMQPConnection":private]=> + string(1) "/" + ["port":"AMQPConnection":private]=> + int(5672) + ["read_timeout":"AMQPConnection":private]=> + float(0) + ["write_timeout":"AMQPConnection":private]=> + float(0) + ["connect_timeout":"AMQPConnection":private]=> + float(0) + ["channel_max":"AMQPConnection":private]=> + int(256) + ["frame_max":"AMQPConnection":private]=> + int(131072) + ["heartbeat":"AMQPConnection":private]=> + int(0) + ["cacert":"AMQPConnection":private]=> + string(0) "" + ["key":"AMQPConnection":private]=> + string(0) "" + ["cert":"AMQPConnection":private]=> + string(0) "" + ["verify":"AMQPConnection":private]=> + bool(true) + } + ["channel":"AMQPExchange":private]=> + object(AMQPChannel)#2 (4) { + ["connection":"AMQPChannel":private]=> + object(AMQPConnection)#1 (15) { + ["login":"AMQPConnection":private]=> + string(5) "guest" + ["password":"AMQPConnection":private]=> + string(5) "guest" + ["host":"AMQPConnection":private]=> + string(9) "localhost" + ["vhost":"AMQPConnection":private]=> + string(1) "/" + ["port":"AMQPConnection":private]=> + int(5672) + ["read_timeout":"AMQPConnection":private]=> + float(0) + ["write_timeout":"AMQPConnection":private]=> + float(0) + ["connect_timeout":"AMQPConnection":private]=> + float(0) + ["channel_max":"AMQPConnection":private]=> + int(256) + ["frame_max":"AMQPConnection":private]=> + int(131072) + ["heartbeat":"AMQPConnection":private]=> + int(0) + ["cacert":"AMQPConnection":private]=> + string(0) "" + ["key":"AMQPConnection":private]=> + string(0) "" + ["cert":"AMQPConnection":private]=> + string(0) "" + ["verify":"AMQPConnection":private]=> + bool(true) + } + ["prefetch_count":"AMQPChannel":private]=> + int(3) + ["prefetch_size":"AMQPChannel":private]=> + int(0) + ["consumers":"AMQPChannel":private]=> + array(0) { + } + } + ["name":"AMQPExchange":private]=> + string(%d) "test.exchange.%f" + ["type":"AMQPExchange":private]=> + string(6) "fanout" + ["passive":"AMQPExchange":private]=> + bool(false) + ["durable":"AMQPExchange":private]=> + bool(false) + ["auto_delete":"AMQPExchange":private]=> + bool(true) + ["internal":"AMQPExchange":private]=> + bool(false) + ["arguments":"AMQPExchange":private]=> + array(5) { + ["x-ha-policy"]=> + string(3) "all" + ["alternate-exchange"]=> + string(%d) "test.exchange.ae.%f" + ["x-empty-string"]=> + string(0) "" + ["x-alternate-exchange-one-more-time"]=> + string(%d) "test.exchange.ae.%f" + ["x-numeric-argument"]=> + int(100000) + } +} +object(AMQPExchange)#4 (9) { + ["connection":"AMQPExchange":private]=> + object(AMQPConnection)#1 (15) { + ["login":"AMQPConnection":private]=> + string(5) "guest" + ["password":"AMQPConnection":private]=> + string(5) "guest" + ["host":"AMQPConnection":private]=> + string(9) "localhost" + ["vhost":"AMQPConnection":private]=> + string(1) "/" + ["port":"AMQPConnection":private]=> + int(5672) + ["read_timeout":"AMQPConnection":private]=> + float(0) + ["write_timeout":"AMQPConnection":private]=> + float(0) + ["connect_timeout":"AMQPConnection":private]=> + float(0) + ["channel_max":"AMQPConnection":private]=> + int(256) + ["frame_max":"AMQPConnection":private]=> + int(131072) + ["heartbeat":"AMQPConnection":private]=> + int(0) + ["cacert":"AMQPConnection":private]=> + string(0) "" + ["key":"AMQPConnection":private]=> + string(0) "" + ["cert":"AMQPConnection":private]=> + string(0) "" + ["verify":"AMQPConnection":private]=> + bool(true) + } + ["channel":"AMQPExchange":private]=> + object(AMQPChannel)#2 (4) { + ["connection":"AMQPChannel":private]=> + object(AMQPConnection)#1 (15) { + ["login":"AMQPConnection":private]=> + string(5) "guest" + ["password":"AMQPConnection":private]=> + string(5) "guest" + ["host":"AMQPConnection":private]=> + string(9) "localhost" + ["vhost":"AMQPConnection":private]=> + string(1) "/" + ["port":"AMQPConnection":private]=> + int(5672) + ["read_timeout":"AMQPConnection":private]=> + float(0) + ["write_timeout":"AMQPConnection":private]=> + float(0) + ["connect_timeout":"AMQPConnection":private]=> + float(0) + ["channel_max":"AMQPConnection":private]=> + int(256) + ["frame_max":"AMQPConnection":private]=> + int(131072) + ["heartbeat":"AMQPConnection":private]=> + int(0) + ["cacert":"AMQPConnection":private]=> + string(0) "" + ["key":"AMQPConnection":private]=> + string(0) "" + ["cert":"AMQPConnection":private]=> + string(0) "" + ["verify":"AMQPConnection":private]=> + bool(true) + } + ["prefetch_count":"AMQPChannel":private]=> + int(3) + ["prefetch_size":"AMQPChannel":private]=> + int(0) + ["consumers":"AMQPChannel":private]=> + array(0) { + } + } + ["name":"AMQPExchange":private]=> + string(%d) "test.exchange.%f" + ["type":"AMQPExchange":private]=> + string(6) "fanout" + ["passive":"AMQPExchange":private]=> + bool(false) + ["durable":"AMQPExchange":private]=> + bool(false) + ["auto_delete":"AMQPExchange":private]=> + bool(true) + ["internal":"AMQPExchange":private]=> + bool(false) + ["arguments":"AMQPExchange":private]=> + array(4) { + ["x-ha-policy"]=> + string(3) "all" + ["alternate-exchange"]=> + string(%d) "test.exchange.ae.%f" + ["x-empty-string"]=> + string(0) "" + ["x-numeric-argument"]=> + int(100000) + } +} diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_set_flag.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_set_flag.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_set_flag.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_set_flag.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,26 @@ +--TEST-- +AMQPExchange set flag string +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +$ex = new AMQPExchange($ch); + +echo $ex->getFlags(); +$ex->setFlags("2"); +echo $ex->getFlags(); + +$ex->setFlags(NULL); +echo $ex->getFlags(); + +$ex->setFlags(2); +echo $ex->getFlags(); + +?> +--EXPECT-- +0202 \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_set_flags.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_set_flags.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_set_flags.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_set_flags.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,117 @@ +--TEST-- +AMQPExchange setFlags() +--SKIPIF-- +connect(); +$ch = new AMQPChannel($cnn); +// Declare a new exchange +$ex = new AMQPExchange($ch); +$ex->setName('exchange-' . microtime(true)); +$ex->setType(AMQP_EX_TYPE_FANOUT); +$ex->setArguments(array("x-ha-policy" => "all")); +$ex->setFlags(AMQP_PASSIVE | AMQP_DURABLE | AMQP_AUTODELETE | AMQP_INTERNAL); + +var_dump($ex); +?> +--EXPECTF-- +object(AMQPExchange)#3 (9) { + ["connection":"AMQPExchange":private]=> + object(AMQPConnection)#1 (15) { + ["login":"AMQPConnection":private]=> + string(5) "guest" + ["password":"AMQPConnection":private]=> + string(5) "guest" + ["host":"AMQPConnection":private]=> + string(9) "localhost" + ["vhost":"AMQPConnection":private]=> + string(1) "/" + ["port":"AMQPConnection":private]=> + int(5672) + ["read_timeout":"AMQPConnection":private]=> + float(0) + ["write_timeout":"AMQPConnection":private]=> + float(0) + ["connect_timeout":"AMQPConnection":private]=> + float(0) + ["channel_max":"AMQPConnection":private]=> + int(256) + ["frame_max":"AMQPConnection":private]=> + int(131072) + ["heartbeat":"AMQPConnection":private]=> + int(0) + ["cacert":"AMQPConnection":private]=> + string(0) "" + ["key":"AMQPConnection":private]=> + string(0) "" + ["cert":"AMQPConnection":private]=> + string(0) "" + ["verify":"AMQPConnection":private]=> + bool(true) + } + ["channel":"AMQPExchange":private]=> + object(AMQPChannel)#2 (4) { + ["connection":"AMQPChannel":private]=> + object(AMQPConnection)#1 (15) { + ["login":"AMQPConnection":private]=> + string(5) "guest" + ["password":"AMQPConnection":private]=> + string(5) "guest" + ["host":"AMQPConnection":private]=> + string(9) "localhost" + ["vhost":"AMQPConnection":private]=> + string(1) "/" + ["port":"AMQPConnection":private]=> + int(5672) + ["read_timeout":"AMQPConnection":private]=> + float(0) + ["write_timeout":"AMQPConnection":private]=> + float(0) + ["connect_timeout":"AMQPConnection":private]=> + float(0) + ["channel_max":"AMQPConnection":private]=> + int(256) + ["frame_max":"AMQPConnection":private]=> + int(131072) + ["heartbeat":"AMQPConnection":private]=> + int(0) + ["cacert":"AMQPConnection":private]=> + string(0) "" + ["key":"AMQPConnection":private]=> + string(0) "" + ["cert":"AMQPConnection":private]=> + string(0) "" + ["verify":"AMQPConnection":private]=> + bool(true) + } + ["prefetch_count":"AMQPChannel":private]=> + int(3) + ["prefetch_size":"AMQPChannel":private]=> + int(0) + ["consumers":"AMQPChannel":private]=> + array(0) { + } + } + ["name":"AMQPExchange":private]=> + string(%d) "exchange-%f" + ["type":"AMQPExchange":private]=> + string(6) "fanout" + ["passive":"AMQPExchange":private]=> + bool(true) + ["durable":"AMQPExchange":private]=> + bool(true) + ["auto_delete":"AMQPExchange":private]=> + bool(true) + ["internal":"AMQPExchange":private]=> + bool(true) + ["arguments":"AMQPExchange":private]=> + array(1) { + ["x-ha-policy"]=> + string(3) "all" + } +} diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_unbind.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_unbind.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_unbind.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_unbind.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,33 @@ +--TEST-- +AMQPExchange::unbind +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +// Declare a new exchange +$ex = new AMQPExchange($ch); +$ex->setName('exchange-unbind-' . microtime(true)); +$ex->setType(AMQP_EX_TYPE_FANOUT); +$ex->declareExchange(); + +// Declare a new exchange +$ex2 = new AMQPExchange($ch); +$ex2->setName('exchange2-unbind-' . microtime(true)); +$ex2->setType(AMQP_EX_TYPE_FANOUT); +$ex2->declareExchange(); + +var_dump($ex->bind($ex2->getName(), 'test-key-1')); + +var_dump($ex->unbind($ex2->getName(), 'test-key-1')); +var_dump($ex->unbind($ex2->getName(), 'test-key-1')); + +?> +--EXPECT-- +bool(true) +bool(true) +bool(true) \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_unbind_with_arguments.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_unbind_with_arguments.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_unbind_with_arguments.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_unbind_with_arguments.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,35 @@ +--TEST-- +AMQPExchange::unbind with arguments +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +// Declare a new exchange +$ex = new AMQPExchange($ch); +$ex->setName('exchange-unbind-' . microtime(true)); +$ex->setType(AMQP_EX_TYPE_FANOUT); +$ex->declareExchange(); + +// Declare a new exchange +$ex2 = new AMQPExchange($ch); +$ex2->setName('exchange2-exchange-unbind-' . microtime(true)); +$ex2->setType(AMQP_EX_TYPE_FANOUT); +$ex2->declareExchange(); + +$time = microtime(true); + +var_dump($ex->bind($ex2->getName(), 'test', array('test' => 'passed', 'at' => $time))); + +var_dump($ex->unbind($ex2->getName(), 'test', array('test' => 'passed', 'at' => $time))); +var_dump($ex->unbind($ex2->getName(), 'test', array('test' => 'passed', 'at' => $time))); + +?> +--EXPECT-- +bool(true) +bool(true) +bool(true) \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_unbind_without_key.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_unbind_without_key.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_unbind_without_key.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_unbind_without_key.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,33 @@ +--TEST-- +AMQPExchange::unbind without key +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +// Declare a new exchange +$ex = new AMQPExchange($ch); +$ex->setName('exchange-unbind-' . microtime(true)); +$ex->setType(AMQP_EX_TYPE_FANOUT); +$ex->declareExchange(); + +// Declare a new exchange +$ex2 = new AMQPExchange($ch); +$ex2->setName('exchange2-unbind-' . microtime(true)); +$ex2->setType(AMQP_EX_TYPE_FANOUT); +$ex2->declareExchange(); + +var_dump($ex->bind($ex2->getName())); +var_dump($ex->unbind($ex2->getName())); +var_dump($ex->unbind($ex2->getName())); + + +?> +--EXPECT-- +bool(true) +bool(true) +bool(true) \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_unbind_without_key_with_arguments.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_unbind_without_key_with_arguments.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_unbind_without_key_with_arguments.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_unbind_without_key_with_arguments.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,41 @@ +--TEST-- +AMQPExchange::unbind without key with arguments +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +// Declare a new exchange +$ex = new AMQPExchange($ch); +$ex->setName('exchange-unbind-' . microtime(true)); +$ex->setType(AMQP_EX_TYPE_FANOUT); +$ex->declareExchange(); + +// Declare a new exchange +$ex2 = new AMQPExchange($ch); +$ex2->setName('exchange2-unbind-' . microtime(true)); +$ex2->setType(AMQP_EX_TYPE_FANOUT); +$ex2->declareExchange(); + +$time = microtime(true); + +var_dump($ex->bind($ex2->getName(), null, array('test' => 'passed', 'at' => $time, 'i am' => 'first'))); +var_dump($ex->unbind($ex2->getName(), null, array('test' => 'passed', 'at' => $time, 'i am' => 'first'))); +var_dump($ex->unbind($ex2->getName(), null, array('test' => 'passed', 'at' => $time, 'i am' => 'first'))); + +var_dump($ex->bind($ex2->getName(), '', array('test' => 'passed', 'at' => $time, 'i am' => 'second'))); +var_dump($ex->unbind($ex2->getName(), '', array('test' => 'passed', 'at' => $time, 'i am' => 'second'))); +var_dump($ex->unbind($ex2->getName(), '', array('test' => 'passed', 'at' => $time, 'i am' => 'second'))); + +?> +--EXPECT-- +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_var_dump.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_var_dump.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpexchange_var_dump.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpexchange_var_dump.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,209 @@ +--TEST-- +AMQPExchange var_dump +--SKIPIF-- +connect(); +$ch = new AMQPChannel($cnn); +// Declare a new exchange +$ex = new AMQPExchange($ch); +$ex->setName('exchange-' . microtime(true)); +$ex->setType(AMQP_EX_TYPE_FANOUT); +var_dump($ex); +$ex->setArguments(array("x-ha-policy" => "all")); +var_dump($ex); +?> +--EXPECTF-- +object(AMQPExchange)#3 (9) { + ["connection":"AMQPExchange":private]=> + object(AMQPConnection)#1 (15) { + ["login":"AMQPConnection":private]=> + string(5) "guest" + ["password":"AMQPConnection":private]=> + string(5) "guest" + ["host":"AMQPConnection":private]=> + string(9) "localhost" + ["vhost":"AMQPConnection":private]=> + string(1) "/" + ["port":"AMQPConnection":private]=> + int(5672) + ["read_timeout":"AMQPConnection":private]=> + float(0) + ["write_timeout":"AMQPConnection":private]=> + float(0) + ["connect_timeout":"AMQPConnection":private]=> + float(0) + ["channel_max":"AMQPConnection":private]=> + int(256) + ["frame_max":"AMQPConnection":private]=> + int(131072) + ["heartbeat":"AMQPConnection":private]=> + int(0) + ["cacert":"AMQPConnection":private]=> + string(0) "" + ["key":"AMQPConnection":private]=> + string(0) "" + ["cert":"AMQPConnection":private]=> + string(0) "" + ["verify":"AMQPConnection":private]=> + bool(true) + } + ["channel":"AMQPExchange":private]=> + object(AMQPChannel)#2 (4) { + ["connection":"AMQPChannel":private]=> + object(AMQPConnection)#1 (15) { + ["login":"AMQPConnection":private]=> + string(5) "guest" + ["password":"AMQPConnection":private]=> + string(5) "guest" + ["host":"AMQPConnection":private]=> + string(9) "localhost" + ["vhost":"AMQPConnection":private]=> + string(1) "/" + ["port":"AMQPConnection":private]=> + int(5672) + ["read_timeout":"AMQPConnection":private]=> + float(0) + ["write_timeout":"AMQPConnection":private]=> + float(0) + ["connect_timeout":"AMQPConnection":private]=> + float(0) + ["channel_max":"AMQPConnection":private]=> + int(256) + ["frame_max":"AMQPConnection":private]=> + int(131072) + ["heartbeat":"AMQPConnection":private]=> + int(0) + ["cacert":"AMQPConnection":private]=> + string(0) "" + ["key":"AMQPConnection":private]=> + string(0) "" + ["cert":"AMQPConnection":private]=> + string(0) "" + ["verify":"AMQPConnection":private]=> + bool(true) + } + ["prefetch_count":"AMQPChannel":private]=> + int(3) + ["prefetch_size":"AMQPChannel":private]=> + int(0) + ["consumers":"AMQPChannel":private]=> + array(0) { + } + } + ["name":"AMQPExchange":private]=> + string(%d) "exchange-%f" + ["type":"AMQPExchange":private]=> + string(6) "fanout" + ["passive":"AMQPExchange":private]=> + bool(false) + ["durable":"AMQPExchange":private]=> + bool(false) + ["auto_delete":"AMQPExchange":private]=> + bool(false) + ["internal":"AMQPExchange":private]=> + bool(false) + ["arguments":"AMQPExchange":private]=> + array(0) { + } +} +object(AMQPExchange)#3 (9) { + ["connection":"AMQPExchange":private]=> + object(AMQPConnection)#1 (15) { + ["login":"AMQPConnection":private]=> + string(5) "guest" + ["password":"AMQPConnection":private]=> + string(5) "guest" + ["host":"AMQPConnection":private]=> + string(9) "localhost" + ["vhost":"AMQPConnection":private]=> + string(1) "/" + ["port":"AMQPConnection":private]=> + int(5672) + ["read_timeout":"AMQPConnection":private]=> + float(0) + ["write_timeout":"AMQPConnection":private]=> + float(0) + ["connect_timeout":"AMQPConnection":private]=> + float(0) + ["channel_max":"AMQPConnection":private]=> + int(256) + ["frame_max":"AMQPConnection":private]=> + int(131072) + ["heartbeat":"AMQPConnection":private]=> + int(0) + ["cacert":"AMQPConnection":private]=> + string(0) "" + ["key":"AMQPConnection":private]=> + string(0) "" + ["cert":"AMQPConnection":private]=> + string(0) "" + ["verify":"AMQPConnection":private]=> + bool(true) + } + ["channel":"AMQPExchange":private]=> + object(AMQPChannel)#2 (4) { + ["connection":"AMQPChannel":private]=> + object(AMQPConnection)#1 (15) { + ["login":"AMQPConnection":private]=> + string(5) "guest" + ["password":"AMQPConnection":private]=> + string(5) "guest" + ["host":"AMQPConnection":private]=> + string(9) "localhost" + ["vhost":"AMQPConnection":private]=> + string(1) "/" + ["port":"AMQPConnection":private]=> + int(5672) + ["read_timeout":"AMQPConnection":private]=> + float(0) + ["write_timeout":"AMQPConnection":private]=> + float(0) + ["connect_timeout":"AMQPConnection":private]=> + float(0) + ["channel_max":"AMQPConnection":private]=> + int(256) + ["frame_max":"AMQPConnection":private]=> + int(131072) + ["heartbeat":"AMQPConnection":private]=> + int(0) + ["cacert":"AMQPConnection":private]=> + string(0) "" + ["key":"AMQPConnection":private]=> + string(0) "" + ["cert":"AMQPConnection":private]=> + string(0) "" + ["verify":"AMQPConnection":private]=> + bool(true) + } + ["prefetch_count":"AMQPChannel":private]=> + int(3) + ["prefetch_size":"AMQPChannel":private]=> + int(0) + ["consumers":"AMQPChannel":private]=> + array(0) { + } + } + ["name":"AMQPExchange":private]=> + string(%d) "exchange-%f" + ["type":"AMQPExchange":private]=> + string(6) "fanout" + ["passive":"AMQPExchange":private]=> + bool(false) + ["durable":"AMQPExchange":private]=> + bool(false) + ["auto_delete":"AMQPExchange":private]=> + bool(false) + ["internal":"AMQPExchange":private]=> + bool(false) + ["arguments":"AMQPExchange":private]=> + array(1) { + ["x-ha-policy"]=> + string(3) "all" + } +} diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_attributes.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_attributes.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_attributes.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_attributes.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,30 @@ +--TEST-- +AMQPQueue attributes +--SKIPIF-- + +--FILE-- +connect(); +$ch = new AMQPChannel($cnn); + +$q = new AMQPQueue($ch); + +$q->setArguments($arr = array('existent' => 'value', 'false' => false)); + +echo 'Initial args: ', count($arr), ', queue args: ', count($q->getArguments()), PHP_EOL; +$q->setArgument('foo', 'bar'); +echo 'Initial args: ', count($arr), ', queue args: ', count($q->getArguments()), PHP_EOL; + +foreach (array('existent', 'false', 'nonexistent') as $key) { + echo "$key: ", var_export($q->hasArgument($key), true), ', ', var_export($q->getArgument($key)), PHP_EOL; +} + +?> +--EXPECT-- +Initial args: 2, queue args: 2 +Initial args: 2, queue args: 3 +existent: true, 'value' +false: true, false +nonexistent: false, false diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_bind_basic_empty_routing_key.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_bind_basic_empty_routing_key.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_bind_basic_empty_routing_key.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_bind_basic_empty_routing_key.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,26 @@ +--TEST-- +AMQPQueue +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +$ex = new AMQPExchange($ch); +$ex->setName('exchange-' . microtime(true)); +$ex->setType(AMQP_EX_TYPE_DIRECT); +$ex->declareExchange(); + +$queue = new AMQPQueue($ch); +$queue->setName("queue-" . microtime(true)); +$queue->declareQueue(); +var_dump($queue->bind($ex->getName())); + +$queue->delete(); +$ex->delete(); +?> +--EXPECT-- +bool(true) diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_bind_basic_headers_arguments.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_bind_basic_headers_arguments.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_bind_basic_headers_arguments.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_bind_basic_headers_arguments.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,28 @@ +--TEST-- +AMQPQueue +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +$ex = new AMQPExchange($ch); +$ex->setName('exchange-' . microtime(true)); +$ex->setType(AMQP_EX_TYPE_HEADERS); +$ex->declareExchange(); + +$queue = new AMQPQueue($ch); +$queue->setName("queue-" . microtime(true)); +$queue->declareQueue(); + +$arguments = array('x-match' => 'all', 'type' => 'custom'); +var_dump($queue->bind($ex->getName(), '', $arguments)); + +$queue->delete(); +$ex->delete(); +?> +--EXPECT-- +bool(true) diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_bind_basic.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_bind_basic.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_bind_basic.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_bind_basic.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,26 @@ +--TEST-- +AMQPQueue +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +$ex = new AMQPExchange($ch); +$ex->setName('exchange-' . microtime(true)); +$ex->setType(AMQP_EX_TYPE_DIRECT); +$ex->declareExchange(); + +$queue = new AMQPQueue($ch); +$queue->setName("queue-" . microtime(true)); +$queue->declareQueue(); +var_dump($queue->bind($ex->getName(), 'routing.key')); + +$queue->delete(); +$ex->delete(); +?> +--EXPECT-- +bool(true) diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_cancel.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_cancel.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_cancel.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_cancel.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,144 @@ +--TEST-- +AMQPQueue cancel +--SKIPIF-- + +--FILE-- +connect(); + return $conn; +} + +function create_channel($connection) { + $channel = new AMQPChannel($connection); + $channel->setPrefetchCount(1); + return $channel; +} + +function create_exchange($channel) { + $exchange = new AMQPExchange($channel); + $exchange->setName('test_cancel_exchange'); + $exchange->setType(AMQP_EX_TYPE_DIRECT); + $exchange->declareExchange(); + return $exchange; +} + +function create_queue($channel) { + $queue = new AMQPQueue($channel); + $queue->setName('test_cancel_queue'); + $queue->setFlags(AMQP_NOPARAM); + $queue->declareQueue(); + $queue->bind('test_cancel_exchange', 'test_cancel_routing_key'); + return $queue; +} + +class TrivialAcceptor { + private $count = 0; + private $maxCount; + + public function __construct($maxCount) { + $this->maxCount = $maxCount; + } + + public function accept($envelope, $queue) { + var_dump( + $envelope->getBody(), + $envelope->getDeliveryTag(), + $envelope->isRedelivery() + ); + echo "\n"; + $queue->ack($envelope->getDeliveryTag()); + $this->count++; + return $this->count < $this->maxCount; + } +} + +function get_acceptor($count) { + $acceptorObject = new TrivialAcceptor($count); + return array($acceptorObject, 'accept'); +} + +function send_message($exchange, $message) { + $exchange->publish($message, 'test_cancel_routing_key'); +} + +function wait_for_messages($queue, $consumer_tag, $message_count, $cancel_afterwards) { + $consumeMethod = new ReflectionMethod('AMQPQueue', 'consume'); + switch ($consumeMethod->getNumberOfParameters()) + { + case 3: + $queue->consume(get_acceptor($message_count), AMQP_NOPARAM, $consumer_tag); + if ($cancel_afterwards) + $queue->cancel($consumer_tag); + break; + + case 2: + $queue->consume(get_acceptor($message_count), AMQP_NOPARAM); + if ($cancel_afterwards) + $queue->cancel(); + break; + + default: + echo "AMQP::consume() takes neither 2 nor 3 parameters"; + exit(1); + } +} + +$consumer_tag_prefix = uniqid(); + +$send_conn = create_connection(); +$send_chan = create_channel($send_conn); +$exchange = create_exchange($send_chan); + +$recv_conn_1 = create_connection(); +$recv_chan_1 = create_channel($recv_conn_1); +$queue_1 = create_queue($recv_chan_1); + +send_message($exchange, 'message 0'); +wait_for_messages($queue_1, $consumer_tag_prefix.'_1', 1, true); + +send_message($exchange, 'message 1'); +send_message($exchange, 'message 2'); + +$recv_chan_2 = create_channel($recv_conn_1); +$queue_2 = create_queue($recv_chan_2); + +wait_for_messages($queue_2, $consumer_tag_prefix.'_2', 2, false); + +$recv_conn_1->disconnect(); +sleep(1); + +$recv_conn_2 = create_connection(); +$recv_chan_3 = create_channel($recv_conn_2); +$queue_3 = create_queue($recv_chan_3); + +send_message($exchange, 'message 3'); +send_message($exchange, 'message 4'); + +wait_for_messages($queue_3, $consumer_tag_prefix.'_3', 2, false); + +$queue_3->delete(AMQP_NOPARAM); +$exchange->delete(); +?> +--EXPECT-- +string(9) "message 0" +int(1) +bool(false) + +string(9) "message 1" +int(1) +bool(false) + +string(9) "message 2" +int(2) +bool(false) + +string(9) "message 3" +int(1) +bool(false) + +string(9) "message 4" +int(2) +bool(false) + diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_construct_basic.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_construct_basic.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_construct_basic.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_construct_basic.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,16 @@ +--TEST-- +AMQPQueue constructor +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +$queue = new AMQPQueue($ch); +echo get_class($queue); +?> +--EXPECT-- +AMQPQueue \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_consume_basic.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_consume_basic.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_consume_basic.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_consume_basic.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,143 @@ +--TEST-- +AMQPQueue::consume basic +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +// Declare a new exchange +$ex = new AMQPExchange($ch); +$ex->setName('exchange-' . microtime(true)); +$ex->setType(AMQP_EX_TYPE_FANOUT); +$ex->declareExchange(); + +// Create a new queue +$q = new AMQPQueue($ch); +$q->setName('queue-' . microtime(true)); +$q->declareQueue(); + +// Bind it on the exchange to routing.key +$q->bind($ex->getName(), 'routing.*'); + +// Publish a message to the exchange with a routing key +$ex->publish('message1', 'routing.1', AMQP_NOPARAM, array('content_type' => 'plain/test', 'headers' => array('foo' => 'bar'))); +$ex->publish('message2', 'routing.2', AMQP_NOPARAM, array('delivery_mode' => AMQP_DURABLE)); +$ex->publish('message3', 'routing.3', AMQP_DURABLE); // this is wrong way to make messages persistent + +$count = 0; + +function consumeThingsTwoTimes($message, $queue) { + global $count; + + echo "call #$count", PHP_EOL; + // Read from the queue + dump_message($message); + echo PHP_EOL; + $count++; + + if ($count >= 2) { + return false; + } + + return true; +} + +// Read from the queue +$q->consume("consumeThingsTwoTimes", AMQP_AUTOACK); + +$q->delete(); +$ex->delete(); + +?> +--EXPECTF-- +call #0 +AMQPEnvelope + getBody: + string(8) "message1" + getContentType: + string(10) "plain/test" + getRoutingKey: + string(9) "routing.1" + getConsumerTag: + string(31) "amq.ctag-%s" + getDeliveryTag: + int(1) + getDeliveryMode: + int(1) + getExchangeName: + string(%d) "exchange-%f" + isRedelivery: + bool(false) + getContentEncoding: + string(0) "" + getType: + string(0) "" + getTimeStamp: + int(0) + getPriority: + int(0) + getExpiration: + string(0) "" + getUserId: + string(0) "" + getAppId: + string(0) "" + getMessageId: + string(0) "" + getReplyTo: + string(0) "" + getCorrelationId: + string(0) "" + getHeaders: + array(1) { + ["foo"]=> + string(3) "bar" +} + +call #1 +AMQPEnvelope + getBody: + string(8) "message2" + getContentType: + string(10) "text/plain" + getRoutingKey: + string(9) "routing.2" + getConsumerTag: + string(31) "amq.ctag-%s" + getDeliveryTag: + int(2) + getDeliveryMode: + int(2) + getExchangeName: + string(%d) "exchange-%f" + isRedelivery: + bool(false) + getContentEncoding: + string(0) "" + getType: + string(0) "" + getTimeStamp: + int(0) + getPriority: + int(0) + getExpiration: + string(0) "" + getUserId: + string(0) "" + getAppId: + string(0) "" + getMessageId: + string(0) "" + getReplyTo: + string(0) "" + getCorrelationId: + string(0) "" + getHeaders: + array(0) { +} diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_consume_multiple_no_doubles.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_consume_multiple_no_doubles.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_consume_multiple_no_doubles.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_consume_multiple_no_doubles.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,33 @@ +--TEST-- +AMQPQueue::consume multiple (no doubles) +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +// Create a new queue +$q = new AMQPQueue($ch); +$q->setName('queue-' . microtime(true)); +$q->declareQueue(); + +var_dump($q->getConsumerTag()); +$q->consume(); +var_dump($tag1=$q->getConsumerTag()); +$q->consume(null, AMQP_JUST_CONSUME); +var_dump($tag2=$q->getConsumerTag()); + +echo ($tag1 == $tag2 ? 'equals' : 'differs'), PHP_EOL; + + +?> +--EXPECTF-- +NULL +string(%d) "amq.ctag-%s" +string(%d) "amq.ctag-%s" +equals \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_consume_multiple.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_consume_multiple.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_consume_multiple.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_consume_multiple.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,81 @@ +--TEST-- +AMQPQueue::consume multiple +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); +$ch2 = new AMQPChannel($cnn); +$ch3 = new AMQPChannel($cnn); + +// Declare a new exchange +$ex = new AMQPExchange($ch); +$ex->setName('exchange-' . $time); +$ex->setType(AMQP_EX_TYPE_TOPIC); +$ex->declareExchange(); + +// Create and bind queues +$q1 = new AMQPQueue($ch); +$q1->setName('queue-one-' . $time); +$q1->declareQueue(); +$q1->bind($ex->getName(), 'routing.one'); + +$q2 = new AMQPQueue($ch2); +$q2->setName('queue-two-' . $time); +$q2->declareQueue(); +$q2->bind($ex->getName(), 'routing.two'); + +$q3 = new AMQPQueue($ch3); +$q3->setName('queue-three-' . $time); +$q3->declareQueue(); +$q3->bind($ex->getName(), 'routing.three'); + + +// Publish a message to the exchange with a routing key +$ex->publish('message1', 'routing.one'); +$ex->publish('message2', 'routing.two'); +$ex->publish('message3', 'routing.three'); + +$count = 0; + +function consumeThings(AMQPEnvelope $message, AMQPQueue $queue) +{ + global $count; + + echo "Message: {$message->getBody()}, routing key: {$message->getRoutingKey()}, consumer tag: {$message->getConsumerTag()}\n"; + echo "Queue: {$queue->getName()}, consumer tag: {$queue->getConsumerTag()}\n"; + echo "Queue and message consumer tag ", ($queue->getConsumerTag() == $message->getConsumerTag() ? 'matches' : 'do not match'), "\n"; + echo PHP_EOL; + + $count++; + + $queue->ack($message->getDeliveryTag()); + + if ($count >= 2) { + return false; + } + + return true; +} + +$q1->consume(); +$q2->consume('consumeThings'); + +// This is important! +$q1->cancel(); +$q2->cancel(); + +?> +--EXPECTF-- +Message: message1, routing key: routing.one, consumer tag: amq.ctag-%s +Queue: queue-one-%f, consumer tag: amq.ctag-%s +Queue and message consumer tag matches + +Message: message2, routing key: routing.two, consumer tag: amq.ctag-%s +Queue: queue-two-%f, consumer tag: amq.ctag-%s +Queue and message consumer tag matches diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_consume_nonexistent.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_consume_nonexistent.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_consume_nonexistent.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_consume_nonexistent.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,34 @@ +--TEST-- +AMQPQueue::consume from nonexistent queue +--SKIPIF-- + +--FILE-- +setReadTimeout(10); // both are empirical values that should be far enough to deal with busy RabbitMQ broker +$cnn->setWriteTimeout(10); +$cnn->connect(); + +$ch = new AMQPChannel($cnn); + +// Declare a new exchange +$ex = new AMQPExchange($ch); +$ex->setName('exchange-' . microtime(true)); +$ex->setType(AMQP_EX_TYPE_FANOUT); +$ex->declareExchange(); + +// Create a new queue +$q = new AMQPQueue($ch); +$q->setName('nonexistent-' . microtime(true)); + +try { + $q->consume('noop'); +} catch (Exception $e) { + echo get_class($e), "({$e->getCode()}): ", $e->getMessage(); +} + +?> +--EXPECTF-- +AMQPQueueException(404): Server channel error: 404, message: NOT_FOUND - no queue 'nonexistent-%f' in vhost '/' diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_consume_timeout.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_consume_timeout.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_consume_timeout.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_consume_timeout.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,42 @@ +--TEST-- +AMQPQueue::consume with timeout +--SKIPIF-- + +--FILE-- + $timeout)); +$conn->connect(); +$chan = new AMQPChannel($conn); +$queue = new AMQPQueue($chan); +$queue->setFlags(AMQP_EXCLUSIVE); +$queue->declareQueue(); +$start = microtime(true); +try { + $queue->consume('nop'); +} catch (AMQPException $e) { + echo get_class($e), "({$e->getCode()}): ", $e->getMessage(); + echo PHP_EOL; +} +$end = microtime(true); +$error = $end - $start - $timeout; +$limit = abs(log10($timeout)); // empirical value + +echo 'timeout: ', $timeout, PHP_EOL; +echo 'takes: ', $end - $start, PHP_EOL; +echo 'error: ', $error, PHP_EOL; +echo 'limit: ', $limit, PHP_EOL; + +echo abs($error) <= $limit ? 'timings OK' : 'timings failed'; // error should be less than 5% of timeout value +$queue->delete(); +?> +--EXPECTF-- +AMQPQueueException(0): Consumer timeout exceed +timeout: %f +takes: %f +error: %f +limit: %f +timings OK diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_declare_basic.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_declare_basic.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_declare_basic.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_declare_basic.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,25 @@ +--TEST-- +AMQPQueue +--SKIPIF-- + +--FILE-- +connect(); +$ch = new AMQPChannel($cnn); + +$ex = new AMQPExchange($ch); +$ex->setName('exchange-' . microtime(true)); +$ex->setType(AMQP_EX_TYPE_DIRECT); +$ex->declareExchange(); + +$queue = new AMQPQueue($ch); +$queue->setName("queue-" . microtime(true)); +$queue->declareQueue(); +var_dump($queue->bind($ex->getName(), 'routing.key')); + +$queue->delete(); +$ex->delete(); +?> +--EXPECT-- +bool(true) diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_declare_with_arguments.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_declare_with_arguments.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_declare_with_arguments.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_declare_with_arguments.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,29 @@ +--TEST-- +AMQPQueue::declareQueue() - with arguments +--SKIPIF-- + +--FILE-- +connect(); +$ch = new AMQPChannel($cnn); + +$ex = new AMQPExchange($ch); +$ex->setName('exchange-' . microtime(true)); +$ex->setType(AMQP_EX_TYPE_DIRECT); +$ex->declareExchange(); + +$queue = new AMQPQueue($ch); +$queue->setName("queue-" . microtime(true)); +$queue->setArgument('x-dead-letter-exchange', ''); +$queue->setArgument('x-dead-letter-routing-key', 'some key'); +$queue->setArgument('x-message-ttl', 42); +$queue->setFlags(AMQP_AUTODELETE); +$res = $queue->declareQueue(); + +var_dump($res); + +$queue->delete(); +?> +--EXPECT-- +int(0) diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_declare_with_stalled_reference.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_declare_with_stalled_reference.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_declare_with_stalled_reference.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_declare_with_stalled_reference.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,40 @@ +--TEST-- +AMQPQueue - declare with stalled reference +--SKIPIF-- + +--FILE-- +declareQueue(); +} catch (\Exception $e) { + echo get_class($e), "({$e->getCode()}): ", $e->getMessage(), PHP_EOL; +} + +?> +--EXPECT-- +AMQPChannelException(0): Could not declare queue. Stale reference to the channel object. diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_delete_basic.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_delete_basic.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_delete_basic.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_delete_basic.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,45 @@ +--TEST-- +AMQPQueue +--SKIPIF-- + +--FILE-- +connect(); +$ch = new AMQPChannel($cnn); + +$ex = new AMQPExchange($ch); +$ex->setName('exchange-' . microtime(true)); +$ex->setType(AMQP_EX_TYPE_FANOUT); +$ex->declareExchange(); + +$queue = new AMQPQueue($ch); +$queue->setName("queue-" . microtime(true)); +$queue->declareQueue(); +$queue->bind($ex->getName()); + +var_dump($queue->delete()); +var_dump($queue->delete()); + +$queue->declareQueue(); +$queue->bind($ex->getName()); + +$ex->publish('test 1'); +$ex->publish('test 2'); +$ex->publish('test 3'); + +var_dump($queue->delete()); + +$ex->publish('test 1'); +$ex->publish('test 2'); +$ex->publish('test 3'); + +var_dump($queue->delete()); + +$ex->delete(); +?> +--EXPECT-- +int(0) +int(0) +int(3) +int(0) diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_empty_name.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_empty_name.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_empty_name.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_empty_name.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,24 @@ +--TEST-- +AMQPQueue declared with empty name +--SKIPIF-- + +--FILE-- +connect(); +$ch = new AMQPChannel($cnn); + +$ex = new AMQPExchange($ch); +$ex->setName('exchange-' . microtime(true)); +$ex->setType(AMQP_EX_TYPE_DIRECT); +$ex->declareExchange(); + +$queue = new AMQPQueue($ch); +$queue->declareQueue(); +var_dump(substr($queue->getName(), 0, strlen('amq.gen-'))); + +$queue->delete(); +$ex->delete(); +?> +--EXPECT-- +string(8) "amq.gen-" diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_get_basic.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_get_basic.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_get_basic.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_get_basic.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,171 @@ +--TEST-- +AMQPQueue::get basic +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +// Declare a new exchange +$ex = new AMQPExchange($ch); +$ex->setName('exchange-'. microtime(true)); +$ex->setType(AMQP_EX_TYPE_FANOUT); +$ex->declareExchange(); + +// Create a new queue +$q = new AMQPQueue($ch); +$q->setName('queue-' . microtime(true)); +$q->declareQueue(); + +// Bind it on the exchange to routing.key +$q->bind($ex->getName(), 'routing.*'); +// Publish a message to the exchange with a routing key +$ex->publish('message1', 'routing.1', AMQP_NOPARAM, array('content_type' => 'plain/test', 'headers' => array('foo' => 'bar'))); +$ex->publish('message2', 'routing.2', AMQP_DURABLE); +$ex->publish('message3', 'routing.3'); + +for ($i = 0; $i < 4; $i++) { + echo "call #$i", PHP_EOL; + // Read from the queue + $msg = $q->get(AMQP_AUTOACK); + dump_message($msg); + echo PHP_EOL; +} + +?> +--EXPECTF-- +call #0 +AMQPEnvelope + getBody: + string(8) "message1" + getContentType: + string(10) "plain/test" + getRoutingKey: + string(9) "routing.1" + getConsumerTag: + string(0) "" + getDeliveryTag: + int(1) + getDeliveryMode: + int(1) + getExchangeName: + string(%d) "exchange-%f" + isRedelivery: + bool(false) + getContentEncoding: + string(0) "" + getType: + string(0) "" + getTimeStamp: + int(0) + getPriority: + int(0) + getExpiration: + string(0) "" + getUserId: + string(0) "" + getAppId: + string(0) "" + getMessageId: + string(0) "" + getReplyTo: + string(0) "" + getCorrelationId: + string(0) "" + getHeaders: + array(1) { + ["foo"]=> + string(3) "bar" +} + +call #1 +AMQPEnvelope + getBody: + string(8) "message2" + getContentType: + string(10) "text/plain" + getRoutingKey: + string(9) "routing.2" + getConsumerTag: + string(0) "" + getDeliveryTag: + int(2) + getDeliveryMode: + int(1) + getExchangeName: + string(%d) "exchange-%f" + isRedelivery: + bool(false) + getContentEncoding: + string(0) "" + getType: + string(0) "" + getTimeStamp: + int(0) + getPriority: + int(0) + getExpiration: + string(0) "" + getUserId: + string(0) "" + getAppId: + string(0) "" + getMessageId: + string(0) "" + getReplyTo: + string(0) "" + getCorrelationId: + string(0) "" + getHeaders: + array(0) { +} + +call #2 +AMQPEnvelope + getBody: + string(8) "message3" + getContentType: + string(10) "text/plain" + getRoutingKey: + string(9) "routing.3" + getConsumerTag: + string(0) "" + getDeliveryTag: + int(3) + getDeliveryMode: + int(1) + getExchangeName: + string(%d) "exchange-%f" + isRedelivery: + bool(false) + getContentEncoding: + string(0) "" + getType: + string(0) "" + getTimeStamp: + int(0) + getPriority: + int(0) + getExpiration: + string(0) "" + getUserId: + string(0) "" + getAppId: + string(0) "" + getMessageId: + string(0) "" + getReplyTo: + string(0) "" + getCorrelationId: + string(0) "" + getHeaders: + array(0) { +} + +call #3 +bool(false) diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_get_channel.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_get_channel.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_get_channel.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_get_channel.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,29 @@ +--TEST-- +AMQPQueue getChannel() test +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); +$ch2 = new AMQPChannel($cnn); + +$q = new AMQPQueue($ch); + +echo $ch === $q->getChannel() ? 'same' : 'not same', PHP_EOL; +echo $ch2 === $q->getChannel() ? 'same' : 'not same', PHP_EOL; + +$old_prefetch = $ch->getPrefetchCount(); +$new_prefetch = 999; + +$q->getChannel()->setPrefetchCount($new_prefetch); + +echo $ch->getPrefetchCount() == $new_prefetch ? 'by ref' : 'copy', PHP_EOL; + +?> +--EXPECT-- +same +not same +by ref diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_get_connection.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_get_connection.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_get_connection.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_get_connection.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,35 @@ +--TEST-- +AMQPQueue getConnection test +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +$q = new AMQPQueue($ch); + +$cnn2 = new AMQPConnection(); + +echo $cnn === $q->getConnection() ? 'same' : 'not same', PHP_EOL; +echo $cnn2 === $q->getConnection() ? 'same' : 'not same', PHP_EOL; + +$old_host = $cnn->getHost(); +$new_host = 'test'; + +$q->getConnection()->setHost($new_host); + +echo $cnn->getHost() == $new_host ? 'by ref' : 'copy', PHP_EOL; + +?> +--EXPECT-- +same +not same +by ref diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_get_empty_body.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_get_empty_body.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_get_empty_body.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_get_empty_body.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,44 @@ +--TEST-- +AMQPQueue::get empty body +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +// Declare a new exchange +$ex = new AMQPExchange($ch); +$ex->setName('exchange' . microtime(true)); +$ex->setType(AMQP_EX_TYPE_FANOUT); +$ex->declareExchange(); + +// Create a new queue +$q = new AMQPQueue($ch); +$q->setName('queue1' . microtime(true)); +$q->declareQueue(); + +// Bind it on the exchange to routing.key +$q->bind($ex->getName(), 'routing.*'); + +// Publish a message to the exchange with a routing key +$ex->publish('', 'routing.1'); + +// Read from the queue +$msg = $q->get(AMQP_AUTOACK); +echo "'" . $msg->getBody() . "'\n"; + +$msg = $q->get(AMQP_AUTOACK); + +if ($msg === FALSE) { + echo "No more messages\n"; +} + +$ex->delete(); +$q->delete(); +?> +--EXPECT-- +'' +No more messages diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_get_headers.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_get_headers.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_get_headers.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_get_headers.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,62 @@ +--TEST-- +AMQPQueue::get headers +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +// Declare a new exchange +$ex = new AMQPExchange($ch); +$ex->setName('exchange' . microtime(true)); +$ex->setType(AMQP_EX_TYPE_FANOUT); +$ex->declareExchange(); + +// Create a new queue +$q = new AMQPQueue($ch); +$q->setName('queue1' . microtime(true)); +$q->declareQueue(); + +// Bind it on the exchange to routing.key +$q->bind($ex->getName(), 'routing.*'); + +// Publish a message to the exchange with a routing key +$ex->publish('body', 'routing.1', AMQP_NOPARAM, array("headers" => array( + "first" => "one", + "second" => 2 +))); + +// Read from the queue +$msg = $q->get(AMQP_AUTOACK); + +echo $msg->getBody() . "\n"; +var_dump($msg->getHeaders()); +echo $msg->getContentType() . "\n"; + +var_dump($msg->hasHeader("first")); +echo $msg->getHeader("first") . "\n"; +echo $msg->getHeader("second") . "\n"; + +echo 'Has nonexistent header: ', var_export($msg->hasHeader("nonexistent"), true), PHP_EOL; +echo 'Get nonexistent header: ', var_export($msg->getHeader("nonexistent"), true), PHP_EOL; + +$ex->delete(); +$q->delete(); +?> +--EXPECT-- +body +array(2) { + ["first"]=> + string(3) "one" + ["second"]=> + int(2) +} +text/plain +bool(true) +one +2 +Has nonexistent header: false +Get nonexistent header: false diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_get_nonexistent.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_get_nonexistent.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_get_nonexistent.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_get_nonexistent.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,32 @@ +--TEST-- +AMQPQueue::get from nonexistent queue +--SKIPIF-- + +--FILE-- +setReadTimeout(10); // both are empirical values that should be far enough to deal with busy RabbitMQ broker +$cnn->setWriteTimeout(10); +$cnn->connect(); + +$ch = new AMQPChannel($cnn); + +// Declare a new exchange +$ex = new AMQPExchange($ch); +$ex->setName('exchange-' . microtime(true)); +$ex->setType(AMQP_EX_TYPE_FANOUT); +$ex->declareExchange(); + +// Create a new queue +$q = new AMQPQueue($ch); +$q->setName('nonexistent-' . microtime(true)); + +try { + $q->get(); +} catch (Exception $e) { + echo get_class($e), "({$e->getCode()}): ", $e->getMessage(); +} + +?> +--EXPECTF-- +AMQPQueueException(404): Server channel error: 404, message: NOT_FOUND - no queue 'nonexistent-%f' in vhost '/' diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_headers_with_bool.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_headers_with_bool.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_headers_with_bool.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_headers_with_bool.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,57 @@ +--TEST-- +AMQPQueue::get headers with bool values +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +$ex = new AMQPExchange($ch); +$ex->setName('exchange' . microtime(true)); +$ex->setType(AMQP_EX_TYPE_TOPIC); +$ex->declareExchange(); +$q = new AMQPQueue($ch); +$q->setName('queue1' . microtime(true)); +$q->declareQueue(); +$q->bind($ex->getName(), '#'); + + +// publish a message: +$ex->publish( + 'body', 'routing.1', AMQP_NOPARAM, array( + 'headers' => array( + 'foo' => 'bar', + 'true' => true, + 'false' => false, + ) + ) +); + +// Read from the queue +$msg = $q->get(AMQP_AUTOACK); + +var_dump($msg->getHeaders()); +echo $msg->getHeader('foo') . "\n"; +var_dump($msg->hasHeader('true'), $msg->getHeader('true')); +var_dump($msg->hasHeader('false'), $msg->getHeader('false')); + +$ex->delete(); +$q->delete(); +?> +--EXPECT-- +array(3) { + ["foo"]=> + string(3) "bar" + ["true"]=> + bool(true) + ["false"]=> + bool(false) +} +bar +bool(true) +bool(true) +bool(true) +bool(false) diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_headers_with_float.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_headers_with_float.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_headers_with_float.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_headers_with_float.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,69 @@ +--TEST-- +AMQPQueue::get headers with float values +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +$ex = new AMQPExchange($ch); +$ex->setName('exchange' . microtime(true)); +$ex->setType(AMQP_EX_TYPE_TOPIC); +$ex->declareExchange(); +$q = new AMQPQueue($ch); +$q->setName('queue1' . microtime(true)); +$q->declareQueue(); +$q->bind($ex->getName(), '#'); + + +// publish a message: +$ex->publish( + 'body', 'routing.1', AMQP_NOPARAM, array( + 'headers' => array( + 'foo' => 'bar', + 'positive' => 2.3, + 'negative' => -1022.123456789, + 'scientific' => 10E2, + 'scientific_big' => 10E23, + ) + ) +); + +// Read from the queue +$msg = $q->get(AMQP_AUTOACK); + +var_dump($msg->getHeaders()); +echo $msg->getHeader('foo') . "\n"; +var_dump($msg->hasHeader('positive'), $msg->getHeader('positive')); +var_dump($msg->hasHeader('negative'), $msg->getHeader('negative')); +var_dump($msg->hasHeader('scientific'), $msg->getHeader('scientific')); +var_dump($msg->hasHeader('scientific_big'), $msg->getHeader('scientific_big')); + +$ex->delete(); +$q->delete(); +?> +--EXPECT-- +array(5) { + ["foo"]=> + string(3) "bar" + ["positive"]=> + float(2.3) + ["negative"]=> + float(-1022.123456789) + ["scientific"]=> + float(1000) + ["scientific_big"]=> + float(1.0E+24) +} +bar +bool(true) +float(2.3) +bool(true) +float(-1022.123456789) +bool(true) +float(1000) +bool(true) +float(1.0E+24) diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_headers_with_null.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_headers_with_null.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_headers_with_null.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_headers_with_null.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,50 @@ +--TEST-- +AMQPQueue::get headers +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +$ex = new AMQPExchange($ch); +$ex->setName('exchange' . microtime(true)); +$ex->setType(AMQP_EX_TYPE_TOPIC); +$ex->declareExchange(); +$q = new AMQPQueue($ch); +$q->setName('queue1' . microtime(true)); +$q->declareQueue(); +$q->bind($ex->getName(), '#'); + + +// publish a message: +$ex->publish( + 'body', 'routing.1', AMQP_NOPARAM, array( + 'headers' => array( + 'foo' => 'bar', + 'null' => NULL + ) + ) +); + +// Read from the queue +$msg = $q->get(AMQP_AUTOACK); + +var_dump($msg->getHeaders()); +echo $msg->getHeader('foo') . "\n"; +var_dump($msg->getHeader('null')); + +$ex->delete(); +$q->delete(); +?> +--EXPECT-- +array(2) { + ["foo"]=> + string(3) "bar" + ["null"]=> + NULL +} +bar +NULL diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_nack.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_nack.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_nack.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_nack.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,55 @@ +--TEST-- +AMQPQueue::nack +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +// Declare a new exchange +$ex = new AMQPExchange($ch); +$ex->setName('testnack' . microtime(true)); +$ex->setType(AMQP_EX_TYPE_FANOUT); +$ex->declareExchange(); +$exchangeName = $ex->getName(); + +// Create a new queue +$q = new AMQPQueue($ch); +$q->setName('testnack' . microtime(true)); +$q->declareQueue(); +$q->bind($exchangeName, '#'); + +// Bind it on the exchange to routing.key +// Publish a message to the exchange with a routing key +$ex->publish('message', 'foo'); + +$env = $q->get(AMQP_NOPARAM); +echo $env->getBody() . PHP_EOL; +echo $env->isRedelivery() ? 'true' : 'false'; +echo PHP_EOL; + +// send the message back to the queue +$q->nack($env->getDeliveryTag(), AMQP_REQUEUE); + +// read again +$env2 = $q->get(AMQP_NOPARAM); +if (false !== $env2) { + $q->ack($env2->getDeliveryTag()); + echo $env2->getBody() . PHP_EOL; + echo $env2->isRedelivery() ? 'true' : 'false'; + echo PHP_EOL; +} else { + echo "could not read message" . PHP_EOL; +} + +$ex->delete(); +$q->delete(); +--EXPECT-- +message +false +message +true diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_nested_arrays.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_nested_arrays.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_nested_arrays.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_nested_arrays.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,64 @@ +--TEST-- +AMQPQueue::get headers +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +$ex = new AMQPExchange($ch); +$ex->setName('exchange' . microtime(true)); +$ex->setType(AMQP_EX_TYPE_TOPIC); +$ex->declareExchange(); +$q = new AMQPQueue($ch); +$q->setName('queue1' . microtime(true)); +$q->declareQueue(); +$q->bind($ex->getName(), '#'); + + +// publish a message: +$ex->publish( + 'body', 'routing.1', AMQP_NOPARAM, array( + 'headers' => array( + 'foo' => 'bar', + 'baz' => array('a', 'bc', 'def') + ) + ) +); + +// Read from the queue +$msg = $q->get(AMQP_AUTOACK); + +var_dump($msg->getHeaders()); +echo $msg->getHeader('foo') . "\n"; +var_dump($msg->getHeader('baz')); + +$ex->delete(); +$q->delete(); +?> +--EXPECT-- +array(2) { + ["foo"]=> + string(3) "bar" + ["baz"]=> + array(3) { + [0]=> + string(1) "a" + [1]=> + string(2) "bc" + [2]=> + string(3) "def" + } +} +bar +array(3) { + [0]=> + string(1) "a" + [1]=> + string(2) "bc" + [2]=> + string(3) "def" +} diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_nested_headers.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_nested_headers.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_nested_headers.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_nested_headers.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,89 @@ +--TEST-- +AMQPQueue::get headers +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +// create an error exchange and bind a queue to it: +$errorXchange = new AMQPExchange($ch); +$errorXchange->setName('errorXchange' . microtime(true)); +$errorXchange->setType(AMQP_EX_TYPE_TOPIC); +$errorXchange->declareExchange(); + +$errorQ = new AMQPQueue($ch); +$errorQ->setName('errorQueue' . microtime(true)); +$errorQ->declareQueue(); +$errorQ->bind($errorXchange->getName(), '#'); + + +// Declare a new exchange and queue using this dead-letter-exchange: +$ex = new AMQPExchange($ch); +$ex->setName('exchange-' . microtime(true)); +$ex->setType(AMQP_EX_TYPE_TOPIC); +$ex->declareExchange(); +$q = new AMQPQueue($ch); +$q->setName('queue-' . microtime(true)); +$q->setArgument('x-dead-letter-exchange', $errorXchange->getName()); +$q->declareQueue(); +$q->bind($ex->getName(), '#'); + + +// publish a message: +$ex->publish( + 'body', 'routing.1', AMQP_NOPARAM, array( + 'headers' => array( + 'foo' => 'bar', + 'baz' => array('a', 'bc', 'def') + ) + ) +); + +// Read from the queue and reject, so it gets dead-lettered: +$msg = $q->get(AMQP_NOPARAM); +$q->nack($msg->getDeliveryTag()); + +sleep(1); +// Now read from the error queue: +$msg = $errorQ->get(AMQP_AUTOACK); + +$header = $msg->getHeader('x-death'); + +echo isset($header[0]['count']) ? 'with' : 'without', ' count ', PHP_EOL; + +unset($header[0]['count']); + +var_dump($header); + +$ex->delete(); +$q->delete(); +$errorXchange->delete(); +$errorQ->delete(); +?> +--EXPECTF-- +%s +array(1) { + [0]=> + array(5) { + ["reason"]=> + string(8) "rejected" + ["queue"]=> + string(%d) "queue-%f" + ["time"]=> + object(AMQPTimestamp)#%d (1) { + ["timestamp":"AMQPTimestamp":private]=> + string(10) "%s" + } + ["exchange"]=> + string(%d) "exchange-%f" + ["routing-keys"]=> + array(1) { + [0]=> + string(9) "routing.1" + } + } +} \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_purge_basic.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_purge_basic.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_purge_basic.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_purge_basic.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,8 @@ +--TEST-- +AMQPQueue +--SKIPIF-- + +--FILE-- + +--EXPECT-- diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_setArgument.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_setArgument.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_setArgument.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_setArgument.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,327 @@ +--TEST-- +AMQPQueue::setArgument() test +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +$heartbeat = 10; +$q_dead_name = 'test.queue.dead.' . microtime(true); +$q_name = 'test.queue.' . microtime(true); + +$q = new AMQPQueue($ch); +$q->setName($q_name); +$q->setFlags(AMQP_AUTODELETE); +$q->declareQueue(); + +var_dump($q); + + +$q_dead = new AMQPQueue($ch); +$q_dead->setName($q_dead_name); +$q_dead->setArgument('x-dead-letter-exchange', ''); +$q_dead->setArgument('x-dead-letter-routing-key', $q_name); +$q_dead->setArgument('x-message-ttl', $heartbeat * 10 * 1000); +$q_dead->setFlags(AMQP_AUTODELETE); +$q_dead->declareQueue(); + +var_dump($q_dead); +$q_dead->setArgument('x-dead-letter-routing-key', null); // removes this key +var_dump($q_dead); +?> +--EXPECTF-- +object(AMQPQueue)#3 (9) { + ["connection":"AMQPQueue":private]=> + object(AMQPConnection)#1 (15) { + ["login":"AMQPConnection":private]=> + string(5) "guest" + ["password":"AMQPConnection":private]=> + string(5) "guest" + ["host":"AMQPConnection":private]=> + string(9) "localhost" + ["vhost":"AMQPConnection":private]=> + string(1) "/" + ["port":"AMQPConnection":private]=> + int(5672) + ["read_timeout":"AMQPConnection":private]=> + float(0) + ["write_timeout":"AMQPConnection":private]=> + float(0) + ["connect_timeout":"AMQPConnection":private]=> + float(0) + ["channel_max":"AMQPConnection":private]=> + int(256) + ["frame_max":"AMQPConnection":private]=> + int(131072) + ["heartbeat":"AMQPConnection":private]=> + int(0) + ["cacert":"AMQPConnection":private]=> + string(0) "" + ["key":"AMQPConnection":private]=> + string(0) "" + ["cert":"AMQPConnection":private]=> + string(0) "" + ["verify":"AMQPConnection":private]=> + bool(true) + } + ["channel":"AMQPQueue":private]=> + object(AMQPChannel)#2 (4) { + ["connection":"AMQPChannel":private]=> + object(AMQPConnection)#1 (15) { + ["login":"AMQPConnection":private]=> + string(5) "guest" + ["password":"AMQPConnection":private]=> + string(5) "guest" + ["host":"AMQPConnection":private]=> + string(9) "localhost" + ["vhost":"AMQPConnection":private]=> + string(1) "/" + ["port":"AMQPConnection":private]=> + int(5672) + ["read_timeout":"AMQPConnection":private]=> + float(0) + ["write_timeout":"AMQPConnection":private]=> + float(0) + ["connect_timeout":"AMQPConnection":private]=> + float(0) + ["channel_max":"AMQPConnection":private]=> + int(256) + ["frame_max":"AMQPConnection":private]=> + int(131072) + ["heartbeat":"AMQPConnection":private]=> + int(0) + ["cacert":"AMQPConnection":private]=> + string(0) "" + ["key":"AMQPConnection":private]=> + string(0) "" + ["cert":"AMQPConnection":private]=> + string(0) "" + ["verify":"AMQPConnection":private]=> + bool(true) + } + ["prefetch_count":"AMQPChannel":private]=> + int(3) + ["prefetch_size":"AMQPChannel":private]=> + int(0) + ["consumers":"AMQPChannel":private]=> + array(0) { + } + } + ["name":"AMQPQueue":private]=> + string(%d) "test.queue.%f" + ["consumer_tag":"AMQPQueue":private]=> + NULL + ["passive":"AMQPQueue":private]=> + bool(false) + ["durable":"AMQPQueue":private]=> + bool(false) + ["exclusive":"AMQPQueue":private]=> + bool(false) + ["auto_delete":"AMQPQueue":private]=> + bool(true) + ["arguments":"AMQPQueue":private]=> + array(0) { + } +} +object(AMQPQueue)#4 (9) { + ["connection":"AMQPQueue":private]=> + object(AMQPConnection)#1 (15) { + ["login":"AMQPConnection":private]=> + string(5) "guest" + ["password":"AMQPConnection":private]=> + string(5) "guest" + ["host":"AMQPConnection":private]=> + string(9) "localhost" + ["vhost":"AMQPConnection":private]=> + string(1) "/" + ["port":"AMQPConnection":private]=> + int(5672) + ["read_timeout":"AMQPConnection":private]=> + float(0) + ["write_timeout":"AMQPConnection":private]=> + float(0) + ["connect_timeout":"AMQPConnection":private]=> + float(0) + ["channel_max":"AMQPConnection":private]=> + int(256) + ["frame_max":"AMQPConnection":private]=> + int(131072) + ["heartbeat":"AMQPConnection":private]=> + int(0) + ["cacert":"AMQPConnection":private]=> + string(0) "" + ["key":"AMQPConnection":private]=> + string(0) "" + ["cert":"AMQPConnection":private]=> + string(0) "" + ["verify":"AMQPConnection":private]=> + bool(true) + } + ["channel":"AMQPQueue":private]=> + object(AMQPChannel)#2 (4) { + ["connection":"AMQPChannel":private]=> + object(AMQPConnection)#1 (15) { + ["login":"AMQPConnection":private]=> + string(5) "guest" + ["password":"AMQPConnection":private]=> + string(5) "guest" + ["host":"AMQPConnection":private]=> + string(9) "localhost" + ["vhost":"AMQPConnection":private]=> + string(1) "/" + ["port":"AMQPConnection":private]=> + int(5672) + ["read_timeout":"AMQPConnection":private]=> + float(0) + ["write_timeout":"AMQPConnection":private]=> + float(0) + ["connect_timeout":"AMQPConnection":private]=> + float(0) + ["channel_max":"AMQPConnection":private]=> + int(256) + ["frame_max":"AMQPConnection":private]=> + int(131072) + ["heartbeat":"AMQPConnection":private]=> + int(0) + ["cacert":"AMQPConnection":private]=> + string(0) "" + ["key":"AMQPConnection":private]=> + string(0) "" + ["cert":"AMQPConnection":private]=> + string(0) "" + ["verify":"AMQPConnection":private]=> + bool(true) + } + ["prefetch_count":"AMQPChannel":private]=> + int(3) + ["prefetch_size":"AMQPChannel":private]=> + int(0) + ["consumers":"AMQPChannel":private]=> + array(0) { + } + } + ["name":"AMQPQueue":private]=> + string(%d) "test.queue.dead.%f" + ["consumer_tag":"AMQPQueue":private]=> + NULL + ["passive":"AMQPQueue":private]=> + bool(false) + ["durable":"AMQPQueue":private]=> + bool(false) + ["exclusive":"AMQPQueue":private]=> + bool(false) + ["auto_delete":"AMQPQueue":private]=> + bool(true) + ["arguments":"AMQPQueue":private]=> + array(3) { + ["x-dead-letter-exchange"]=> + string(0) "" + ["x-dead-letter-routing-key"]=> + string(%d) "test.queue.%f" + ["x-message-ttl"]=> + int(100000) + } +} +object(AMQPQueue)#4 (9) { + ["connection":"AMQPQueue":private]=> + object(AMQPConnection)#1 (15) { + ["login":"AMQPConnection":private]=> + string(5) "guest" + ["password":"AMQPConnection":private]=> + string(5) "guest" + ["host":"AMQPConnection":private]=> + string(9) "localhost" + ["vhost":"AMQPConnection":private]=> + string(1) "/" + ["port":"AMQPConnection":private]=> + int(5672) + ["read_timeout":"AMQPConnection":private]=> + float(0) + ["write_timeout":"AMQPConnection":private]=> + float(0) + ["connect_timeout":"AMQPConnection":private]=> + float(0) + ["channel_max":"AMQPConnection":private]=> + int(256) + ["frame_max":"AMQPConnection":private]=> + int(131072) + ["heartbeat":"AMQPConnection":private]=> + int(0) + ["cacert":"AMQPConnection":private]=> + string(0) "" + ["key":"AMQPConnection":private]=> + string(0) "" + ["cert":"AMQPConnection":private]=> + string(0) "" + ["verify":"AMQPConnection":private]=> + bool(true) + } + ["channel":"AMQPQueue":private]=> + object(AMQPChannel)#2 (4) { + ["connection":"AMQPChannel":private]=> + object(AMQPConnection)#1 (15) { + ["login":"AMQPConnection":private]=> + string(5) "guest" + ["password":"AMQPConnection":private]=> + string(5) "guest" + ["host":"AMQPConnection":private]=> + string(9) "localhost" + ["vhost":"AMQPConnection":private]=> + string(1) "/" + ["port":"AMQPConnection":private]=> + int(5672) + ["read_timeout":"AMQPConnection":private]=> + float(0) + ["write_timeout":"AMQPConnection":private]=> + float(0) + ["connect_timeout":"AMQPConnection":private]=> + float(0) + ["channel_max":"AMQPConnection":private]=> + int(256) + ["frame_max":"AMQPConnection":private]=> + int(131072) + ["heartbeat":"AMQPConnection":private]=> + int(0) + ["cacert":"AMQPConnection":private]=> + string(0) "" + ["key":"AMQPConnection":private]=> + string(0) "" + ["cert":"AMQPConnection":private]=> + string(0) "" + ["verify":"AMQPConnection":private]=> + bool(true) + } + ["prefetch_count":"AMQPChannel":private]=> + int(3) + ["prefetch_size":"AMQPChannel":private]=> + int(0) + ["consumers":"AMQPChannel":private]=> + array(0) { + } + } + ["name":"AMQPQueue":private]=> + string(%d) "test.queue.dead.%f" + ["consumer_tag":"AMQPQueue":private]=> + NULL + ["passive":"AMQPQueue":private]=> + bool(false) + ["durable":"AMQPQueue":private]=> + bool(false) + ["exclusive":"AMQPQueue":private]=> + bool(false) + ["auto_delete":"AMQPQueue":private]=> + bool(true) + ["arguments":"AMQPQueue":private]=> + array(2) { + ["x-dead-letter-exchange"]=> + string(0) "" + ["x-message-ttl"]=> + int(100000) + } +} diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_unbind_basic_empty_routing_key.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_unbind_basic_empty_routing_key.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_unbind_basic_empty_routing_key.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_unbind_basic_empty_routing_key.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,28 @@ +--TEST-- +AMQPQueue +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +$ex = new AMQPExchange($ch); +$ex->setName('exchange-' . microtime(true)); +$ex->setType(AMQP_EX_TYPE_DIRECT); +$ex->declareExchange(); + +$queue = new AMQPQueue($ch); +$queue->setName("queue-" . microtime(true)); +$queue->declareQueue(); +var_dump($queue->bind($ex->getName())); +var_dump($queue->unbind($ex->getName())); + +$queue->delete(); +$ex->delete(); +?> +--EXPECT-- +bool(true) +bool(true) diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_unbind_basic_headers_arguments.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_unbind_basic_headers_arguments.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_unbind_basic_headers_arguments.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_unbind_basic_headers_arguments.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,31 @@ +--TEST-- +AMQPQueue +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +$ex = new AMQPExchange($ch); +$ex->setName('exchange-' . microtime(true)); +$ex->setType(AMQP_EX_TYPE_DIRECT); +$ex->declareExchange(); + +$queue = new AMQPQueue($ch); +$queue->setName("queue-" . microtime(true)); +$queue->declareQueue(); + +$arguments = array('x-match' => 'all', 'type' => 'custom'); + +var_dump($queue->bind($ex->getName(), '', $arguments)); +var_dump($queue->unbind($ex->getName(), '', $arguments)); + +$queue->delete(); +$ex->delete(); +?> +--EXPECT-- +bool(true) +bool(true) diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_var_dump.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_var_dump.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqpqueue_var_dump.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqpqueue_var_dump.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,117 @@ +--TEST-- +AMQPQueue var_dump +--SKIPIF-- +connect(); +$ch = new AMQPChannel($cnn); +// Declare a new exchange +$ex = new AMQPExchange($ch); +$ex->setName('exchange1'); +$ex->setType(AMQP_EX_TYPE_FANOUT); +$ex->declareExchange(); +// Create a new queue +$q = new AMQPQueue($ch); +$q->setName('queue_var_dump'); +$q->declareQueue(); +var_dump($q); +?> +--EXPECT-- +object(AMQPQueue)#4 (9) { + ["connection":"AMQPQueue":private]=> + object(AMQPConnection)#1 (15) { + ["login":"AMQPConnection":private]=> + string(5) "guest" + ["password":"AMQPConnection":private]=> + string(5) "guest" + ["host":"AMQPConnection":private]=> + string(9) "localhost" + ["vhost":"AMQPConnection":private]=> + string(1) "/" + ["port":"AMQPConnection":private]=> + int(5672) + ["read_timeout":"AMQPConnection":private]=> + float(0) + ["write_timeout":"AMQPConnection":private]=> + float(0) + ["connect_timeout":"AMQPConnection":private]=> + float(0) + ["channel_max":"AMQPConnection":private]=> + int(256) + ["frame_max":"AMQPConnection":private]=> + int(131072) + ["heartbeat":"AMQPConnection":private]=> + int(0) + ["cacert":"AMQPConnection":private]=> + string(0) "" + ["key":"AMQPConnection":private]=> + string(0) "" + ["cert":"AMQPConnection":private]=> + string(0) "" + ["verify":"AMQPConnection":private]=> + bool(true) + } + ["channel":"AMQPQueue":private]=> + object(AMQPChannel)#2 (4) { + ["connection":"AMQPChannel":private]=> + object(AMQPConnection)#1 (15) { + ["login":"AMQPConnection":private]=> + string(5) "guest" + ["password":"AMQPConnection":private]=> + string(5) "guest" + ["host":"AMQPConnection":private]=> + string(9) "localhost" + ["vhost":"AMQPConnection":private]=> + string(1) "/" + ["port":"AMQPConnection":private]=> + int(5672) + ["read_timeout":"AMQPConnection":private]=> + float(0) + ["write_timeout":"AMQPConnection":private]=> + float(0) + ["connect_timeout":"AMQPConnection":private]=> + float(0) + ["channel_max":"AMQPConnection":private]=> + int(256) + ["frame_max":"AMQPConnection":private]=> + int(131072) + ["heartbeat":"AMQPConnection":private]=> + int(0) + ["cacert":"AMQPConnection":private]=> + string(0) "" + ["key":"AMQPConnection":private]=> + string(0) "" + ["cert":"AMQPConnection":private]=> + string(0) "" + ["verify":"AMQPConnection":private]=> + bool(true) + } + ["prefetch_count":"AMQPChannel":private]=> + int(3) + ["prefetch_size":"AMQPChannel":private]=> + int(0) + ["consumers":"AMQPChannel":private]=> + array(0) { + } + } + ["name":"AMQPQueue":private]=> + string(14) "queue_var_dump" + ["consumer_tag":"AMQPQueue":private]=> + NULL + ["passive":"AMQPQueue":private]=> + bool(false) + ["durable":"AMQPQueue":private]=> + bool(false) + ["exclusive":"AMQPQueue":private]=> + bool(false) + ["auto_delete":"AMQPQueue":private]=> + bool(true) + ["arguments":"AMQPQueue":private]=> + array(0) { + } +} diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/amqptimestamp.phpt php-amqp-1.9.3/amqp-1.9.3/tests/amqptimestamp.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/amqptimestamp.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/amqptimestamp.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,55 @@ +--TEST-- +AMQPTimestamp +--SKIPIF-- +getTimestamp(), (string) $timestamp); + +$timestamp = new AMQPTimestamp(100000.1); +var_dump($timestamp->getTimestamp(), (string) $timestamp); + +new AMQPTimestamp(); + +new AMQPTimestamp("string"); + +try { + new AMQPTimestamp(AMQPTimestamp::MIN - 1); +} catch (AMQPValueException $e) { + echo $e->getMessage() . "\n"; +} + +try { + new AMQPTimestamp(INF); +} catch (AMQPValueException $e) { + echo $e->getMessage() . "\n"; +} + +var_dump((new ReflectionClass("AMQPTimestamp"))->isFinal()); + +var_dump(AMQPTimestamp::MAX); +var_dump(AMQPTimestamp::MIN); +?> + +==END== +--EXPECTF-- +string(6) "100000" +string(6) "100000" +string(6) "100000" +string(6) "100000" + +Warning: AMQPTimestamp::__construct() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: AMQPTimestamp::__construct() expects parameter 1 to be %s, string given in %s on line %d +The timestamp parameter must be greater than 0. +The timestamp parameter must be less than 18446744073709551616. +bool(true) +string(20) "18446744073709551616" +string(1) "0" + +==END== \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/bug_17831.phpt php-amqp-1.9.3/amqp-1.9.3/tests/bug_17831.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/bug_17831.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/bug_17831.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,25 @@ +--TEST-- +Segfault when publishing to non existent exchange +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($c); + +$ex = new AMQPExchange($ch); +$ex->setName("exchange-" . microtime(true)); +$ex->setType(AMQP_EX_TYPE_FANOUT); +$ex->declareExchange(); +try { + $ex->publish("data", "bar"); + echo "Success\n"; +} catch (Exception $e) { + echo "Success\n"; +} +$ex->delete(); +?> +--EXPECT-- +Success diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/bug_19707.phpt php-amqp-1.9.3/amqp-1.9.3/tests/bug_19707.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/bug_19707.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/bug_19707.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,61 @@ +--TEST-- +AMQPQueue::get() doesn't return the message +--SKIPIF-- + +--FILE-- +connect(); + +$ch = new AMQPChannel($cnn); + +$ex = new AMQPExchange($ch); +$ex->setName("exchange_testing_19707"); +$ex->setType(AMQP_EX_TYPE_FANOUT); +$ex->declareExchange(); + +$q = new AMQPQueue($ch); +$q->setName('queue' . microtime(true)); +$q->setFlags(AMQP_DURABLE); +$q->declareQueue(); + +$q->bind($ex->getName(), 'routing.key'); + +$ex->publish('message', 'routing.key'); + +$msg = $q->get(); + +echo "message received from get:\n"; +$funcs = array( + 'getAppId', 'getBody', 'getContentEncoding', 'getContentType', + 'getCorrelationId', 'getDeliveryTag', 'getExchangeName', 'getExpiration', + 'getHeaders', 'getMessageId', 'getPriority', 'getReplyTo', 'getRoutingKey', + 'getTimeStamp', 'getType', 'getUserId', 'isRedelivery' +); +foreach ($funcs as $func) { + printf("%s => %s\n", $func, var_export($msg->$func(), true)); +}; + +$q->delete(); +$ex->delete(); +?> +--EXPECT-- +message received from get: +getAppId => '' +getBody => 'message' +getContentEncoding => '' +getContentType => 'text/plain' +getCorrelationId => '' +getDeliveryTag => 1 +getExchangeName => 'exchange_testing_19707' +getExpiration => '' +getHeaders => array ( +) +getMessageId => '' +getPriority => 0 +getReplyTo => '' +getRoutingKey => 'routing.key' +getTimeStamp => 0 +getType => '' +getUserId => '' +isRedelivery => false \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/bug_19840.phpt php-amqp-1.9.3/amqp-1.9.3/tests/bug_19840.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/bug_19840.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/bug_19840.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,22 @@ +--TEST-- +Bug 19840: Connection Exception +--SKIPIF-- + +--FILE-- +connect(); + echo "No exception thrown\n"; +} catch (Exception $e) { + echo get_class($e), "({$e->getCode()}): ", $e->getMessage(); +} +?> +--EXPECT-- +AMQPConnectionException(0): Socket error: could not connect to host. \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/bug_61533.phpt php-amqp-1.9.3/amqp-1.9.3/tests/bug_61533.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/bug_61533.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/bug_61533.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,24 @@ +--TEST-- +Constructing AMQPQueue with AMQPConnection segfaults +--SKIPIF-- + +--FILE-- +connect(); +$chan = new AMQPChannel($conn); + +if (!class_exists('TypeError')) { + class TypeError extends Exception {} +} + +try { + error_reporting(error_reporting() & ~E_WARNING); + $queue = new AMQPQueue($conn); +} catch (TypeError $e) { + echo get_class($e), "({$e->getCode()}): ", $e->getMessage(), '.', PHP_EOL; // we pad exception message with dot to make EXPETF be the same on PHP 5 and PHP 7 +} + +?> +--EXPECTF-- +%s: Argument 1 passed to AMQPQueue::__construct() must be an instance of AMQPChannel, instance of AMQPConnection given%s diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/bug_62354.phpt php-amqp-1.9.3/amqp-1.9.3/tests/bug_62354.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/bug_62354.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/bug_62354.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,23 @@ +--TEST-- +Constructing AMQPQueue with AMQPConnection segfaults +--SKIPIF-- + +--FILE-- +conn = new AMQPConnection(); +$funcs = array( + 'getHost', 'getLogin', 'getPassword', 'getPort', 'getVHost', 'isConnected' +); +foreach ($funcs as $func) { + printf("%s => %s\n", $func, var_export($o->conn->$func(), true)); +}; +?> +--EXPECT-- +getHost => 'localhost' +getLogin => 'guest' +getPassword => 'guest' +getPort => 5672 +getVHost => '/' +isConnected => false \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/bug_gh147.phpt php-amqp-1.9.3/amqp-1.9.3/tests/bug_gh147.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/bug_gh147.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/bug_gh147.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,44 @@ +--TEST-- +#147 Segfault when catchable fatal error happens in consumer +--SKIPIF-- + +--FILE-- +connect(); + +$channel = new AMQPChannel($connection); +$channel->setPrefetchCount(2); + +$exchange = new AMQPExchange($channel); +$exchange->setType(AMQP_EX_TYPE_TOPIC); +$exchange->setName('test_' . $time); +$exchange->setFlags(AMQP_AUTODELETE); +$exchange->declareExchange(); + +$queue = new AMQPQueue($channel); +$queue->setName('test_' . $time); +$queue->declareQueue(); + +$queue->bind($exchange->getName(), 'test'); + +$exchange->publish('test message', 'test'); + +echo 'start', PHP_EOL; +$queue->consume(function(AMQPEnvelope $e) use (&$consume) { + echo 'consuming'; + $e . 'should fail'; + + return false; +}); + +echo 'done', PHP_EOL; + + +?> +--EXPECTF-- +start +consuming +%s fatal error: Object of class %s could not be converted to string in %s on line %d \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/bug_gh155_direct_reply_to.phpt php-amqp-1.9.3/amqp-1.9.3/tests/bug_gh155_direct_reply_to.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/bug_gh155_direct_reply_to.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/bug_gh155_direct_reply_to.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,76 @@ +--TEST-- +#155 RabbitMQ's Direct reply-to (related to consume multiple) +--SKIPIF-- + +--FILE-- +connect(); + +$channel = new AMQPChannel($conn); +$exchange = new AMQPExchange($channel); + + +$q_reply_to = new AMQPQueue($channel); +$q_reply_to->setName('amq.rabbitmq.reply-to'); +$q_reply_to->consume(null, AMQP_AUTOACK); + + +// this will be kind out long-living queue to +$q_request = new AMQPQueue($channel); +$q_request->setName('reply-to-requests'); +$q_request->setFlags(AMQP_DURABLE); +$q_request->declareQueue(); +$q_request->purge(); + +$q_request_name = $q_request->getName(); + +echo 'Publishing request...' . PHP_EOL; + +$exchange->publish('request', $q_request_name, AMQP_NOPARAM, array('reply_to' => 'amq.rabbitmq.reply-to')); + +$request_message = $q_request->get(AMQP_AUTOACK); + +$reply_to = $request_message->getReplyTo(); + +echo 'Reply-to queue: ', $reply_to, PHP_EOL; + +echo 'Prepare response queue...' . PHP_EOL; + +$channel_2 = new AMQPChannel($conn); + +$q_reply = new AMQPQueue($channel_2); +$q_reply->setName($reply_to); +$q_reply->setFlags(AMQP_PASSIVE); +$q_reply->declareQueue(); + +echo 'Publishing response...' . PHP_EOL; + +$exchange->publish('response', $reply_to, AMQP_NOPARAM); + + +echo 'Waiting for reply...' . PHP_EOL; +$q_reply_to->consume(function (AMQPEnvelope $message, AMQPQueue $queue) { + echo $message->getBody() . ': ' . $message->getRoutingKey() . PHP_EOL; + + echo 'Received on ', $queue->getName(), ' queue', PHP_EOL; + + return false; +}, AMQP_JUST_CONSUME); + +echo 'done', PHP_EOL; + + + +?> +--EXPECTF-- +Publishing request... +Reply-to queue: amq.rabbitmq.reply-to.%s.%s== +Prepare response queue... +Publishing response... +Waiting for reply... +response: amq.rabbitmq.reply-to.%s.%s== +Received on amq.rabbitmq.reply-to queue +done \ No newline at end of file diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/bug_gh50-1.phpt php-amqp-1.9.3/amqp-1.9.3/tests/bug_gh50-1.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/bug_gh50-1.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/bug_gh50-1.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,27 @@ +--TEST-- +Channel creation race condition (https://github.com/pdezwart/php-amqp/issues/50) (1) +--SKIPIF-- + +--FILE-- +connect(); + +for ($i = 0; $i < 3; $i++) { + + $channel = new AMQPChannel($connection); + var_dump($channel->getChannelId()); + + $queue = new AMQPQueue($channel); + $queue->setName('test' . $i); + + $queue->declareQueue(); + $queue->delete(); +} +?> +==DONE== +--EXPECT-- +int(1) +int(2) +int(1) +==DONE== diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/bug_gh50-2.phpt php-amqp-1.9.3/amqp-1.9.3/tests/bug_gh50-2.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/bug_gh50-2.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/bug_gh50-2.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,30 @@ +--TEST-- +Channel creation race condition (https://github.com/pdezwart/php-amqp/issues/50) (2) +--SKIPIF-- + +--FILE-- +connect(); + +for ($i = 0; $i < 3; $i++) { + + $channel = new AMQPChannel($connection); + var_dump($channel->getChannelId()); + + $queue = new AMQPQueue($channel); + $queue->setName('test' . $i); + + $queue->declareQueue(); + $queue->delete(); + + unset($queue); + unset($channel); +} +?> +==DONE== +--EXPECT-- +int(1) +int(1) +int(1) +==DONE== diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/bug_gh50-3.phpt php-amqp-1.9.3/amqp-1.9.3/tests/bug_gh50-3.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/bug_gh50-3.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/bug_gh50-3.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,47 @@ +--TEST-- +Channel creation race condition (https://github.com/pdezwart/php-amqp/issues/50) (3) +--SKIPIF-- + +--FILE-- +connect(); + +for ($i = 0; $i < 3; $i++) { + + $channel = new AMQPChannel($connection); + var_dump($channel->getChannelId()); + + $queue = new AMQPQueue($channel); + $queue->setName('test' . $i); + + $queue->declareQueue(); + $queue->delete(); +} + +$connection = new AMQPConnection(); +$connection->connect(); + +for ($i = 0; $i < 3; $i++) { + + $channel = new AMQPChannel($connection); + var_dump($channel->getChannelId()); + + $queue = new AMQPQueue($channel); + $queue->setName('test' . $i); + + $queue->declareQueue(); + $queue->delete(); +} + + +?> +==DONE== +--EXPECT-- +int(1) +int(2) +int(1) +int(1) +int(2) +int(1) +==DONE== diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/bug_gh50-4.phpt php-amqp-1.9.3/amqp-1.9.3/tests/bug_gh50-4.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/bug_gh50-4.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/bug_gh50-4.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,49 @@ +--TEST-- +Channel creation race condition (https://github.com/pdezwart/php-amqp/issues/50) (4) +--SKIPIF-- + +--FILE-- +connect(); + +$channels = array(); + +for ($i = 0; $i < 3; $i++) { + + $channel = $channels[] = new AMQPChannel($connection); + var_dump($channel->getChannelId()); + + $queue = new AMQPQueue($channel); + $queue->setName('test' . $i); + + $queue->declareQueue(); + $queue->delete(); +} + +$connection = new AMQPConnection(); +$connection->connect(); + +for ($i = 0; $i < 3; $i++) { + + $channel = $channels[] = new AMQPChannel($connection); + var_dump($channel->getChannelId()); + + $queue = new AMQPQueue($channel); + $queue->setName('test' . $i); + + $queue->declareQueue(); + $queue->delete(); +} + + +?> +==DONE== +--EXPECT-- +int(1) +int(2) +int(3) +int(1) +int(2) +int(3) +==DONE== diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/bug_gh53-2.phpt php-amqp-1.9.3/amqp-1.9.3/tests/bug_gh53-2.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/bug_gh53-2.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/bug_gh53-2.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,36 @@ +--TEST-- +Upgrade to RabbitMQ 3.1.0-1: AMQPConnectionException: connection closed unexpectedly (2) +--SKIPIF-- + +--FILE-- +connect(); + +$channel = new AMQPChannel($connection); + +$exchange = new AMQPExchange($channel); +$exchange->setName('exchange' . microtime(true)); +$exchange->setType(AMQP_EX_TYPE_TOPIC); +$exchange->declareExchange(); + +$queue = new AMQPQueue($channel); +$queue->setName('queue1' . microtime(true)); +$queue->declareQueue(); +$queue->bind($exchange->getName(), '#'); + +$exchange->publish('body1', 'routing.1'); +$exchange->publish('body2', 'routing.1'); + +$msg = $queue->get(AMQP_AUTOACK); +var_dump($msg->getBody()); + +$msg = $queue->get(AMQP_AUTOACK); +var_dump($msg->getBody()); + +?> +==DONE== +--EXPECT-- +string(5) "body1" +string(5) "body2" +==DONE== diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/bug_gh53.phpt php-amqp-1.9.3/amqp-1.9.3/tests/bug_gh53.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/bug_gh53.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/bug_gh53.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,40 @@ +--TEST-- +Upgrade to RabbitMQ 3.1.0-1: AMQPConnectionException: connection closed unexpectedly +--SKIPIF-- + +--FILE-- +connect(); + +$channel = new AMQPChannel($connection); +var_dump($channel->getPrefetchSize()); +var_dump($channel->getPrefetchCount()); + +$channel->setPrefetchCount(10); +var_dump($channel->getPrefetchSize()); +var_dump($channel->getPrefetchCount()); + +// NOTE: RabbitMQ Doesn't support prefetch size +try { + $channel->setPrefetchSize(1024); + +} catch (AMQPConnectionException $e) { + echo get_class($e), "({$e->getCode()}): ", $e->getMessage(), PHP_EOL; +} +var_dump($channel->isConnected()); +var_dump($connection->isConnected()); +var_dump($channel->getPrefetchSize()); +var_dump($channel->getPrefetchCount()); + +?> +--EXPECTF-- +int(0) +int(3) +int(0) +int(10) +AMQPConnectionException(540): Server connection error: 540, message: NOT_IMPLEMENTED - prefetch_size!=0 (%d) +bool(false) +bool(false) +int(0) +int(10) diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/bug_gh72-1.phpt php-amqp-1.9.3/amqp-1.9.3/tests/bug_gh72-1.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/bug_gh72-1.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/bug_gh72-1.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,18 @@ +--TEST-- +#72 Publishing to an exchange with an empty name is valid and should not throw an exception (1) +--SKIPIF-- + +--FILE-- +connect(); +$channel = new AMQPChannel($connection); + +$exchange = new AMQPExchange($channel); +$exchange->setName(''); + +$exchange->publish('msg', 'key'); +?> +==DONE== +--EXPECT-- +==DONE== diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/bug_gh72-2.phpt php-amqp-1.9.3/amqp-1.9.3/tests/bug_gh72-2.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/bug_gh72-2.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/bug_gh72-2.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,20 @@ +--TEST-- +#72 Publishing to an exchange with an empty name is valid and should not throw an exception (2) +--SKIPIF-- + +--FILE-- +connect(); +$channel = new AMQPChannel($connection); + +$exchange = new AMQPExchange($channel); + +try { + $exchange->setName(str_repeat('a', 256)); +} catch (AMQPExchangeException $e) { + echo get_class($e), "({$e->getCode()}): ", $e->getMessage(), PHP_EOL; +} +?> +--EXPECT-- +AMQPExchangeException(0): Invalid exchange name given, must be less than 255 characters long. diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/package-version.phpt php-amqp-1.9.3/amqp-1.9.3/tests/package-version.phpt --- php-amqp-1.7.1/amqp-1.9.3/tests/package-version.phpt 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/package-version.phpt 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,25 @@ +--TEST-- +Compare version in package.xml and module +--SKIPIF-- + +--FILE-- +version->release; + +$ext = new ReflectionExtension('amqp'); +$srcVersion = $ext->getVersion(); + +if (0 === strcmp($packageVersion, $srcVersion)) { + echo "package.xml matches phpinfo() output\n"; +} else { + printf("src version: %s, package.xml: %s\n", $srcVersion, $packageVersion); +} +if (0 === strcmp($packageVersion, $ext->getVersion())) { + echo "package.xml matches extension version\n"; +} else { + printf("ext version: %s, package.xml: %s\n", $ext->getVersion(), $packageVersion); +} +--EXPECT-- +package.xml matches phpinfo() output +package.xml matches extension version diff -Nru php-amqp-1.7.1/amqp-1.9.3/tests/_test_helpers.php.inc php-amqp-1.9.3/amqp-1.9.3/tests/_test_helpers.php.inc --- php-amqp-1.7.1/amqp-1.9.3/tests/_test_helpers.php.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-amqp-1.9.3/amqp-1.9.3/tests/_test_helpers.php.inc 2017-10-19 13:51:16.000000000 +0000 @@ -0,0 +1,71 @@ +$m()); + } +} + +function dump_message($msg) { + if (!$msg) { + var_dump($msg); + return false; + } + + echo get_class($msg), PHP_EOL; + echo " getBody:", PHP_EOL, " "; + var_dump($msg->getBody()); + echo " getContentType:", PHP_EOL, " "; + var_dump($msg->getContentType()); + echo " getRoutingKey:", PHP_EOL, " "; + var_dump($msg->getRoutingKey()); + echo " getConsumerTag:", PHP_EOL, " "; + var_dump($msg->getConsumerTag()); + echo " getDeliveryTag:", PHP_EOL, " "; + var_dump($msg->getDeliveryTag()); + echo " getDeliveryMode:", PHP_EOL, " "; + var_dump($msg->getDeliveryMode()); + echo " getExchangeName:", PHP_EOL, " "; + var_dump($msg->getExchangeName()); + echo " isRedelivery:", PHP_EOL, " "; + var_dump($msg->isRedelivery()); + echo " getContentEncoding:", PHP_EOL, " "; + var_dump($msg->getContentEncoding()); + echo " getType:", PHP_EOL, " "; + var_dump($msg->getType()); + echo " getTimeStamp:", PHP_EOL, " "; + var_dump($msg->getTimeStamp()); + echo " getPriority:", PHP_EOL, " "; + var_dump($msg->getPriority()); + echo " getExpiration:", PHP_EOL, " "; + var_dump($msg->getExpiration()); + echo " getUserId:", PHP_EOL, " "; + var_dump($msg->getUserId()); + echo " getAppId:", PHP_EOL, " "; + var_dump($msg->getAppId()); + echo " getMessageId:", PHP_EOL, " "; + var_dump($msg->getMessageId()); + echo " getReplyTo:", PHP_EOL, " "; + var_dump($msg->getReplyTo()); + echo " getCorrelationId:", PHP_EOL, " "; + var_dump($msg->getCorrelationId()); + echo " getHeaders:", PHP_EOL, " "; + var_dump($msg->getHeaders()); + + return false; +} + +function consumeThings($message, $queue) { + var_dump($message); + return false; +} diff -Nru php-amqp-1.7.1/debian/changelog php-amqp-1.9.3/debian/changelog --- php-amqp-1.7.1/debian/changelog 2018-02-02 03:49:14.000000000 +0000 +++ php-amqp-1.9.3/debian/changelog 2018-08-19 12:02:58.000000000 +0000 @@ -1,14 +1,28 @@ -php-amqp (1.7.1-1build2) bionic; urgency=medium +php-amqp (1.9.3-2) unstable; urgency=medium - * No-change rebuild for PHP7.2. + * Update Vcs-* to salsa.d.o + * Update maintainer email to team+php-pecl@tracker.debian.org + (Closes: #899635) - -- Nishanth Aravamudan Thu, 01 Feb 2018 19:49:14 -0800 + -- Ondřej Surý Sun, 19 Aug 2018 12:02:58 +0000 -php-amqp (1.7.1-1build1) artful; urgency=medium +php-amqp (1.9.3-1) unstable; urgency=medium - * No-change rebuild for PHP7.1. + * New upstream version 1.9.3 - -- Nishanth Aravamudan Fri, 28 Apr 2017 15:51:08 -0700 + -- Ondřej Surý Tue, 05 Dec 2017 13:22:12 +0000 + +php-amqp (1.9.1-1) unstable; urgency=medium + + * New upstream version 1.9.1 + + -- Ondřej Surý Tue, 27 Jun 2017 09:30:05 +0200 + +php-amqp (1.9.0-1) unstable; urgency=medium + + * New upstream version 1.9.0 + + -- Ondřej Surý Tue, 30 May 2017 10:13:09 +0200 php-amqp (1.7.1-1) unstable; urgency=medium diff -Nru php-amqp-1.7.1/debian/control php-amqp-1.9.3/debian/control --- php-amqp-1.7.1/debian/control 2016-12-05 10:27:57.000000000 +0000 +++ php-amqp-1.9.3/debian/control 2018-08-19 12:02:58.000000000 +0000 @@ -1,7 +1,7 @@ Source: php-amqp Section: php Priority: optional -Maintainer: Debian PHP PECL Maintainers +Maintainer: Debian PHP PECL Maintainers Uploaders: Ondřej Surý , Prach Pongpanich Build-Depends: debhelper (>= 9), @@ -9,8 +9,8 @@ librabbitmq-dev (>= 0.7.0), php-all-dev Standards-Version: 3.9.8 -Vcs-Browser: http://anonscm.debian.org/gitweb/?p=pkg-php/php-amqp.git -Vcs-Git: git://anonscm.debian.org/pkg-php/php-amqp.git +Vcs-Browser: https://salsa.debian.org/php-team/pecl/php-amqp +Vcs-Git: https://salsa.debian.org/php-team/pecl/php-amqp.git Homepage: http://pecl.php.net/package/amqp Package: php-amqp diff -Nru php-amqp-1.7.1/package.xml php-amqp-1.9.3/package.xml --- php-amqp-1.7.1/package.xml 2016-07-09 14:58:52.000000000 +0000 +++ php-amqp-1.9.3/package.xml 2017-10-19 13:51:16.000000000 +0000 @@ -16,11 +16,17 @@ pdezwart@php.net no - 2016-07-09 - + + Bogdan Padalko + pinepain + pinepain@gmail.com + yes + + 2017-10-19 + - 1.7.1 - 1.0.0 + 1.9.3 + 1.3.0 stable @@ -28,55 +34,61 @@ PHP License -* Add support for pkg-config (Remi Collet) -* Fixed wrongful truncation of amqp.password to the length of amqp.login (https://github.com/skobkars) +* Fix handling channel consumers (#284) (Bogdan Padalko) +* Add support for consumer tags (#282) (Bogdan Padalko) For a complete list of changes see: -https://github.com/pdezwart/php-amqp/compare/v1.7.0...v1.7.1 +https://github.com/pdezwart/php-amqp/compare/v1.9.1...v1.9.3 - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + @@ -84,16 +96,16 @@ - + - - - + + + - + @@ -115,12 +127,15 @@ - - - - - - + + + + + + + + + @@ -128,76 +143,104 @@ - - - - + + + + + - + + + - + + + + - + - + - - + + + + - + - - + + - - + + - - + + - + - + - + + + + - + - + - + + - - + + - + - + - + + + + + + + + + + + + + + + + + @@ -217,6 +260,141 @@ + 1.9.1 + 1.3.0 + + + stable + stable + + PHP License + +* Separate queue and exchange args to prevent segfault with opcache enabled (Bogdan Padalko) + + For a complete list of changes see: + https://github.com/pdezwart/php-amqp/compare/v1.9.0...v1.9.1 + + + + + 1.9.0 + 1.3.0 + + + stable + stable + + PHP License + +* AMQP types are now better supported through value objects (see #271, #269, #265) (Bogdan Padalko, Lars Strojny) + +For a complete list of changes see: +https://github.com/pdezwart/php-amqp/compare/v1.8.0...v1.9.0 + + + + + 1.9.0beta2 + 1.3.0 + + + beta + stable + + PHP License + +* AMQP types are now better supported through value objects (see #271, #269, #265) (Bogdan Padalko, Lars Strojny) + +For a complete list of changes see: +https://github.com/pdezwart/php-amqp/compare/v1.8.0...v1.9.0beta2 + + + + + 1.9.0beta1 + 1.3.0 + + + stable + stable + + PHP License + +* AMQP types are now better supported through value objects (see #271, #269, #265) (Bogdan Padalko, Lars Strojny) + + For a complete list of changes see: + https://github.com/pdezwart/php-amqp/compare/v1.8.0...v1.9.0beta1 + + + + + 1.8.0 + 1.2.0 + + + stable + stable + + PHP License + +* Add SSL connection support (Bogdan Padalko) +* Support for server method handling: confirms (publisher acknowledgments) and basic.return (Bogdan Padalko) +* Add support for pkg-config (Remi Collet) +* Preserve AMQP server error code for exceptions (Bogdan Padalko) +* Add AMQPChannel::close() (Bogdan Padalko) +* Fix segfault when deleting an unknown exchange (Bogdan Padalko) +* Fix segfault with PHPUnit and xdebug for PHP 7 (Bogdan Padalko) +* Add publisher confirms (Bogdan Padalko) + + For a complete list of changes see: + https://github.com/pdezwart/php-amqp/compare/v1.7.1...v1.8.0 + + + + + 1.8.0beta2 + 1.2.0 + + + beta + stable + + PHP License + +* Add SSL connection support (Bogdan Padalko) +* Support for server method handling: confirms (publisher acknowledgments) and basic.return (Bogdan Padalko) +* Add support for pkg-config (Remi Collet) +* Preserve AMQP server error code for exceptions (Bogdan Padalko) +* Add AMQPChannel::close() (Bogdan Padalko) +* Fix segfault when deleting an unknown exchange (Bogdan Padalko) +* Fix segfault with PHPUnit and xdebug for PHP 7 (Bogdan Padalko) +* Add publisher confirms (Bogdan Padalko) +* Fix 1.8.0 release (Lars Strojny) + + For a complete list of changes see: + https://github.com/pdezwart/php-amqp/compare/v1.7.1...v1.8.0beta2 + + + + + 1.7.1 + 1.0.0 + + + stable + stable + + PHP License + +* Add support for pkg-config (Remi Collet) +* Fixed wrongful truncation of amqp.password to the length of amqp.login (https://github.com/skobkars) + +For a complete list of changes see: +https://github.com/pdezwart/php-amqp/compare/v1.7.0...v1.7.1 + + + + 1.7.0 1.0.0