VirtueMart Forum

VirtueMart 2 + 3 => Plugins: Payment, Shipment and others => Topic started by: gba on June 13, 2018, 14:13:07 pm

Title: Function plgVmOnPaymentNotification in payment plugins without parameter
Post by: gba on June 13, 2018, 14:13:07 pm
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:
Code: [Select]
function plgVmOnPaymentNotification(&$html)
New definition:
Code: [Select]
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
Title: Re: Function plgVmOnPaymentNotification in payment plugins without parameter
Post by: Jörgen on June 13, 2018, 16:27:22 pm
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
Title: Re: Function plgVmOnPaymentNotification in payment plugins without parameter
Post by: gba on June 13, 2018, 16:42:08 pm
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.

Quote
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?
Do you have any hint for me?

Kind regards,
Gerald
Title: Re: Function plgVmOnPaymentNotification in payment plugins without parameter
Post by: Jörgen on June 13, 2018, 17:18:56 pm
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
Title: Re: Function plgVmOnPaymentNotification in payment plugins without parameter
Post by: jenkinhill on June 13, 2018, 17:27:33 pm
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.