Skip to content

Conversation

@bafbes
Copy link
Contributor

@bafbes bafbes commented Jan 7, 2025

Fix : To be accessible by doActions hook, $tmpthirdparty must not be redeclared after its execution

@eldy
Copy link
Member

eldy commented Jan 14, 2025

Sorru i don't understand. Why do you need to use tmpthirdparty.
It is an object that is initialized later by a fetch, why declare it before hook doAction

@eldy eldy added the discussion Further information is requested label Jan 14, 2025
@bafbes
Copy link
Contributor Author

bafbes commented Jan 14, 2025

When I use the sellyoursaasGetRegisterPageForm in register.php to get more fields about the thirdparty, in conjuction with the doActions hook to add the posted information to tmpthirdparty, I need to reuse the object tmpthirdparty and have it already created and ready to be modified as it will be saved later to database after the hook. If the object is created after the hook, it won't be useful for this matter.

@eldy
Copy link
Member

eldy commented Feb 28, 2025

When I use the sellyoursaasGetRegisterPageForm in register.php to get more fields about the thirdparty, in conjuction with the doActions hook to add the posted information to tmpthirdparty, I need to reuse the object tmpthirdparty and have it already created and ready to be modified as it will be saved later to database after the hook. If the object is created after the hook, it won't be useful for this matter.

This means you are using a
global $tmpthirdparty
into your doAction ? so you can propagate properties out of the hook ?
But this var is a tmp var and is not dedicated to this and has no reason to be declared before the core code need it.
If you really need to propagate data out of the hook doAction, you can set it into conf->cache array or into a global variable name of your choice.
Then later it can be used the same way by the second hook that need it.

@hregis
Copy link
Contributor

hregis commented Feb 28, 2025

@eldy désolé je le fait en français, ligne 735 on a

$contract->fetch_thirdparty();
$tmpthirdparty = $contract->thirdparty;

et ligne 897 ont a :

$tmpthirdparty=new Societe($db);

je n'ai pas approfondi mais est-ce que $tmpthirdparty est écrasé ou pas ?

@bafbes
Copy link
Contributor Author

bafbes commented Mar 13, 2025

No. It's not overwritten, but only updated as a global variable, as noted by eldy.
This is the simplest way I've found to do it. We may then need to change the variable name to reflect its global nature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

discussion Further information is requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants