I wrote a PHP class to process a CSV file and upload entries. The last round was over 15,000+ row in the file.
Previously, in my wrapper I would return the json response like so:
echo json_encode($jsonResponse);
wp_die();
That worked fine when we were uploading files that had up to 2,000 rows. Recently, we uploaded a file that had 4,000+ rows and the json response never would print - response
would be NULL
. After many hours of checking if the file itself was causing the issue, I elected to use the following
wp_send_json($jsonResponse);
And my response would show to the screen as expected. I've looked into the wp_send_json()
method and understand it is the expected usage for WP. My question is why did my previous implementation work up to now? I'm assuming the response being ran through manual json_encode()
was too large?
I'm looking for insight into the root of the problem here, and a deeper understanding of why my solution is working.