Post by Qphoria » Sat Jun 04, 2016 4:19 am

pm-netti wrote:
brik wrote: Question:
I have an upgraded system and a couple of systems installed from scratch. The new installations don't have the file system/library.user.php where did this file come from is it legacy? Is it even being used?
In version 2.2 this is in file system/library/cart/user.php
Ah yea.. good catch.. years of typing the old file paths... now I have to remember to add the new subfolders.

OpenCart 2.0.x Mod Update Info

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by adilbhatofficial » Mon Jun 06, 2016 11:31 pm

For those who are getting this error

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


SOLUTION

1) Open the Xampp control panel
2) Click on 'config' behind 'Apache'
3) Select 'PHP (php.ini)' from the dropdown -> A file should now open in your text editor
4) Press ctrl+f and search for 'max_execution_time', you should fine a line which only says

5) max_execution_time=30
6) Change 30 to a bigger number (180 worked for me), like this:

7) max_execution_time=180
8) Save the file
9) 'Stop' Apache server
10) Close Xampp
11) Restart Xampp
12) 'Start' Apache server
13) Run Continue Button Again
Enjoy ;)


Posts

Joined
Mon Mar 23, 2015 3:08 pm

Post by OSWorX » Mon Jun 06, 2016 11:46 pm

Quite nice, but how many are working locale (XAMPP)???
And what for all those who cannot change the time (because of provider restrictions or not parsing additional *.ini files)?

Image


User avatar
Expert Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by Qphoria » Tue Jun 07, 2016 5:01 am

adilbhatofficial wrote:For those who are getting this error

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
OSWorX wrote:Quite nice, but how many are working locale (XAMPP)???
And what for all those who cannot change the time (because of provider restrictions or not parsing additional *.ini files)?
I do already include an updated php.ini within the install folder that "should" go longer than 30, but as osworks says, only if the server supports that. The work around for that is to "chunk" the opencart.sql file. The longest running, most intensive process is the install/model/upgrade/1000.php file as that file parses the entire database and attempts to reconcile it to match the structure of the opencart.sql file. This is good because it can repair some broken indexes and field types and lengths, but also is quite intensive and tedious so it takes the longest amount of time.

Some work arounds for that:

Work around 1: Local upgrade
1. Backup the database and install to a local wamp install where you have full control. Set the memory and timeout really high.
2. Run the upgrade locally, then export the database to a file.
3. Upload the new files to your live site and import the new database.
4. Remove the install/model/upgrade/1000.php file from your live site's install folder.
5. Run the upgrade on the live site and it will run through the remaining upgrade scripts there to get the config.php file changes and stuff

Work around 2: Chunk the opencart.sql file
1. Create a subfolder called "disabled" in the install/model/upgrade/ folder and move all files except 1000.php into that folder.
2. Edit the install/opencart.sql file and select and cut the majority portion of the file out and paste into another file. Be sure to cut at breakpoints and not in the middle of any sql commands. This will leave only a few table references in the opencart.sql (I usually cut everything after oc_coupon for example).
3. Save the now smaller opencart.sql file and upload back to the server.
4. Run the installer. It should go quick since there are fewer tables to try to parse against.
5. Edit the opencart.sql file again, this time replacing it all with another chunk of data from the place where you pasted it earlier. Cut it from there and paste into opencart.sql. Save it and run the installer again.
6. Do this multiple times until you get all the chunks.
7. After completing the last run. Go back to the install/model/upgrade/disabled folder and move all the files back into the install/model/upgrade folder that they were originally from. This time, move the 1000.php file into that disabled folder so that it doesn't try to run again.
8. Run the upgrade script one more time, this will now run the remaining scripts and complete the upgrade.

It sounds complicated but its not really too bad. I've used it many times when doing upgrades for people with questionable servers.

OpenCart 2.0.x Mod Update Info

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by OSWorX » Tue Jun 07, 2016 4:47 pm

While the proposal form Qphoria may acceptable for 'experienced developers', many of the users are 'not so experienced' (to stay nice ..).
Why not creating something like a 'self calling' script which loads the update commands in chunks by itself (as many other very big projects already doing)?
That should be possible with a few lines of ajax within the lowest possible value of 30 seconds most of the servers are configured actually.

Image


