Skip to content
This repository was archived by the owner on Sep 28, 2022. It is now read-only.

Commit eb076d7

Browse files
authoredDec 14, 2020
Compatibility with php8 (#49)
Thank you!
1 parent ab616db commit eb076d7

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed
 

‎swoole_postgresql_coro.cc

+21-22
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ static void swoole_pgsql_coro_onTimeout(Timer *timer, TimerNode *tnode) {
413413
PQfinish(pgsql);
414414
}
415415

416-
zend_update_property_string(swoole_postgresql_coro_ce, zobject, "error", 5, "ontimeout");
416+
zend_update_property_string(swoole_postgresql_coro_ce, SW_Z8_OBJ_P(zobject), "error", 5, "ontimeout");
417417
PHPCoroutine::resume_m(ctx, result);
418418
zval_ptr_dtor(result);
419419
}
@@ -442,7 +442,7 @@ static void connect_callback(pg_object *object, Reactor *reactor, Event *event)
442442
case PGRES_POLLING_FAILED:
443443
events = 0;
444444
err_msg = PQerrorMessage(conn);
445-
zend_update_property_string(swoole_postgresql_coro_ce, object->object, ZEND_STRL("error"), err_msg);
445+
zend_update_property_string(swoole_postgresql_coro_ce, SW_Z8_OBJ_P(object->object), ZEND_STRL("error"), err_msg);
446446
break;
447447
default:
448448
swWarn("PQconnectPoll unexpected status");
@@ -466,7 +466,7 @@ static void connect_callback(pg_object *object, Reactor *reactor, Event *event)
466466
ZVAL_BOOL(&return_value, object->connected);
467467

468468
if (object->connected == 1) {
469-
zend_update_property_null(swoole_postgresql_coro_ce, object->object, ZEND_STRL("error"));
469+
zend_update_property_null(swoole_postgresql_coro_ce, SW_Z8_OBJ_P(object->object), ZEND_STRL("error"));
470470
}
471471
PHPCoroutine::resume_m(context, &return_value);
472472
}
@@ -555,8 +555,8 @@ static int meta_data_result_parse(pg_object *object) {
555555
add_assoc_zval(&return_value, name, &elem);
556556
}
557557
FutureTask *context = php_swoole_postgresql_coro_get_context(object->object);
558-
zend_update_property_null(swoole_postgresql_coro_ce, object->object, ZEND_STRL("error"));
559-
zend_update_property_null(swoole_postgresql_coro_ce, object->object, ZEND_STRL("resultDiag"));
558+
zend_update_property_null(swoole_postgresql_coro_ce, SW_Z8_OBJ_P(object->object), ZEND_STRL("error"));
559+
zend_update_property_null(swoole_postgresql_coro_ce, SW_Z8_OBJ_P(object->object), ZEND_STRL("resultDiag"));
560560
PHPCoroutine::resume_m(context, &return_value);
561561
swoole_event_del(object->socket);
562562
zval_ptr_dtor(&return_value);
@@ -620,7 +620,7 @@ static void set_error_diag(const pg_object *object, const PGresult *pgsql_result
620620
}
621621
}
622622

623-
zend_update_property(swoole_postgresql_coro_ce, object->object, ZEND_STRL("resultDiag"), &result_diag);
623+
zend_update_property(swoole_postgresql_coro_ce, SW_Z8_OBJ_P(object->object), ZEND_STRL("resultDiag"), &result_diag);
624624
zval_dtor(&result_diag);
625625
}
626626

