Skip to content

Conversation

alamowo
Copy link

@alamowo alamowo commented Nov 12, 2018

If $patternData["lineages"] equals false, make it an empty array to prevent php warning:

Warning: count(): Parameter must be an array or an object that implements Countable in /.../pattern-lab/vendor/pattern-lab/plugin-data-inheritance/src/PatternLab/DataInheritance/PatternLabListener.php on line 43


foreach ($storePatternData as $patternStoreKey => $patternData) {

if ($patternData["lineages"] === false) {
Copy link

Choose a reason for hiding this comment

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

Suggested change
if ($patternData["lineages"] === false) {

Copy link

Choose a reason for hiding this comment

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

This fails with PHP Notice: Undefined index: lineages

foreach ($storePatternData as $patternStoreKey => $patternData) {

if ($patternData["lineages"] === false) {
$patternData["lineages"] = array();
Copy link

Choose a reason for hiding this comment

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

Suggested change
$patternData["lineages"] = array();


if ($patternData["lineages"] === false) {
$patternData["lineages"] = array();
}
Copy link

Choose a reason for hiding this comment

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

Suggested change
}

if ($patternData["lineages"] === false) {
$patternData["lineages"] = array();
}

Copy link

Choose a reason for hiding this comment

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

Suggested change

$patternData["lineages"] = array();
}

if (isset($patternData["lineages"]) && (count($patternData["lineages"]) > 0)) {
Copy link

Choose a reason for hiding this comment

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

Suggested change
if (isset($patternData["lineages"]) && (count($patternData["lineages"]) > 0)) {
if (isset($patternData["lineages"]) && is_array($patternData["lineages"]) && (count($patternData["lineages"]) > 0)) {

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.

2 participants