From c6d8b5f3122614222f9f79ad6651cc2780d4debd Mon Sep 17 00:00:00 2001 From: Tobias Reich Date: Thu, 24 Mar 2016 18:23:19 +0100 Subject: [PATCH] Fixed long albums/photos ids for 32bit PHP versions #487 --- php/Access/Admin.php | 2 +- php/Modules/Response.php | 4 ++-- php/helpers/generateID.php | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/php/Access/Admin.php b/php/Access/Admin.php index 927198b..790f398 100644 --- a/php/Access/Admin.php +++ b/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); } diff --git a/php/Modules/Response.php b/php/Modules/Response.php index 01c4c10..289c42e 100644 --- a/php/Modules/Response.php +++ b/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)); } diff --git a/php/helpers/generateID.php b/php/helpers/generateID.php index 80f42c1..84c463d 100644 --- a/php/helpers/generateID.php +++ b/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; }