@@ -637,7 +637,7 @@ static int query_result_parse(pg_object *object) {
637637
pgsql_result = PQgetResult(object->conn);
638638
status = PQresultStatus(pgsql_result);
639639

640-
zend_update_property_long(swoole_postgresql_coro_ce, object->object, ZEND_STRL("resultStatus"), status);
640+
zend_update_property_long(swoole_postgresql_coro_ce, SW_Z8_OBJ_P(object->object), ZEND_STRL("resultStatus"), status);
641641

642642
switch (status)
643643
{
@@ -650,7 +650,7 @@ static int query_result_parse(pg_object *object) {
650650
PQclear(pgsql_result);
651651
ZVAL_FALSE(&return_value);
652652
swoole_event_del(object->socket);
653-
zend_update_property_string(swoole_postgresql_coro_ce, object->object, ZEND_STRL("error"), err_msg);
653+
zend_update_property_string(swoole_postgresql_coro_ce, SW_Z8_OBJ_P(object->object), ZEND_STRL("error"), err_msg);
654654
PHPCoroutine::resume_m(context, &return_value);
655655
break;
656656
case PGRES_COMMAND_OK: /* successful command that did not return rows */
@@ -661,8 +661,8 @@ static int query_result_parse(pg_object *object) {
661661
res = PQflush(object->conn);
662662
swoole_event_del(object->socket);
663663
ZVAL_RES(&return_value, zend_register_resource(pgsql_result, le_result));
664-
zend_update_property_null(swoole_postgresql_coro_ce, object->object, ZEND_STRL("error"));
665-
zend_update_property_null(swoole_postgresql_coro_ce, object->object, ZEND_STRL("resultDiag"));
664+
zend_update_property_null(swoole_postgresql_coro_ce, SW_Z8_OBJ_P(object->object), ZEND_STRL("error"));
665+
zend_update_property_null(swoole_postgresql_coro_ce, SW_Z8_OBJ_P(object->object), ZEND_STRL("resultDiag"));
666666
PHPCoroutine::resume_m(context, &return_value);
667667
if (error != 0) {
668668
php_swoole_fatal_error(E_WARNING, "socket error. Error: %s [%d]", strerror(error), error);
@@ -688,7 +688,7 @@ static int prepare_result_parse(pg_object *object) {
688688
pgsql_result = PQgetResult(object->conn);
689689
status = PQresultStatus(pgsql_result);
690690

691-
zend_update_property_long(swoole_postgresql_coro_ce, object->object, ZEND_STRL("resultStatus"), status);
691+
zend_update_property_long(swoole_postgresql_coro_ce, SW_Z8_OBJ_P(object->object), ZEND_STRL("resultStatus"), status);
692692

693693
switch (status)
694694
{
@@ -701,7 +701,7 @@ static int prepare_result_parse(pg_object *object) {
701701
PQclear(pgsql_result);
702702
ZVAL_FALSE(&return_value);
703703
swoole_event_del(object->socket);
704-
zend_update_property_string(swoole_postgresql_coro_ce, object->object, ZEND_STRL("error"), err_msg);
704+
zend_update_property_string(swoole_postgresql_coro_ce, SW_Z8_OBJ_P(object->object), ZEND_STRL("error"), err_msg);
705705
PHPCoroutine::resume_m(context, &return_value);
706706
if (error != 0) {
707707
php_swoole_fatal_error(E_WARNING, "socket error. Error: %s [%d]", strerror(error), error);
@@ -713,8 +713,8 @@ static int prepare_result_parse(pg_object *object) {
713713
PQclear(pgsql_result);
714714
swoole_event_del(object->socket);
715715
ZVAL_TRUE(&return_value);
716-
zend_update_property_null(swoole_postgresql_coro_ce, object->object, ZEND_STRL("error"));
717-
zend_update_property_null(swoole_postgresql_coro_ce, object->object, ZEND_STRL("resultDiag"));
716+
zend_update_property_null(swoole_postgresql_coro_ce, SW_Z8_OBJ_P(object->object), ZEND_STRL("error"));
717+
zend_update_property_null(swoole_postgresql_coro_ce, SW_Z8_OBJ_P(object->object), ZEND_STRL("resultDiag"));
718718
PHPCoroutine::resume_m(context, &return_value);
719719
if (error != 0) {
720720
php_swoole_fatal_error(E_WARNING, "socket error. Error: %s [%d]", strerror(error), error);
@@ -724,7 +724,7 @@ static int prepare_result_parse(pg_object *object) {
724724
PQclear(pgsql_result);
725725
swoole_event_del(object->socket);
726726
ZVAL_FALSE(&return_value);
727-
zend_update_property_string(swoole_postgresql_coro_ce, object->object, ZEND_STRL("error"), "Bad result returned to prepare");
727+
zend_update_property_string(swoole_postgresql_coro_ce, SW_Z8_OBJ_P(object->object), ZEND_STRL("error"), "Bad result returned to prepare");
728728
PHPCoroutine::resume_m(context, &return_value);
729729
if (error != 0) {
730730
php_swoole_fatal_error(E_WARNING, "socket error. Error: %s [%d]", strerror(error), error);
@@ -757,7 +757,7 @@ static PHP_METHOD(swoole_postgresql_coro, query) {
757757
int ret = PQsendQuery(pgsql, Z_STRVAL_P(query));
758758
if (ret == 0) {
759759
char *err_msg = PQerrorMessage(pgsql);
760-
zend_update_property_string(swoole_postgresql_coro_ce, ZEND_THIS, ZEND_STRL("error"), err_msg);
760+
zend_update_property_string(swoole_postgresql_coro_ce, SW_Z8_OBJ_P(ZEND_THIS), ZEND_STRL("error"), err_msg);
761761
RETURN_FALSE;
762762
}
763763

@@ -1300,7 +1300,6 @@ static void php_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, zend_long result_
13001300
fci.retval = &retval;
13011301
fci.params = NULL;
13021302
fci.param_count = 0;
1303-
fci.no_separation = 1;
13041303

13051304
if (ctor_params && Z_TYPE_P(ctor_params) != IS_NULL) {
13061305
if (zend_fcall_info_args(&fci, ctor_params) == FAILURE) {
@@ -1395,7 +1394,7 @@ static int swoole_pgsql_coro_onError(swReactor *reactor, swEvent *event) {
13951394
ZVAL_FALSE(result);
13961395

13971396
FutureTask *context = php_swoole_postgresql_coro_get_context(zobject);
1398-
zend_update_property_string(swoole_postgresql_coro_ce, zobject, "error", 5, "onerror");
1397+
zend_update_property_string(swoole_postgresql_coro_ce, SW_Z8_OBJ_P(zobject), "error", 5, "onerror");
13991398
PHPCoroutine::resume_m(context, result);
14001399
zval_ptr_dtor(result);
14011400

@@ -1460,8 +1459,8 @@ static PHP_METHOD(swoole_postgresql_coro, escape) {
14601459
size_t new_len = PQescapeStringConn(object->conn, result->val, str, l_str, &error);
14611460

14621461
if (new_len == 0 || error) {
1463-
zend_update_property_string(swoole_postgresql_coro_ce, ZEND_THIS, ZEND_STRL("error"), PQerrorMessage(pgsql));
1464-
zend_update_property_long(swoole_postgresql_coro_ce, ZEND_THIS, ZEND_STRL("errCode"), error);
1462+
zend_update_property_string(swoole_postgresql_coro_ce, SW_Z8_OBJ_P(ZEND_THIS), ZEND_STRL("error"), PQerrorMessage(pgsql));
1463+
zend_update_property_long(swoole_postgresql_coro_ce, SW_Z8_OBJ_P(ZEND_THIS), ZEND_STRL("errCode"), error);
14651464
zend_string_free(result);
14661465
RETURN_FALSE;
14671466
} else {
@@ -1485,7 +1484,7 @@ static PHP_METHOD(swoole_postgresql_coro, escapeLiteral) {
14851484

14861485
tmp = PQescapeLiteral(pgsql, str, l_str);
14871486
if (tmp == nullptr) {
1488-
zend_update_property_string(swoole_postgresql_coro_ce, ZEND_THIS, ZEND_STRL("error"), PQerrorMessage(pgsql));
1487+
zend_update_property_string(swoole_postgresql_coro_ce, SW_Z8_OBJ_P(ZEND_THIS), ZEND_STRL("error"), PQerrorMessage(pgsql));
14891488

14901489
RETURN_FALSE;
14911490
}
@@ -1508,7 +1507,7 @@ static PHP_METHOD(swoole_postgresql_coro, escapeIdentifier) {
15081507

15091508
tmp = PQescapeIdentifier(pgsql, str, l_str);
15101509
if (tmp == nullptr) {
1511-
zend_update_property_string(swoole_postgresql_coro_ce, ZEND_THIS, ZEND_STRL("error"), PQerrorMessage(pgsql));
1510+
zend_update_property_string(swoole_postgresql_coro_ce, SW_Z8_OBJ_P(ZEND_THIS), ZEND_STRL("error"), PQerrorMessage(pgsql));
15121511

15131512
RETURN_FALSE;
15141513
}

0 commit comments

Comments
 (0)
This repository has been archived.