Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Account Constructor delegate behaves unexpectedly
I recently upgraded from rev. 225 to rev. 300. One of my homebrew extensions broke, and I cannot figure out exactly why. Here's the contents of it:
Before, it would redirect to the external page of the user being viewed. Now, it redirects to the external page of the person who is logged in. Any ideas why the Account Constructor delegate is being called for the logged-in user with the new version?
Thanks!
if (is_numeric($Context->SelfUrl)) { # Is it an account?
function Redirect_External(&$Account) {
header("location: http://wso.williams.edu/facebook/view?unix=".$Account->User->Name);
}
$Context->AddToDelegate("Account", "Constructor", "Redirect_External");
}
?>
Before, it would redirect to the external page of the user being viewed. Now, it redirects to the external page of the person who is logged in. Any ideas why the Account Constructor delegate is being called for the logged-in user with the new version?
Thanks!
0
This discussion has been closed.
Comments
If I were you I'd try some local debugging. I'd go into account.php and check to see that the account control itself is getting the correct user.
account.php lines 83-85:
echo '<div>Username before entering control: '.$AccountUser->Name.'</div>'; // Create the account profile $AccountProfile = $Context->ObjectFactory->CreateControl($Context, "Account", $AccountUser);
I'd run that and then see what name comes up.
I'd do the same right before the constructor delegate is called in the control.
I'd do the same within your delegate function, followed by a die();
Basically I'd try to narrow down where it is screwing up and assigning the wrong user.
that's not going to work, is it?
$Context->SelfUrl is going to be something like "account.php". it'll never be numeric.
if ($Context->SelfUrl == 'account.php') {
if ($Context->SelfUrl == 'account.php') {
previously, but for some reason it wasn't working when I did the upgrade. Some testing showed that $Context->SelfUrl was evaluating to the UserID of the user being displayed, which makes zero sense to me, but that's what it was. Testing for numericality didn't seem to break anything else, so that became my test.
Thanks for the tips, Mark, I'll try them out.
That rewrite rule looks good to me. Not really sure why it's not working. But it took me two weeks just to get mod_rewrite to work in the first place. Mod_rewrite is a finnicky module, that is for sure.