Exporter: Handle NULL values properly #286
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary of Changes
Right now we are not handling NULL values properly in export and import. We are effectively converting them from NULL to an empty string, which is actually a big problem. This PR adds a new attribute to the exported data
value_is_null. If that attribute is set, on import it is replaced with NULL.Right now, this also creates lots of errors in PHP 8.1, because htmlspecialchars() should not be called with a NULL value.
Testing Instructions
On PHP 8.1 in Joomla call the CLI database exporter and see the notices. Apply the changes and instead of the notices see the new attribute. Works especially well in Joomla 5.
Documentation Changes Required
This is a change in behavior, however for current backups the behavior would still be the same as before. Instead of a NULL value, you get an empty string. Also new exports would still be possible to be imported by old importers with the same behavior as before. The correct behavior to keep the NULL values would only work when both sides had this new feature and otherwise would simply behave like right now.