Login  |  Register
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome, Guest. Please login or register.
Did you miss your activation email?

February 08, 2023, 11:05:10 AM

Login with username, password and session length
Members
Stats
  • Total Posts: 194007
  • Total Topics: 21135
  • Online today: 64
  • Online ever: 3540
  • (September 02, 2022, 06:38:54 PM)
Users Online
Users: 3
Guests: 56
Total: 59

Author Topic: Too few arguments to function TinyPortal\Integrate::hookRedirect()  (Read 822 times)

0 Members and 1 Guest are viewing this topic.

Offline Arminus

  • Newbie
  • *
  • Posts: 4
Link to my forum: www dot roberge dot de
SMF version: 2.1.2
TP version: 2.2.2
Default Forum Language: German
Theme name and version: Curve 2
Browser Name and Version: Firefox
Mods installed:
Related Error messages:

Code: [Select]
Fatal error: Uncaught ArgumentCountError: Too few arguments to function TinyPortal\Integrate::hookRedirect(), 2 passed in /var/www/roberge.de2/html/Sources/Subs.php on line 5772 and exactly 3 expected in /var/www/roberge.de2/html/TinyPortal/Integrate.php:812 Stack trace: #0 /var/www/roberge.de2/html/Sources/Subs.php(5772): TinyPortal\Integrate::hookRedirect('?action=modul;s...', false) #1 /var/www/roberge.de2/html/Sources/Alps/includes/function_module.php(344): call_integration_hook('integrate_redir...', Array) #2 /var/www/roberge.de2/html/Sources/Alps/includes/search-includes/stichworturl.php(37): redirectboard('?action=modul;s...') #3 /var/www/roberge.de2/html/Sources/Alps/includes/function_search.php(53): stichwortUrl() #4 /var/www/roberge.de2/html/Sources/Alps/includes/function_search.php(22): ModulIndex() #5 /var/www/roberge.de2/html/suche.php(428): search_main() #6 {main} thrown in /var/www/roberge.de2/html/TinyPortal/Integrate.php on line 812
Although for the repro, this is called top-level from custom code, the issue is between Sources/Subs.php(5772) and TinyPortal/Integrate.php:812 - patching the latter to remove the 3rd argument (which isn't used by that function anyway?) "solves" the issue.

Is there a bug in TinyPortal/Integrate.php:812 ?

Offline @rjen

  • Support Team
  • *
  • Posts: 3497
    • FJR-club Nederland
Re: Too few arguments to function TinyPortal\Integrate::hookRedirect()
« Reply #1 on: October 07, 2022, 04:59:09 AM »
Never seen this error before.

can you tell us what exacty you are doing to trigger this error?
How can we reproduce it?

Any particular function or action?
Running Latest TP on SMF2.1 at: www.fjr-club.nl

Offline Arminus

  • Newbie
  • *
  • Posts: 4
Re: Too few arguments to function TinyPortal\Integrate::hookRedirect()
« Reply #2 on: October 07, 2022, 06:26:23 AM »
I inherited the forum maintenance from someone else, so I don't have a clear picture yet. (and this problem never happened until we installed TinyPortal, so there is some incompatibility there...)

Anyway:

this is TinyPortal/Integrate.php with 3 params, 2 of which aren't even used in that function:

Code: [Select]
public static function hookRedirect(&$setLocation, &$refresh, &$permanent)
According to the stack trace, it gets called from Sources/Subs.php on line 5772 with
Code: [Select]
$results[$function] = call_user_func_array($call, $parameters);and only 2 prams?!
which in turn gets called by this line in some custom code which I haven't written:
Code: [Select]
call_integration_hook('integrate_redirect', array(&$setLocation, &$refresh));
I'm afraid my PHP understanding is rather limited, I'm more a Java/JS/Python guy, so I really don't understand how these hooks work. I just interpreted the different function signatures as not matching and thus removed the apparently superfluous/unused 3rd param in hookRedirect to make it work as a short-term hack for the site.

I can only guess that this call_integration_hook needs a 3rd parameter?! Whatever &$permanent may be in hookRedirect.

And by the way: I accidentally misspelled my nickname for this forum and can't seem to change it, letter swap, should be Arminus ;)

Thanks for helping!

Offline @rjen

  • Support Team
  • *
  • Posts: 3497
    • FJR-club Nederland
Re: Too few arguments to function TinyPortal\Integrate::hookRedirect()
« Reply #3 on: October 07, 2022, 06:52:47 AM »
Sorry, but I have been using TinyPortal for years and I never had this issue, nor has it been reported before.

So it is either something very specific or related to your forum configuration.
Where is this custom code coming from? That may very well be the explantion that you are this first one having this issue...

Unless the issue is something I can reproduce I cannot troubleshoot it.

So I have to ask again: when does this error occur exactly?
Is it directly after installing TinyPortal? Or is it when a specific function is used?

As for the coding specifics, I will leave that to tino, who will probably reply some time later.

What I do notice is that your error refers to position 812 and the function hookRedirect is on line 821?
Running Latest TP on SMF2.1 at: www.fjr-club.nl

Offline @rjen

  • Support Team
  • *
  • Posts: 3497
    • FJR-club Nederland
Re: Too few arguments to function TinyPortal\Integrate::hookRedirect()
« Reply #4 on: October 07, 2022, 06:54:34 AM »
By the way: I have changed your user name to Arminus.
Password is unchanged...
Running Latest TP on SMF2.1 at: www.fjr-club.nl

Offline Arminus

  • Newbie
  • *
  • Posts: 4
Re: Too few arguments to function TinyPortal\Integrate::hookRedirect()
« Reply #5 on: October 07, 2022, 07:38:27 AM »
Where is this custom code coming from? That may very well be the explantion that you are this first one having this issue...
From someone who wrote this code years ago.

Unless the issue is something I can reproduce I cannot troubleshoot it.
I understand that...

So I have to ask again: when does this error occur exactly?
Is it directly after installing TinyPortal? Or is it when a specific function is used?
The error happens when this custom code is called from a form to search in table which is unrelated to SMF or TinyPortal but integrated via a menu into the site.

As for the coding specifics, I will leave that to tino, who will probably reply some time later.
From my POV, that custom code would need to call the integrate_redirect hook not with 2 but with 3 parameters.

Without TinyPortal installed, this call with 2 params apparently never caused a problem, with TinyPortal installed, it seems to call a different hook which now requires 3 params, but I don't know what that 3rd param (&$permanent) should be because it isn't actually used in TinyPortal's hookRedirect. I suppose I could just add a dummy param in the custom code, but that's just the same kind of blind hack I did on the opposite end so far. So it would really be interesting to know what the purpose of this param is so that I can possibly fix that in other places inside the custom code.

What I do notice is that your error refers to position 812 and the function hookRedirect is on line 821?
In my copy of TinyPortal/Integrate.php that function is indeed on line 812.

And thanks for changing my nickname!

Online tino

  • Developer
  • *
  • Posts: 2716
Re: Too few arguments to function TinyPortal\Integrate::hookRedirect()
« Reply #6 on: October 08, 2022, 09:06:11 AM »
We use three parameters as the core code in SMF passes three in.

https://github.com/SimpleMachines/SMF/blob/090a5b403f8f9846e3ce96aab40d931bcdddf225/Sources/Subs.php#L4081

call_user_func_array is a php function which takes the first call as the function name and the second is an array of parameters, in this instance from SMF it’s array(&$setLocation, &$refresh, &$permanent)

I think that code you have is from SMF 1.1 as that was formally two parameters, If we changed it to two it would break the SMF call so unfortunately the code at fault is your custom code. We don’t use permanent as you’ve notice but other modifications might so we accept it passed in by reference and don’t manipulate it at all. 

Offline Arminus

  • Newbie
  • *
  • Posts: 4
Re: Too few arguments to function TinyPortal\Integrate::hookRedirect()
« Reply #7 on: October 10, 2022, 09:32:59 AM »
I think that code you have is from SMF 1.1 as that was formally two parameters,
Yes that code is some years old, so that is the explanation then. Thanks for pointing that out, I hate to patch things by just hacking some symptom.

If we changed it to two it would break the SMF call so unfortunately the code at fault is your custom code. We don’t use permanent as you’ve notice but other modifications might so we accept it passed in by reference and don’t manipulate it at all.
I wouldn't expect it to change on your side, I'm passing false now as 3rd param so all is fine.

Online tino

  • Developer
  • *
  • Posts: 2716
Re: Too few arguments to function TinyPortal\Integrate::hookRedirect()
« Reply #8 on: October 10, 2022, 10:46:56 AM »
I wouldn't expect it to change on your side, I'm passing false now as 3rd param so all is fine.

I would copy SMF personally, and have the following.

Code: [Select]
(&$setLocation, &$refresh, &$permanent)
As other applications which extend that hook may manipulate that value and having a false will throw an error.