PHP 7.2 compatibility: count(null) now generates a PHP warning !!

SVN:trunk[5815]
This commit is contained in:
Denis Flaven
2018-05-28 14:08:31 +00:00
parent 04e41ab676
commit 6cc4a6e1be
4 changed files with 7 additions and 6 deletions

View File

@@ -2367,7 +2367,7 @@ EOF
else
{
$aAllowedValues = MetaModel::GetAllowedValues_att($sClass, $sAttCode, $aArgs);
if (count($aAllowedValues) == 1)
if (is_array($aAllowedValues) && (count($aAllowedValues) == 1))
{
$aValues = array_keys($aAllowedValues);
$oObj->Set($sAttCode, $aValues[0]);
@@ -3461,7 +3461,7 @@ EOF
foreach (MetaModel::EnumPlugins('iApplicationObjectExtension') as $oExtensionInstance)
{
$aNewIssues = $oExtensionInstance->OnCheckToWrite($this);
if (count($aNewIssues) > 0)
if (is_array($aNewIssues) && (count($aNewIssues) > 0)) // Some extensions return null instead of an empty array
{
$this->m_aCheckIssues = array_merge($this->m_aCheckIssues, $aNewIssues);
}

View File

@@ -1234,7 +1234,7 @@ abstract class DBObject implements iDisplay
elseif ($oAtt->IsScalar())
{
$aValues = $oAtt->GetAllowedValues($this->ToArgsForQuery());
if (count($aValues) > 0)
if (is_array($aValues) && (count($aValues) > 0))
{
if (!array_key_exists($toCheck, $aValues))
{

View File

@@ -6185,7 +6185,7 @@ abstract class MetaModel
{
$sQuerySign .= '_all_';
}
if (count($aModifierProperties))
if (is_array($aModifierProperties) && (count($aModifierProperties) > 0))
{
array_multisort($aModifierProperties);
$sModifierProperties = json_encode($aModifierProperties);

View File

@@ -457,7 +457,8 @@ class SearchForm
$aAllowedValues = $oAttrDef->GetAllowedValues();
return array('values' => $aAllowedValues, 'count' => count($aAllowedValues));
$iCount = is_array($aAllowedValues) ? count($aAllowedValues) : 0;
return array('values' => $aAllowedValues, 'count' => $iCount);
}
/**
@@ -668,4 +669,4 @@ class SearchForm
return $aOrCriterion;
}
}
}