Forums / Upgrading to 1.5.x / Can't upgrade database doing upgrade from 1.5.1 to 1.5.4

Can't upgrade database doing upgrade from 1.5.1 to 1.5.4

Views: 2,500

Results 1 to 3 of 3
27 Mar 2015, 12:57 PM
#1
blueskyhigh avatar

blueskyhigh

New Zenner

Join Date:
Dec 2005
Posts:
8
Plugin Contributions:
0

Can't upgrade database doing upgrade from 1.5.1 to 1.5.4

Problem - When running the installer I get to the point where it wants to step thru the three database upgrades
1.5.1 to 1.5.2
1.5.2 to 1.5.3
1.5.3 to 1.5.4
But when I select upgrade database it wont accept my verified correct admin backend username and password.
Server is using PHP 5.5

I am not yet upgrading the live system which lives in a directory called "shop"

THE PROCESS SO FAR...
I created a new test shop directory called "shoptest".
I backed up the original "shop" fileset and database.
I created a new database for the new "shoptest" test site.
I successfully imported the backed up 1.5.1 DB into the new database created for the "shoptest" test site.
I used DiffMerge to compare the backed up 1.5.1 version "shop" fileset with the latest 1.5.4 version fileset.
I incorporated necessary changes into the new 1.5.4 file set.
I added additional files for the template I use and shipping modules etc from the 1.5.1 fileset to the new 1.5.4 fileset (compatible).
I checked and double checked I hadn't missed anything.
I then copied the new customized 1.5.4 version fileset with additional files to the new "shoptest" directory on the server.
I edited the two configure.php files as required and checked directory permissions were correct.

I run the zc_install/index.php. It runs correctly and sees everything.
It returns a page full of green ticks. All looks okay.
I select upgrade database.
The correct screen appears showing three upgrade steps required:

  • Upgrade DB from 1.5.1 to 1.5.2
  • Upgrade DB from 1.5.2 to 1.5.3
  • Upgrade DB from 1.5.3 to 1.5.4
    I enter the verified correct shop admin username from the original site but get the error:

"X Admin Password required to proceed with upgrade more info..."

I have checked everything in the universe and cannot figure this out. After two days trying I'm fading!!

Any help or ideas appreciated!

28 Mar 2015, 10:52 AM
#2
blueskyhigh avatar

blueskyhigh

New Zenner

Join Date:
Dec 2005
Posts:
8
Plugin Contributions:
0

Re: Can't upgrade database doing upgrade from 1.5.1 to 1.5.4

Problem solved. For others here's what happened and some thoughts...

We had installed the new adjusted 1.5.4 file set to a new directory on the server using a new database to check all our edits carried across from the 1.5.1 version to the 1.5.4 version file set... so we could verify and test.

On our live site we use an SSL certificate. The reason we couldn't update the DB while running the install routine (upgrade) was because we had some errors in the configure.php files which prevented us logging in to change the admin password. An unusual requirement when going from 1.5.1 to 1.5.4 and perhaps other versions. (I do think some greater emphasis on this requirement up front would have better prepared us).

So... to upgrade from 1.5.1 to 1.5.4 you need to update the store administrator password after you have upgraded the files, but before you run the zc_install routine which does the DB upgrade. Without doing this you get the notorious database update password error.

Before you login to the 1.5.4 version to change the password, you need to rename the zc_install directory to something else i.e. temp_zc_install. Also, because we were "upgrading"... our admin directory in the new files had been given its cryptic name the live site uses; you also need to rename this back to admin. You can then login to the 1.5.4 files admin area, despite the fact you haven't upgraded the database to 1.5.4.

In our case, once we corrected the configure.php files we were able to log into the 1.5.4 version of the test website (as I mentioned this logging in works even though you have not yet upgraded the database from 1.5.1 to 1.5.4). Once logged in it prompted us to change the password on logging in. We did this then logged off.

We then renamed the temp_zc_install dir back to zc_install and ran the install routine taking the database upgrade path. "This" time, our newly changed admin password worked and the database updated correctly, the process then completing.

