Oscommerce auf php5/mysql5

23.05.08

 
Permalink 17:14:12, Kategorien: blade the bofh  

Oscommerce auf php5/mysql5

Alte Oscommerce Installationen, so wie die ChaosCompany sie einsetzt haben einige mit php5 und mysql5. Unter anderem erhält man wenn man eine Kategorie aufruft anstatt der gewünschten Artikel folgende Fehlermeldung:

1054 - Unknown column 'p.products_id' in 'on clause'

select count(p.products_id) as total from products_description pd, products p left join manufacturers m on p.manufacturers_id = m.manufacturers_id, products_to_categories p2c left join specials s on p.products_id = s.products_id where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '4' and p2c.categories_id = '75'

[TEP STOP]

oder diese Fehlermeldung wenn man die Suchfunktion benuzt:

1054 - Unknown column 'p.products_id' in 'on clause'

select count(distinct p.products_id) as total from products p left join manufacturers m using(manufacturers_id), products_description pd left join specials s on p.products_id = s.products_id, categories c, products_to_categories p2c where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '4' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and ((pd.products_name like '%foo%' or p.products_model like '%foo%' or m.manufacturers_name like '%foo%') )

[TEP STOP]

Am einfachsten kann man dieses Problem umgehen indem man eine Aktuelle Oscommerce Version herunterlädt und installiert, da neuere Versionen keine Probleme mehr mit Mysql5 haben. Nun sind unsere Shops aber sehr stark modifiziert und ein Upgrade kommt nicht infrage, eine Situation wie sie bei vielen Betreibern von Oscommerce Shops vorkommen dürfte - unmodifiziert ist Oscommerce nahezu nicht zu gebrauchen. Ein Downgrade von Mysql und Php kommt selbstverständlich auch nicht in Betracht, zum einen weil unsere andere Software nicht in einer derat Antiquierten Umgebung funktionieren würde, andererseits weil solche Software Dinosaurier kaum noch Support genießen und Scheunentor grosse Sicherheitslücken aufreißen können. Nachdem somit alle anderen Möglichkeiten ausgeschöpft sind bleibt mir nur übrig das alte Oscommerce an die Aktuelle Laufzeitumgebung anzupassen.

Überaschenderweise sind dazu nur wenige Änderungen nötig, die leicht von der Hand gehen. Folgende Modifikationen müssen vorgenommen werden:

in advanced_search_result.php

In Zeile 218 (Zeilennummern können Abweichen, gegebenenfalls Suchfunktion benutzen):


$from_str = "from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m using(manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c";

if ( (DISPLAY_PRICE_WITH_TAX == 'true') && (tep_not_null($pfrom) || tep_not_null($pto)) ) {
if (!tep_session_is_registered('customer_country_id')) {
$customer_country_id = STORE_COUNTRY;
$customer_zone_id = STORE_ZONE;
}
$from_str .= " left join " . TABLE_TAX_RATES . " tr on p.products_tax_class_id = tr.tax_class_id left join " . TABLE_ZONES_TO_GEO_ZONES . " gz on tr.tax_zone_id = gz.geo_zone_id and (gz.zone_country_id is null or gz.zone_country_id = '0' or gz.zone_country_id = '" . (int)$customer_country_id . "') and (gz.zone_id is null or gz.zone_id = '0' or gz.zone_id = '" . (int)$customer_zone_id . "')";
}

ersetzen mit:

$from_str = "from (((((" . TABLE_PRODUCTS . " p) left join " . TABLE_MANUFACTURERS .
" m using(manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION .
" pd ) left join " . TABLE_SPECIALS .
" s on (p.products_id = s.products_id), " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c)";

