guys
I've been freaking out for the last 4 weeks because I'm not able to solve this problem:
I'm using Laravel 5.3 for a PHP application. This application has a reporting system which performs several queries to database, then it gathers all results in a single variable (a Multi-dimensional array) and stores it to database as a serialized array (LONGTEXT utf8_general_ci type column). The system works perfectly on localhost but, on server, sometimes I get the "unserialize(): Error at offset x of y bytes". The problem is that this error comes kinda randomly... Unserialization works for some reports (small arrays) but it doesn't work for large arrays.
I'm using this to store the array to database:
base64_encode(serialize($results));
And this to retrieve it:
unserialize(base64_decode($results));
I firstly tried using it without base64 functions, but I was getting these errors. Then I added the base64 encode/decode functions and the errors persisted. I thought it might be related to some char encoding problem but data are being stored in a LONGTEXT utf8_general_ci column and there's no length problems with the serialized string (remember that I said that it works perfectly on localhost).
On production server, I get this error:
But in localhost, I get the report normally:
What on earth could be causing this problem?
Localhost info: Windows 10 64bits (also works on Windows 7) PHP 7.1.9 Apache 2.4 (I'm using Xampp Server 3.2.2)
Remote server info: Oracle Linux Server release 6.9 PHP 7.1.8 Apache 2.2.15 MySQL 5.7.19 (database is used for both local and remote cases).