FWIW - The upgrade process...

  • comparing your existing file set with the new version file set,
  • then carefully incorporating changes you and modules you'd installed had made in the existing site into files in the new site,
  • followed by adding to the new version file set all the files from your template and modules
  • then double checking (in our case that we had all the edits right but missed a few files needing copying)
    Is time consuming and tiring, but it works and is not as hard as it seems, just time consuming, it takes a day. It's the first time we've done this, previously we did fresh installs and reloaded products. I was quite pleased.

An unexpected benefit of the pain of this upgrade process is that it refamiliarises you with your site and how it works and you gain greater confidence in zencart. Hope this is helpful to others.

2 Apr 2015, 12:38 PM
#3
reetp avatar

reetp

New Zenner

Join Date:
Nov 2008
Posts:
46
Plugin Contributions:
0

Re: Can't upgrade database doing upgrade from 1.5.1 to 1.5.4

I tried this, and other solutions. Wasted a whole day on it, and all of this morning. I tried new databases, and importing the old, and every other solution I could find here with no joy.

Eventually I stepped it through a debugger and found that the password check was failing but I could not see why.

The answer is in zc_install/functions/general.php

  function zen_validate_password($plain, $encrypted) {

    if (!zen_not_null($plain) || !zen_not_null($encrypted)) {
      return false;
    }

    if (strpos($encrypted, '$2y$') === 0) {
      return zcPassword::getInstance(PHP_VERSION)->validatePassword($plain, $encrypted);
    }

    $stack = explode(':', $encrypted);
    if (sizeof($stack) == 2) {
      return (md5($stack[1] . $plain) == $stack[0]);
    }

    return false;
  }

The actual line that fails is the password test on line 498

return (md5($stack[1] . $plain) == $stack[0]);

Following the method above, I installed 1.5.4. Logged in as admin. Set new password. Tried upgrade. Failed

I then tried a manual test of this with the passwords copied out of the debugger.

<?php

$plain = "abcd1234";
$encrypted = "42f389b2fd2b940226f62902200f1bb3d7c6d8a51ed6c108764a7bcda66bbe13:0bc48938797c1c45dd59b268898b9e5f66186dc590412d6566715f40784bafbd";

$stack = explode(':', $encrypted);
if (sizeof($stack) == 2) {
	//return (md5($stack[1] . $plain) == $stack[0]);
	if (md5($stack[1] . $plain) == $stack[0]) {
		print "Pass";
	}
	else {
		print "Fail";
	}
}

?>

So I then took a sledgehammer to the code as follows :

:bangin:

zc_install_/includes/classes/installer.php

@@ -709,11 +709,11 @@
 //@TODO: deal with super-user requirement and expired-passwords?
         $sql = "select admin_id, admin_name, admin_pass from " . $prefix . "admin where admin_name = '" . $this->db->prepareInput($admin_name) . "'";
         $result = $this->db->Execute($sql);
-        if ($result->EOF || $admin_name != $result->fields['admin_name'] || !zen_validate_password($admin_pass, $result->fields['admin_pass'])) {
-          $this->setError(ERROR_TEXT_ADMIN_PWD_REQUIRED, ERROR_CODE_ADMIN_PWD_REQUIRED, true);
-        } else {
+//        if ($result->EOF || $admin_name != $result->fields['admin_name'] || !zen_validate_password($admin_pass, $result->fields['admin_pass'])) {
+//          $this->setError(ERROR_TEXT_ADMIN_PWD_REQUIRED, ERROR_CODE_ADMIN_PWD_REQUIRED, true);
+//        } else {
           $this->candidateSuperuser = $result->fields['admin_id'];
-        }
+//        }
         $this->db->Close();
       }
     }

This basically removes the password check and assumes that your password is OK.

There is clearly some issue but I have no idea what. I am no coder - but I can work my way through stuff slowly. I hope someone has a look at this for a fix, or at least it is useful to someone.

I may and try running it with the old admin password in 1.5.1 format and see what that comes up with.
:cheers:

B. Rgds
John