Skip to content

Commit

Permalink
Merge pull request #67 from rryqszq4/development
Browse files Browse the repository at this point in the history
[pr] Release version to 0.0.20
  • Loading branch information
rryqszq4 authored Oct 17, 2019
2 parents 1a0d72d + 46f760b commit 6ea7567
Show file tree
Hide file tree
Showing 5 changed files with 156 additions and 1 deletion.
15 changes: 15 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
ngx_php7 0.0.20 changes: 17 Oct 2019
* Add directive php_set, php_rewrite, php_access, php_content, php_log, php_header_filter, php_body_filter and php_body_filter.

* Add impl ngx_cookie_set, ngx_cookie_get, ngx_cookie_get_all.

* Add impl ngx_msleep.

* Add redis non-block driver.

* Fixed remove time event and usage of read event.

* Fixed in mysql driver more than double query will fail. Should be reset.

* Fixed ngx_php tcp socket timeout.

ngx_php7 0.0.19 changes: 26 Aug 2019
* Add nginx directive php_keepalive.

Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ ngx_cookie_set
Nginx non-blocking API for php
------------------------------
* [yield ngx_sleep](#ngx_sleep)
* [yield ngx_msleep](#ngx_msleep)
* [ngx_socket_create](#ngx_socket_create)
* [ngx_socket_iskeepalive](#ngx_socket_iskeepalive)
* [yield ngx_socket_connect](#ngx_socket_connect)
Expand All @@ -556,6 +557,12 @@ ngx_sleep

Delays the program execution for the given number of seconds.

ngx_msleep
---------
**syntax:** `yield ngx_msleep(int milliseconds)`

Delays the program execution for the given number of milliseconds.

ngx_socket_create
-----------------
**syntax:** `ngx_socket_create(int $domain, int $type, int $protocol) : resource`
Expand Down
2 changes: 1 addition & 1 deletion src/ngx_http_php_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef __NGX_HTTP_PHP_VERSION_H__
#define __NGX_HTTP_PHP_VERSION_H__

#define NGX_HTTP_PHP_MODULE_VERSION "0.0.19"
#define NGX_HTTP_PHP_MODULE_VERSION "0.0.20"

#endif
21 changes: 21 additions & 0 deletions t/018-ngx_mysql.t
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,24 @@ GET /ngx_mysql_destruct
1,Kabul,AFG,Kabol,1780000
1,Kabul,AFG,Kabol,1780000
1,Kabul,AFG,Kabol,1780000
=== TEST 5: test mysql sleep
mysql sleep
--- timeout: 10
--- config
location =/ngx_mysql_sleep {
content_by_php '
require_once("$TEST_NGINX_BUILD_DIR/t/lib/mysql.php");
$m = new php\\ngx\mysql();
yield from $m->connect("127.0.0.1","3306","ngx_php","ngx_php","world");
$sql = "select sleep(5) as sleep;";
$ret = yield from $m->query($sql);
echo $ret[0]["sleep"]."\n";
';
}
--- request
GET /ngx_mysql_sleep
--- response_body
0
112 changes: 112 additions & 0 deletions t/lib/app-async.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<?php

require_once "/mnt/hgfs/github/ngx_php7/t/lib/mysql.php";
define("DBIP", gethostbyname("localhost"));
define("DB_HOST", gethostbyname("tfb-database"));
define("DB_PORT", "3306");
define("DB_USER", "benchmarkdbuser");
define("DB_PASS", "benchmarkdbpass");
define("DB_NAME", "hello_world");

function fortune()
{
ngx_header_set("Content-Type", "text/html; charset=UTF-8");

$my = new php\ngx\mysql();
yield from $my->connect(DB_HOST, DB_PORT, DB_USER, DB_PASS, DB_NAME);
$ret = yield from $my->query("SELECT id, message FROM Fortune");

$arr = [];
foreach ($ret as $row) {
$arr[$row["id"]] = $row["message"];
}
$arr[0] = "Additional fortune added at request time.";
asort($arr);

$html = "";
foreach ($arr as $id => $message) {
$message = htmlspecialchars($message, ENT_QUOTES, "UTF-8");
$html .= "<tr><td>$id</td><td>$message</td></tr>";
}

echo "<!DOCTYPE html><html><head><title>Fortunes</title></head><body><table><tr><th>id</th><th>message</th></tr>",
$html,
"</table></body></html>";

unset($my);
}


function dbquery()
{
ngx_header_set("Content-Type", "application/json");

$my = new php\ngx\mysql();
yield from $my->connect(DB_HOST, DB_PORT, DB_USER, DB_PASS, DB_NAME);

$query_count = 1;
$params = ngx_query_args();
if ($params["queries"] > 1) {
$query_count = $params["queries"] > 500 ? 500 : $params["queries"];
}

$arr = [];
while (0 < $query_count--) {
$rand = mt_rand(1, 10000);
$arr[] = (yield from $my->query("SELECT id,randomNumber FROM World WHERE id = {$rand}"))[0];
}

unset($my);

echo json_encode($arr);
}


function dbraw()
{
ngx_header_set("Content-Type", "application/json");

$my = new php\ngx\mysql();
yield from $my->connect(DB_HOST, DB_PORT, DB_USER, DB_PASS, DB_NAME);

$data = (yield from $my->query("SELECT id,randomNumber FROM World WHERE id = ".mt_rand(1, 10000)))[0];

unset($my);

echo json_encode($data);

}


function update()
{
ngx_header_set("Content-Type", "application/json");

$my = new php\ngx\mysql();
yield from $my->connect(DB_HOST, DB_PORT, DB_USER, DB_PASS, DB_NAME);

$query_count = 1;
$params = ngx_query_args();
if ($params["queries"] > 1) {
$query_count = $params["queries"] > 500 ? 500 : $params["queries"];
}

$arr = [];
while (0 < $query_count--) {
$id = mt_rand(1, 10000);

$world = (yield from $my->query("SELECT id, randomNumber FROM World WHERE id = {$id}"))[0];
$world["id"] = $id;
$world["randomNumber"] = mt_rand(1, 10000);

yield from $my->query("UPDATE World SET randomNumber = {$world['randomNumber']} WHERE id = {$world['id']}");

$arr[] = $world;
}

unset($my);

echo json_encode($arr);
}


0 comments on commit 6ea7567

Please sign in to comment.