diff --git a/Zend/zend_portability.h b/Zend/zend_portability.h index 6801131e41da..cd26aa174712 100644 --- a/Zend/zend_portability.h +++ b/Zend/zend_portability.h @@ -314,15 +314,14 @@ char *alloca(); #if (defined(__GNUC__) && ZEND_GCC_VERSION >= 4003) || __has_attribute(cold) # define ZEND_COLD __attribute__((cold)) -# ifdef __OPTIMIZE__ -# define ZEND_OPT_SIZE __attribute__((optimize("Os"))) -# define ZEND_OPT_SPEED __attribute__((optimize("Ofast"))) -# else -# define ZEND_OPT_SIZE -# define ZEND_OPT_SPEED -# endif #else # define ZEND_COLD +#endif + +#if ((defined(__GNUC__) && ZEND_GCC_VERSION >= 4003) || __has_attribute(optimize)) && defined(__OPTIMIZE__) +# define ZEND_OPT_SIZE __attribute__((optimize("Os"))) +# define ZEND_OPT_SPEED __attribute__((optimize("Ofast"))) +#else # define ZEND_OPT_SIZE # define ZEND_OPT_SPEED #endif diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c index ccb1da6af738..c667712f85fe 100644 --- a/ext/mysqli/mysqli_api.c +++ b/ext/mysqli/mysqli_api.c @@ -1488,6 +1488,15 @@ PHP_FUNCTION(mysqli_stmt_data_seek) MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID); + if (!stmt->stmt->data || !stmt->stmt->data->result || !stmt->stmt->data->result->stored_data) { + if (hasThis()) { + zend_throw_error(NULL, "mysqli_stmt::data_seek(): No result set associated with the statement"); + } else { + zend_throw_error(NULL, "mysqli_stmt_data_seek(): No result set associated with the statement"); + } + RETURN_THROWS(); + } + mysql_stmt_data_seek(stmt->stmt, offset); } /* }}} */ diff --git a/ext/mysqli/tests/mysqli_stmt_data_seek.phpt b/ext/mysqli/tests/mysqli_stmt_data_seek.phpt index a36daebc7951..e4b913229cd0 100644 --- a/ext/mysqli/tests/mysqli_stmt_data_seek.phpt +++ b/ext/mysqli/tests/mysqli_stmt_data_seek.phpt @@ -25,6 +25,11 @@ require_once 'skipifconnectfailure.inc'; if (true !== ($tmp = mysqli_stmt_execute($stmt))) printf("[006] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); + try { + mysqli_stmt_data_seek($stmt, 1); + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; + } $id = null; if (!mysqli_stmt_bind_result($stmt, $id)) @@ -82,6 +87,7 @@ require_once 'skipifconnectfailure.inc'; ?> --EXPECT-- mysqli_stmt object is not fully initialized +mysqli_stmt_data_seek(): No result set associated with the statement int(3) int(1) int(1) diff --git a/ext/phar/phar.c b/ext/phar/phar.c index 5829d32e615e..4855517dd627 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -192,7 +192,7 @@ PHP_INI_END() */ void phar_destroy_phar_data(phar_archive_data *phar) /* {{{ */ { - if (phar->alias && phar->alias != phar->fname) { + if (phar->alias) { pefree(phar->alias, phar->is_persistent); phar->alias = NULL; } diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index 377f35832910..2e309d9a9831 100644 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -2631,7 +2631,7 @@ PHP_METHOD(Phar, getAlias) PHAR_ARCHIVE_OBJECT(); - if (phar_obj->archive->alias && phar_obj->archive->alias != phar_obj->archive->fname) { + if (phar_obj->archive->alias) { RETURN_STRINGL(phar_obj->archive->alias, phar_obj->archive->alias_len); } }