<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[FrontAccounting forum — PHP 7.4 bug]]></title>
	<link rel="self" href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=8791&amp;type=atom" />
	<updated>2021-10-17T08:57:36Z</updated>
	<generator>PunBB</generator>
	<id>https://frontaccounting.com/punbb/viewtopic.php?id=8791</id>
		<entry>
			<title type="html"><![CDATA[Re: PHP 7.4 bug]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=40123#p40123" />
			<content type="html"><![CDATA[<p>@kvvaradha</p><p>Workbook.php has been fixed and committed to stable. A fixed file /reporting/includes/workbook.php can be downloaded and replaced <a href="https://sourceforge.net/p/frontaccounting/git/ci/master/tree/reporting/includes/Workbook.php">here</a>.</p><p>Joe</p>]]></content>
			<author>
				<name><![CDATA[joe]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=3</uri>
			</author>
			<updated>2021-10-17T08:57:36Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=40123#p40123</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: PHP 7.4 bug]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=40122#p40122" />
			<content type="html"><![CDATA[<p>We have another issue {$} in reporting\includes\Workbook.php.</p><p>@joe. kindly update them to work on php 8.0</p>]]></content>
			<author>
				<name><![CDATA[kvvaradha]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=19348</uri>
			</author>
			<updated>2021-10-16T14:57:45Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=40122#p40122</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: PHP 7.4 bug]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=38482#p38482" />
			<content type="html"><![CDATA[<p>I used the Mysql restore. First problems with the timestamp (ERROR 1067). After adding <br />mysql&gt; SET @@session.sql_mode =&quot; &quot;;<br />the restore worked. Thanks.</p>]]></content>
			<author>
				<name><![CDATA[thorbjornw]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=14181</uri>
			</author>
			<updated>2020-10-12T18:45:13Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=38482#p38482</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: PHP 7.4 bug]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=38481#p38481" />
			<content type="html"><![CDATA[<p>After overriding the initial errors, I now get:<br />Trying to access array offset on value of type null in file: /var/www/html/frontaccounting/includes/db/connect_db_mysqli.inc at line 55<br />Line 55 is:<br />&nbsp; &nbsp; $cur_prefix = $db_connections[$comp][&#039;tbpref&#039;];</p>]]></content>
			<author>
				<name><![CDATA[thorbjornw]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=14181</uri>
			</author>
			<updated>2020-10-12T18:01:19Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=38481#p38481</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: PHP 7.4 bug]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=38480#p38480" />
			<content type="html"><![CDATA[<p>Thanks for the clarification. I suspected it was a language issue. </p><p>When starting the FA installation there are actually a lot of warnings, which disappear when i try login once again:<br />* include_once(../installed_extensions.php): failed to open stream: No such file or directory in file: /var/www/html/frontaccounting/frontaccounting.php at line 23<br />* include_once(): Failed opening &#039;../installed_extensions.php&#039; for inclusion (include_path=&#039;.:/usr/share/php&#039;) in file: /var/www/html/frontaccounting/frontaccounting.php at line 23<br />* include_once(../config_db.php): failed to open stream: No such file or directory in file: /var/www/html/frontaccounting/includes/session.inc at line 383<br />* include_once(): Failed opening &#039;../config_db.php&#039; for inclusion (include_path=&#039;.:/usr/share/php&#039;) in file: /var/www/html/frontaccounting/includes/session.inc at line 383<br />* Undefined variable: installed_extensions in file: /var/www/html/frontaccounting/includes/session.inc at line 392<br />Line 383 in sessions.inc is:<br />&quot;include_once($path_to_root . &quot;/config_db.php&quot;);&quot;<br />Line 392 in sessions.inc is:<br />&quot;foreach ($installed_extensions as $ext)&quot;</p><p>Regarding the language this has been a pain in each new installation since we started using FA 8 years ago. I have managed to get it to work, but I am a bit lost in the question of utf8 vs. ISO. Which of those am I supposed to install? According to phpmyadmin utf8_unicode_ci is the default for creating databases and my FA db is utf8.</p>]]></content>
			<author>
				<name><![CDATA[thorbjornw]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=14181</uri>
			</author>
			<updated>2020-10-12T17:47:47Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=38480#p38480</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: PHP 7.4 bug]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=38476#p38476" />
			<content type="html"><![CDATA[<p>The <strong>isession.inc</strong> error is because you have not installed the locale (Spanish and en_US in your case) in your Linux Mint. FA generally degrades to &#039;C&#039; language only if you did not choose a valid (and possibly not installed) language.</p><p>Use mysql restore from backup sql file from the CLI.</p>]]></content>
			<author>
				<name><![CDATA[apmuthu]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=364</uri>
			</author>
			<updated>2020-10-12T06:52:17Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=38476#p38476</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: PHP 7.4 bug]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=38475#p38475" />
			<content type="html"><![CDATA[<p>Trying to install FA 2.4.8 with PHP 7.4.3 on Linux Mint 20 to go from FA 2.4.4 on Linux Mint 19. When installing I get the following error: <br />Trying to access array offset on value of type null in file: /var/www/html/frontaccounting/install/isession.inc at line 140<br />If I ignore the error, the install goes on but returns an error:<br />Trying to access array offset on value of type null in file: /var/www/html/frontaccounting/includes/db/connect_db_mysqli.inc at line 55<br />Apparently it is starts OK with an US 4 digit COA and Spanish interface. I can then upload a back-up from our working system (after increasing the parameters in the php.ini file), but it will not restore from the backup file (11 MB gzip file). I have tried doing the restore in phpmyadmin, but it turns up a blank page.<br />Any hint?</p>]]></content>
			<author>
				<name><![CDATA[thorbjornw]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=14181</uri>
			</author>
			<updated>2020-10-11T18:12:55Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=38475#p38475</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: PHP 7.4 bug]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=37918#p37918" />
			<content type="html"><![CDATA[<p>Thanks. Committed to 2.4.8 repo.</p><p>Joe</p>]]></content>
			<author>
				<name><![CDATA[joe]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=3</uri>
			</author>
			<updated>2020-08-04T06:10:07Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=37918#p37918</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: PHP 7.4 bug]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=37915#p37915" />
			<content type="html"><![CDATA[<p>Also,</p><div class="codebox"><pre><code>diff --git a/core/purchasing/includes/db/grn_db.inc b/core/purchasing/includes/db/grn_db.inc
index d2fbd7f..0820fb3 100644
--- a/core/purchasing/includes/db/grn_db.inc
+++ b/core/purchasing/includes/db/grn_db.inc
@@ -17,15 +17,14 @@ function update_average_material_cost($supplier, $stock_id, $price, $qty, $date,
        // save a couple of db calls like get_supplier()
        
        $supp = get_supplier($supplier);
-       if ($supplier != null)
+       if ($supplier != null) {
                $currency = $supp[&#039;curr_code&#039;];
-       else
+        if ($supp[&#039;tax_included&#039;])
+            $price = get_tax_free_price_for_item($stock_id, $price, $supp[&#039;tax_group_id&#039;],
+                $supp[&#039;tax_included&#039;]);
+    } else
                $currency = null;
 
-       if ($supp[&#039;tax_included&#039;])
-               $price = get_tax_free_price_for_item($stock_id, $price, $supp[&#039;tax_group_id&#039;],
-                       $supp[&#039;tax_included&#039;]);
-
        if ($currency != null)
        {
                $ex_rate = get_exchange_rate_to_home_currency($currency, $date);</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Braath Waate]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=41493</uri>
			</author>
			<updated>2020-08-03T13:22:59Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=37915#p37915</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: PHP 7.4 bug]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=37914#p37914" />
			<content type="html"><![CDATA[<p>Thanks @Braath Waate,</p><p>Really nice of you to catch these nasty errors. It was really frustating to have come from a compiled language like C/C++ many years ago to the sloppy PHP at that time. During the PHP period we have learnt a lot about this language.<br />But, nice to get help with these errors. Will be committed asap this day.</p><p>/Joe</p>]]></content>
			<author>
				<name><![CDATA[joe]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=3</uri>
			</author>
			<updated>2020-08-03T10:13:23Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=37914#p37914</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: PHP 7.4 bug]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=37913#p37913" />
			<content type="html"><![CDATA[<p>Beginning with PHP 7.4.8 (perhaps earlier), php started announcing the following error:</p><p>Trying to access array offset on value of type bool ...</p><p>Mostly the error can be ignored, but it does indicate improper coding in FA, and possibly bugs.&nbsp; I haven&#039;t done much investigation, but here are a few suggested PHP 7.4.8 fixes to FA (and I am sure there will be many more):</p><div class="codebox"><pre><code>--- a/core/gl/gl_journal.php
+++ b/core/gl/gl_journal.php
@@ -149,7 +149,7 @@ function create_cart($type=0, $trans_no=0)
         {
             $net_sum = 0;
             foreach($cart-&gt;gl_items as $gl)
-                if (!is_tax_account($gl-&gt;code_id) &amp;&amp; !is_subledger_account($gl-&gt;code_id, $gl-&gt;person_id))
+                if (!is_tax_account($gl-&gt;code_id) &amp;&amp; !is_subledger_account($gl-&gt;code_id))
                     $net_sum += $gl-&gt;amount;
 
             $ex_net = abs($net_sum) - array_sum($tax_info[&#039;net_amount&#039;]);
diff --git a/core/gl/includes/db/gl_db_accounts.inc b/core/gl/includes/db/gl_db_accounts.inc
index 53eb5a9..dc60c13 100644
--- a/core/gl/includes/db/gl_db_accounts.inc
+++ b/core/gl/includes/db/gl_db_accounts.inc
@@ -224,7 +224,7 @@ function is_subledger_account($account)
 
     $result = db_query($sql,&quot;Couldn&#039;t test AR/AP account&quot;);
     $myrow = db_fetch_row($result);
-    return $myrow[0];
+    return $myrow == false ? 0 : $myrow[0];
 }
 
 function get_subaccount_data($code_id, $person_id)
diff --git a/core/includes/references.inc b/core/includes/references.inc
index a928c7e..027aafd 100644
--- a/core/includes/references.inc
+++ b/core/includes/references.inc
@@ -227,7 +227,7 @@ class references
             return false;
 
         $result = db_fetch_row($result);
-        return $result[0];
+        return $result == false ? false : $result[0];
     }
 
     function is_new_reference($ref, $type, $trans_no=0)
diff --git a/core/includes/ui/items_cart.inc b/core/includes/ui/items_cart.inc
index 2fe92da..3c91f0b 100644
--- a/core/includes/ui/items_cart.inc
+++ b/core/includes/ui/items_cart.inc
@@ -144,8 +144,8 @@ class items_cart
         $this-&gt;gl_items[$index]-&gt;code_id = $code_id;
         $this-&gt;gl_items[$index]-&gt;person_id = $person_id;
 
-        $gl_type = is_subledger_account($code_id, $person_id);
-        if ($gl_type)
+        $gl_type = is_subledger_account($code_id);
+        if ($person_id != null &amp;&amp; $gl_type)
         {
             $this-&gt;gl_items[$index]-&gt;person_type_id = $gl_type &gt; 0 ? PT_CUSTOMER : PT_SUPPLIER;
             $data = get_subaccount_data($code_id, $person_id);
@@ -263,7 +263,7 @@ class items_cart
 
         foreach($this-&gt;gl_items as $gl)
         {
-            if ($person_type = is_subledger_account($gl-&gt;code_id, $gl-&gt;person_id))
+            if ($person_type = is_subledger_account($gl-&gt;code_id))
             {
                 $tax_info[&#039;person_type&#039;] = $person_type &lt; 0 ? PT_SUPPLIER : PT_CUSTOMER;
                 $tax_info[&#039;person_id&#039;] = $gl-&gt;person_id;
@@ -520,8 +520,8 @@ class gl_item
 
         $this-&gt;code_id = $code_id;
         $this-&gt;person_id = $person_id;
-        $gl_type = is_subledger_account($code_id, $person_id);
-        if ($gl_type)
+        $gl_type = is_subledger_account($code_id);
+        if ($person_id != null  &amp;&amp; $gl_type)
         {
             $this-&gt;person_type_id = $gl_type &gt; 0 ? PT_CUSTOMER : PT_SUPPLIER;
             $data = get_subaccount_data($code_id, $person_id);
diff --git a/core/sales/includes/db/sales_order_db.inc b/core/sales/includes/db/sales_order_db.inc
index fcc19fd..17952e3 100644
--- a/core/sales/includes/db/sales_order_db.inc
+++ b/core/sales/includes/db/sales_order_db.inc
@@ -648,5 +648,5 @@ function last_sales_order_detail($order, $field)
 
         $last_query=db_query($sql, &quot;Could not retrieve last order detail&quot;);
         $row = db_fetch_row($last_query);
-        return $row[0];
+        return $row == false ? false : $row[0];
 }
diff --git a/core/sales/includes/sales_db.inc b/core/sales/includes/sales_db.inc
index 6ff05f1..02cbaaf 100644
--- a/core/sales/includes/sales_db.inc
+++ b/core/sales/includes/sales_db.inc
@@ -231,6 +231,7 @@ function read_sales_trans($doc_type, $trans_no, &amp;$cart)
     } else {
         // read header data from first document
         $myrow = get_customer_trans($trans_no[0],$doc_type);
+        $debtor_no = $myrow[&#039;debtor_no&#039;];
         if (count_array($trans_no)&gt;1)
             $cart-&gt;trans_no = get_customer_trans_version($doc_type, $trans_no);
         else
@@ -238,7 +239,7 @@ function read_sales_trans($doc_type, $trans_no, &amp;$cart)
 
         $cart-&gt;set_sales_type($myrow[&quot;tpe&quot;], $myrow[&quot;sales_type&quot;], $myrow[&quot;tax_included&quot;],0);
 
-        $cart-&gt;set_customer($myrow[&quot;debtor_no&quot;], $myrow[&quot;DebtorName&quot;],
+        $cart-&gt;set_customer($debtor_no, $myrow[&quot;DebtorName&quot;],
             $myrow[&quot;curr_code&quot;], $myrow[&quot;discount&quot;], $myrow[&quot;payment_terms&quot;]);
 
         $cart-&gt;set_branch($myrow[&quot;branch_code&quot;], $myrow[&quot;tax_group_id&quot;],
@@ -279,7 +280,7 @@ function read_sales_trans($doc_type, $trans_no, &amp;$cart)
                     @$myrow[&quot;src_id&quot;]);
             }
         }
-        $cart-&gt;prepayments = get_payments_for($trans_no, $doc_type, $myrow[&quot;debtor_no&quot;]);
+        $cart-&gt;prepayments = get_payments_for($trans_no, $doc_type, $debtor_no);
 
     } // !newdoc
 
diff --git a/core/sales/includes/ui/sales_order_ui.inc b/core/sales/includes/ui/sales_order_ui.inc
index babf8f2..7172dff 100644
--- a/core/sales/includes/ui/sales_order_ui.inc
+++ b/core/sales/includes/ui/sales_order_ui.inc
@@ -400,7 +400,7 @@ function display_order_header(&amp;$order, $editable, $date_text)
     if (($order-&gt;pos[&#039;cash_sale&#039;] || $order-&gt;pos[&#039;credit_sale&#039;]) 
         &amp;&amp; !$order-&gt;is_started()) {
          // editable payment type 
-        if (get_post(&#039;payment&#039;) !== $order-&gt;payment) {
+        if (isset($_POST[&#039;payment&#039;]) &amp;&amp; $_POST[&#039;payment&#039;] !== $order-&gt;payment) {
             $order-&gt;payment = get_post(&#039;payment&#039;);
             $order-&gt;payment_terms = get_payment_terms($order-&gt;payment);
             $order-&gt;due_date = get_invoice_duedate($order-&gt;payment, $order-&gt;document_date);</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Braath Waate]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=41493</uri>
			</author>
			<updated>2020-08-03T00:38:27Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=37913#p37913</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: PHP 7.4 bug]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=37774#p37774" />
			<content type="html"><![CDATA[<p>@itronics <a href="https://github.com/FrontAccountingERP/FA/commit/fe984d19a32486bb72c6489fab3bd26a2dd3b3f2">commit</a> should fix it.</p>]]></content>
			<author>
				<name><![CDATA[apmuthu]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=364</uri>
			</author>
			<updated>2020-07-10T14:32:38Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=37774#p37774</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: PHP 7.4 bug]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=37752#p37752" />
			<content type="html"><![CDATA[<p>Some of the compatibility problems have now been fixed and committed to 2.4.8 stable repo.</p><p>The following compatibility bugs still remains for fixing:<br /></p><div class="codebox"><pre><code>Function get_magic_quotes_gpc() is deprecated in file: C:\wamp3\www\account24\includes\session.inc at line 315

implode(): Passing glue string after array is deprecated. Swap the parameters in file: C:\wamp3\www\account24\includes\ui\ui_lists.inc at line 161

Trying to access array offset on value of type null in file: C:\wamp3\www\account24\reporting\includes\tcpdf.php at line 1127

chr() expects parameter 1 to be int, string given in file: C:\wamp3\www\account24\reporting\includes\tcpdf.php at line 3525</code></pre></div><p>Joe</p>]]></content>
			<author>
				<name><![CDATA[joe]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=3</uri>
			</author>
			<updated>2020-07-04T13:00:32Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=37752#p37752</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: PHP 7.4 bug]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=37748#p37748" />
			<content type="html"><![CDATA[<p>This is good reporting. Let us continue to use this thread for new php version problems.</p><p>I will occasionally try to fix the problems with backward compatibility.</p><p>Joe</p>]]></content>
			<author>
				<name><![CDATA[joe]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=3</uri>
			</author>
			<updated>2020-07-04T07:13:13Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=37748#p37748</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: PHP 7.4 bug]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=37743#p37743" />
			<content type="html"><![CDATA[<p>Please try the attached fix on both PHP 7.4 and PHP5.x as well.</p><p>@joe: please verify and take in the fix into the core ensuring backwards compatibility.</p>]]></content>
			<author>
				<name><![CDATA[apmuthu]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=364</uri>
			</author>
			<updated>2020-07-04T05:20:24Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=37743#p37743</id>
		</entry>
</feed>