User avatar
Expert Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by SeniorSE » Tue Jun 07, 2016 11:20 pm

Hi everyone. I used the new upgrade script to go from 1.5.5.1 to 2.2.0.0, and it worked great! Except, now I get an error when I try to load the Admin console or the store:

Admin Console

Code: Select all

Fatal error: Uncaught exception 'Exception' with message 'Error: Could not load database adaptor mysqli!' in /home4/onemuga1/public_html/store2/system/library/db.php:11 Stack trace: #0 /home4/onemuga1/public_html/store2/system/framework.php(25): DB->__construct('mysqli', 'localhost', '<deleted>', '<deleted>', 'onemuga1_oc2', '3306') #1 /home4/onemuga1/public_html/store2/admin/index.php(26): require_once('/home4/onemuga1...') #2 {main} thrown in /home4/onemuga1/public_html/store2/system/library/db.php on line 11
Store

Code: Select all

Fatal error: Uncaught exception 'Exception' with message 'Error: Could not load database adaptor mysqli!' in /home4/onemuga1/public_html/store2/system/library/db.php:11 Stack trace: #0 /home4/onemuga1/public_html/store2/system/framework.php(25): DB->__construct('mysqli', 'localhost', '<deleted>', '<deleted>', 'onemuga1_oc2', '3306') #1 /home4/onemuga1/public_html/store2/index.php(26): require_once('/home4/onemuga1...') #2 {main} thrown in /home4/onemuga1/public_html/store2/system/library/db.php on line 11
Any ideas on what needs to be done?

I made copies of the files and made a duplicate of the DB. Then, I changed all the config files to the correct directory and DB name.

Please help...

Newbie

Posts

Joined
Fri Mar 18, 2011 9:46 pm

Post by Qphoria » Wed Jun 08, 2016 1:14 am

SeniorSE wrote:Hi everyone. I used the new upgrade script to go from 1.5.5.1 to 2.2.0.0, and it worked great! Except, now I get an error when I try to load the Admin console or the store:

Admin Console

Code: Select all

Fatal error: Uncaught exception 'Exception' with message 'Error: Could not load database adaptor mysqli!' in /home4/onemuga1/public_html/store2/system/library/db.php:11 Stack trace: #0 /home4/onemuga1/public_html/store2/system/framework.php(25): DB->__construct('mysqli', 'localhost', '<deleted>', '<deleted>', 'onemuga1_oc2', '3306') #1 /home4/onemuga1/public_html/store2/admin/index.php(26): require_once('/home4/onemuga1...') #2 {main} thrown in /home4/onemuga1/public_html/store2/system/library/db.php on line 11
Are you sure you uploaded all files from the oc2200 package? it looks like some files aren't there, namely the system/library/db/mysqli.php file

OpenCart 2.0.x Mod Update Info

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Qphoria » Wed Jun 08, 2016 1:16 am

OSWorX wrote:While the proposal form Qphoria may acceptable for 'experienced developers', many of the users are 'not so experienced' (to stay nice ..).
Why not creating something like a 'self calling' script which loads the update commands in chunks by itself (as many other very big projects already doing)?
That should be possible with a few lines of ajax within the lowest possible value of 30 seconds most of the servers are configured actually.
I made it simple enough to follow.. but you aren't wrong. It should probably be chunked up. But that adds additional tedious work to other steps in the process. Exporting the default sql file from the master release would now need to be manipulated. Perhaps a script that reads that opencart.sql file into smaller temp file chunks and reads those. But there are only so many hours in a day....

OpenCart 2.0.x Mod Update Info

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by SeniorSE » Wed Jun 08, 2016 2:51 am

Qphoria wrote:
Are you sure you uploaded all files from the oc2200 package? it looks like some files aren't there, namely the system/library/db/mysqli.php file
Yes. All the files are there. Could it be a permissions issue? What rights should the files be set at? All the PHP files are set to rw-r--r--.

Thanks.
Mark

Newbie

Posts

Joined
Fri Mar 18, 2011 9:46 pm

Post by Qphoria » Wed Jun 08, 2016 9:31 pm

Check that your host has the mysqli php extension installed. You can probably do this by creating a phpinfo.php file with the following content

Code: Select all

<?php phpinfo(); ?>
and load that in your browser. Then search for mysqli

