<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[FrontAccounting forum — Two bugs in backup module]]></title>
		<link>https://frontaccounting.com/punbb/viewtopic.php?id=87</link>
		<atom:link href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=87&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Two bugs in backup module.]]></description>
		<lastBuildDate>Wed, 16 Apr 2008 07:37:32 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Two bugs in backup module]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=568#p568</link>
			<description><![CDATA[<p>Please update to version 1.16. I think there was a bug related to this, reported by itronics and he fixed it in 1.16.<br />There are no changes in the database structure between 1.12 and 1.16. Just follow the update.html instructions.</p><p>/Joe</p>]]></description>
			<author><![CDATA[null@example.com (joe)]]></author>
			<pubDate>Wed, 16 Apr 2008 07:37:32 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=568#p568</guid>
		</item>
		<item>
			<title><![CDATA[Re: Two bugs in backup module]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=567#p567</link>
			<description><![CDATA[<p>hi Joe, </p><p>Thank you for the response - i had problems restoring the company still having version 1.12. Somebody told me that script file is inconsistent (data is conflicting with table descriptions - specifically, having NULL values where &quot;NOT NULL&quot; is declaired). </p><p>Is there anything I can do with my backup file? Shall I install later version compatible with 1.12? Or shall I set up the 1.12 and try to import (again) the data there? </p><p>Thank you in advance!!</p>]]></description>
			<author><![CDATA[null@example.com (patsko)]]></author>
			<pubDate>Tue, 15 Apr 2008 21:37:31 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=567#p567</guid>
		</item>
		<item>
			<title><![CDATA[Re: Two bugs in backup module]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=556#p556</link>
			<description><![CDATA[<p>Hello Alexey,<br />The version 1.12 and v2.0 are not compatible. There are changes in the database structure. Therefore you can not restore the backup from v1.12 on the newly installed v2.0. <br />You can, however, run the update_db.php script on the companies if you have installed in the same folder as the 1.12. This should be done before logging into the companies.</p><p>/Joe</p>]]></description>
			<author><![CDATA[null@example.com (joe)]]></author>
			<pubDate>Sun, 13 Apr 2008 20:53:28 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=556#p556</guid>
		</item>
		<item>
			<title><![CDATA[Re: Two bugs in backup module]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=555#p555</link>
			<description><![CDATA[<p>I am sure I have the case related to described in this tread - I made a backup of 0_ company (version 1.12 build 31) and now can not restore it. The database is getting corrupt as result of the restore. </p><p>I have setup v. 2.0 (beta build 22) but the issue remains - can&#039;t restore the backup. </p><p>Is there anything I can do about it? I have damn lots of transactions made, so will hate the idea of manual re-work. </p><p>Please help!</p><p>regarsd, <br />Alexey</p>]]></description>
			<author><![CDATA[null@example.com (patsko)]]></author>
			<pubDate>Sun, 13 Apr 2008 17:43:45 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=555#p555</guid>
		</item>
		<item>
			<title><![CDATA[Re: Two bugs in backup module]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=267#p267</link>
			<description><![CDATA[<p>Fixed in the CVS repository at Sourceforge. Thanks janusz.</p><p>/Joe</p>]]></description>
			<author><![CDATA[null@example.com (joe)]]></author>
			<pubDate>Sun, 30 Dec 2007 23:44:29 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=267#p267</guid>
		</item>
		<item>
			<title><![CDATA[Re: Two bugs in backup module]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=266#p266</link>
			<description><![CDATA[<p>Hi joe<br />I double checked the problem and found that you are partially right.<br />If the backup tool is used on account with any standard prefix or to install fresh new company from reference files (sql statements with prefix 0_)&nbsp; all is correct. </p><p>But the problem exists. If you are logged on account with no prefix db_export() makes backup file for the whole database (all table sets). And here problems described in my earlier posts arise.</p><p>Below is new patch which remove this issue. One issue still exists, but must be changed in report generator module. database xx_reports is backed up only for user which has empty prefix.</p><p>Regards<br />janusz</p><br /><br /><p>--- /var/www/frontaccounting/admin/db/maintenance_db.inc&nbsp; &nbsp; 2007-10-01 10:13:28.000000000 +0200<br />+++ /var/www/fa/admin/db/maintenance_db.inc&nbsp; &nbsp; 2007-12-30 13:20:45.000000000 +0100<br />@@ -126,7 +126,6 @@<br /> &nbsp; &nbsp; &nbsp; &nbsp; $line = trim($line);</p><p> &nbsp; &nbsp; &nbsp; &nbsp; $line = str_replace(&quot;0_&quot;, $connection[&quot;tbpref&quot;], $line);<br />-&nbsp; &nbsp; &nbsp; &nbsp; $line = str_replace(&quot;Y_&quot;, &quot;0_&quot;, $line);<br /> &nbsp; &nbsp; &nbsp; &nbsp; // the last line did not belong to a &#039;create&#039; sql query<br /> &nbsp; &nbsp; &nbsp; &nbsp; if (!$table) <br /> &nbsp; &nbsp; &nbsp; &nbsp; {<br />@@ -321,7 +320,8 @@<br />&nbsp; &nbsp; &nbsp;$all_tables = array();<br />&nbsp; &nbsp; &nbsp;while($row = db_fetch($res)) <br />&nbsp; &nbsp; &nbsp;{<br />-&nbsp; &nbsp; &nbsp; &nbsp; if ($conn[&quot;tbpref&quot;] == &quot;&quot; || strpos($row[&#039;Name&#039;], $conn[&quot;tbpref&quot;]) !== false)<br />+&nbsp; &nbsp; &nbsp; &nbsp; if (($conn[&quot;tbpref&quot;] == &#039;&#039; &amp;&amp; !preg_match(&#039;/[0-9]+_/&#039;, $row[&#039;Name&#039;]))<br />+&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; || ($conn[&quot;tbpref&quot;] != &#039;&#039; &amp;&amp; strpos($row[&#039;Name&#039;], $conn[&quot;tbpref&quot;]) !== false))<br />&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; $all_tables[] = $row;<br />&nbsp; &nbsp; &nbsp;}</p>]]></description>
			<author><![CDATA[null@example.com (itronics)]]></author>
			<pubDate>Sun, 30 Dec 2007 12:32:08 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=266#p266</guid>
		</item>
		<item>
			<title><![CDATA[Re: Two bugs in backup module]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=263#p263</link>
			<description><![CDATA[<p>Hello again janusz,<br />I&#039;m not sure if I understand your answer.<br />When you choose the backup/restore in the setup tab, only the current company is backed up. If this company has a table prefix of 0_, the backup file will show up as: dbname_0_Ymd_Hi.sql, where dbname is the name of the database, _0 is the table prefix. It is important that you select the correct sql file with the correct table prefix when you later restore this file on the company.<br />If there is no table prefix the backup file will show: dbname_Ymd_Hi.sql. In this case you would chose the correct dbname when restoring.<br />String replacing a 0_ with 0_ will result in 0_<br />String replacing a 0_ with an empty string will result in an empty string (no table prefix).<br />The only cases that the str_replace line will be executed are when you replace a 0_ with 0_. (backup/restore), and when creating a new company. It will either replace the 0_ with the selected table prefix or an empty string if no prefixes.</p><p>So I really see no problem here if you take these precautions when restoring the databases.</p><p>/Joe</p>]]></description>
			<author><![CDATA[null@example.com (joe)]]></author>
			<pubDate>Sun, 30 Dec 2007 00:09:33 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=263#p263</guid>
		</item>
		<item>
			<title><![CDATA[Re: Two bugs in backup module]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=259#p259</link>
			<description><![CDATA[<p>Hello&nbsp; joe<br />May be my previous post was not clear, but sorry - english is not my native language. I&#039;ll try again.<br /></p><div class="quotebox"><cite>joe wrote:</cite><blockquote><p>#2. A temporarily fix to the Report Generator is to limit the access to Admins only.</p></blockquote></div><p>Yes, it is. This suggests backup of whole database in a manner which makes possible restoring all table sets for all companies from admin generated sql file. But:<br />1. db_import() function doesn&#039;t restore 0_ prefix.<br />2. what about such case:&nbsp; you have in database 2 sets of tables for 2 companies with prefixes: 0_, 1_ . Assuming you are logged on admin account with &#039;1_&#039; prefix, after export you have sql backup file with&nbsp; statements creating table sets with prefixes: &#039;1_&#039; and &#039;1_&#039; (once again). How will look your database after restoring from such backup file? Answer: as before restore operation, or worse - dataset &#039;1_&#039; will be updated with &#039;0_&#039;.</p><br /><div class="quotebox"><cite>joe wrote:</cite><blockquote><p>The problem here is that all the various chart of accounts have been implemented with this 0_ prefix. What do you say to this? When we have solved this we can update the CVS repository.</p></blockquote></div><p>This is no problem. If you want to use backup module to make &#039;reference&#039; sql files on development system - you can. Play with database with only one table set with prefix &#039;0_&#039;, logging from its account. Then none prefix substitution is necessary. </p><div class="quotebox"><cite>joe wrote:</cite><blockquote><p>Again, did you see my answer to your PDF presentation? If we are sure about that we can include this also.</p></blockquote></div><p>I&#039;ve answered in that thread.</p><p>Regards<br />janusz</p>]]></description>
			<author><![CDATA[null@example.com (itronics)]]></author>
			<pubDate>Sat, 29 Dec 2007 19:03:53 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=259#p259</guid>
		</item>
		<item>
			<title><![CDATA[Re: Two bugs in backup module]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=255#p255</link>
			<description><![CDATA[<p>Thank you Janusz for your help.<br />#1 is ok. Will be fixed asap.<br />#2. A temporarily fix to the Report Generator is to limit the access to Admins only. Page_security 15. I think the second str_replace line was mistakenly implemented during development of the Report Generator. It is not neccessary. But the first line with str_replace with replacement of 0_ to currentry table-pref is neccessary due to importing new chart of accounts when creating new companies. These charts have a prefix of 0_. It shouldn&#039;t create any troubles at least as I see it. If it does, we have to find another way of adding the table-prefixes into the tables. The problem here is that all the various chart of accounts have been implemented with this 0_ prefix. What do you say to this? When we have solved this we can update the CVS repository.<br />Again, did you see my answer to your PDF presentation? If we are sure about that we can include this also.</p><p>Kind regards<br />Joe</p>]]></description>
			<author><![CDATA[null@example.com (joe)]]></author>
			<pubDate>Sat, 29 Dec 2007 16:35:00 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=255#p255</guid>
		</item>
		<item>
			<title><![CDATA[Re: Two bugs in backup module]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=253#p253</link>
			<description><![CDATA[<p>Hi joe<br />Ad 1. Diff folows.</p><p>Ad 2. Nope. Report generator stores all reports (for all users and all companies) in one MySQL table xx_reports. This is not good solution, because all users has access to all other company data via &#039;Test the SQL statement&#039; button. This is serious security issue.</p><p>On the other way if backup system is available for Admins only this implies backing up whole database, not only for one company. In one database can coexist table sets with 0_, 1_ etc prefixes and with no prefix at all. So why the code changes only tables with prefix 0_, but the others are backed up with table names leaved intact?</p><p>So is the diff:</p><p>--- /var/www/frontaccounting/admin/db/maintenance_db.inc&nbsp; &nbsp; 2007-10-01 10:13:28.000000000 +0200<br />+++ /var/www/fa/admin/db/maintenance_db.inc&nbsp; &nbsp; 2007-12-27 21:36:05.000000000 +0100<br />@@ -125,8 +125,8 @@<br /> &nbsp; &nbsp; {<br /> &nbsp; &nbsp; &nbsp; &nbsp; $line = trim($line);</p><p>-&nbsp; &nbsp; &nbsp; &nbsp; $line = str_replace(&quot;0_&quot;, $connection[&quot;tbpref&quot;], $line);<br />-&nbsp; &nbsp; &nbsp; &nbsp; $line = str_replace(&quot;Y_&quot;, &quot;0_&quot;, $line);<br />+//&nbsp; &nbsp; &nbsp; &nbsp; $line = str_replace(&quot;0_&quot;, $connection[&quot;tbpref&quot;], $line);<br />+//&nbsp; &nbsp; &nbsp; &nbsp; $line = str_replace(&quot;Y_&quot;, &quot;0_&quot;, $line);<br /> &nbsp; &nbsp; &nbsp; &nbsp; // the last line did not belong to a &#039;create&#039; sql query<br /> &nbsp; &nbsp; &nbsp; &nbsp; if (!$table) <br /> &nbsp; &nbsp; &nbsp; &nbsp; {<br />@@ -397,7 +397,7 @@<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for ($k = 0; $k &lt; $nf = db_num_fields($res2); $k++) <br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // identify null values and save them as null instead of &#039;&#039;<br />-&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ($field_type[$k] != &quot;&quot; &amp;&amp; $row2[$k] == &quot;&quot;) <br />+&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ($field_type[$k] != &quot;&quot; &amp;&amp; $field_type[$k] != &quot;NO&quot; &amp;&amp; $row2[$k] == &quot;&quot;) <br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $out .= &quot;NULL&quot;; <br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else <br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $out .= &quot;&#039;&quot; . db_escape($row2[$k]) . &quot;&#039;&quot;;</p>]]></description>
			<author><![CDATA[null@example.com (itronics)]]></author>
			<pubDate>Sat, 29 Dec 2007 13:47:18 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=253#p253</guid>
		</item>
		<item>
			<title><![CDATA[Re: Two bugs in backup module]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=249#p249</link>
			<description><![CDATA[<p>Hello,<br />Thanks for your contribution. Regarding #1. Do you have a solution to that?<br />Regarding #2. These 2 lines with str_replace() is neccessary. The first line is for empty chart of accounts. They are marked with a 0_ table prefix and are replaces with the current company table prefix. The second line is for the Report Generator SQL file. A table prefix of Y_ should be replaced with the 0_ prefix. Could this be rewritten to work with your test?</p><p>Kind regards<br />Joe</p>]]></description>
			<author><![CDATA[null@example.com (joe)]]></author>
			<pubDate>Fri, 28 Dec 2007 22:47:29 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=249#p249</guid>
		</item>
		<item>
			<title><![CDATA[Two bugs in backup module]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=248#p248</link>
			<description><![CDATA[<p>Hi joe</p><p>I found 2 bugs in admin/db/maintenance_db.inc:</p><p>1. Backup files made on MySQL (as of version 5.0.32) are unusable. This is because of bad interpretation of NULL fields in response of &#039;SHOW COLUMNS xxx&#039; clause at db_export() function. These fields are filled with with &#039;NO&#039; value (not empty field) at least in above MySQL version.</p><p>2. At start of function db_import() there are 2 lines with str_replace() calls which seems to be garbage from any earlier FA version. Anyway with these two lines uncommented database is corrupted after export/import cycle.</p><p>BTW I think available range of backup (all tables vs data for one company) could depend on current user privileges. However this implies separate per user folders.</p><p>PS. If you want I can send diff for above changes.</p><p>janusz</p>]]></description>
			<author><![CDATA[null@example.com (itronics)]]></author>
			<pubDate>Thu, 27 Dec 2007 21:11:02 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=248#p248</guid>
		</item>
	</channel>
</rss>
