Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Paypal Express PHP 7.2 Undefined Notice


altoid

Recommended Posts

Using the PayPal App in OsC version CE...running php 7.2 in the error log I see the following undefined notice:

 PHP Notice:  Undefined index: osC_Action in /home/MyUsername/public_html/ext/modules/payment/paypal/express.php on line 63

In /ext/modules/payment/paypal/express.php starting on line 63 we find.

 switch ($HTTP_GET_VARS['osC_Action']) {
    case 'cancel':
      tep_session_unregister('appPayPalEcResult');
      tep_session_unregister('appPayPalEcSecret');

Any suggestions for a fix for this?

I am not a professional webmaster or PHP coder by background or training but I will try to help as best I can.

I remember what it was like when I first started with osC. It can be overwhelming.

However, I strongly recommend considering hiring a professional for extensive site modifications, site cleaning, etc.

There are several good pros here on osCommerce. Look around, you'll figure out who they are.

Link to comment
Share on other sites

 Its just php 7.2 now classes an undefined verable / array as a scurity risk hence the warning

Relying on the default value of an uninitialized variable is problematic in the case of including one file into another which uses the same variable name. It is also a major security risk with register_globals turned on. E_NOTICE level error is issued in case of working with uninitialized variables, however not in the case of appending elements to the uninitialized array. isset() language construct can be used to detect if a variable has been already initialized. Additionally and more ideal is the solution of empty() since it does not generate a warning or error message if the variable is not initialized.

Please check with someone else more experianced first before trying on live site. This clears the error in sandbox.

if(isset($HTTP_GET_VARS['osC_Action']))

 switch ($HTTP_GET_VARS['osC_Action']) {
    case 'cancel':
      tep_session_unregister('appPayPalEcResult');
      tep_session_unregister('appPayPalEcSecret');
 }

 

http://sandbox.onlinephpfunctions.com/code/3b0feba987250aac1cd386e3c12ca2ab396437c2

 

Link to comment
Share on other sites

Link to comment
Share on other sites

@raiwa @JcMagpie Thanks for the response. I will look at Zahid's suggestion and see how that goes.

Rainer, if you look at commit

https://github.com/gburton/Responsive-osCommerce/commit/c0aeb3f2cb86d865e6a04ad9982852c026c4083b

You'll see Gary reverted code for some PP App files, apparently so things would work when any updates come out. So there's many of these issues in there that I'm going to let go for now.

I am not a professional webmaster or PHP coder by background or training but I will try to help as best I can.

I remember what it was like when I first started with osC. It can be overwhelming.

However, I strongly recommend considering hiring a professional for extensive site modifications, site cleaning, etc.

There are several good pros here on osCommerce. Look around, you'll figure out who they are.

Link to comment
Share on other sites

10 hours ago, altoid said:

You'll see Gary reverted code for some PP App files, apparently so things would work when any updates come out. So there's many of these issues in there that I'm going to let go for now.

Then for the same reason the above posted notice error fix shouldn't be applied. Anyway a notice error is not important if production error settings are used.

Link to comment
Share on other sites

37 minutes ago, raiwa said:

Then for the same reason the above posted notice error fix shouldn't be applied. Anyway a notice error is not important if production error settings are used.

I've been thinking about turning off notices, but I've been trying to keep the code as clean as possible thinking as php version update notices could become warnings then fatal errors. Then again as long as my host let's me control the phone version, there you go.

I am not a professional webmaster or PHP coder by background or training but I will try to help as best I can.

I remember what it was like when I first started with osC. It can be overwhelming.

However, I strongly recommend considering hiring a professional for extensive site modifications, site cleaning, etc.

There are several good pros here on osCommerce. Look around, you'll figure out who they are.

Link to comment
Share on other sites

@altoid

https://github.com/osCommerce/oscommerce2/blob/de9e922377cbfd0678c9e4b9e8eb51123f3e230a/catalog/ext/modules/payment/paypal/express.php#L63

change:

  switch ($HTTP_GET_VARS['osC_Action']) {

to:
 

  if (isset($HTTP_GET_VARS['osC_Action']))
  switch ($HTTP_GET_VARS['osC_Action']) {

This is not a big deal. If you dont use ";" at the end of if condition the rule do effect to next enclosed ";" character or next end of following function in PHP

Link to comment
Share on other sites

@altoid,

please read again the previous posts regarding auto update the PayPal App version.

If you manually modify the code, it seems you will have trouble when you intend to use the auto update feature for future versions.

So you have 2 possibilities:

1. leave the PayPal App as is and accept the notice warnings (there are more still in the CE if you have a look around) and use the recommended production error setting which will not show them.

2. Update the code and keep in mind that it will probably break the auto update feature. (you can keep track on it and revert your changes before trying to run the update to the next version(s) once they will be available).

Link to comment
Share on other sites

7 minutes ago, raiwa said:

@altoid,

please read again the previous posts regarding auto update the PayPal App version.

If you manually modify the code, it seems you will have trouble when you intend to use the auto update feature for future versions.

So you have 2 possibilities:

1. leave the PayPal App as is and accept the notice warnings (there are more still in the CE if you have a look around) and use the recommended production error setting which will not show them.

2. Update the code and keep in mind that it will probably break the auto update feature. (you can keep track on it and revert your changes before trying to run the update to the next version(s) once they will be available).

Back when I was updating commit by commit towards Edge (at the time) a PP App came along in between and undid many of the changes that Gary and John had done toward 7.2 compatibility. That's when I threw the towel in on trying to keep the App up myself.

Then later as noted Gary took steps to keep the PP App capability for updating in CE.

Anwya, I'm aware if I modify any PP App related files any further update pushed out by Herald may affect what I've done.

I think I'll try fixing this Notice and since that's all I see in the error log for anything PP App file related, I'll let it go from there.

I'm hoping if/when Herald does an update any changes would work out for the best.

Thanks for the input.

I am not a professional webmaster or PHP coder by background or training but I will try to help as best I can.

I remember what it was like when I first started with osC. It can be overwhelming.

However, I strongly recommend considering hiring a professional for extensive site modifications, site cleaning, etc.

There are several good pros here on osCommerce. Look around, you'll figure out who they are.

Link to comment
Share on other sites

44 minutes ago, raiwa said:

@altoid,

2. Update the code and keep in mind that it will probably break the auto update feature. (you can keep track on it and revert your changes before trying to run the update to the next version(s) once they will be available).

its not true

Link to comment
Share on other sites

36 minutes ago, tothcom said:

its not true

sorry, I may be wrong, but can you explain, please.

Link to comment
Share on other sites

auto update is an unzip method and a simple file overwriting process based on PP app version number.

https://github.com/osCommerce/oscommerce2/blob/de9e922377cbfd0678c9e4b9e8eb51123f3e230a/catalog/includes/apps/paypal/admin/actions/update/apply.php

The user modified files are not relevant. Only the file changes will be lost. The solution could be to report the problem to App developer but code change is allowed (Released under the GNU General Public License) temporary.

https://github.com/osCommerce/oscommerce2/blob/de9e922377cbfd0678c9e4b9e8eb51123f3e230a/catalog/ext/modules/payment/paypal/express.php#L5-L10

If you have a cotract with App developer then this is a relevant request but depends on contract rules. If you dont have prohibition on laws then you can modify codes.

I dont know what is the custom on this forum but should respect the app developer authority. On github projects this is working well.

Link to comment
Share on other sites

If clean file overwrite, why then the update reversion mentioned here:

I understand it's because of code (line by line) update, not file overwrite.

Link to comment
Share on other sites

5 hours ago, tothcom said:

@altoid

https://github.com/osCommerce/oscommerce2/blob/de9e922377cbfd0678c9e4b9e8eb51123f3e230a/catalog/ext/modules/payment/paypal/express.php#L63

change:


  switch ($HTTP_GET_VARS['osC_Action']) {

to:
 


  if (isset($HTTP_GET_VARS['osC_Action']))
  switch ($HTTP_GET_VARS['osC_Action']) {

This is not a big deal. If you dont use ";" at the end of if condition the rule do effect to next enclosed ";" character or next end of following function in PHP

I tried this change, but in testing, live shop, the checkout process kept looping back after I reached the checkout shipping stage. Like ground hog day.

So I reverted to the original and was able to get to the PayPal log in page as usual.

Here's the before and after coding copied from Winmerge

 

  switch ($HTTP_GET_VARS['osC_Action']) {
and....after

      if (isset($HTTP_GET_VARS['osC_Action']))
    switch ($HTTP_GET_VARS['osC_Action']) {

As of now, I'm back to the original as noted.

I am not a professional webmaster or PHP coder by background or training but I will try to help as best I can.

I remember what it was like when I first started with osC. It can be overwhelming.

However, I strongly recommend considering hiring a professional for extensive site modifications, site cleaning, etc.

There are several good pros here on osCommerce. Look around, you'll figure out who they are.

Link to comment
Share on other sites

If you use it, I would also say it should be wrapped around the switch:

if (isset($HTTP_GET_VARS['osC_Action'])) {
  	switch ($HTTP_GET_VARS['osC_Action']) {
		...
		...
		...
	} //end switch
} //end if isset
Link to comment
Share on other sites

I see  @altoid Author pressed it directly in switch statments

https://github.com/osCommerce/oscommerce2/blob/de9e922377cbfd0678c9e4b9e8eb51123f3e230a/catalog/ext/modules/payment/paypal/express.php#L706

default branch can not run when you examine $HTTP_GET_VARS['osC_Action'] before

I wont give you a solution because you have to totaly revrite the switch-case statement into elseif statements to prevent $_GET exeption.

Please report it to the Author to edit switch() to elseif() statement to hide the error notice.
https://github.com/haraldpdl/oscom2_app_paypal/issues


@JcMagpie
have you ever tried coding tool in forum posts? This maybe help a lot

coding.PNG.45ffba7a470cee58f49a892f0dbb5739.PNG

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...