OSCOMMERCE SUPPORT CALL 702-453-3332

 

Help - Search - Members - Calendar
Full Version: array_merge problems in PHP5.2.x
osCommerce Community Support Forums > osCommerce Online Merchant v2.x > Tips and Tricks
web-project
The oscommerce is full of array_merge the osc developers couldn't live without this peace of code.

Due to changes of PHP language structure, you need to update all the code with array_merge.

example:
QUOTE
if ((!isset($_GET['bID']) || (isset($_GET['bID']) && ($_GET['bID'] == $pages['pages_id']))) && !isset($bInfo) && (substr($action, 0, 3) != 'new')) {
$bInfo_array = array_merge($pages, $info);
$bInfo = new objectInfo($bInfo_array);
}


change to:
QUOTE
if ((!isset($_GET['bID']) || (isset($_GET['bID']) && ($_GET['bID'] == $pages['pages_id']))) && !isset($bInfo) && (substr($action, 0, 3) != 'new')) {
$bInfo_array = array_merge((array)$pages, (array)$info);
$bInfo = new objectInfo($bInfo_array);
}


According to PHP manual:
http://uk2.php.net/array_merge

The behaviour of array_merge() was modified in PHP 5. Unlike PHP 4, array_merge() now only accepts parameters of type array. However, you can use typecasting to merge other types. See the example below for details.



Example 258. [b]array_merge() PHP 5 example[/b]

CODE
<span class="default"><?php
   $beginning </span><span class="keyword">= </span><span class="string">'foo'</span><span class="keyword">;
   </span><span class="default">$end </span><span class="keyword">= array(</span><span class="default">1 </span><span class="keyword">=> </span><span class="string">'bar'</span><span class="keyword">);
   </span><span class="default">$result </span><span class="keyword">= </span><span class="default">array_merge</span><span class="keyword">((array)</span><span class="default">$beginning</span><span class="keyword">, (array)</span><span class="default">$end</span><span class="keyword">);
   </span><span class="default">print_r</span><span class="keyword">(</span><span class="default">$result</span><span class="keyword">);
   </span><span class="default">?></span>
The above example will output:

CODE
  Array
   (
       [0] => foo
       [1] => bar
   )
CRUZN8R
OK, where in OSC needs to be modified? What files where?
web-project
QUOTE (CRUZN8R @ Feb 24 2008, 02:48 AM) *
OK, where in OSC needs to be modified? What files where?


In the following files:

/catalog/admin/
banner_manager.php
categories.php
configuration.php
customers.php
manufacturers.php
orders.php
orders_status.php
reviews.php
specials.php

/catalog/admin/includes/clases/
emails.php

/catalog/admin/includes/functions/
compatibility.php
general.php

/catalog/includes/clases/
emails.php
http_client.php

/catalog/includes/functions/
compatibility.php

/catalog/includes/modules/payment/
paypal_uk_direct.php
paypal_uk_express.php
Coopco
Thanks for posting web-project, a great time saver.
GemRock
the rc versions (at least RC2a) do not seem to have this issue?

Ken
web-project
QUOTE (GemRock @ Apr 6 2008, 03:15 PM) *
the rc versions (at least RC2a) do not seem to have this issue?

Ken


for older versions as most of users are still using the 2.2
Coopco
QUOTE (web-project @ Apr 7 2008, 02:45 AM) *
for older versions as most of users are still using the 2.2

And for some of the contributions.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.