Function plgVmOnPaymentNotification in payment plugins without parameter

Started by gba, June 13, 2018, 14:13:07 PM

Previous topic - Next topic

gba

Hi plugin developers!

We just ran into problems, if we used the function 'plgVmOnPaymentNotification' in our own payment plugin.
After updating to VM 3.2.14 this function has a new definition now.

Old definition:
function plgVmOnPaymentNotification(&$html)

New definition:
function plgVmOnPaymentNotification()

As you can see, the function now does not have any parameter anymore.

We found that out, because a payment provider could not notify VM anymore, as the old function definition produces an error now:
"Error: 0 Too few arguments to function plgVmPaymentOurPaymentMethod::plgVmOnPaymentNotification(), 0 passed in /home/www/gmr/libraries/joomla/event/event.php on line 70 and exactly 1 expected"

As soon as we removed the parameter, the problems where gone.
Maybe this information is helpful also for someone else.

BTW:
Do we need to run into problems to find out such (quite essential) code changes in VM, or is there any information source about necessary changes for third party extensions to be able to keep them up-to-date with VM before updating to each next version?

Kind regards,
Gerald

Jörgen

This sounds like a strange issue, how old is Your plugin ?
What VM version have You updated from ?

I can see this so called "new" declaration to be used already in VM version 3.0.6 from may 2015, three years ago....

Who has developed "Your" plugin ?

regards

Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

gba

Hi!

I developed it myself and used it without issues with VM 3.2.12.
But I guess moving from PHP 7.0 to 7.2 now brought that issue up.

QuoteBTW:
Do we need to run into problems to find out such (quite essential) code changes in VM, or is there any information source about necessary changes for third party extensions to be able to keep them up-to-date with VM before updating to each next version?
Do you have any hint for me?

Kind regards,
Gerald

Jörgen

I do not know where You got your declaration from, but this function has not had any parameters as far as I know. Check the PayPal plugin as an example for how to design the calls. PHP seven has a stricter type check than PHP five and but this does not make an badly designed call better. It was wrong from the beginning and most certainly not caused by a VM update.

regards

Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

jenkinhill

AFAIK there are still some issues with PHP7.2, I don't recommend any higher than 7.1 and I'm staying at 7.0 for most of my websites. The advice given on the Joomla facebook group is still to use no higher than 7.1 with the current Joomla version.
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

gba

Thank you very much for your advice - I turned back to PHP 7.1 now.

QuoteBTW:
Do we need to run into problems to find out such (quite essential) code changes in VM, or is there any information source about necessary changes for third party extensions to be able to keep them up-to-date with VM before updating to each next version?
Do you have any hint for me?

Kind regards,
Gerald

Jörgen

Read my reply:
QuoteI do not know where You got your declaration from, but this function has not had any parameters as far as I know. Check the PayPal plugin as an example for how to design the calls. PHP seven has a stricter type check than PHP five and but this does not make an badly designed call better. It was wrong from the beginning and most certainly not caused by a VM update.

What more Do you need ?

regards

Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

gba

Hi!

I would like to know about necessary code changes in the VM extensions I made before I update to the next VM version.
Is there any information source about that anywhere?

Kind regards,
Gerald

jenkinhill

Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Studio 42

check in another payment plugins, paypal, paybox or standard for basic functions.

gba

@jenkinhill: Thank you very much for that hint!
@Studio 42: Thank you, too - a bit off-topic, though  ;)

Studio 42

Quote from: gba on June 21, 2018, 22:30:39 PM
@Studio 42: Thank you, too - a bit off-topic, though  ;)
It's the best way to check what to do, when you have not a full doc (and i dont mean that any real doc exist, only some lines )
If you check in paybox plugin for eg. You can understand how it work and compare the function
About
Quote"Error: 0 Too few arguments to function plgVmPaymentOurPaymentMethod::plgVmOnPaymentNotification(), 0 passed in /home/www/gmr/libraries/joomla/event/event.php on line 70 and exactly 1 expected"
This error is since php 7, because it's bad to not provide same number of arguments and PHP parent/child class should always follow this rule, to prevent mistake.
This can be a problem when a new argument is needed and sometime you cannot follow this rule, it's why you see a warning and not a fatal error, chaneg your PHP error reporting level, if you dont want see this message.