<div dir="ltr">Ah, right! The logic isn&#39;t looking for &gt; 1, it&#39;s looking for &lt; 1.  Thanks, man.  Whenever I can&#39;t believe my eyes it is always good to ask for a second opinion.</div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Wed, Jan 23, 2013 at 4:45 PM, Joe Bordes <span dir="ltr">&lt;<a href="mailto:joe@tsolucio.com" target="_blank">joe@tsolucio.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

  
    
  
  <div text="#000000" bgcolor="#FFFFFF">
    <div>Hi Adam,<br>
      <br>
      I think the function is correct. Let me try to explain what I
      understand:<br>
      <br>
      In line 1309:<br>
      <br>
      $query=&quot;select smownerid from vtiger_crmentity where crmid = ?&quot;;<br>
      <br>
      We get the ownerid of the record passed in as a parameter, but we
      don&#39;t know if this ID belongs to a user or to a group.<br>
      <br>
      The next step is to make sure we got an ownerid:<br>
      <br>
      if($adb-&gt;num_rows($result) &gt; 0)<br>
      <br>
      Ok, once inside this &quot;if&quot;, we need to know if the ID we have is a
      user or a group, so we launch the SQL:<br>
      <br>
      <br>
      $sql_result = $adb-&gt;pquery(&quot;select count(*) as count from
      vtiger_users where id = ?&quot;,array($ownerId));<br>
      <br>
      if the ownerid is of a user, this will return 1, if it belongs to
      a group it will return 0, thus the next &quot;if&quot; which fills the array
      (with only one ID always).<br>
      <br>
      So, I&#39;m not sure what the stock functions is sending in, probably
      still the prior to 5.4.0 product handler instead of the new 5.4.0
      assigned user, but I think the getRecordOwnerId() function is
      correct.<br>
      <br>
      Joe<br>
      TSolucio<div><div class="h5"><br>
      <br>
      <br>
      <br>
      On 23/01/13 21:24, Adam Heinz wrote:<br>
    </div></div></div>
    <blockquote type="cite"><div><div class="h5">
      <div dir="ltr">I&#39;m mucking around with an aftersave handler for
        the Quotes module today and I started seeing some warnings
        getting logged.  It looks like the product stock email is
        causing them, but when I trace into the code [1] my jaw hit the
        floor.  Am I reading this right?  This function seems to think
        that you can get back more than one user for a given id, which
        is impossible, since id is the primary key for vtiger_users.  So
        then it passes the array(&#39;Users&#39; =&gt; ID) to getOwnerName
        to getOwnerNameList and eventually blows up because it tries to
        use an array for an array key.  To keep the blast radius small,
        I patched around the error [2], but I think the moral of the
        story is that getRecordOwnerId() should be rewritten or removed
        and all uses of it changed.
        <div>
          <br>
        </div>
        <div>[1] <a href="http://trac.vtiger.com/cgi-bin/trac.cgi/browser/vtigercrm/branches/5.4.0/include/utils/utils.php#L1303" target="_blank">http://trac.vtiger.com/cgi-bin/trac.cgi/browser/vtigercrm/branches/5.4.0/include/utils/utils.php#L1303</a></div>

        <div>[2]</div>
        <div>
          <div>Index: include/utils/InventoryUtils.php</div>
          <div>===================================================================</div>
          <div>--- include/utils/InventoryUtils.php<span style="white-space:pre-wrap"> </span>(revision 3777)</div>
          <div>+++ include/utils/InventoryUtils.php<span style="white-space:pre-wrap"> </span>(working copy)</div>
          <div>@@ -110,7 +110,7 @@</div>
          <div> <span style="white-space:pre-wrap"> </span>if($upd_qty
            &lt; $reorderlevel)</div>
          <div> <span style="white-space:pre-wrap"> </span>{</div>
          <div> <span style="white-space:pre-wrap"> </span>//send
            mail to the handler</div>
          <div>-<span style="white-space:pre-wrap"> </span>$handler
            = getRecordOwnerId($product_id);</div>
          <div>+<span style="white-space:pre-wrap"> </span>$handler
            = $adb-&gt;database-&gt;GetOne(&quot;SELECT smownerid FROM
            vtiger_crmentity WHERE crmid = ?&quot;, array($product_id));</div>
          <div> <span style="white-space:pre-wrap"> </span>$handler_name
            = getOwnerName($handler);</div>
          <div> <span style="white-space:pre-wrap"> </span>if(vtws_isRecordOwnerUser($handler))
            {</div>
          <div> <span style="white-space:pre-wrap"> </span>$to_address
            = getUserEmail($handler);</div>
        </div>
        <div><br>
        </div>
      </div>
      <br>
      <fieldset></fieldset>
      <br>
      </div></div><pre>_______________________________________________
<a href="http://www.vtiger.com/" target="_blank">http://www.vtiger.com/</a></pre>
    </blockquote>
    <br>
  </div>

<br>_______________________________________________<br>
<a href="http://www.vtiger.com/" target="_blank">http://www.vtiger.com/</a><br></blockquote></div><br></div>