You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.
Zend\Log\Writer\Db::eventIntoColumn creates new non-existing database table columns when $value is an array.
protected function eventIntoColumn(array $event)
{
if (empty($event)) {
return array();
}
$data = array();
foreach ($event as $name => $value) {
if (is_array($value)) {
foreach ($value as $key => $subvalue) {
// New database table columns are being created here...
$data[$name . $this->separator . $key] = $subvalue;
}
} else {
$data[$name] = $value;
}
}
return $data;
}```
This is highly illogical, because now this PHP-script decides what database table columns should exist. When an array with other keys is used all of a sudden the script generates new, other database columns and eventually make the entire script fail again because of a database error due to non-existing columns. The user should define the columns to be used and the script should never add non-existing database tabel columns on its own.
More logical would be to define a way to handle arrays with something like json_encode() or serialize(). The most important thing is that it does not break the logging like it does now, so when $value is an array it *must always* return a string, because that is the only type of variable you can write to a database table column.
The text was updated successfully, but these errors were encountered:
Generally developer will define it over the columnMap, so it's fine.
If you use it, it won't create new columns, it maybe tries to insert data into not existing columns and so the database will throw an error, because the table doesn't have this columns.
Maybe it's better to throw an exception, but it will break BC! If someone just used it this way and defined the columns like they are coming in the array....
Jira Information
Description
Zend\Log\Writer\Db::eventIntoColumn creates new non-existing database table columns when $value is an array.
The text was updated successfully, but these errors were encountered: