Page 1 of 13

2.2.0.0 Upgrade Script Improvements by Qphoria - TEST PLEASE

Posted: Wed Mar 23, 2016 4:19 am
by Qphoria
UPGRADE FOR 2.2.0.0 ONLY! DO NOT USE ON FUTURE VERSIONS.
FUTURE VERSIONS WILL ALREADY HAVE THESE FIXES PLUS MORE!



Ok I'm trying to improve the upgrade script for 2.2.x and going forward. I've tweaked some things to improve memory usage, clean up old ocmod files, etc. So please test when you can and report any issues you have with it.

How to use:
This package should replace the existing "install" folder from 2.2.0.0 when you first unzip.
1. Download the OpenCart 2.2.0.0 zip file (do not use this script for any other version. Newer versions may already have updated versions of the upgrade script.)
2. Upload all files and folders from inside the "upload" folder to your server EXCEPT for the "install" folder. Overwrite the existing files on your server. You do not need any file outside of the upload folder.
3. Download my upgrade package from the bottom of this post
4. Upload the "install" folder within to the root of your store. The same place you uploaded admin, catalog, etc
5. Run the upgrade script by going to

Code: Select all

http://<yoursite.com>/install
6. After upgrade, login to your admin and goto User Groups and edit the Top Administrator and check all boxes so that you have permissions to access the new files.

It should support any version from 1.5.0 or later
You should be able to run it multiple times without error.
The first patch file (1000.php) will take the longest as that is where the dynamic database parsing script is and that can take a long time. Feel free to run the upgrade script a few times. It should be fine to run multiple times.
Common Errors and Solutions:
"Allowed memory size of xxxxxx bytes exhausted"
This means your server memory is lower than it needs to process the upgrade. This usually happens on the first patch file (1000.php) because it has a lot to do.
Possible solutions:
- Edit the install/php.ini file and change memory_limit = 512M; to memory_limit = 1024M;
- Create a "disabled" folder in install/model/upgrade. Move all upgrade scripts except for 1000.php into the disabled folder. Now edit the install/opencart.sql file and split it up into 4 or more smaller chunks of total steps. Keep a copy of the remaining steps and add small chunks to the opencart.sql file, save to your server and rerun the upgrade script multiple times, pasting and overwriting a new chunk from the remaining sql code until you finish it all. You may need to try a few times how many lines your server can handle at a time. Then on the last batch, restore the other upgrade script files back to the install/model/upgrade folder and let the upgrade run all patch files.
"select ..... returns more than one record"
I've seen this on sites that have multilingual url alias mods. The core script doesn't expect this and searches based on the query. If you have multiple languages it will return more than one record for url alias and choke. Install the updated 3rd party mod for multiple language url alias to satisfy the requirement. Or delete the language_id column from the url_alias table manually.

Things to expect after upgrade:
- 3rd party modules from 1.5.x to 2.x should be automatically disabled to avoid errors. "Modules" are the blocks on your store front. Basically any module found that has a "position" value but isn't one of the core modules will be set to a status of 0
- 3rd party extension from previous versions MAY NOT WORK. If coming from 1.5.x to 2.x you will see an error like "Indirect modification of data.... blah blah". That means that module needs to be updated for 2.x
- Your custom theme WIL NOT WORK. The upgrade script forces you back to the default theme so that you can limit your downtime.
- ocmods will be cleared and disabled. You will want to check that the scripts that are installed are valid for 2.2.x before reactivating them.
- vQmod will need to be updated to the latest (2.6.1 or later). You will also likely want to move your vqmod/xml scripts into a subfolder called "disabled" to prevent incompatible scripts from running after vQmod is reinstalled. Don't forget after uploading the new vQmod files, goto

Code: Select all

http://<yoursite.com>/vqmod/install
to run the vQmod installer.
- Your site should look like the default opencart theme with your products and data.
Please post any errors not shown here so that we can try to mitigate them in future updates.

Re: 2.2.0.0 Upgrade Script Improvements by Qphoria - TEST PL

