Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent unserialization error in DataTableFactory #14669

Merged
merged 1 commit into from Aug 1, 2019
Merged

Prevent unserialization error in DataTableFactory #14669

merged 1 commit into from Aug 1, 2019

Conversation

jajm
Copy link
Contributor

@jajm jajm commented Jul 18, 2019

Sometimes $blobRow[$blobName] is set but its value is false and
DataTable::fromSerializedArray will throw an exception if called with a
false value

This patch prevents this by verifying that the value is not 'empty'
instead

Sometimes $blobRow[$blobName] is set but its value is false and
DataTable::fromSerializedArray will throw an exception if called with a
false value

This patch prevents this by verifying that the value is not 'empty'
instead
@@ -397,7 +397,7 @@ private function setSubtables($dataTable, $blobRow, $treeLevel = 0)
}

$blobName = $dataName . "_" . $sid;
if (isset($blobRow[$blobName])) {
if (!empty($blobRow[$blobName])) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cheers @jajm . Maybe we should simply check like isset($blobRow[$blobName]) && is_array($blobRow[$blobName])? I haven't looked in detail but wonder if we would still want to go in the if when there is eg an empty array? I guess if it was an empty array, it would simply set an empty subtable which probably isn't wanted so the patch looks good with the !empty() check actually. Maybe @diosmosis can confirm?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be ok, blobRow[...] should never be set to false/empty array AFAIK.

@tsteur tsteur added this to the 3.12.0 milestone Jul 18, 2019
@diosmosis diosmosis merged commit 077c6b0 into matomo-org:3.x-dev Aug 1, 2019
@diosmosis
Copy link
Member

Thanks for the first contribution @jajm!

@mattab mattab modified the milestones: 3.13.0, 3.12.0 Oct 25, 2019
@jajm jajm deleted the fix-unserialization-error branch June 29, 2020 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants