PHP 7.2 + mysql_ext compile Error



  • Hallo die Runde,
    ich weiß dass das was ich hier Nachfrage gegen alle Regeln der Vernunft geht, und ja ich weiß dass es Gründe gibt wieso die alte mysql_ext aus dem PHP SRC gelöscht wurde - aber da ich leider auf einem riesengroßen, extrem alten PHP Monolithen sitze bleibt im Moment keine andere Lösung ... daher bitte keine Diskussion über die Sinnhaftigkeit meiner Frage ... 😉

    Also - versuche die alte mysql_ext für PHP unter PHP 7.2 zu kompilieren ... konnte alle Fehler bis auf 2 auch bereinigen ... aber an diesen beiße ich mir leider gerade die Zähne aus ...

    /dl/mysql/php_mysql.c: In function 'zif_mysql_list_fields':
    /dl/mysql/php_mysql.c:1760:19: warning: assignment makes pointer from integer without a cast [enabled by default]
      if ((mysql_result=mysql_list_fields(mysql->conn, table, NULL))==NULL) {
    Code:
          if ((mysql_result=mysql_list_fields(mysql->conn, table, NULL))==NULL) {
                    php_error_docref(NULL, E_WARNING, "Unable to save MySQL query result");
                    RETURN_FALSE;
            }
    
    /dl/mysql/php_mysql.c: In function 'zif_mysql_fetch_lengths':
        /dl/mysql/php_mysql.c:2372:14: warning: assignment discards 'const' qualifier from pointer target type [enabled by default]
          if ((lengths=mysql_fetch_lengths(mysql_result))==NULL) {
        Code: 
                if ((lengths=mysql_fetch_lengths(mysql_result))==NULL) {               
                        RETURN_FALSE;
                }
    

    Source: https://github.com/php/php-src/tree/PRE_PHP7_EREG_MYSQL_REMOVALS/ext/mysql

    Mein Patchfile um es mit PHP 7.0/7.1/7.2 compile-fähig zu machen:

    --- php_mysql.c.orig    2018-02-02 12:42:13.419067600 +0100
    +++ php_mysql.c 2018-02-05 14:30:46.165067600 +0100
    @@ -767,7 +767,7 @@
                    MySG(default_port) = MYSQL_PORT;
     #endif
            }
    -
    +#if PHP_VERSION_ID < 70200
            if (PG(sql_safe_mode)) {
                    if (ZEND_NUM_ARGS()>0) {
                            php_error_docref(NULL, E_NOTICE, "SQL safe mode in effect - ignoring host/user/password information");
    @@ -777,6 +777,7 @@
                    snprintf(ZSTR_VAL(hashed_details), ZSTR_LEN(hashed_details) + 1, "mysql__%s_", user);
                    client_flags = CLIENT_INTERACTIVE;
            } else {
    +#endif
                    /* mysql_pconnect does not support new_link parameter */
                    if (persistent) {
                            if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!s!s!l", &host_and_port, &host_len,
    @@ -821,8 +822,9 @@
                    hashed_details = zend_string_alloc(sizeof("mysql____") + (host_and_port? strlen(host_and_port) : 0)
                                    + (user? strlen(user) : 0) + (passwd? strlen(passwd) : 0) + MAX_LENGTH_OF_LONG - 1, 0);
                    ZSTR_LEN(hashed_details) = snprintf(ZSTR_VAL(hashed_details), ZSTR_LEN(hashed_details) + 1, "mysql_%s_%s_%s_" ZEND_LONG_FMT, SAFE_STRING(host_and_port), SAFE_STRING(user), SAFE_STRING(passwd), client_flags);
    +#if PHP_VERSION_ID < 70200
            }
    -
    +#endif
            /* We cannot use mysql_port anymore in windows, need to use
             * mysql_real_connect() to set the port.
             */
    @@ -1756,11 +1758,12 @@
            }
    
            PHPMY_UNBUFFERED_QUERY_CHECK();
    -
    +#if PHP_VERSION_ID < 70100
            if ((mysql_result=mysql_list_fields(mysql->conn, table, NULL))==NULL) {
                    php_error_docref(NULL, E_WARNING, "Unable to save MySQL query result");
                    RETURN_FALSE;
            }
    +#endif
            MySG(result_allocated)++;
            ZVAL_RES(return_value, zend_register_resource(mysql_result, le_result));
     }
    @@ -2238,9 +2241,13 @@
    
                    if (ce->constructor) {
                            fci.size = sizeof(fci);
    +#if PHP_VERSION_ID < 70100
                            fci.function_table = &ce->function_table;
    +#endif
                            ZVAL_UNDEF(&fci.function_name);
    +#if PHP_VERSION_ID < 70100
                            fci.symbol_table = NULL;
    +#endif
                            fci.object = Z_OBJ_P(return_value);
                            fci.retval = &retval;
                            fci.params = NULL;
    @@ -2262,7 +2269,9 @@
    
                            fcc.initialized = 1;
                            fcc.function_handler = ce->constructor;
    +#if PHP_VERSION_ID < 70100
                            fcc.calling_scope = EG(scope);
    +#endif
                            fcc.called_scope = Z_OBJCE_P(return_value);
                            fcc.object = Z_OBJ_P(return_value);
    
    @@ -2362,10 +2371,11 @@
            if ((mysql_result = (MYSQL_RES *)zend_fetch_resource(Z_RES_P(result), "MySQL result", le_result)) == NULL) {
                    RETURN_FALSE;
            }
    -
    +#if PHP_VERSION_ID < 70100
            if ((lengths=mysql_fetch_lengths(mysql_result))==NULL) {
                    RETURN_FALSE;
            }
    +#endif
            array_init(return_value);
            num_fields = mysql_num_fields(mysql_result)
    

    Unter PHP 7.0 100% funktionalität - alles läuft
    Unter PHP 7.1/7.2 natürlich Probleme mit mysql_list_fields & mysql_fetch_lengths da ich nen Teil auskommentieren musste um die compile Warnings los zu werden ...

    Nun die Frage ob mir hier vielleicht irgendjemand nen Tipp geben kann wie ich die 2 compile Errors los bekommen könnte?

    Hoffe es findet sich jemand der mir hier weiterhelfen kann, vielen Dank, lg
    Andreas



  • Das ist C.

    Ich würde sagen, dass mysql_list_fields ein int liefert, mysql_result aber ein Pointer ist. Da passt was nicht zusammen.


Anmelden zum Antworten