Posted: Wed Mar 23, 2016 7:59 am
by JNeuhoff
Good to see progress as regards upgrade scripts.

I recently tested the upgrade before you released this patch, and I was quite amazed to see that by and large it went quite smoothly. The upgrade I did was from 2.1.0.2 to 2.2.0.0. My old 2.1.0.2 site had loads of extensions using the Override Engine and Integrated VQmod. I used the following steps:
  • Create a copy of the 2.1.0.2 database
  • copy the 2.1.0.2 files and the 3rd party extension files to a new test site
  • upgrade the config.php and .htaccess files for the new test site and for the copied database
  • upload all the 2.2.0.0 files to the new test site, overwriting the old 2.1.0.2 files
  • upload a matching 2.2.0.0 Override Engine to the new test site
  • upload a matching 2.2.0.0 Integrated VQmod to the new test site
  • clear the system/storage/modification and system/storage/cache
  • run the upgrade script from <newsite>/install
  • go into new sites admin backend and re-save the System > Settings > store
  • rename the folders in catalog/language using something like 'fr-FR', 'de', 'es' etc, also add images by same name e.g. 'fr-fr.png', 'de.png', 'es.png' etc, Adjust 'oc_language' DB table accordingly via PHPMyAdmin (the fields locale, image, directory aren't being used any more by the new OpenCart
  • test and upgrade any other 3rd party extension, one by one, to make sure they all work
  • do some bugfixes to the 2.2.0.0 new site (genuine Opencart 2.2.0.0 bugs, nothing to do with upgrade)
Not quite for the faint-hearted, but I hope it will help some to give it go.

Re: 2.2.0.0 Upgrade Script Improvements by Qphoria - TEST PL

Posted: Wed Mar 23, 2016 12:29 pm
by Qphoria
Great to hear! And a good list of steps for moving to a fresh setup with the old database.

You bring up a good point of note, and you probably ran into this as well...
If you move your database to a new site, but not the 3rd party extension files, you will likely see an error on the catalog side like "cannot load route total/custom_total" or something like that because the files for the 3rd party module no longer exist.

One thing I added back in 1.4.x was auto-cleanup of extensions that were installed in the database. If the main admin file didn't exist, it would self-delete the extension record from the database. So I would note that if you do copy your database to a "fresh" location. Be sure you visit each of the extension pages in the admin (module, shipping, payment, order total) to force the database to self-clean any non-existent left over mods still in the database.

Re: 2.2.0.0 Upgrade Script Improvements by Qphoria - TEST PL

Posted: Wed Mar 23, 2016 5:38 pm
by JNeuhoff
Qphoria wrote:Great to hear! And a good list of steps for moving to a fresh setup with the old database.

You bring up a good point of note, and you probably ran into this as well...
If you move your database to a new site, but not the 3rd party extension files, you will likely see an error on the catalog side like "cannot load route total/custom_total" or something like that because the files for the 3rd party module no longer exist.
Good point. I moved the 3rd party extension files, too, so never ran into this issue. I have now updated my previous post on this.

Re: 2.2.0.0 Upgrade Script Improvements by Qphoria - TEST PL

Posted: Wed Mar 23, 2016 10:30 pm
by dmsims
Q

thank you for your efforts with this ( despite Daniel's incorrect assertion that 2.2.0.0 upgrade works!)

I can confirm that following your procedure I successfully upgraded a fairly complex 1.5.5.1 store

Sorting out all the VQmods and modules that require upgrading will take a bit longer!

thanks again

Re: 2.2.0.0 Upgrade Script Improvements by Qphoria - TEST PL

Posted: Thu Mar 24, 2016 1:36 am
by shbakawy
hi
i have test this script on localhost to upgrade from 2.0.3.1 to 2.2 but it is not work for me
this error is appear during Upgrade Progress
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data OK
Fatal error: Maximum execution time of 30 seconds exceeded in C:\xampp\htdocs\testcart\system\library\db\mysqli.php on line 18
i hope to find solution for it

regards

Re: 2.2.0.0 Upgrade Script Improvements by Qphoria - TEST PL

Posted: Thu Mar 24, 2016 2:55 am
by dmsims
Find xampp\phpMyAdmin\libraries\config.default.php

Increase this value

$cfg['ExecTimeLimit'] = 300;

Re: 2.2.0.0 Upgrade Script Improvements by Qphoria - TEST PL

Posted: Thu Mar 24, 2016 5:46 am
by shbakawy
i have tried your method but still not work
does there any solution for this problem?

Re: 2.2.0.0 Upgrade Script Improvements by Qphoria - TEST PL

Posted: Thu Mar 24, 2016 4:17 pm
by macmac
Hi i have tested you methods and when i try to log into the admin i have this error.
Can you help me please?

Notice: Error: Could not load template /data/www/testrange.net/subdomains/neuco/html/admin/view/template/common/header! in /data/www/testrange.net/subdomains/neuco/html/system/modification/system/engine/loader.php on line 90

Re: 2.2.0.0 Upgrade Script Improvements by Qphoria - TEST PL

Posted: Thu Mar 24, 2016 9:59 pm
by Qphoria
macmac wrote:Hi i have tested you methods and when i try to log into the admin i have this error.
Can you help me please?

Notice: Error: Could not load template /data/www/testrange.net/subdomains/neuco/html/admin/view/template/common/header! in /data/www/testrange.net/subdomains/neuco/html/system/modification/system/engine/loader.php on line 90
Hmm this should have been cleared during upgrade
Manually go into your
system/modification
or
system/storage/modification
folder and delete everything but the index.html file

That "should" fix it.

Re: 2.2.0.0 Upgrade Script Improvements by Qphoria - TEST PL

Posted: Thu Mar 24, 2016 10:00 pm
by Qphoria
shbakawy wrote:i have tried your method but still not work
does there any solution for this problem?
When you make that change, be sure you restart xampp. That is a server configuration timeout issue and xampp should never have set it to 30 to begin with. Localhosts should be set to 2 minutes at least.

Re: 2.2.0.0 Upgrade Script Improvements by Qphoria - TEST PL

Posted: Fri Mar 25, 2016 12:46 am
by exit15
I have an active store with Version 2.0.3.1 and 50K products. I really want to try this...
What do you recommend?
1. Making a test copy of the store and trying the upgrade there (copying all the images, changing the config files..)
2. Make a full backup of code and DB and run your script (roll back if it fails)
I don't mind an hour downtime in the middle of the night.

Re: 2.2.0.0 Upgrade Script Improvements by Qphoria - TEST PL

Posted: Fri Mar 25, 2016 2:09 am
by kirkhall
exit15 wrote:[..]
1. Making a test copy of the store and trying the upgrade there (copying all the images, changing the config files..)
[..].
I would do your #1. It's a pain but if you do it on a live store and things go wrong you might be down way more than an hour in the middle of the night.

Re: 2.2.0.0 Upgrade Script Improvements by Qphoria - TEST PL

Posted: Fri Mar 25, 2016 4:58 am
by OSWorX
exit15 wrote:I have an active store with Version 2.0.3.1 and 50K products. I really want to try this...
What do you recommend?
1. Making a test copy of the store and trying the upgrade there (copying all the images, changing the config files..)
2. Make a full backup of code and DB and run your script (roll back if it fails)
I don't mind an hour downtime in the middle of the night.
Basically NEVER play with your 'working' live shop - Never!
Therefore option #1 should be your choice - and should be done by everyone, always.

If everything is okay, you have now 2 options:

A. use the 'new' testshop now as your live shop
B. upgrade the liveshop same way as you did before (and let the second 'testshop' as future playground)

Re: 2.2.0.0 Upgrade Script Improvements by Qphoria - TEST PL

Posted: Fri Mar 25, 2016 5:17 am
by pm-netti
Delete of modification files is not work versions 2.0.x.
install/index.php line 21:

Code: Select all

define('DIR_MODIFICATION', DIR_SYSTEM . 'storage/modification/');
This change to file 1006.php is work:

Code: Select all

       if(is_dir(DIR_SYSTEM . 'modification/')){
        	$dir_modification = DIR_SYSTEM . 'modification/';
        } else {
        	$dir_modification = DIR_MODIFICATION;
        }
			$files = array();

			// Make path into an array
			$path = array($dir_modification . '*');

			// While the path array is still populated keep looping through
			while (count($path) != 0) {
				$next = array_shift($path);

				foreach (glob($next) as $file) {
					// If directory add to path array
					if (is_dir($file)) {
						$path[] = $file . '/*';
					}

					// Add the file to the files to be deleted array
					$files[] = $file;
				}

			// Reverse sort the file array
			rsort($files);

			// Clear all modification files
			foreach ($files as $file) {
				if ($file != $dir_modification . 'index.html') {
					// If file just delete
					if (is_file($file)) {
						@unlink($file);

					// If directory use the remove directory function
					} elseif (is_dir($file)) {
						@rmdir($file);
					}
				}
			}
		}
Ps. This can add conditionals for oc 1.5.x:

Code: Select all

			$files = array();

        if(is_dir($dir_modification . 'system/')){
			// Make path into an array
			$path = array($dir_modification . '*');
                    // script continue.....

Re: 2.2.0.0 Upgrade Script Improvements by Qphoria - TEST PL

Posted: Fri Mar 25, 2016 6:44 pm
by pm-netti
Wheb upgarde eg. from 1.5.6.4 to 2.2, it do this dir modification:

Code: Select all

define('DIR_MODIFICATION', 'C:/MAMP/htdocs/test/b1564/system/modification/');
It should be '....../system/storage/modification/'

How can fix this?

Ps. This "informal" replace to line 42 to file 1006.php fix paths:

Code: Select all

$output = str_replace('system/modification','system/storage/modification',$output);
$output = str_replace('system/upload','system/storage/upload',$output);
$output = str_replace('system/logs','system/storage/logs',$output);
$output = str_replace('system/cache','system/storage/cache',$output);

Re: 2.2.0.0 Upgrade Script Improvements by Qphoria - TEST PL

Posted: Sat Mar 26, 2016 8:11 am
by Qphoria
While it is true that new 2.x installs will point to storage, upgrades don't really need to.

You can technically put it anywhere so I didn't bother to update the config files as it then adds more confusion when you have left over folders like system/logs and system/storage/logs and or system/download and system/storage/download, and trying to explain to people where to find their files. We could add more code to delete those log folders but then you have to worry about file system errors when you get poorly configured web hosts, and moving the files that are currently inside the logs, download, and upload folder to the correct place.. it just isn't worth all the hassle and risk of issue to move them. They will still work fine in their original places.

Re: 2.2.0.0 Upgrade Script Improvements by Qphoria - TEST PL

Posted: Sat Mar 26, 2016 12:05 pm
by godesigns
Thank You!!!! Upgraded a store from 1.5.6.1 to 2.2.0.0 with ease.

Thank you so much.

Gary

Posted: Sat Mar 26, 2016 4:20 pm
by thietbivesinhads
Xin chào bạn, cho mình hỏi bạn có thể giúp mình inbox về thông tin của bạn ko

Cảm ơn bạn

Re: 2.2.0.0 Upgrade Script Improvements by Qphoria - TEST PL

Posted: Sat Mar 26, 2016 5:27 pm
by pm-netti
Qphoria wrote:While it is true that new 2.x installs will point to storage, upgrades don't really need to.

You can technically put it anywhere so I didn't bother to update the config files as it then adds more confusion when you have left over folders like system/logs and system/storage/logs and or system/download and system/storage/download, and trying to explain to people where to find their files. We could add more code to delete those log folders but then you have to worry about file system errors when you get poorly configured web hosts, and moving the files that are currently inside the logs, download, and upload folder to the correct place.. it just isn't worth all the hassle and risk of issue to move them. They will still work fine in their original places.
Ok. But when do upgrade from 1.5.x to 2.2, folders 'system/modification' and 'system/upload' is not found.