Bug 235467 - www/oscommerce: patch to make compatible with php70+
Summary: www/oscommerce: patch to make compatible with php70+
Status: Closed Overcome By Events
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: Dmitry Marakasov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-02-03 17:07 UTC by Greg Quinlan
Modified: 2021-02-16 16:20 UTC (History)
1 user (show)

See Also:


Attachments
Both files that can be extracted using "tar xzf both_files.tgz" (167.09 KB, application/x-compressed)
2019-02-03 17:07 UTC, Greg Quinlan
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Greg Quinlan 2019-02-03 17:07:20 UTC
Created attachment 201689 [details]
Both files that can be extracted using "tar xzf both_files.tgz"

Background:
For some time the oscommerce port has been ignored due to compatibility problems with php70+.
The main issue is that "each()" has been "deprecated" from php70+ and oscommerce uses it extensively.
I downloaded the latest oscommerce from oscommerce.com which at the time was version 2.3.4.1 .

After looking at the effected code and carefully translating each command that used "each()" to use "foreach()" instead. Which has been available since php4.?!

===
#This code example 1:
   reset($array);
   while (list($key, ) = each($array)) {

#Is updated to this code example 1:
   foreach(array_keys($array) as $key) {
===
#This code example 2:
reset($array);
while (list(, $value) = each($array)) {

#Is updated to this code example 2
foreach($array as $value) {
===
# This code example 3
reset($array);
while (list($key, $value) = each($array)) {

#Is updated to example 3
foreach($array as $key => $value) {
===

Thses are the proposed fixes to all the effected files in oscommerce2.3.4.1
Attached are the "diff -u" (patches_oscommerce_php7_each.tgz) and actual patched files ending in "<file>.patched" (patched_files_oscommerce_php7_each.tgz)

Please look at the code carefully!

Thanks for your help.
There is also a list of the patched files called "files_patched".

I have also installed (from packages) php73-mysqli-7.3.1_1          # The mysqli shared extension for php

Note: I still get the error: "Unknown extension mysql for PHP 73."
Comment 1 Walter Schwarzenfeld freebsd_triage 2019-02-03 17:40:08 UTC
www/oscommerce||2018-12-30|Has expired: Works only with EOL php 5.6.
Comment 2 Greg Quinlan 2019-02-03 18:12:11 UTC
Thanks, yes I am aware and did have it working (on that version). What I want to achieve is to fix all the depreciated PHP code/commands from PHP5.6 (working) to PHP7+ (not working) in the existing (current) oscommerce PHP code. I could not find the official oscommerce 2.3.4.1 source code on gthub.com! That would have been my preference! I want to see if wen@FreeBSD.org has any influence over oscommerce's development team (to merge my changes). This isn't difficult, but obviously not a priority for them.
Comment 3 Walter Schwarzenfeld freebsd_triage 2019-02-03 18:44:15 UTC
https://www.oscommerce.de/Products

Maybe you try v2.4.0 beta ?
Comment 4 Greg Quinlan 2019-02-04 08:43:04 UTC
Did not see that...

After a quick glance they have made the exactly the some changes.. :) there are files that don't exist (anymore) between versions, extra code (of course) and they missed this one.

./catalog/includes/classes/navigation_history.php

code: (starting at line 133)
function unserialize($broken) {
      for(reset($broken);$kv=each($broken);) {
//                           ^^^^
        $key=$kv['key'];
        if (gettype($this->$key)!="user function")
        $this->$key=$kv['value'];
      }
    }

This should be:
code:
function unserialize($broken) {
        foreach ($broken as $k => $v) {
          $kv = [$k, $v];
        }
        $key=$kv['key'];
        if (gettype($this->$key)!="user function")
        $this->$key=$kv['value'];
      }
    }
Comment 5 Greg Quinlan 2019-02-04 08:53:51 UTC
I mean the exact same changes. (where "each()" neeeded to be removed and replaced with "foreach()") so I VERY confident in my patches! :) And all that extra code most be regression tested, that will take a long time.
Comment 6 Dmitry Marakasov freebsd_committer freebsd_triage 2021-02-16 16:20:51 UTC
oscommerce was removed from the ports collection.