Based on the array-related functions, after the same input, the analysis of the differences under different execution orders (include, reference)
1. Reference: In Laravel 6, after the array is operated based on the array-related functions, the same input, the analysis of the differences under different execution orders (include, reference).https://www.shuijingwanwq.com/2023/06/13/7716/
2. The solution at that time: replace $value with $SectionSettingValue, temporarily avoid the problem of the variable name of the referenced variable
3. After that, there is a similar problem, which needs to be able to quickly locate which variables are caused by the names of variables. Decide to print out the variables in the file that are executed incorrectly at the beginning of the file. In the end, the print result is not null, all unset() is dropped.
\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 printing result is as follows, and confirm that after the last execution, the variables: $SectionKey, $Section, $BlockKey, $Block, $BlockOrderKey, and $Type are all null, and all need to be destroyed.
[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 variable is as follows
unset($sectionKey, $section, $blockKey, $block, $blockOrderKey, $type);