Page 1 of 1

Problem with nuProcedure in new version

Posted: Wed Feb 05, 2020 7:48 pm
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

Re: Problem with nuProcedure in new version

Posted: Thu Feb 06, 2020 12:05 am
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;
	
}

Re: Problem with nuProcedure in new version

Posted: Thu Feb 06, 2020 12:19 am
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 '';
	}
	
}

Re: Problem with nuProcedure in new version

Posted: Thu Feb 06, 2020 8:47 pm
by Jannie
Thank you for reply!
I tested with old code -> result is OK :)
I also tested your advice admin -> result is OK. :D

Re: Problem with nuProcedure in new version

Posted: Fri Feb 07, 2020 6:16 am
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

Re: Problem with nuProcedure in new version

Posted: Fri Feb 14, 2020 11:33 pm
by admin
kev1n,

I have added your changes to Github, thanks.

Please test it.

Steven

Re: Problem with nuProcedure in new version

Posted: Wed Feb 19, 2020 8:30 am
by kev1n
Works for me, thanks.

Re: Problem with nuProcedure in new version

Posted: Wed Feb 19, 2020 6:06 pm
by admin
.