if ( (DISPLAY_PRICE_WITH_TAX == 'true') && (tep_not_null($pfrom) || tep_not_null($pto)) )
{
if (!tep_session_is_registered('customer_country_id'))
{
$customer_country_id = STORE_COUNTRY;
$customer_zone_id = STORE_ZONE;
}

$from_str .= " left join " . TABLE_TAX_RATES . " tr on (p.products_tax_class_id = tr.tax_class_id ))left join " . TABLE_ZONES_TO_GEO_ZONES . " gz on (tr.tax_zone_id = gz.geo_zone_id and (gz.zone_country_id is null or gz.zone_country_id = '0' or gz.zone_country_id = '" . (int)$customer_country_id . "') and (gz.zone_id is null or gz.zone_id = '0' or gz.zone_id = '" . (int)$customer_zone_id . "')))";
}

in index.php

In Zeile 178 (Zeilennummern können Abweichen, gegebenenfalls Suchfunktion benutzen):



// show the products of a specified manufacturer
if (isset($HTTP_GET_VARS['manufacturers_id'])) {
if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {
// We are asked to show only a specific category
$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "'";
} else {
// We show them all
$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'";
}
} else {
// show the products in a given categorie
if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {
// We are asked to show only specific catgeory
$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";
} else {
// We show them all
$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";
}
}

ersetzen mit:

// show the products of a specified manufacturer
if (isset($HTTP_GET_VARS['manufacturers_id'])) {
if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {
// We are asked to show only a specific category
$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from (" . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c ) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "'";
} else {
// We show them all
$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from (" . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'";
}
} else {
// show the products in a given categorie
if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {
// We are asked to show only specific catgeory
$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from (" . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";
} else {
// We show them all
$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from ((" . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p) left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";
}
}

in admin/includes/classes/upload.php

In Zeile 31 (Zeilennummern können Abweichen, gegebenenfalls Suchfunktion benutzen):


$this = null;

ersetzen mit:

unset $this;

Damit sollte auch ein altes Oscommerce mit Aktuellen mysql und php Installationen zurecht kommen. Da ich es in diesem Eintrag noch nicht getan habe möchte ich noch folgendes Anmerken: Oscommerce ist der letzte Dreck.

Trackback Adresse für diesen Eintrag:

http://dropfknuck.net/dropfblog/blogs/htsrv/trackback.php/449

Kommentare, Trackbacks, Pingbacks:

Kommentar von: Tears [Besucher] Email · http://www.iguts.de
Willst du uns jetzt oscommerce aufschwätzen? :D
PermalinkPermalink 26.05.08 @ 18:39
Kommentar von: blade [Mitglied] Email · http://dropfknuck.net
Nein, natürlich nicht.
Ist bloss eine Anleitung für andere OSC Opfer. Ausserdem muss ich den Task wohl noch öfter machen da ich sämtliche Shops auf Root Server umziehen werde, und dann muss ich mir die fixes nicht mühsam Zusammensuchen..

PermalinkPermalink 27.05.08 @ 08:54
Kommentar von: mike [Besucher] Email
admin/includes/classesupload.php gibt es nicht. Die anderen Sachen konnte ich ändern aber leider hilft es mir nicht weiter. ;(
PermalinkPermalink 12.10.10 @ 22:55
Kommentar von: blade [Mitglied] Email · http://dropfknuck.net
Du hast recht. Das müsste eigentlich admin/includes/classes/upload.php heissen.

-blade
PermalinkPermalink 12.10.10 @ 23:05

Der Eintrag hat 3 auf Moderation wartende Feedbacks...

Hinterlasse einen Kommentar:

Deine E-Mail Adresse wird nicht angezeigt.
Deine URL wird angezeigt.

Erlaubte XHTML Tags: <p, ul, ol, li, dl, dt, dd, address, blockquote, ins, del, span, bdo, br, em, strong, dfn, code, samp, kdb, var, cite, abbr, acronym, q, sub, sup, tt, i, b, big, small>
(Zeilenumbrüche werden zu <br />)
(Setze Cookies für Name, E-Mail und URL)
(Erlaube Benutzern, Dich über ein Nachrichten-Formular zu kontaktieren (Deine E-Mail Adresse wird NICHT angezeigt).)