Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Upgrading osCommerce 2.2 RC2a to PHP 5.6


dr_lucas

Recommended Posts

We are using a super heavily modified osCommerce 2.2 RC2a that has previously been upgraded to work with PHP 5.4 and is working perfectly fine on 5.4

The site is currently utilizing Boostrap 3.3.5 and plenty of enhancements and it's quite insane to upgrade it to a new osCommerce version.

We would like to upgrade the code to be fully compatible with PHP 5.6 and wondering what the osC experts here suggest to do in order to achieve that (again, starting by upgrading to a newer osC is not an option for us at the moment).

Link to comment
Share on other sites

If it works on PHP5.4, it should not be that much work making it work on PHP5.6.

Link to comment
Share on other sites

At this point what you effectively have is your own "fork" of osC, that you are responsible for maintaining. Over time, there will be less and less support available here, simply because no one will be using osC 2.2 any more. I know you don't want to hear this, but in the long run, migrating to a current version of osC may be the easiest option. You need to honestly assess what "super heavily modified" really means -- was it really major functional changes, was there a lot of custom coding, or was it mostly installing a bunch of add-ons? You may be pleasantly surprised at how much of this is already built into osC 2.3.4BS, or if not, how easy it is to tweak the CSS to get what you want or to install an add-on. You at least owe it to yourself to see what would be involved in migrating to the current version, and how much work that is compared to manually keeping up with PHP version changes, necessary security patches to osC, and new features you want. You may decide that you really didn't have that much in actual work done (more of an emotional investment) in 2.2, and moving to current levels would be less work. Or, your current store may genuinely be so far off the "vanilla" track that indeed it is easier to maintain it yourself. Only you can tell, after making a test installation of 2.3.4BS. As I said before, you may well have created your own fork, and only you will be able to maintain it because so few shops will still be 2.2-based.

Link to comment
Share on other sites

Yes, @@MrPhil, the current site is that heavily modified that it can be considered as our own fork. Upgrading it to the latest code base is, as I said, insane. Trust me on this, I am a diligent programmer and saying this.

Frankly, we will move to a different code base (probably Magento 2 or Presta) once we decide it's time to upgrade, not to latest osC. But that's a different topic entirely.

 

I realized that making the site php 5.6 compatible  (from 5.4) is, as @@toyicebear suggested, quite simple.

Basically I just needed to modify to database.php files and merge them with the changes related to mysqli (new database.php files taken from the latest osC), then I just went through all our files and searched for any mysql_ function and modified them to tep_db functions (rewriting some of the code there of course, for example mysql_fetch_array($var, MYSQL_ASSOC) should have changed to tep_db_fetch_array($var) etc.

Now everything seems to be working fine.

Hope I am not missing anything, am I? :)

Link to comment
Share on other sites

And also had to add dual charset support, due to UTF-8 encoding: http://www.oscommerce-addons.com/download.php?Type=Package&PackageID=39

Link to comment
Share on other sites

No response, so I assume that's all that is needed. Funny, but testing the site on PHP 7 now, seems to be working fine too after upgrading it for 5.6

