foreach in ToolsPropertyInput::renderPropertyArray unintentionally overrides $property
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3545134. --> Reported by: [michaellander](https://www.drupal.org/user/636494) Related to !862 >>> <h3 id="summary-problem-motivation">Problem/Motivation</h3> <p>The foreach loop in <code>\Drupal\ai\OperationType\Chat\Tools\ToolsPropertyInput::renderPropertyArray</code> is unintentionally overriding the <code>$property</code> variable:</p> <div class="codeblock"> <pre><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br>&nbsp;&nbsp;&nbsp; </span><span style="color: #007700">if (!empty(</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">properties</span><span style="color: #007700">)) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach (</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">properties </span><span style="color: #007700">as </span><span style="color: #0000BB">$property</span><span style="color: #007700">) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #0000BB">$property</span><span style="color: #007700">[</span><span style="color: #DD0000">'properties'</span><span style="color: #007700">][</span><span style="color: #0000BB">$property</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getName</span><span style="color: #007700">()] = </span><span style="color: #0000BB">$property</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">renderPropertyArray</span><span style="color: #007700">();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; }<br></span><span style="color: #0000BB">?&gt;</span></span></pre></div> <p>The function is building up a <code>$property</code> array, but then the loop is overriding it with property objects.</p> <h3 id="summary-proposed-resolution">Proposed resolution</h3> <p>Fix.</p>
issue