MyBB Community Forums

Full Version: Hooks in xmlhttp.php
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I couldn't belive that there is only one hook for xmlhttp.php file. One file, multiple application and only one hook. To be able to make full feature plugins associated with things that xmlhttp.php offers more particular hooks would be very very helpful (for each action). Don't you think so?
xmlhttp.php is used for Ajax so having more hooks there is definitely not good since it will just slow down server responses.
There is a hook in the file so splitting it into many hooks for each action won't slow down execution at all (each action ends up with exit, so only one action can be taken - only one hook run). After moving current hook at the end of the file will make it much more flexible without noticeable slow down.
(2010-08-18, 12:28 AM)marines Wrote: [ -> ]There is a hook in the file so splitting it into many hooks for each action won't slow down execution at all (each action ends up with exit, so only one action can be taken - only one hook run). After moving current hook at the end of the file will make it much more flexible without noticeable slow down.

So what you're suggesting is, moving the current hook to the end of the file and add another one per action? There are some actions that do not end with exit; so an extra hook will be run.
(2010-08-18, 12:44 AM)Pirata Nervo Wrote: [ -> ]So what you're suggesting is, moving the current hook to the end of the file and add another one per action?
Right.

Quote:There are some actions that do not end with exit; so an extra hook will be run.
What is clearly a bug. As I can see there is no exit in get_buddyselect action (which is quite understandable because it's last checked action), refresh_captcha, edit_post (with update_post subaction), get_users and get_usergroups. Apart from the first action I can't see any reasonable explanation of not exiting after doing the job. If there is any explanation why other actions are exited? Not exiting actions does additional elsif checks which slow down script execution. Huh
(2010-08-18, 01:05 AM)marines Wrote: [ -> ]
(2010-08-18, 12:44 AM)Pirata Nervo Wrote: [ -> ]So what you're suggesting is, moving the current hook to the end of the file and add another one per action?
Right.

Quote:There are some actions that do not end with exit; so an extra hook will be run.
What is clearly a bug. As I can see there is no exit in get_buddyselect action (which is quite understandable because it's last checked action), refresh_captcha, edit_post (with update_post subaction), get_users and get_usergroups. Apart from the first action I can't see any reasonable explanation of not exiting after doing the job. If there is any explanation why other actions are exited? Not exiting actions does additional elsif checks which slow down script execution. Huh

I have no idea, I guess the team should answer those questions, not myself Toungue
Do you guys know how an 'else if' statement works?

$i = 3;

if($i == 0)
{
  // This won't get executed
}
else if($i == 1)
{
   // This won't get executed
   exit;
}
else if($i == 2)
{
   // This won't get executed
}
else if($i == 3)
{
   // This will get executed
}
else if($i == 4)
{
  // This won't get executed
}
else if($i == 5)
{
  // This won't get executed
  exit;
}
else
{
  // this won't get executed
}


The exit statements themselves that are used post-competition are actually arbitrary. There is however, no bug.


Back to the original issue. If you have plugin hooks you wish to request, please list them and where you want them placed.
If no hook exists add one manually and include that as part of the installation instructions. Then petition MyBB to add the hook. They've added them in the past for authors if the location is within the normal parameters of MyBB and a hook makes sense. And I agree that this file could use a start and end hook.
(2010-08-18, 02:21 AM)Ryan Gordon Wrote: [ -> ]Do you guys know how an 'else if' statement works?

$i = 3;

if($i == 0)
{
  // This won't get executed
}
else if($i == 1)
{
   // This won't get executed
   exit;
}
else if($i == 2)
{
   // This won't get executed
}
else if($i == 3)
{
   // This will get executed
}
else if($i == 4)
{
  // This won't get executed
}
else if($i == 5)
{
  // This won't get executed
  exit;
}
else
{
  // this won't get executed
}


The exit statements themselves that are used post-competition are actually arbitrary. There is however, no bug.


Back to the original issue. If you have plugin hooks you wish to request, please list them and where you want them placed.

You're completely correct but who talked about else if's being run or not after an if/else if condition has been validated as true? Am I blind? :s

Edit:
Ooops I just read post #5 carefully Toungue It was 2:14 AM when I posted a reply so I didn't read it properly I guess
(2010-08-18, 02:21 AM)Ryan Gordon Wrote: [ -> ]
$i = 3;

if($i == 0)
{
  // This won't get executed
}
else if($i == 1)
{
   // This won't get executed
   exit;
}
else if($i == 2)
{
   // This won't get executed
}
else if($i == 3)
{
   // This will get executed
}
else if($i == 4)
{
  // This won't get executed
}
else if($i == 5)
{
  // This won't get executed
  exit;
}
else
{
  // this won't get executed
}

Yes, but:
$i = 3;

if($i == 0) // <- this will be executed
{
  // This won't get executed
}
else if($i == 1) // <- this will be executed
{
   // This won't get executed
   exit;
}
else if($i == 2) // <- this will be executed
{
   // This won't get executed
}
else if($i == 3) // <- this will be executed
{
   // This will get executed
}
else if($i == 4) // <- this will be executed TOO
{
  // This won't get executed
}
else if($i == 5) // <- this will be executed TOO
{
  // This won't get executed
  exit;
}
else
{
  // this won't get executed
}

It's rather unneccessary. Putting exit in the end of ech action is not a big deal.

$i = 3;

if($i == 0) // <- this will be executed
{
  // This won't get executed
  exit;
}
else if($i == 1) // <- this will be executed
{
   // This won't get executed
   exit;
}
else if($i == 2) // <- this will be executed
{
   // This won't get executed
   exit;
}
else if($i == 3) // <- this will be executed
{
   // This will get executed
   exit;
}
else if($i == 4) // <- this will NOT be executed now
{
  // This won't get executed
  exit;
}
else if($i == 5) // <- this will NOT be executed now
{
  // This won't get executed
  exit;
}
else
{
  // this won't get executed
}

Am I wrong? Perhaps it looks silly but it really takes time which is very valuable as Pirata Nervo said.

Comming back to the topic. I see but xmlhttp.php has one hook while others have more. I'm just suggesting. Smile
Pages: 1 2