Forums / Bug Reports / [Done v1.6.0] Installer database upgrade db-error fails

[Done v1.6.0] Installer database upgrade db-error fails

Locked

Views: 2,062

Results 1 to 10 of 10
This thread is locked. New replies are disabled.
10 Feb 2015, 2:59 PM
#1
jarkko avatar

jarkko

New Zenner

Join Date:
Jan 2013
Posts:
7
Plugin Contributions:
0

[Done v1.6.0] Installer database upgrade db-error fails

From zc_install/includes/classes/installer.php:686

$this->db->Execute($sql) or die("Error in query: $sql".$this->db->ErrorMsg());

But in /includes/classes/db/mysql/query_factory.php no function ErrorMsg() is defined (just checked in 1.54). Apparently ErrorMsg() is only called in the installer-script.

This makes it difficult to debug why Zc_install -> Database Upgrade fails, since it crashes the whole script, and no error messages is displayed.

Tested with 1.53, just checked that 1.54 seems to suffer from same bug.

For reference:
http://www.zen-cart.com/showthread.php?213976-Install-ZC-1-5-3-Call-to-undefined-method-queryFactory

10 Feb 2015, 5:49 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: [Done v1.6.0] Installer database upgrade db-error fails

I've done hundreds of installs and upgrades of v1.5.3 and v1.5.4, and don't recall seeing anything like what you're describing.

Please describe more detail of how exactly I should be able to recreate these symptoms, including server configuration and all alterations to any ZC files.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

11 Feb 2015, 7:07 AM
#3
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: [Done v1.6.0] Installer database upgrade db-error fails

DrByte:

I've done hundreds of installs and upgrades of v1.5.3 and v1.5.4, and don't recall seeing anything like what you're describing.

Please describe more detail of how exactly I should be able to recreate these symptoms, including server configuration and all alterations to any ZC files.

Mind if I add my 2cents worth here? <too bad>

From what I can gather is that if you can somehow force a DB error during the install, the code should produce an error message as to the reason for the error, but because the db->ErrorMsg() isn't defined anywhere it causes a PHP error that stops any further processing.

I'm guessing that this piece of code would rarely (if ever) be triggered because under normal conditions any errors would have been triggered or trapped before it even gets to this part of the code, which means that the ErrorMsg output would be superfluous anyway (probably a left over from old code?).

IOW, it isn't an actual problem, unless perhaps the DB server happens to 'die' at some stage between it's initial test/check and this part of the code.

At least that is my take on things.

Cheers
RodG

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

11 Feb 2015, 1:29 PM
#4
jarkko avatar

jarkko

New Zenner

Join Date:
Jan 2013
Posts:
7
Plugin Contributions:
0

Re: [Done v1.6.0] Installer database upgrade db-error fails

DrByte:

I've done hundreds of installs and upgrades of v1.5.3 and v1.5.4, and don't recall seeing anything like what you're describing.

Please describe more detail of how exactly I should be able to recreate these symptoms, including server configuration and all alterations to any ZC files.

Current

  1. Make a new Zen Cart 1.53 installation
  2. Copy Database from 1.3.9 to this installation, except Admin-table (to recreate the error in the query)
  3. Go to zc_install/index.php
  4. Start doing Database upgrade from 1.39 to 1.53
  5. When you actually try to upgrade the database, you will get HTTP Response 500 - Internal Server error
  6. In logs -folder you will find new zcInstallDEBUG-file with following message:
[10-Feb-2015 16:39:16] PHP Fatal error:  Call to undefined method queryFactory::ErrorMsg() in /var/www/html/zc153/zc_install/includes/classes/installer.php on line 728

Expected

      1. the same
  1. Log message should have the SQL-error to help track down the real problem, eg:
[10-Feb-2015 16:47:44] PHP Fatal error:  1064:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 :: UPDATE admin SET admin_profile = 1 WHERE admin_id =  ==>

Actually I had the Admin table myself, but had some other problem in the old database, for which I needed to write the ErrorMsg to queryFactory class to see the actual error message from MySQL.

11 Feb 2015, 4:17 PM
#5
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: [Done v1.6.0] Installer database upgrade db-error fails

