Msphpsql: PHP 7.4 support

Created on 5 Jun 2019  路  25Comments  路  Source: microsoft/msphpsql

For now, build fails

/dev/shm/BUILD/php74-php-sqlsrv-5.6.1/NTS/sqlsrv/shared/core_sqlsrv.h: In function 'void core::sqlsrv_add_index_zval(sqlsrv_context&, zval*, zend_ulong, zval*)':
/opt/remi/php74/root/usr/include/php/Zend/zend_API.h:421:2: error: expected id-expression before '(' token
  (zend_hash_index_update(Z_ARRVAL_P(arg), index, value) ? SUCCESS : FAILURE)
  ^
/dev/shm/BUILD/php74-php-sqlsrv-5.6.1/NTS/sqlsrv/shared/core_sqlsrv.h:2405:20: note: in expansion of macro 'add_index_zval'
         int zr = ::add_index_zval( array, index, value );
                    ^~~~~~~~~~~~~~
/dev/shm/BUILD/php74-php-sqlsrv-5.6.1/NTS/sqlsrv/shared/core_sqlsrv.h: In function 'void core::sqlsrv_add_next_index_zval(sqlsrv_context&, zval*, zval*)':
/opt/remi/php74/root/usr/include/php/Zend/zend_API.h:433:2: error: expected id-expression before '(' token
  (zend_hash_next_index_insert(Z_ARRVAL_P(arg), value) ? SUCCESS : FAILURE)
  ^
/dev/shm/BUILD/php74-php-sqlsrv-5.6.1/NTS/sqlsrv/shared/core_sqlsrv.h:2413:20: note: in expansion of macro 'add_next_index_zval'
         int zr = ::add_next_index_zval( array, value );
                    ^~~~~~~~~~~~~~~~~~~

Most helpful comment

Looks like somethin like this fixes the compilation error:

diff --git a/source/shared/core_stream.cpp b/source/shared/core_stream.cpp
index 7d0e1be..6d3453b 100644
--- a/source/shared/core_stream.cpp
+++ b/source/shared/core_stream.cpp
@@ -44,7 +44,11 @@ int sqlsrv_stream_close( _Inout_ php_stream* stream, int /*close_handle*/ TSRMLS
 // read from a sqlsrv stream into the buffer provided by Zend.  The parameters for binary vs. char are
 // set when sqlsrv_get_field is called by the user specifying which field type they want.

+#if PHP_VERSION_ID >= 70400
+ssize_t sqlsrv_stream_read( _Inout_ php_stream* stream, _Out_writes_bytes_(count) char* buf, _Inout_ size_t count TSRMLS_DC )
+#else
 size_t sqlsrv_stream_read( _Inout_ php_stream* stream, _Out_writes_bytes_(count) char* buf, _Inout_ size_t count TSRMLS_DC )
+#endif
 {
    SQLLEN read = 0;
     SQLSMALLINT c_type = SQL_C_CHAR;

All 25 comments

add_next_index_zval has been replaced by a macro. That doesn't seem to be mentioned in UPGRADING.INTERNALS, though.

Thanks @remicollet and @cmb69
We will investigate and get back to you.

This issue might get resolved on the PHP side, see php/php-src#4250.

Thanks @cmb69 for the reference! We will keep an eye on this.

FYI, I confirm than 5.6.1 build without error against 7.4.0-dev (so with upcoming alpha2)

For memory, if someone need to build against alpha1, here is a small workaround
https://git.remirepo.net/cgit/rpms/php/php-sqlsrv.git/plain/shared.patch

Cool! Thanks @remicollet and @cmb69 !

Hi guys ! @remicollet, @cmb69 and @yitam
Do you guys have a 64bits windows dll for PHP 7.4?

Thanks in advance !

The PHP for Windows team is planning to provide PECL DLLs for PHP 7.4 starting around beta1.

Thanks @cmb69 for the heads up.

Hi @celsowm if you're asking about the php drivers for SQL Server, we will test if v5.6.1 supports PHP 7.4 beta versions. If not, we tentatively plan to release a preview that will be compatible.

The PHP for Windows team is planning to provide PECL DLLs for PHP 7.4 starting around beta1.

Alas. It fails in 7.4-beta1 now:

ext\sqlsrv\shared\core_stream.cpp(201): error C2078: too many initializers
ext\sqlsrv\shared\core_stream.cpp(201): error C2440: 'initializing': cannot convert from 'size_t (__cdecl *(php_stream *,char *,size_t)' to 'SSIZE_T (__cdecl *)(php_stream *,char *,size_t)'

This was after replacing some instances of 'uint' by 'unsigned long' in the 5.6.1 release, but in git head the error is the same.

The error was introduced in 7.4-beta1. 7.4-alpha3 still compiled OK. I do not know what caused the error.
@cmb69 Is it documented in UPGRADING.INTERNALS?

Could it be this change https://github.com/php/php-src/commit/845d07b3431e1e5901f609120360bf907fc7c08f#diff-2e4b71f255095863524bb18e8e26b815 ?
Then @nikic documented it yesterday.

@nikic I had just noticed that too

Thanks @Jan-E and @nikic for the info. As mentioned above we tentatively plan to release a preview that supports PHP 7.4 beta or RC.

Hi guys ! @remicollet, @cmb69 and @yitam
Do you guys have a 64bits windows dll for PHP 7.4?

You could try the ones in the Alpha3 zips here:
https://www.apachelounge.com/viewtopic.php?t=6617

Looks like somethin like this fixes the compilation error:

diff --git a/source/shared/core_stream.cpp b/source/shared/core_stream.cpp
index 7d0e1be..6d3453b 100644
--- a/source/shared/core_stream.cpp
+++ b/source/shared/core_stream.cpp
@@ -44,7 +44,11 @@ int sqlsrv_stream_close( _Inout_ php_stream* stream, int /*close_handle*/ TSRMLS
 // read from a sqlsrv stream into the buffer provided by Zend.  The parameters for binary vs. char are
 // set when sqlsrv_get_field is called by the user specifying which field type they want.

+#if PHP_VERSION_ID >= 70400
+ssize_t sqlsrv_stream_read( _Inout_ php_stream* stream, _Out_writes_bytes_(count) char* buf, _Inout_ size_t count TSRMLS_DC )
+#else
 size_t sqlsrv_stream_read( _Inout_ php_stream* stream, _Out_writes_bytes_(count) char* buf, _Inout_ size_t count TSRMLS_DC )
+#endif
 {
    SQLLEN read = 0;
     SQLSMALLINT c_type = SQL_C_CHAR;

Thanks again @Jan-E

I only fixed the compilation error. Testing etc is up to you.

Of course, @Jan-E :-)

Yet it's unlikely we will release a preview just to fix this compilation issue. The preview will include new feature(s) as well. Thanks!

see pr #1013

Closing this issue as 5.7.0 preview is already released.

@yitam That's great! When is 5.7.0 scheduled to be release? This is the only thing keeping us from migrating to PHP 7.4. Thanks!

@iluuu1994 it depends on ODBC driver. We will likely release shortly afterwards, ETA as indicated here

@yitam I see. Thank you for your response!

Was this page helpful?
0 / 5 - 0 ratings