Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Problem with nuProcedure in new version

Questions related to customising nuBuilder Forte with JavaScript or PHP.
Post Reply
Jannie
Posts: 35
Joined: Sat Jun 09, 2018 4:36 pm
Location: Netherlands
Has thanked: 5 times
Been thanked: 1 time
Contact:

Problem with nuProcedure in new version

Unread post by Jannie »

Last week I updated my nuBuilder4-database from the version of may 2019 to newest version.
In this new version a nuProcedure started in BeforeBrowse-routine of a browse-form doesn't run.
Because af that, I created a very small php-procedure with only a nuDebug()-line. I tested with this one and I don't see anything in the logging.

Conclusion: I seems a problem with nuProcedure
BeforeBrowsePHP.jpg
LogOnly-procedure.jpg
NuDebugEntries.jpg
You do not have the required permissions to view the files attached to this post.
kev1n
nuBuilder Team
Posts: 4416
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 74 times
Been thanked: 472 times
Contact:

Re: Problem with nuProcedure in new version

Unread post by kev1n »

The function was changed with that commit
https://github.com/steven-copley/nubuil ... daaaee6043

but the function no longer works as described here:

https://wiki.nubuilder.cloud/ ... uProcedure


Fix: Undo that change in nucommon.php:

Replace this function

Code: Select all

function nuProcedure($c){

	$s							= "SELECT * FROM zzzzsys_php WHERE sph_code = ? ";
	$t							= nuRunQuery($s, [$c]);
	$r							= db_fetch_object($t);
	$php						= nuReplaceHashVariables($r->sph_php);
	$php						= "$php \n\n//--Added by nuProcedure()\n\n$"."_POST['nuProcedureEval'] = '';";
	$_POST['nuProcedureEval']	= "Procedure <b>$r->sph_code</b> - run inside ";
	
	return '';//$php;
	
}
wtih this

Code: Select all

function nuProcedure($c){

	$s							= "SELECT * FROM zzzzsys_php WHERE sph_code = ? ";
	$t							= nuRunQuery($s, [$c]);
	$r							= db_fetch_object($t);
	$php						= nuReplaceHashVariables($r->sph_php);
	$php						= "$php \n\n//--Added by nuProcedure()\n\n$"."_POST['nuProcedureEval'] = '';";
	$_POST['nuProcedureEval']	= "Procedure <b>$r->sph_code</b> - run inside ";
	
	return $php;
	
}
kev1n
nuBuilder Team
Posts: 4416
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 74 times
Been thanked: 472 times
Contact:

Re: Problem with nuProcedure in new version

Unread post by kev1n »

Background information for admin: It was changed after I had posted this: https://forums.nubuilder.cloud/viewtopic. ... ure#p19620
But now the function always returns an empty string. It should only return an empty string if the Procedure does not exist.


I think nuProcedure() should look like this:

Code: Select all

function nuProcedure($c){

	$s							= "SELECT * FROM zzzzsys_php WHERE sph_code = ? ";
	$t							= nuRunQuery($s, [$c]);
	
	if (db_num_rows($t) > 0) {  // procedure exists
	
		$r							= db_fetch_object($t);
		$php						= nuReplaceHashVariables($r->sph_php);
		$php						= "$php \n\n//--Added by nuProcedure()\n\n$"."_POST['nuProcedureEval'] = '';";
		$_POST['nuProcedureEval']	= "Procedure <b>$r->sph_code</b> - run inside ";
		return $php;
	} else
	{
		return '';
	}
	
}
Last edited by kev1n on Thu Feb 06, 2020 9:08 pm, edited 1 time in total.
Jannie
Posts: 35
Joined: Sat Jun 09, 2018 4:36 pm
Location: Netherlands
Has thanked: 5 times
Been thanked: 1 time
Contact:

Re: Problem with nuProcedure in new version

Unread post by Jannie »

Thank you for reply!
I tested with old code -> result is OK :)
I also tested your advice admin -> result is OK. :D
kev1n
nuBuilder Team
Posts: 4416
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 74 times
Been thanked: 472 times
Contact:

Re: Problem with nuProcedure in new version

Unread post by kev1n »

Jannie wrote:Thank you for reply!
I tested with old code -> result is OK :)
I also tested your advice admin -> result is OK. :D
Thanks for testing. Added this issue to my bug list:

https://github.com/smalos/nuBuilder4-Bu ... ocedure.md
admin
Site Admin
Posts: 2822
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 29 times

Re: Problem with nuProcedure in new version

Unread post by admin »

kev1n,

I have added your changes to Github, thanks.

Please test it.

Steven
kev1n
nuBuilder Team
Posts: 4416
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 74 times
Been thanked: 472 times
Contact:

Re: Problem with nuProcedure in new version

Unread post by kev1n »

Works for me, thanks.
admin
Site Admin
Posts: 2822
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 29 times

Re: Problem with nuProcedure in new version

Unread post by admin »

.
Post Reply