Skip to content

Commit

Permalink
Fixing scalar value access error in display function
Browse files Browse the repository at this point in the history
  • Loading branch information
jegelstaff committed Mar 4, 2025
1 parent fe5f77b commit 6c565f9
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions modules/formulize/include/extract.php
Original file line number Diff line number Diff line change
Expand Up @@ -1298,12 +1298,7 @@ function processGetDataResults($resultData)
if ($curFormAlias == "main" and isset($writtenMains[$entryIdIndex['main']])) {
continue;
}
if (isMetaDataField($elementHandle)) {
$valueArray = $value;
} else {
$valueArray = array($value);
}
$masterResults[$masterIndexer][getFormTitle($curFormId)][$entryIdIndex[$curFormAlias]][$elementHandle] = $valueArray;
$masterResults[$masterIndexer][getFormTitle($curFormId)][$entryIdIndex[$curFormAlias]][$elementHandle] = $value;
} // end of foreach field loop within a record
} // end of main while loop for all records
unset($queryRes[$queryResIndex]);
Expand Down Expand Up @@ -2521,31 +2516,32 @@ function display($entry, $handle, $datasetKey = null, $localEntryId = null)
{

$entry = is_numeric($datasetKey) ? $entry[$datasetKey] : $entry;

// return nothing if handle is not part of entry
if (!$formhandle = getFormHandleFromEntry($entry, $handle)) {
return "";
} // return nothing if handle is not part of entry
}

$GLOBALS['formulize_mostRecentLocalId'] = array();
$formulize_mostRecentLocalId = array();
foreach ($entry[$formhandle] as $lid => $elements) {
if (!$localEntryId or $localEntryId == "NULL" or $lid == $localEntryId) { // legacy "NULL" string value is valid :(
if ($handle == "owner_groups") { // owner groups is always a simple array, return as is
if (isMetaDataField($handle)) {
$GLOBALS['formulize_mostRecentLocalId'] = $lid;
return $elements[$handle];
} elseif (is_array($elements[$handle])) { // will only ever be one item in this array! holdover from when we used to prep values as part of preparing dataset, and everything, even single values, was put into an array. Now we put the raw DB value into an array, and prep it here. Sticking with it in an array is consistent for existing logic that expects only metadata values to not be in an array, which is hacky, but less disruptive.
foreach (prepvalues($elements[$handle][0], $handle, $lid) as $thisValue) {
} else {
foreach (prepvalues($elements[$handle], $handle, $lid) as $thisValue) {
$foundValues[] = htmlspecialchars_decode($thisValue);
$GLOBALS['formulize_mostRecentLocalId'][] = $lid;
$formulize_mostRecentLocalId[] = $lid;
}
} else { // the handle is for non-owner-groups metadata, all other fields will be arrays in the dataset
$GLOBALS['formulize_mostRecentLocalId'] = $lid;
return prepvalues($elements[$handle], $handle, $lid);
}
}
}

if (count((array) $foundValues) == 1) {
$GLOBALS['formulize_mostRecentLocalId'] = $GLOBALS['formulize_mostRecentLocalId'][0];
$GLOBALS['formulize_mostRecentLocalId'] = $formulize_mostRecentLocalId[0];
return $foundValues[0];
} else {
$GLOBALS['formulize_mostRecentLocalId'] = $formulize_mostRecentLocalId;
return $foundValues;
}
}
Expand Down

0 comments on commit 6c565f9

Please sign in to comment.