In 2019 a "band aid" was put in by @alikon to prevent JSON data getting truncating when saving a module where the params data exceeded the 65535 limit.
I believe there have been multiple discussions in regards to increasing the field size in MySQL but the consensus is to keep it as it is for performance reasons.
We have a scenario where the data in "params" for a module exceeds the 65535 limit. We don't wish to save the data in the table but to save it as a file. To do this we run a routine within onExtensionBeforeSave However that routine will never run as the "check the data" routine happens before the "Trigger the before save event".
// Prepare the row for saving
$this->prepareTable($table);
// Check the data.
if (!$table->check()) {
$this->setError($table->getError());
return false;
}
// Trigger the before save event.
$result = Factory::getApplication()->triggerEvent($this->event_before_save, [$context, &$table, $isNew]);
if (\in_array(false, $result, true)) {
$this->setError($table->getError());
return false;
}
// Store the data.
if (!$table->store()) {
$this->setError($table->getError());
return false;
}
Logically I would have thought it should be Prepare, Trigger before save, Check the Data, Store. So I am proposing that the check and trigger change order.
// Prepare the row for saving
$this->prepareTable($table);
// Trigger the before save event.
$result = Factory::getApplication()->triggerEvent($this->event_before_save, [$context, &$table, $isNew]);
if (\in_array(false, $result, true)) {
$this->setError($table->getError());
return false;
}
// Check the data.
if (!$table->check()) {
$this->setError($table->getError());
return false;
}
// Store the data.
if (!$table->store()) {
$this->setError($table->getError());
return false;
}
The above seems logically to me but I'm hoping a discussion would highlight any potential issues with this.
Labels |
Added:
No Code Attached Yet
|
@felixkat can you submit a pull request with your proposal ?