OpenCart 2.0.x Mod Update Info

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by SeniorSE » Wed Jun 08, 2016 11:54 pm

I just ran the phpinfo(), and mysqli shows up. Please see below for the information.

Code: Select all

mysqli

MysqlI Support	enabled
Client API library version	5.5.42-37.1
Active Persistent Links	0
Inactive Persistent Links	0
Active Links	0
Client API header version	5.5.42-37.1
MYSQLI_SOCKET	/var/lib/mysql/mysql.sock

Directive	Local Value	Master Value
mysqli.allow_local_infile	On	On
mysqli.allow_persistent	On	On
mysqli.default_host	no value	no value
mysqli.default_port	3306	3306
mysqli.default_pw	no value	no value
mysqli.default_socket	/var/lib/mysql/mysql.sock	/var/lib/mysql/mysql.sock
mysqli.default_user	no value	no value
mysqli.max_links	Unlimited	Unlimited
mysqli.max_persistent	Unlimited	Unlimited
mysqli.reconnect	Off	Off

Newbie

Posts

Joined
Fri Mar 18, 2011 9:46 pm

Post by mattslack » Sun Jun 12, 2016 10:05 pm

Hi Qphoria,

Thanks for the good work on this. Worked fine for me going from 2.0.2.0 to 2.2 after previously throwing a JSON unexpected < symbol syntax error at me after step 1 of 8.

Regards,
Matt

Newbie

Posts

Joined
Sun Jun 12, 2016 10:01 pm

Post by labeshops » Fri Jun 17, 2016 3:18 am

Trying to do the upgrade on a test copy of my 1.5.6.4 going to 2.2.0 using your upgrade script. I get:

Code: Select all

Progress
Error Code(0): Error: Duplicate entry '103-1' for key 'PRIMARY'
Error No: 1062
Error in: /home/xxxx/public_html/upgrade-test/install/model/upgrade/1000.php line 293
ALTER TABLE `oc_product_description` ADD PRIMARY KEY(`product_id`,`language_id`) in /home/xxxx/public_html/upgrade-test/system/library/db/mysql.php on line 54
and it fails.

Running Opencart v2.2 with multi-stores from http://www.labeshops.com which has links to all my stores.

Image


User avatar
Expert Member

Posts

Joined
Thu Aug 04, 2011 4:41 am
Location - Florida, USA

Post by Qphoria » Fri Jun 17, 2016 4:48 am

labeshops wrote:Trying to do the upgrade on a test copy of my 1.5.6.4 going to 2.2.0 using your upgrade script. I get:

Code: Select all

Progress
Error Code(0): Error: Duplicate entry '103-1' for key 'PRIMARY'
Error No: 1062
Error in: /home/xxxx/public_html/upgrade-test/install/model/upgrade/1000.php line 293
ALTER TABLE `oc_product_description` ADD PRIMARY KEY(`product_id`,`language_id`) in /home/xxxx/public_html/upgrade-test/system/library/db/mysql.php on line 54
and it fails.
So this is a little bit of a trickier one. I've not seen it happen with the product_description table, but with other tables that had a custom mod that added a language_id column in their current version.

For example, the banner_image table. Some mods add multi-language banner_image by adding a language_id column. This now means that there are 2 primary keys for the table: banner_image_id AND language_id. This means you can have the same banner_image_id with a different language_id.
1 - 1
1 - 2
But the default opencart.sql file only has a single primary: banner_image_id.
So when the upgrade script runs, it tries to repair existing tables to match the structure of the opencart.sql file
This causes it to choke because now it reset banner_image_id as the only primary and now you get the error about Duplicate entry.

The fix is to figure out which new column was added to this table and add it to the opencart.sql file so that it doesn't try to remove it from the primary key list. So my guess is that with your product_description table, since it already has a language_id column by default, you have some other mod that adds another column as a primary key. Adding that additional primary key to the opencart.sql file should fix it.

Now of course this is advanced developer level stuff to make these types of changes and adaptations. So I will look at maybe skipping over the primary key repair when there is more than one primary key added to a core table. It sort of defeats the purpose of the general upgrade script (1000.php), but I guess it's more realistic and less ideal.

