joomla-framework / database

Joomla Framework Database Package
GNU General Public License v2.0
28 stars 35 forks source link

Exporter: Handle NULL values properly #286

Closed Hackwar closed 10 months ago

Hackwar commented 10 months ago

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.