Always good to run the code through the compatibility checker (https://github.com/sstalle/php7cc), will do so shortly...

Link to comment
Share on other sites

I also have a modified version that I've been running on 5.6 since Thanksgiving and it seems fine.  I also moved from 5.4 basically skipping 5.5 since there was little needed.  Of course, I was testing on my local machine first, and I hit some minor glitches there first.  Often, it's the older addons that need the work.

I'm not really a dog.

Link to comment
Share on other sites

I'm another in the same situation. I have been running with mysqli on 5.4 for a while and it seems to work, but the error logs are full of complaints such as:

 

PHP Warning:  mysqli_query() expects parameter 1 to be mysqli, null given 

 

What I discovered is that the session close kills $db_link but there are still some queries that get executed after the last line of code on a page. It largely seems harmless, but it bothers me nonetheless.  tep_db_input is another one where $db_link has disappeared.

 

I did try switching to 5.6 yesterday but PHP suddenly complained of "unexpected end of file" on one of my pages, so I switched back. I'll have to figure out what THAT'S all about...

Link to comment
Share on other sites

"PHP Warning:  mysqli_query() expects parameter 1 to be mysqli, null given" is probably NOT harmless and must never appear if your shop code is properly written.

You really should backport includes/functions/database.php and  includes/admin/functions/database.php from the latest osC release. It is fully mysqli compatible.

Search all your files, except for these database.php files, for the term mysql_

This is a great tool to do that on windows: http://www.nirsoft.net/utils/search_my_files.html

If you find any occurrences, check them to see if they are part of mysql function and if so - they must be properly converted to the matching tep_db function code and structure, which will then correctly use mysqli.

 

As for the "unexpected end of file", you may have setup your new PHP 5.6 with short_open_tag flag turned off (in your php.ini). You must turn it on or fix your code to make sure it doesn't use any short open tags (ie. all <? must be <?php)

http://fr.php.net/manual/en/ini.core.php#ini.short-open-tag

 

This error is not exclusive for PHP 5.6 by the way. If you have this flag turned off on 5.4 - you will get the same "unexpected end of file" you got.

Link to comment
Share on other sites

  • 4 weeks later...

We have forks of Osc 2.2 ms2 that we support, they have been heavily modified since 2003 with contributions and custom modifications and the necessary security updates, currently running on PHP5.4 and MYSQL 5.5. I would be very interested in any useful check lists for upgrading from these versions. I've eradicated short tags and long arrays, looks like I'll need to do the mysqli conversion though.

 

Love it when developers say the only option is to start again when it's commercially impractical, just makes me more determined to find an upgrade solution.

Link to comment
Share on other sites

Love it when developers say the only option is to start again when it's commercially impractical, just makes me more determined to find an upgrade solution.

 

All the more reason to keep careful and thorough track of all changes you make to your store (including why you make a change), so that you can easily modify a fresh copy ("start again") if upgrading is impractical. It also makes it easier to stay up to date, rather than falling so far behind, as most of the work (PHP compatibility, security fixes, etc.) is done for you. All I can do is roll my eyes when someone says they "have to stay" on a 10 year old version because they've invested thousands of man-hours in customizing and bringing it up to date PHP- and security-wise, when they could have transferred their carefully logged changes to the current osC with so much less effort.

 

I know it can be a pain when an application's developers don't or can't provide a clean update path. Perhaps the improved modularity in osC 2.4 will help with making add-ons more transferable across versions.

Link to comment
Share on other sites

Overall there are very little changes for php, so eventhough you could argue that staying closer to the core osCommerce releases is easier now, i think it would be foolish to make that decision just to keep up with php versions.

I would however try to migrate your codebase to version 2.3.4 with the modularity, this would give you a bit more flexibility and an upgrade path going forward, and might make your customizations less custom and just another custom module going forward ...

 

I would also look at upgrading to php 7 , you need to change class constructors but otherwise there are very little changes, for the gain in performance improvements.

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

We have forks of Osc 2.2 ms2 that we support, they have been heavily modified since 2003 with contributions and custom modifications and the necessary security updates, currently running on PHP5.4 and MYSQL 5.5. I would be very interested in any useful check lists for upgrading from these versions. I've eradicated short tags and long arrays, looks like I'll need to do the mysqli conversion though.

 

Love it when developers say the only option is to start again when it's commercially impractical, just makes me more determined to find an upgrade solution.

 

As far as I remember, check list for upgrading to PHP 7 (I got my osc RC2a working perfectly on PHP7 this way):

- mysqli compatibility (back port both database.php function files from the latest osC release)

- go through all your code to make sure there are no mysql_ functions. If there are any - modify them to their tep_db_ equivalent, some will require syntax modifications (as I wrote in my post above)

- convert all php files to UTF-8 (Without BOM!)

- convert your database tables to UTF-8 using my script: http://www.oscommerce.com/forums/topic/408961-script-converting-the-entire-database-to-utf-8-including-tables-and-columns/

- ensure there are no white-spaces before the opening <?php and closing ?> tags. For safety, I recommend completely removing all closing tags from the end of all php files where that tag is the last thing in the file

- change all classes to have a constructor, as I explained here: http://www.oscommerce.com/forums/topic/408220-php-7/

- Click Like on this post if it helped you :P

Link to comment
Share on other sites

  • 3 months later...

I just want to jump in here and say that the fundamental reason for using osCommerce is so you can build you own unique solution. "Forking it" is fundamental to its use. 

 

While you continue to keep the underlying platform up to date you can continue to use whatever version you like:  2.2, RC2a or 2.3.4. 

 

So kudos to Michaela for taking the time to map out the work involved.

osCommerce Official Partner
www.ozEworks.com

Link to comment
Share on other sites

I just want to jump in here and say that the fundamental reason for using osCommerce is so you can build you own unique solution. "Forking it" is fundamental to its use. 

 

Well..... I see a difference between customizing your store with add-ons, etc., and a fork where you get to the point where the code is now so different from the standard product that you're pretty much on your own, support-wise. Unless you're very skilled at software architecture, and willing to invest the time and effort to keep your code base up to date, you would probably be better off sticking closely to the standard product. That means periodically upgrading to a new base level, and reapplying your changes.

Link to comment
Share on other sites

@dr_lucas

Good on you for keeping an older version of oscommerce updated and running. As some others have said, if it works for you and you can update the code, and keep the software secure yourself, why change.

REMEMBER BACKUP, BACKUP AND BACKUP

Link to comment
Share on other sites

  • 6 months later...

Hello,
 

we have modified our shop (2.2 RC2a) for running under php 5.5

Frontend is running without problems.

But we have no entrance into the admin.

If I start, at 1-st I see a
Warning: require(includes/languages/.php): failed to open stream: No such file or directory in /www/htdocs/w01568d0/catalog/admin/includes/application_top.php on line 158

I fix it for the Moment in the application_top.php with:

// include the language translations
 $language="german";
 

 

2-nd Problem:
I can not get in the admin-area.
If I type the username and Password every time it jump back an ask me for Login again.
If I delete the entry in my database table "Administrators", I can create a new entry but after this the same Problem (can not get in)

I have found no solution for my problem and hope for help here.

Thank you very much in advanve

Peter


 

Link to comment
Share on other sites

I believe you are running into session problems.  Use a file comparator like Beyond Compare and look at upgrading your session files.  It's really best to make a test copy of your shop and make changes like this first in a test enviroment so you don't get in this situation. 

I'm not really a dog.

Link to comment
Share on other sites

  • 1 month later...

@dr_lucas What exactly should I do to get my site back on-line? I did a PHP5.6 and MySQL update because the server asked me too. After that server update, it crashed. 

 

OSC 2.3.4

Apach 3.34

pHp 5.6

mysql 5.6

Link to comment
Share on other sites

SHOUT OUT TO MY BOY!!!! @@mcmannehan  for getting my websites back online. 

 

Thank you! You are welcome!!!

  • The clever one learn from everything and from everybody
  • The normal one learn from his experience
  • The silly one knows everything better

[socrates, 412 before Christ]

Computers help us with the problems we wouldn't have without them!
99.9% of the bugs sit in front of the computer!
My programmed add-ons: WDW EasyTabs 1.0.3, WDW Facebook Like 1.0.0

if(isset($this) || !isset($this)){ // that's the question...

 

Link to comment
Share on other sites

  • 1 month later...

Hello,

 

we have modified our shop (2.2 RC2a) for running under php 5.5

 

Frontend is running without problems.

 

Inox-store and others here, can you share the steps and tricks you used?

 

My heavily modified 2003 store works just once, on any page, but thereafter any click-through or re-load gives a blank page, with no errors. Obviously something to do with the sessions, but I've been through sessions.php and application_top with a comparator, and changed all those functions that were different to the latest version.

 

This is very frustrating, because I can see the store works, its just the session handling thats stopping it.

Background ; it was working fine on an old server until that server crashed, and now I've been re-located on a server with PHP 5.6

Link to comment
Share on other sites

@@John_from_Oz

 

Heavily modified or not, you should upgrade your store to a modern version compatible with current servers if you want your business to remain relevant and earning income. osCommerce 2.3.4BS is secure, modern, responsive and Google friendly. There is no excuse not to upgrade if you are serious about selling online.

 

Download it from here http://www.oscommerce.com/forums/topic/396152-bootstrap-3-in-234-responsive-from-the-get-go/

osCommerce user since 2003! :thumbsup:

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...