From d38e7c5b67bcb159c68a15bbec9494c8116aaf43 Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Sun, 28 Oct 2018 21:31:19 +0000 Subject: [PATCH] FIX Replace Convert JSON methods with json_* methods, deprecated from SilverStripe 4.4 --- src/Admin/CommentsGridFieldBulkAction/CommentHandler.php | 2 +- src/Admin/CommentsGridFieldBulkAction/Handler.php | 4 ++-- src/Forms/CommentForm.php | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Admin/CommentsGridFieldBulkAction/CommentHandler.php b/src/Admin/CommentsGridFieldBulkAction/CommentHandler.php index b22d04f..f2e1739 100644 --- a/src/Admin/CommentsGridFieldBulkAction/CommentHandler.php +++ b/src/Admin/CommentsGridFieldBulkAction/CommentHandler.php @@ -27,7 +27,7 @@ abstract class CommentHandler extends Handler $this->updateComment($comment); } - $response = new HTTPResponse(Convert::raw2json([ + $response = new HTTPResponse(json_encode([ 'done' => true, 'records' => $ids, ])); diff --git a/src/Admin/CommentsGridFieldBulkAction/Handler.php b/src/Admin/CommentsGridFieldBulkAction/Handler.php index d47be6b..ced63e4 100644 --- a/src/Admin/CommentsGridFieldBulkAction/Handler.php +++ b/src/Admin/CommentsGridFieldBulkAction/Handler.php @@ -37,7 +37,7 @@ class Handler extends GridFieldBulkActionHandler $record->markSpam(); } - $response = new HTTPResponse(Convert::raw2json(array( + $response = new HTTPResponse(json_encode(array( 'done' => true, 'records' => $ids ))); @@ -60,7 +60,7 @@ class Handler extends GridFieldBulkActionHandler $record->markApproved(); } - $response = new HTTPResponse(Convert::raw2json(array( + $response = new HTTPResponse(json_encode(array( 'done' => true, 'records' => $ids ))); diff --git a/src/Forms/CommentForm.php b/src/Forms/CommentForm.php index 04c1a68..c8639f5 100644 --- a/src/Forms/CommentForm.php +++ b/src/Forms/CommentForm.php @@ -146,7 +146,7 @@ class CommentForm extends Form // load user data from previous form request back into form. if (array_key_exists('UserData', $data)) { - $formData = Convert::json2array($data['UserData']); + $formData = json_decode($data['UserData'], true); $this->loadDataFrom([ 'Name' => isset($formData['Name']) ? $formData['Name'] : '', @@ -199,7 +199,7 @@ class CommentForm extends Form // cache users data $form->setSessionData([ - 'UserData' => Convert::raw2json($data), + 'UserData' => json_encode($data), 'Comment' => $data['Comment'] ]); @@ -270,7 +270,7 @@ class CommentForm extends Form // cache users data (name, email, etc to prepopulate on other forms). $form->setSessionData([ - 'UserData' => Convert::raw2json($data), + 'UserData' => json_encode($data), ]); // Find parent link