Skip to content
  • Sean Griffin's avatar
    6fd53486
    Don't instantiate attribute values in `columns_hash` · 6fd53486
    Sean Griffin authored
    This bug only occurs on 4-2-stable. The conditions to make it occur
    require doing a number of pretty dirty things. All of the following must
    be true (roughly in order)
    
    - The column is of a type which coerces to a complex data structure
    - The data structure has mutability which is not protected by a shallow
      copy
    - You are calling `.dup` on records which have never read or assigned
      that field
    - You are mutating values deep inside the datastructure on records which
      have never had a value assigned
    
    The reason this manifested through `.dup` on an Active Record model was
    due to how we calculated changes in 4.2, which forced values to be
    assigned on the defaults, and as per our documentation we only perform a
    shallow copy of attributes, not a deep one. This issue does not occur on
    5.0 and later due to sweeping changes in how duplication and dirty
    tracking occur.
    
    Fixes #25954
    6fd53486
    Don't instantiate attribute values in `columns_hash`
    Sean Griffin authored
    This bug only occurs on 4-2-stable. The conditions to make it occur
    require doing a number of pretty dirty things. All of the following must
    be true (roughly in order)
    
    - The column is of a type which coerces to a complex data structure
    - The data structure has mutability which is not protected by a shallow
      copy
    - You are calling `.dup` on records which have never read or assigned
      that field
    - You are mutating values deep inside the datastructure on records which
      have never had a value assigned
    
    The reason this manifested through `.dup` on an Active Record model was
    due to how we calculated changes in 4.2, which forced values to be
    assigned on the defaults, and as per our documentation we only perform a
    shallow copy of attributes, not a deep one. This issue does not occur on
    5.0 and later due to sweeping changes in how duplication and dirty
    tracking occur.
    
    Fixes #25954
Loading