summaryrefslogtreecommitdiff
path: root/add_prebuild.php
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.co.uk>2026-06-21 08:58:42 +0100
committerLester Caine <lester@lsces.co.uk>2026-06-21 08:58:42 +0100
commitdf3841bcb4dc82103d3fca46a4257446680bb51a (patch)
treeae7d098142fb8161ea3c47389d295393eda45beb /add_prebuild.php
parent468ab44fb7db3abe6ff28ea6085a7e0b64b0c185 (diff)
downloadstock-df3841bcb4dc82103d3fca46a4257446680bb51a.tar.gz
stock-df3841bcb4dc82103d3fca46a4257446680bb51a.tar.bz2
stock-df3841bcb4dc82103d3fca46a4257446680bb51a.zip
Fix assembly search returning no results in add_prebuild
array_map over the content_id-keyed getList() result preserves associative keys, so json_encode produced a JS object instead of an array — making items.filter() throw TypeError. Wrap with array_values() to reindex. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'add_prebuild.php')
-rw-r--r--add_prebuild.php4
1 files changed, 2 insertions, 2 deletions
diff --git a/add_prebuild.php b/add_prebuild.php
index 2c0e9fe..c213e19 100644
--- a/add_prebuild.php
+++ b/add_prebuild.php
@@ -92,10 +92,10 @@ if( $itemIds ) {
);
foreach( $klidRows as $r ) { $klidMap[$r['content_id']] = $r['xkey']; }
}
-$itemListJson = json_encode( array_map(
+$itemListJson = json_encode( array_values( array_map(
fn( $i ) => [ 'id' => (int)$i['content_id'], 'text' => $i['title'], 'klid' => $klidMap[$i['content_id']] ?? '' ],
$assemblyList
-) );
+) ) );
$preselectTitle = '';
if( $preselect ) {
foreach( $assemblyList as $item ) {