Author Topic: Function plgVmOnPaymentNotification in payment plugins without parameter  (Read 651 times)

gba

  • Jr. Member
  • **
  • Posts: 274
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

Jörgen

  • Global Moderator
  • Full Member
  • *
  • Posts: 1808
    • Kreativ Fotografi
  • VirtueMart Version: 3.2.12
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.8.3
Virtuemart 3.2.12
Olympiantheme Hera (customized)

gba

  • Jr. Member
  • **
  • Posts: 274
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

Jörgen

  • Global Moderator
  • Full Member
  • *
  • Posts: 1808
    • Kreativ Fotografi
  • VirtueMart Version: 3.2.12
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.8.3
Virtuemart 3.2.12
Olympiantheme Hera (customized)

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 27107
  • Always on vacation
    • Jenkin Hill Internet
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

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

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

Currently using VM 3.4.3.9989 on Joomla 3.9.1 PHP 7.0.32
Testing VM 3.4.3.9993 on Joomla 3.9.1

gba

  • Jr. Member
  • **
  • Posts: 274
Thank you very much for your advice - I turned back to PHP 7.1 now.

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

Jörgen

  • Global Moderator
  • Full Member
  • *
  • Posts: 1808
    • Kreativ Fotografi
  • VirtueMart Version: 3.2.12
Read my reply:
Quote
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.

What more Do you need ?

regards

Jörgen @ Kreativ Fotografi
Joomla 3.8.3
Virtuemart 3.2.12
Olympiantheme Hera (customized)

gba

  • Jr. Member
  • **
  • Posts: 274
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

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 27107
  • Always on vacation
    • Jenkin Hill Internet
You could check the comments for changes in the repository.  http://dev.virtuemart.net/projects/virtuemart/repository
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

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

Currently using VM 3.4.3.9989 on Joomla 3.9.1 PHP 7.0.32
Testing VM 3.4.3.9993 on Joomla 3.9.1

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3534
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3.0.x.y
check in another payment plugins, paypal, paybox or standard for basic functions.

gba

  • Jr. Member
  • **
  • Posts: 274
@jenkinhill: Thank you very much for that hint!
@Studio 42: Thank you, too - a bit off-topic, though  ;)

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3534
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3.0.x.y
@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.