<?xml version="1.0" encoding="UTF-8"?> 
<?xml-stylesheet href="https://dev.horde.org/themes/horde//default/feed-rss.xsl" type="text/xsl"?> 
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> 
 <channel> 
  <title>Restrict Comment To: groups lose group id when rendered</title> 
  <pubDate>Fri, 10 Apr 2026 05:31:47 +0000</pubDate> 
  <link>https://bugs.horde.org/ticket/6569</link> 
  <atom:link rel="self" type="application/rss+xml" title="Restrict Comment To: groups lose group id when rendered" href="https://bugs.horde.org/ticket/6569/rss" /> 
  <description>Restrict Comment To: groups lose group id when rendered</description> 
 
   
   
  <item> 
   <title>In lib/Forms/EditTicket.php, the comment restriction code go</title> 
   <description>In lib/Forms/EditTicket.php, the comment restriction code goes like this (I&#039;ve annotated, as the code isn&#039;t commented):

// get all the groups I can access in array (group_id =&gt; label, ...) format

foreach (array_keys($mygroups) as $gid) { 

    $grouplist[$gid] = $groups-&gt;getGroupName($gid, true);

}

// sort those by name

asort($grouplist);

// tack &quot;Any Group&quot; onto the front

$grouplist = array_merge(array(0 =&gt; _(&quot;Any Group&quot;)), $grouplist);

// push into the form

$this-&gt;addVariable(_(&quot;Restrict Comment to:&quot;), &#039;group&#039;, &#039;enum&#039;, true, false, null, array($grouplist));



The intent of this code seems to be to create the drop-down for restricting comments using the group ID (from the data tree) as the option value and the group Name (also from the data tree) as the option label.



However, array_merge() screws that up, because PHP 5 &amp; PHP 4 re-index the array, destroying the key association needed: 

[bishop@predator staging]$ cat array_merge.php 

&lt;?php

$a = array (23 =&gt; &#039;Hello&#039;, &#039;42&#039; =&gt; &#039;World&#039;);

$a = array_merge(array (0 =&gt; &#039;I say, &#039;), $a);

var_dump($a);

?&gt;

[bishop@predator staging]$ php-5.2.5 array_merge.php 

array(3) {

  [0]=&gt;

  string(7) &quot;I say, &quot;

  [1]=&gt;

  string(5) &quot;Hello&quot; 

  [2]=&gt;

  string(5) &quot;World&quot; 

}

[bishop@predator staging]$ php-4.4.7 array_merge.php 

array(3) {

  [0]=&gt;

  string(7) &quot;I say, &quot;

  [1]=&gt;

  string(5) &quot;Hello&quot; 

  [2]=&gt;

  string(5) &quot;World&quot; 

}



My suggested patch (attached) is to replace array_merge() with the plus operator.

</description> 
   <pubDate>Fri, 04 Apr 2008 22:06:58 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/6569#t44429</link> 
  </item> 
   
  <item> 
   <title>Committed, thanks.</title> 
   <description>Committed, thanks.</description> 
   <pubDate>Thu, 24 Apr 2008 02:51:38 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/6569#t44851</link> 
  </item> 
   
   
 
 </channel> 
</rss> 