OpenCart 2.0.x Mod Update Info

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by labeshops » Fri Jun 17, 2016 5:10 am

Hmmm

I think the problem might be that years ago I ran this http://forum.opencart.com/viewtopic.php?f=121&t=107756 which added indexes? Not sure how I can undo that???

I have only ever used 1 language though.

Running Opencart v2.2 with multi-stores from http://www.labeshops.com which has links to all my stores.

Image


User avatar
Expert Member

Posts

Joined
Thu Aug 04, 2011 4:41 am
Location - Florida, USA

Post by pm-netti » Fri Jun 17, 2016 4:03 pm

labeshops wrote:Hmmm

I think the problem might be that years ago I ran this http://forum.opencart.com/viewtopic.php?f=121&t=107756 which added indexes? Not sure how I can undo that???

I have only ever used 1 language though.
How is work this change to file 1000.php about by line 292:

Code: Select all

				if ($primary_data) {
					       $this->db->query("ALTER TABLE `" . $table['name'] . "` ADD PRIMARY KEY(" . implode(',', $primary_data) . ")");
				}
change to:

Code: Select all

				if ($query->num_rows && $primary_data) {
					foreach ($query->rows as $result) {
						if ($result['Key_name'] != 'PRIMARY' && $result['Key_name']) {
					       $this->db->query("ALTER TABLE `" . $table['name'] . "` ADD PRIMARY KEY(" . implode(',', $primary_data) . ")");
				        }
				    }
				}
I have not tested. :)

Image
- - - OpenCart Upgrade Service - - -


User avatar
Active Member

Posts

Joined
Sat Apr 07, 2012 11:22 pm
Location - Kittilä-Finland

Post by labeshops » Fri Jun 17, 2016 6:56 pm

Hmm well tried that and now have a different error...

Code: Select all

Error Code(0): Error: Incorrect table definition; there can be only one auto column and it must be defined as a key
Error No: 1075
ALTER TABLE `oc_affiliate` CHANGE `affiliate_id` `affiliate_id` INT(11) NOT NULL AUTO_INCREMENT in /home/xxxx/public_html/upgrade-test/system/library/db/mysqli.php on line 40
Last edited by labeshops on Fri Jun 17, 2016 9:52 pm, edited 1 time in total.

Running Opencart v2.2 with multi-stores from http://www.labeshops.com which has links to all my stores.

Image


User avatar
Expert Member

Posts

Joined
Thu Aug 04, 2011 4:41 am
Location - Florida, USA

Post by pm-netti » Fri Jun 17, 2016 7:48 pm

labeshops wrote:Hmm well tried that and now have a different error...

Code: Select all

Error Code(0): Error: Incorrect table definition; there can be only one auto column and it must be defined as a key
Error No: 1075
ALTER TABLE `oc_affiliate` CHANGE `affiliate_id` `affiliate_id` INT(11) NOT NULL AUTO_INCREMENT in /home/ammaaset/public_html/upgrade-test/system/library/db/mysqli.php on line 40
You try this, 1000.php line 190:

Code: Select all

if ($oldfield['Extra'] == 'auto_increment' && $field['autoincrement']) {
change to:

Code: Select all

if ($oldfield['Extra'] == 'auto_increment' && $field['autoincrement'] && $oldfield['Field'] != $field['name']) {

Image
- - - OpenCart Upgrade Service - - -


User avatar
Active Member

Posts

Joined
Sat Apr 07, 2012 11:22 pm
Location - Kittilä-Finland

Post by labeshops » Fri Jun 17, 2016 8:53 pm

That didn't work - same error :(

Running Opencart v2.2 with multi-stores from http://www.labeshops.com which has links to all my stores.

Image


User avatar
Expert Member

Posts

Joined
Thu Aug 04, 2011 4:41 am
Location - Florida, USA

Post by pm-netti » Fri Jun 17, 2016 9:35 pm

labeshops wrote:That didn't work - same error :(
How can be same error

Code: Select all

$oldfield['Field'] != $field['name']
So column `affiliate_id`not try change?

Image
- - - OpenCart Upgrade Service - - -


User avatar
Active Member

Posts

Joined
Sat Apr 07, 2012 11:22 pm
Location - Kittilä-Finland
Who is online

Users browsing this forum: No registered users and 13 guests