Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

array_merge problems in PHP5.2.x


web-project

Recommended Posts

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:

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:

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. array_merge() PHP 5 example

 

<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:

 

  Array
  (
   [0] => foo
   [1] => bar
  )

Please read this line: Do you want to find all the answers to your questions? click here. As for contribution database it's located here!

8 people out of 10 don't bother to read installation manuals. I can recommend: if you can't read the installation manual, don't bother to install any contribution yourself.

Before installing contribution or editing/updating/deleting any files, do the full backup, it will save to you & everyone here on the forum time to fix your issues.

Any issues with oscommerce, I am here to help you.

Link to comment
Share on other sites

  • 3 months later...
  • 1 month later...
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

Please read this line: Do you want to find all the answers to your questions? click here. As for contribution database it's located here!

8 people out of 10 don't bother to read installation manuals. I can recommend: if you can't read the installation manual, don't bother to install any contribution yourself.

Before installing contribution or editing/updating/deleting any files, do the full backup, it will save to you & everyone here on the forum time to fix your issues.

Any issues with oscommerce, I am here to help you.

Link to comment
Share on other sites

the rc versions (at least RC2a) do not seem to have this issue?

 

Ken

commercial support - unProtected channel, not to be confused with the forum with same name - open to everyone who need some professional help: either PM/email me, or go to my website (URL can be found in my profile).

over 20 years of computer programming experience.

Link to comment
Share on other sites

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

Please read this line: Do you want to find all the answers to your questions? click here. As for contribution database it's located here!

8 people out of 10 don't bother to read installation manuals. I can recommend: if you can't read the installation manual, don't bother to install any contribution yourself.

Before installing contribution or editing/updating/deleting any files, do the full backup, it will save to you & everyone here on the forum time to fix your issues.

Any issues with oscommerce, I am here to help you.

Link to comment
Share on other sites

  • 5 months later...
in the above files I have noticed the array's... do I change it for everyone of them in the files or specific one's?

 

http://www.oscommerce.com/forums/index.php?showtopic=316064

 

in your screen shot example you are on the customers (customers.php) page. You have 2 choices: 1) update/patch the arrays or 2) upgrade to new version of oscommerce.

Please read this line: Do you want to find all the answers to your questions? click here. As for contribution database it's located here!

8 people out of 10 don't bother to read installation manuals. I can recommend: if you can't read the installation manual, don't bother to install any contribution yourself.

Before installing contribution or editing/updating/deleting any files, do the full backup, it will save to you & everyone here on the forum time to fix your issues.

Any issues with oscommerce, I am here to help you.

Link to comment
Share on other sites

in your screen shot example you are on the customers (customers.php) page. You have 2 choices: 1) update/patch the arrays or 2) upgrade to new version of oscommerce.

 

 

this is what I found in customer.php:

 

$reviews_query = tep_db_query("select count(*) as number_of_reviews from " . TABLE_REVIEWS . " where customers_id = '" . (int)$customers['customers_id'] . "'");

$reviews = tep_db_fetch_array($reviews_query);

 

$customer_info = array_merge($country, $info, $reviews);

 

$cInfo_array = array_merge($customers, $customer_info);

$cInfo = new objectInfo($cInfo_array);

}

 

 

If I am correct I would change it to:

 

$reviews_query = tep_db_query("select count(*) as number_of_reviews from " . TABLE_REVIEWS . " where customers_id = '" . (int)$customers['customers_id'] . "'");

$reviews = tep_db_fetch_array($reviews_query);

 

$customer_info = array_merge((array)$country, (array)$info, (array)$reviews);

 

$cInfo_array = array_merge((array)$customers, (array)$customer_info);

$cInfo = new objectInfo($cInfo_array);

}

 

I can only assume...

 

I have never done coding... please let me know.. :)

Link to comment
Share on other sites

Rather than get every coding change "approved" take a back up ofthe files you are going to change.

 

Make the change.

 

Test it.

 

If it works, great, otherwise restore the backup and no damage done.

Need help installing add ons/contributions, cleaning a hacked site or a bespoke development, check my profile

 

Virus Threat Scanner

My Contributions

Basic install answers.

Click here for Contributions / Add Ons.

UK your site.

Site Move.

Basic design info.

 

For links mentioned in old answers that are no longer here follow this link Useful Threads.

 

If this post was useful, click the Like This button over there ======>>>>>.

Link to comment
Share on other sites

Rather than get every coding change "approved" take a back up ofthe files you are going to change.

 

Make the change.

 

Test it.

 

If it works, great, otherwise restore the backup and no damage done.

 

So I added the (array) into the file like above....

 

and now I have this on the Jon Doe profile it does not show on the other two customer profiles...

 

Snapshotjondoe.jpg

 

 

if the below code is correct? Do I need to do the same on the object_info.php?

Link to comment
Share on other sites

Rather than get every coding change "approved" take a back up ofthe files you are going to change.

 

Make the change.

 

Test it.

 

If it works, great, otherwise restore the backup and no damage done.

 

Exactly the same I mean in my second line of the signature.

 

To: ladiessymbol

I did the whole patch of arrays (as described earlier - few posts above) as one of my software applications running on the oscommerce 2.2 Milestone 2 with huge amount of contributions/modules & it's working without any issues on PHP 5.2.x

 

Simply backup and patch also the following files:

/catalog/admin/includes/functions/

compatibility.php

general.php

Please read this line: Do you want to find all the answers to your questions? click here. As for contribution database it's located here!

