Fix custom settings not available in the builder after import#21
Conversation
Code Review SummaryCode Quality & Best PracticesPositives:
Issues:
Potential Bugs & Edge Cases
Performance
SecurityNo concerns - internal data reorganization only. Critical Fix NeededLine 349 must preserve original types: $value = $this->settings[ $key ];
if ( is_array( $value ) ) {
$value = wp_json_encode( $value );
} elseif ( is_bool( $value ) ) {
$value = $value ? 'true' : 'false';
} elseif ( is_scalar( $value ) ) {
$value = (string) $value;
}VerdictThe core logic is sound. The type coercion bug is the main issue to fix before merging. |
Code Review IssuesCritical Bugs1. Type Coercion Loss (lines 366, 371)
2. Closure Redefinition (lines 349-360)
Medium Issues3. Redundant JSON+Cast (lines 364-369)
4. Duplicate Entry Generation (lines 374-382)
Low Issues5. No
6. Nullable Return (line 331)
Edge Cases7. Boolean Arrays
|
|
Looking at the code changes in Critical Bugs1. Type Coercion Loss (lines 361-362) 'key' => (string) $k,
'value' => (string) $v,
2. Duplicate Entry Generation (lines 347-350) $values_to_add = $this->array_to_dot_notation( (array) $value, $key );
$values_to_add[ $key ] = wp_json_encode( $value );
Medium Issues3. Redundant String Cast (line 362)
4. No FieldKeys Dependency Check (line 334)
Low Issues5. No
6. Potential ID Collision (line 358)
|
|
Based on my review of the code changes in Critical Issues1. Missing method existence check (line 334) // Current:
$all_keys = \MBB\Helpers\FieldKeys::all();
// Should be:
if ( ! method_exists( '\MBB\Helpers\FieldKeys', 'all' ) ) {
return $this;
}Medium Issues2. No constant for 'custom_settings' string 3. Potential stale reference in $original_keys Low Issues4. Redundant uniqid() calls in nested loop (lines 347-352) 5. Unclear intent of $original_keys capture point Not Issues (Based on Code Analysis)
|




No description provided.