<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[FrontAccounting forum — Bug due to commit]]></title>
	<link rel="self" href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=7886&amp;type=atom" />
	<updated>2018-12-16T15:22:41Z</updated>
	<generator>PunBB</generator>
	<id>https://frontaccounting.com/punbb/viewtopic.php?id=7886</id>
		<entry>
			<title type="html"><![CDATA[Re: Bug due to commit]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=33644#p33644" />
			<content type="html"><![CDATA[<p>It works in PHP 5.3.1 on WinXP3 as well (XAMPP 1.7.3).</p>]]></content>
			<author>
				<name><![CDATA[apmuthu]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=364</uri>
			</author>
			<updated>2018-12-16T15:22:41Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=33644#p33644</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Bug due to commit]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=33641#p33641" />
			<content type="html"><![CDATA[<p>Hello again,</p><p>I have now tested your example, @notrinos, and it doesn&#039;t work as intended.<br />I have now changed the function count_array($array) in /includes/ui/ui_globals.inc to this:<br /></p><div class="codebox"><pre><code>function count_array($array)
{
    return (is_array($array)) ? count($array) : (($array === NULL) ? 0 : 1);
}</code></pre></div><p>and it works for PHP versions 7.2.12, 7.1.9, 7.0.23, 5.6.31, 5.5.25 and 5.4.10.</p><p>It gives the same return as the old count() without errors or warnings.<br />We only have to convert more counts() if we detect more errors. We can wait until next major to do this.</p><p>This has now been committed and a new file can be downloaded <a href="https://sourceforge.net/p/frontaccounting/git/ci/master/tree/includes/ui/ui_globals.inc">here</a>:</p><p>/Joe.</p>]]></content>
			<author>
				<name><![CDATA[joe]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=3</uri>
			</author>
			<updated>2018-12-16T15:16:41Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=33641#p33641</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Bug due to commit]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=33636#p33636" />
			<content type="html"><![CDATA[<p>ok, I will just test this before committing.</p><p>Joe</p>]]></content>
			<author>
				<name><![CDATA[joe]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=3</uri>
			</author>
			<updated>2018-12-16T13:45:26Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=33636#p33636</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Bug due to commit]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=33635#p33635" />
			<content type="html"><![CDATA[<p>before the function count_array() was deployed we used PHP build in function count() for validating both array and number<br />since the count() has been changed to validate array, object only so we need to create new function in FA for checking both number and array.<br />The current function count_array() should be modified to:<br /></p><div class="codebox"><pre><code>function fa_count($input)
{
    if(is_array($input))
        return count($input);
    elseif(ctype_digit($input) &amp;&amp; (int)$input &gt; 0)
        return (int)$input;
    else
        return 0;
}</code></pre></div><p>Do this we could change every curently count() to fa_count() without worry about errors that may arise somewhere.</p>]]></content>
			<author>
				<name><![CDATA[notrinos]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=36772</uri>
			</author>
			<updated>2018-12-16T13:20:33Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=33635#p33635</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Bug due to commit]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=33633#p33633" />
			<content type="html"><![CDATA[<p>@joe<br />my function is not working because it is called inside function get_sales_child_documents which use 3 times in file view_sales_order.php validating for both number and array.</p><p>your solution is working in this case but seems we still need a function to check both array element and number</p>]]></content>
			<author>
				<name><![CDATA[notrinos]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=36772</uri>
			</author>
			<updated>2018-12-16T13:07:00Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=33633#p33633</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Bug due to commit]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=33631#p33631" />
			<content type="html"><![CDATA[<p>@notrinos</p><p>The function is_positive_int doesn&#039;t work as you provide in php 7.2.</p><p>However changing <br /></p><div class="codebox"><pre><code>if (!is_positive_int($trans_no))
to
if (!trans_no)
do work.</code></pre></div><p>what do you think?</p><p>joe</p>]]></content>
			<author>
				<name><![CDATA[joe]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=3</uri>
			</author>
			<updated>2018-12-16T12:32:45Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=33631#p33631</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Bug due to commit]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=33630#p33630" />
			<content type="html"><![CDATA[<p>yes, function count_array() is for the purpose as of its name.<br />all places that are checking positive intergers need a different function.</p><div class="codebox"><pre><code>function is_positive_int($input)
{
    if(ctype_digit($input) &amp;&amp; (int)$input &gt; 0)
        return true;

    return false;
}</code></pre></div><p>and line 371 of sales_db.inc needs to be modified to :<br /></p><div class="codebox"><pre><code>if (!is_positive_int($trans_no))</code></pre></div><p>also roll back the last commit.</p>]]></content>
			<author>
				<name><![CDATA[notrinos]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=36772</uri>
			</author>
			<updated>2018-12-16T11:58:14Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=33630#p33630</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Bug due to commit]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=33624#p33624" />
			<content type="html"><![CDATA[<p>Found this <a href="https://github.com/FrontAccountingERP/FA/commit/f9dd78a24383c61eaed49836155d673cb2f913ca#r31692518">bug</a> after new commit</p><p>And I doubt <a href="https://github.com/FrontAccountingERP/FA/commit/ad0504645e3632d169d0f253bb5eb4db8b7e18b9#r31692538">this one</a> also have logical error after this new commit.</p>]]></content>
			<author>
				<name><![CDATA[boxygen]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=20175</uri>
			</author>
			<updated>2018-12-16T10:43:23Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=33624#p33624</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Bug due to commit]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=33622#p33622" />
			<content type="html"><![CDATA[<p>I guess you are right guys. Sorry that we didn&#039;t detect this before the minor release. However now it seems to work.<br />Please help me test it. You can make a global search on count_array and try to run the routines involved. It should be 6 files.</p><p>Committed to stable repo. New file can be downloaded <a href="https://sourceforge.net/p/frontaccounting/git/ci/master/tree/includes/ui/ui_globals.inc">here</a>.</p><p>Joe</p>]]></content>
			<author>
				<name><![CDATA[joe]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=3</uri>
			</author>
			<updated>2018-12-16T07:40:01Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=33622#p33622</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Bug due to commit]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=33620#p33620" />
			<content type="html"><![CDATA[<p>@joe: Please commit this and verify that all files that partook of this change and the ones before this function came in are all okay.</p>]]></content>
			<author>
				<name><![CDATA[apmuthu]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=364</uri>
			</author>
			<updated>2018-12-16T06:26:34Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=33620#p33620</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Bug due to commit]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=33619#p33619" />
			<content type="html"><![CDATA[<p>Yes changing the return to 1 has worked.</p>]]></content>
			<author>
				<name><![CDATA[boxygen]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=20175</uri>
			</author>
			<updated>2018-12-16T06:07:45Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=33619#p33619</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Bug due to commit]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=33605#p33605" />
			<content type="html"><![CDATA[<p>The following test code was executed in PHP 5.3.3:<br /></p><div class="codebox"><pre><code>    $a = 0; // Scalar
    $b = count($a);
    echo var_dump($b); // returns int(1)

    $a = array(); // Array
    $b = count($a);
    echo var_dump($b); // returns int(0)</code></pre></div><p>Hence we should return a 1 if it is a scalar and not a 0!</p>]]></content>
			<author>
				<name><![CDATA[apmuthu]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=364</uri>
			</author>
			<updated>2018-12-15T17:12:05Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=33605#p33605</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Bug due to commit]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=33599#p33599" />
			<content type="html"><![CDATA[<p>Which version of PHP are you using?<br />Make a test script with empty array and see what appears in var_dump on using the new function.</p><p>In the old dispensation, the argument could be either an array or a scalar and the count() faithfully returned an acceptable result - was it a 0 or just false? In the current codebase, it will return a 0 if &quot;it is a scalar&quot; and also &quot;even if it is an array and if the array has no elements&quot;.</p>]]></content>
			<author>
				<name><![CDATA[apmuthu]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=364</uri>
			</author>
			<updated>2018-12-15T14:46:00Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=33599#p33599</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Bug due to commit]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=33594#p33594" />
			<content type="html"><![CDATA[<p>Please try to give more details about this. I don&#039;t know how to fix it.</p><p>Joe</p>]]></content>
			<author>
				<name><![CDATA[joe]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=3</uri>
			</author>
			<updated>2018-12-15T06:05:26Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=33594#p33594</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Bug due to commit]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=33591#p33591" />
			<content type="html"><![CDATA[<p>This <a href="https://github.com/FrontAccountingERP/FA/commit/ad0504645e3632d169d0f253bb5eb4db8b7e18b9#r31688124">commit</a> has created a bug shown in image.</p><p>I could have caught just one. May be this is affecting other places too.</p><p>Please rectify.</p>]]></content>
			<author>
				<name><![CDATA[boxygen]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=20175</uri>
			</author>
			<updated>2018-12-15T05:20:41Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=33591#p33591</id>
		</entry>
</feed>