8 people out of 10 don't bother to read installation manuals. I can recommend: if you can't read the installation manual, don't bother to install any contribution yourself.

Before installing contribution or editing/updating/deleting any files, do the full backup, it will save to you & everyone here on the forum time to fix your issues.

Any issues with oscommerce, I am here to help you.

Link to comment
Share on other sites

We have hundreds of osCommerce 2.2 MS2 websites running on PHP 5.2.6, and the only problems experienced have been the way that PHP 5.2.6 handles commenting out of php and html. Old code which was commented out but left in place has caused problems.

 

More of a problem for osCommerce is when hosts, as part of the upgrade to PHP 5.2+, turn off Register Long Arrays in php.ini. So that all of the entries for $HTTP_POST_VARS etc. have to be changed to their shortened form.

 

For the longer term Register Long Arrays and Register Globals won't even be available in PHP 6 when it comes out.

 

Another thing that is disabled by default in PHP 5.2+ is gpc_magic_quotes, and this causes problems for some osCommerce add-ons if turned off.

 

Vger

Link to comment
Share on other sites

  • 8 months later...
  • 1 month later...

I tried this and the problem still exists as follows:

 

Warning: array_merge() [function.array-merge]: Argument #1 is not an array in /home/logoread/public_html/admin/customers.php on line 733

 

Warning: array_merge() [function.array-merge]: Argument #2 is not an array in /home/logoread/public_html/admin/customers.php on line 733

 

Warning: array_merge() [function.array-merge]: Argument #2 is not an array in /home/logoread/public_html/admin/customers.php on line 735

 

Warning: reset() [function.reset]: Passed variable is not an array or object in /home/logoread/public_html/admin/includes/classes/object_info.php on line 17

 

Warning: Variable passed to each() is not an array or object in /home/logoread/public_html/admin/includes/classes/object_info.php on line 18

How do I fix this? Maybe I'm misunderstanding. I changed the code as suggested and still get this warning when I go to customers in the admin section.

 

Joe

Link to comment
Share on other sites

  • 5 months later...

Warning: array_merge() [function.array-merge]: Argument #1 is not an array in /home/logoread/public_html/admin/customers.php on line 733

$customer_info = array_merge((array)$country, (array)$info, (array)$reviews);

 

Warning: array_merge() [function.array-merge]: Argument #2 is not an array in /home/logoread/public_html/admin/customers.php on line 735

$cInfo_array = array_merge((array)$customers, (array)$customer_info);

Please read this line: Do you want to find all the answers to your questions? click here. As for contribution database it's located here!

8 people out of 10 don't bother to read installation manuals. I can recommend: if you can't read the installation manual, don't bother to install any contribution yourself.

Before installing contribution or editing/updating/deleting any files, do the full backup, it will save to you & everyone here on the forum time to fix your issues.

Any issues with oscommerce, I am here to help you.

Link to comment
Share on other sites

  • 10 months later...

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

 

We have an old OSC installation and our ISP updated PHP on our server and we got the array_merge errors as mentioned in this thread. I am new to OSC and PHP, but I managed to update all of the files mentioned in the quote above except for the two compatibilty.php files. The only mention of array_merge in these two files is the actual function itself, so I wasn't sure what to specifically update in these two files? Any help? Thanks.

Link to comment
Share on other sites

  • 7 months later...

I have the fallowing issues

Warning: in_array() [function.in-array]: Wrong datatype for second argument in public_html/seret/admin25xrt/edit_orders.php on line 441

 

Warning: in_array() [function.in-array]: Wrong datatype for second argument in public_html/seret/admin25xrt/edit_orders.php on line 441

 

Warning: Cannot modify header information - headers already sent by (output started at html/seret/admin25xrt/edit_orders.php on line 441 in html/seret/admin25xrt/includes/functions/general.php on line 22

 

according to this warnings the file says:

 

	    //save ot_skippy from certain annihilation
		 if ( (!in_array($ot_class, $written_ot_totals_array)) && (!in_array($ot_title, $written_ot_titles_array)) && (tep_not_null($ot_value)) && (tep_not_null($ot_title)) && ($ot_class != 'ot_tax') && ($ot_class != 'ot_loworderfee') ) { //7
		//this is supposed to catch the oddball components that don't show up in $order_totals

 

 

i tried to fix it canging to this:

               //save ot_skippy from certain annihilation

if ( (!in_array((array)$ot_class, (array)$written_ot_totals_array)) && (!in_array((array)$ot_title, (array)$written_ot_titles_array)) && (tep_not_null($ot_value)) && (tep_not_null($ot_title)) && ($ot_class != 'ot_tax') && ($ot_class != 'ot_loworderfee') ) { //7

       //this is supposed to catch the oddball components that don't show up in $order_totals

 

but no luck... how can i make it work

 

thanks

Link to comment
Share on other sites

It says the second instance of the array...

 

Warning: in_array() [function.in-array]: Wrong datatype for second argument

 

Place this:

 

//save ot_skippy from certain annihilation

if ( (!in_array($ot_class, (array)$written_ot_totals_array)) && (!in_array($ot_title, (array)$written_ot_titles_array)) && (tep_not_null($ot_value)) && (tep_not_null($ot_title)) && ($ot_class != 'ot_tax') && ($ot_class != 'ot_loworderfee') ) { //7

//this is supposed to catch the oddball components that don't show up in $order_totals

 

TEST IT and let us know.

Link to comment
Share on other sites

  • 2 months later...
  • 2 months later...

Archived

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

×
×
  • Create New...