So, this situation is caused by deleting (or not copying over) the admin table?

(I'm not disagreeing that ErrorMsg() is missing. But if it's even being triggered at all, there's a more important issue to handle, thus my many questions.)

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

11 Feb 2015, 4:48 PM
#6
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: [Done v1.6.0] Installer database upgrade db-error fails

Jarkko:

Current

  1. Make a new Zen Cart 1.53 installation
  2. Copy Database from 1.3.9 to this installation, except Admin-table (to recreate the error in the query)
  3. Go to zc_install/index.php
  4. Start doing Database upgrade from 1.39 to 1.53
    Actually, when I delete the admin table, I can't even start the upgrade because the inspection process discovers that there's no admin table when checking whether the various version steps need to be run, and throws a blank screen when it tests whether it needs to pre-check the v150 box. Not even a 500 Internal Server Error. And doesn't trigger ErrorMsg() at all ... just "Call to a member function MoveNext() on boolean".

Further, your first post quoted line 686, but then your SQL query later (UPDATE admin SET admin_profile = 1 WHERE admin_id = ) is from the query on 728.

I'd still like to be able to understand the order of steps which consistently trigger the problem where your admin table is gone.

I toyed with the idea that maybe you had emptied your admin table, but that theory failed too, because you can't even start the upgrade process without providing a valid admin password. So, there had to be a valid admin user in the database already, else you couldn't have started the upgrade, and thus couldn't have triggered the error.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

11 Feb 2015, 5:19 PM
#7
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: [Done v1.6.0] Installer database upgrade db-error fails

Jarkko:

[10-Feb-2015 16:47:44] PHP Fatal error: 1064:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 :: UPDATE admin SET admin_profile = 1 WHERE admin_id = ==>

> **DrByte:**
>
> your SQL query later (UPDATE admin SET admin_profile = 1 WHERE admin_id = ) is from the query on 728.
Still looking at this, the PHP code that builds that query sets "...admin_id = " . (int)$aVariable ... so, even if $aVariable is blank the (int) forces it to become an integer value, thus it would always be "something", not a blank value like your error message reported.

... so that leads me to have to believe your Zen Cart zc_install code has been tampered with.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

11 Feb 2015, 5:27 PM
#8
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: [Done v1.6.0] Installer database upgrade db-error fails

Here's a fix to the "symptom" where ErrorMsg() triggers a crash:

Replace 4 references to $this->db->ErrorMsg() with $this->db->show_error()
3 in /zc_install/includes/classes/installer.php on lines 686, 690, 728
and 1 in /zc_install/includes/modules/pages/store_setup/header_php.php on line 90.

But that's just a bandage because it still doesn't explain HOW you even tripped the problem in the first place ... which is a more important piece of information. Armed with that we could do additional inspections to report potential problems sooner, and avoid even needing to look at error logs.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

12 Feb 2015, 1:06 PM
#9
jarkko avatar

jarkko

New Zenner

Join Date:
Jan 2013
Posts:
7
Plugin Contributions:
0

Re: [Done v1.6.0] Installer database upgrade db-error fails

Hi

Sorry if I misled you, I should have made it clearer that bug wasn't about the failure to update itself, but about the missing ErrorMsg() -function.

Indeed I had tampered the install-script, since I was suffering the "Admin Password required to proceed with upgrade" problem:
http://www.zen-cart.com/showthread.php?215814-Database-Upgrade-Not-Accepting-Password-1-5-3-to-1-5-4

I searched for any information and fixes for that error, and tried some fixes to go past the incorrect Admin Password, but none worked. Then I started to dig in to the code, and made changes to install-script itself, which probably made the SQL fail, and therefore I encountered the error about missing ErrorMsg().

I just thought you might want to fix that missing ErrorMsg() -calls, since it had affected not only me, but also the user for whom thread I referenced in my first post.

12 Feb 2015, 8:00 PM
#10
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: [Done v1.6.0] Installer database upgrade db-error fails

Fixes for the call to ErrorMsg() are being made in v1.6.0.

Thanks for pointing it out.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.