2. The solution at the time: Replace $value with $sectionSettingValue to temporarily work around the variable name conflict caused by references.
3. Later, a similar issue arose, and I needed to quickly identify which variable name conflicts were causing the problem. I decided to print all variables at the beginning of the file where the execution error occurred. Finally, I would unset() all variables in the printed results that were not null.
PHP
\Illuminate\Support\Facades\Log::info(
'schema.v2.1.80',
[
'$sectionKey' => $sectionKey ?? null,
'$section' => $section ?? null,
'$blockKey' => $blockKey ?? null,
'$block' => $block ?? null,
'$blockOrderKey' => $blockOrderKey ?? null,
'$blocks' => $blocks ?? null,
]
);
4. The printed results are as follows. I confirmed that after the previous execution, the variables $sectionKey, $section, $blockKey, $block, $blockOrderKey, and $type were all not null and all needed to be destroyed.
Plaintext
[2023-09-04 10:43:45] local.INFO: schema.v2.1.80 {
"$sectionKey": "image-1",
"$section": {
"type": "image",
"disabled": false,
"settings": {
"heading": "",
"heading_align": "center"
},
"blocks": {
"column-0": {
"type": "column",
"settings": {
"image": "https://xxx-s3.s3.us-east-2.amazonaws.com/image/736589fac73c7dfdbf61efadb49a95fb9af16efb.jpeg",
"mobile_image": "https://cdn.xxx.com/image/2022/03/200062b82e8cbae7cf7c48b425a33260686fd4aa3e6ed656901cb4cc7a283487.jpeg",
"url": "/"
}
},
"column-1": {
"type": "column",
"settings": {
"image": "https://xxx-s3.s3.us-east-2.amazonaws.com/image/736589fac73c7dfdbf61efadb49a95fb9af16efb.jpeg",
"mobile_image": "https://cdn.xxx.com/image/2022/03/200062b82e8cbae7cf7c48b425a33260686fd4aa3e6ed656901cb4cc7a283487.jpeg",
"url": "/"
}
}
}
},
"$blockKey": "column-1",
"$block": {
"type": "column",
"settings": {
"image": "https://xxx-s3.s3.us-east-2.amazonaws.com/image/736589fac73c7dfdbf61efadb49a95fb9af16efb.jpeg",
"mobile_image": "https://cdn.xxx.com/image/2022/03/200062b82e8cbae7cf7c48b425a33260686fd4aa3e6ed656901cb4cc7a283487.jpeg",
"url": "/"
}
},
"$blockOrderKey": 8,
"$type": [
"search",
"all_collections"
]
}
5. The code to destroy the variables is as follows:
PHP
unset($sectionKey, $section, $blockKey, $block, $blockOrderKey, $type);
