Browse Source

[php] fixed invalid result of Web.getPostData() (fixes #6073)

Alexander Kuzmenko 8 years ago
parent
commit
0cb0098f98
3 changed files with 5 additions and 4 deletions
  1. 1 0
      extra/CHANGES.txt
  2. 2 2
      std/php/Web.hx
  3. 2 2
      std/php7/Web.hx

+ 1 - 0
extra/CHANGES.txt

@@ -3,6 +3,7 @@ next release
 	Bugfixes:
 
 	all : fixed compilation server issue with two identical @:native paths on extern abstracts (#5993)
+	php/php7 : fixed invalid result of Web.getPostData() (#6073)
 
 2017-01-31: 3.4.0
 

+ 2 - 2
std/php/Web.hx

@@ -245,14 +245,14 @@ class Web {
 		case, you will have to use `php.Web.getMultipart()` or
 		`php.Web.parseMultipart()` methods.
 	**/
-	public static function getPostData() {
+	public static function getPostData() : Null<String> {
 		var h = untyped __call__("fopen", "php://input", "r");
 		var bsize = 8192;
 		var max = 32;
 		var data : String = null;
 		var counter = 0;
 		while (!untyped __call__("feof", h) && counter < max) {
-			data += untyped __call__("fread", h, bsize);
+			data = untyped __php__('{0} . fread({1}, {2})', data, h, bsize);
 			counter++;
 		}
 		untyped __call__("fclose", h);

+ 2 - 2
std/php7/Web.hx

@@ -265,14 +265,14 @@ class Web {
 		case, you will have to use `php.Web.getMultipart()` or
 		`php.Web.parseMultipart()` methods.
 	**/
-	public static function getPostData() {
+	public static function getPostData() : Null<String> {
 		var h = fopen("php://input", "r");
 		var bsize = 8192;
 		var max = 32;
 		var data : String = null;
 		var counter = 0;
 		while (!feof(h) && counter < max) {
-			data += fread(h, bsize);
+			data = Syntax.binop(data, ' . ', fread(h, bsize));
 			counter++;
 		}
 		fclose(h);