Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Php 225 #146

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Dockerfile
docker-compose.yml
58 changes: 58 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
FROM debian:buster-slim AS cassandra_cpp_driver

# Datastax/Cassandra CPP Driver
WORKDIR /tmp

RUN echo "deb http://deb.debian.org/debian buster-backports main" > /etc/apt/sources.list.d/backports.list
RUN apt-get update

RUN apt-get -y install g++
RUN apt-get -y install make
RUN apt-get -y install cmake
RUN apt-get -y install libuv1-dev
RUN apt-get -y install libssl-dev
RUN apt-get -y install libgmp-dev
RUN apt-get -y install openssl
RUN apt-get -y install libpcre3-dev
RUN apt-get -y install git
RUN apt-get -y install checkinstall
RUN apt-get -y install libz-dev

RUN git clone https://github.com/datastax/cpp-driver.git \
&& cd cpp-driver \
&& git checkout tags/2.16.0 \
&& mkdir build \
&& cd build \
&& cmake .. \
&& make

RUN cd /tmp/cpp-driver/build \
&& checkinstall -y -D --install=no --pkgname=cassandra-cpp-driver --pkgversion=2.16.0 --pkgarch=amd64

FROM debian:buster-slim

COPY --from=cassandra_cpp_driver /tmp/cpp-driver/build/cassandra-cpp-driver_2.16.0-1_amd64.deb /tmp/cpp-driver/build/cassandra-cpp-driver_2.16.0-1_amd64.deb
RUN dpkg -i /tmp/cpp-driver/build/cassandra-cpp-driver_2.16.0-1_amd64.deb

WORKDIR /tmp
RUN apt-get update
# PHP
RUN apt-get install -y php php-fpm
RUN apt-get install -y php-pear
RUN apt-get install -y php-dev

# Cassandra PHP Driver - PECL Installation
RUN apt-get install -y git
RUN mkdir -p /tmp/php-driver
COPY . /tmp/php-driver/

# Install from git source
#RUN git clone https://github.com/datastax/php-driver.git \
# && cd /tmp/php-driver \
# && rm -R /tmp/php-driver/.git

