Browse Source

Fixed long albums/photos ids for 32bit PHP versions #487

Tobias Reich 9 years ago
parent
commit
c6d8b5f312
3 changed files with 6 additions and 5 deletions
  1. 1 1
      php/Access/Admin.php
  2. 2 2
      php/Modules/Response.php
  3. 3 2
      php/helpers/generateID.php

+ 1 - 1
php/Access/Admin.php

@@ -93,7 +93,7 @@ final class Admin extends Access {
 		Validator::required(isset($_POST['title']), __METHOD__);
 
 		$album = new Album(null);
-		Response::json($album->add($_POST['title']));
+		Response::json($album->add($_POST['title']), JSON_NUMERIC_CHECK);
 
 	}
 

+ 2 - 2
php/Modules/Response.php

@@ -16,9 +16,9 @@ final class Response {
 
 	}
 
-	public static function json($str) {
+	public static function json($str, $options = 0) {
 
-		exit(json_encode($str));
+		exit(json_encode($str, $options));
 
 	}
 

+ 3 - 2
php/helpers/generateID.php

@@ -8,8 +8,9 @@ function generateID() {
 	// Ensure that the id has a length of 14 chars
 	while(strlen($id)<14) $id .= 0;
 
-	// Return the integer value of the id
-	return intval($id);
+	// Return id as a string. Don't convert the id to an integer
+	// as 14 digits are too big for 32bit PHP versions.
+	return $id;
 
 }