RUN apt-get install -y libgmp-dev
RUN apt-get install -y libuv1-dev
RUN cd /tmp/php-driver \
&& pecl install ext/package.xml \
&& rm -R /tmp/*
7 changes: 7 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: "3.5"

services:
php-driver:
build:
context: .
image: cassandra-php-driver
4 changes: 2 additions & 2 deletions ext/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,10 @@ if test "$PHP_CASSANDRA" != "no"; then

case $(uname -s) in
Linux)
CASSANDRA_CFLAGS="-Wall -Wextra -Wno-long-long -Wno-deprecated-declarations -Wno-unused-parameter -Wno-unused-result -Wno-variadic-macros -Wno-extra-semi -pthread"
CASSANDRA_CFLAGS="-Wall -Wextra -Wno-long-long -Wno-deprecated-declarations -Wno-unused-parameter -Wno-unused-result -Wno-variadic-macros -pthread"
;;
Darwin)
CASSANDRA_CFLAGS="-Wall -Wextra -Wno-long-long -Wno-deprecated-declarations -Wno-unused-parameter -Wno-unused-result -Wno-variadic-macros -Wno-extra-semi"
CASSANDRA_CFLAGS="-Wall -Wextra -Wno-long-long -Wno-deprecated-declarations -Wno-unused-parameter -Wno-unused-result -Wno-variadic-macros"
;;
esac

Expand Down
18 changes: 18 additions & 0 deletions ext/php_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,13 +337,31 @@ throw_invalid_argument(zval *object,
object_name, expected_type);
}
} else if (Z_TYPE_P(object) == IS_STRING) {
// remember current diagnostic state
#pragma GCC diagnostic push
// suppress warnings relating %Z
#pragma GCC diagnostic ignored "-Wformat"
#pragma GCC diagnostic ignored "-Wformat-extra-args"

zend_throw_exception_ex(php_driver_invalid_argument_exception_ce, 0 TSRMLS_CC,
"%s must be %s, '%Z' given",
object_name, expected_type, object);

// restore diagnostic state
#pragma GCC diagnostic pop
} else {
// remember current diagnostic state
#pragma GCC diagnostic push
// suppress warnings relating %Z
#pragma GCC diagnostic ignored "-Wformat"
#pragma GCC diagnostic ignored "-Wformat-extra-args"

zend_throw_exception_ex(php_driver_invalid_argument_exception_ce, 0 TSRMLS_CC,
"%s must be %s, %Z given",
object_name, expected_type, object);

// restore diagnostic state
#pragma GCC diagnostic pop
}
}

Expand Down
2 changes: 1 addition & 1 deletion ext/src/Bigint.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ php_driver_bigint_init(INTERNAL_FUNCTION_PARAMETERS)

if (double_value > INT64_MAX || double_value < INT64_MIN) {
zend_throw_exception_ex(php_driver_range_exception_ce, 0 TSRMLS_CC,
"value must be between " LL_FORMAT " and " LL_FORMAT ", %g given",
"value must be between %+" PRId64 " and %+" PRId64 ", %g given",
INT64_MIN, INT64_MAX, double_value);
return;
}
Expand Down
4 changes: 2 additions & 2 deletions ext/src/Date.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ PHP_METHOD(Date, toDateTime)
#endif

str_len = spprintf(&str, 0, "%lld",
cass_date_time_to_epoch(self->date,
(long long int) cass_date_time_to_epoch(self->date,
time_obj != NULL ? time_obj->time : 0));
php_date_initialize(datetime_obj, str, str_len, "U", NULL, 0 TSRMLS_CC);
efree(str);
Expand Down Expand Up @@ -154,7 +154,7 @@ PHP_METHOD(Date, __toString)

self = PHP_DRIVER_GET_DATE(getThis());

spprintf(&ret, 0, PHP_DRIVER_NAMESPACE "\\Date(seconds=%lld)", cass_date_time_to_epoch(self->date, 0));
spprintf(&ret, 0, PHP_DRIVER_NAMESPACE "\\Date(seconds=%lld)", (long long int) cass_date_time_to_epoch(self->date, 0));
PHP5TO7_RETVAL_STRING(ret);
efree(ret);
}
Expand Down
2 changes: 1 addition & 1 deletion ext/src/Decimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ from_double(php_driver_numeric *result, double value)
#ifdef _WIN32
sprintf(mantissa_str, "%I64d", mantissa);
#else
sprintf(mantissa_str, "%lld", mantissa);
sprintf(mantissa_str, "%lld", (long long int) mantissa);
#endif
mpz_set_str(result->data.decimal.value, mantissa_str, 10);

Expand Down
12 changes: 6 additions & 6 deletions ext/src/Duration.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ zend_class_entry *php_driver_duration_ce = NULL;
static void to_string(zval *result, cass_int64_t value)
{
char *string;
spprintf(&string, 0, LL_FORMAT, value);
spprintf(&string, 0, LL_FORMAT, (long long int) value);
PHP5TO7_ZVAL_STRING(result, string);
efree(string);
}
Expand All @@ -35,7 +35,7 @@ static int get_param(zval* value,
if (long_value > max || long_value < min) {
zend_throw_exception_ex(php_driver_invalid_argument_exception_ce, 0 TSRMLS_CC,
"%s must be between " LL_FORMAT " and " LL_FORMAT ", " LL_FORMAT " given",
param_name, min, max, long_value);
param_name, (long long int) min, (long long int) max, (long long int) long_value);
return 0;
}

Expand All @@ -46,7 +46,7 @@ static int get_param(zval* value,
if (double_value > max || double_value < min) {
zend_throw_exception_ex(php_driver_invalid_argument_exception_ce, 0 TSRMLS_CC,
"%s must be between " LL_FORMAT " and " LL_FORMAT ", %g given",
param_name, min, max, double_value);
param_name, (long long int) min, (long long int) max, double_value);
return 0;
}
*destination = (cass_int64_t) double_value;
Expand All @@ -59,7 +59,7 @@ static int get_param(zval* value,
if (parsed_big_int > max || parsed_big_int < min) {
zend_throw_exception_ex(php_driver_invalid_argument_exception_ce, 0 TSRMLS_CC,
"%s must be between " LL_FORMAT " and " LL_FORMAT ", " LL_FORMAT " given",
param_name, min, max, parsed_big_int);
param_name, (long long int) min, (long long int) max, (long long int) parsed_big_int);
return 0;
}
*destination = parsed_big_int;
Expand All @@ -71,7 +71,7 @@ static int get_param(zval* value,
if (bigint_value > max || bigint_value < min) {
zend_throw_exception_ex(php_driver_invalid_argument_exception_ce, 0 TSRMLS_CC,
"%s must be between " LL_FORMAT " and " LL_FORMAT ", " LL_FORMAT " given",
param_name, min, max, bigint_value);
param_name, (long long int) min, (long long int) max, (long long int) bigint_value);
return 0;
}

Expand Down Expand Up @@ -104,7 +104,7 @@ char *php_driver_duration_to_string(php_driver_duration *duration)
if (final_nanos < 0)
final_nanos = -final_nanos;

spprintf(&rep, 0, "%s%dmo%dd" LL_FORMAT "ns", is_negative ? "-" : "", final_months, final_days, final_nanos);
spprintf(&rep, 0, "%s%dmo%dd" LL_FORMAT "ns", is_negative ? "-" : "", final_months, final_days, (long long int) final_nanos);
return rep;
}

Expand Down
4 changes: 2 additions & 2 deletions ext/src/Timeuuid.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ php_driver_timeuuid_init(INTERNAL_FUNCTION_PARAMETERS)
switch (Z_TYPE_P(param)) {
case IS_LONG:
if (Z_LVAL_P(param) < 0) {
zend_throw_exception_ex(php_driver_invalid_argument_exception_ce, 0 TSRMLS_CC, "Timestamp must be a positive integer, %d given", Z_LVAL_P(param));
zend_throw_exception_ex(php_driver_invalid_argument_exception_ce, 0 TSRMLS_CC, "Timestamp must be a positive integer, %li given", (long int) Z_LVAL_P(param));
return;
}
php_driver_uuid_generate_from_time(Z_LVAL_P(param), &self->uuid TSRMLS_CC);
break;
case IS_STRING:
if (cass_uuid_from_string(Z_STRVAL_P(param), &self->uuid) != CASS_OK) {
zend_throw_exception_ex(php_driver_invalid_argument_exception_ce, 0 TSRMLS_CC, "Invalid UUID: '%.*s'", Z_STRLEN_P(param), Z_STRVAL_P(param));
zend_throw_exception_ex(php_driver_invalid_argument_exception_ce, 0 TSRMLS_CC, "Invalid UUID: '%.*s'", (int) Z_STRLEN_P(param), Z_STRVAL_P(param));
return;
}

Expand Down
2 changes: 1 addition & 1 deletion ext/src/Uuid.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ php_driver_uuid_init(INTERNAL_FUNCTION_PARAMETERS)
} else {
if (cass_uuid_from_string(value, &self->uuid) != CASS_OK) {
zend_throw_exception_ex(php_driver_invalid_argument_exception_ce, 0 TSRMLS_CC,
"Invalid UUID: '%.*s'", value_len, value);
"Invalid UUID: '%.*s'", (int) value_len, value);
return;
}
}
Expand Down
1 change: 1 addition & 0 deletions ext/util/inet.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#define IPV6 2
#define TOKEN_MAX_LEN 4
#define IP_MAX_ADDRLEN 50
#pragma GCC diagnostic ignored "-Wmultistatement-macros"
#define EXPECTING_TOKEN(expected) \
zend_throw_exception_ex(php_driver_invalid_argument_exception_ce, 0 TSRMLS_CC, \
"Unexpected %s at position %d in address \"%s\", expected " expected, \
Expand Down
2 changes: 1 addition & 1 deletion ext/util/math.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ php_driver_parse_bigint(char *in, int in_len, cass_int64_t *number TSRMLS_DC)

if (errno == ERANGE) {
zend_throw_exception_ex(php_driver_range_exception_ce, 0 TSRMLS_CC,
"value must be between " LL_FORMAT " and " LL_FORMAT ", %s given", INT64_MIN, INT64_MAX, in);
"value must be between " LL_FORMAT " and " LL_FORMAT ", %s given", (long long int) INT64_MIN, (long long int) INT64_MAX, in);
return 0;
}

Expand Down