Problem with nuProcedure in new version

Questions related to customising nuBuilder Forte with Javascript or PHP.

Problem with nuProcedure in new version

Postby Jannie » Thu Feb 06, 2020 4:18 am

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
Test BeforeBrowsPHP
BeforeBrowsePHP.jpg (18.85 KiB) Viewed 1998 times

LogOnly-procedure.jpg
LogOnly procedure
LogOnly-procedure.jpg (19.79 KiB) Viewed 1998 times

NuDebugEntries.jpg
Nu Debug Result; As you can see there are 3 log-lines In spite off description: All lines come from BeforeBrowse procedure (see line-numbers) and no line comes from LogOnly-procedure.
NuDebugEntries.jpg (60.06 KiB) Viewed 1998 times
Jannie
 
Posts: 15
Joined: Sun Jun 10, 2018 12:06 am
Location: Netherlands

Re: Problem with nuProcedure in new version

Postby kev1n » Thu Feb 06, 2020 8:35 am

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.net/nubuilderfor ... 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
 
Posts: 969
Joined: Mon Oct 15, 2018 2:13 am

Re: Problem with nuProcedure in new version

Postby kev1n » Thu Feb 06, 2020 8:49 am

Background information for admin: It was changed after I had posted this: viewtopic.php?f=19&t=9859&p=19620&hilit=nuProcedure#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 Fri Feb 07, 2020 5:38 am, edited 1 time in total.
kev1n
 
Posts: 969
Joined: Mon Oct 15, 2018 2:13 am

Re: Problem with nuProcedure in new version

Postby Jannie » Fri Feb 07, 2020 5:17 am

Thank you for reply!
I tested with old code -> result is OK :)
I also tested your advice admin -> result is OK. :D
Jannie
 
Posts: 15
Joined: Sun Jun 10, 2018 12:06 am
Location: Netherlands

Re: Problem with nuProcedure in new version

Postby kev1n » Fri Feb 07, 2020 2:46 pm

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
kev1n
 
Posts: 969
Joined: Mon Oct 15, 2018 2:13 am

Re: Problem with nuProcedure in new version

Postby admin » Sat Feb 15, 2020 8:03 am

kev1n,

I have added your changes to Github, thanks.

Please test it.

Steven
admin
Site Admin
 
Posts: 3348
Joined: Mon Jun 15, 2009 9:53 am

Re: Problem with nuProcedure in new version

Postby kev1n » Wed Feb 19, 2020 5:00 pm

Works for me, thanks.
kev1n
 
Posts: 969
Joined: Mon Oct 15, 2018 2:13 am

Re: Problem with nuProcedure in new version

Postby admin » Thu Feb 20, 2020 2:36 am

.
admin
Site Admin
 
Posts: 3348
Joined: Mon Jun 15, 2009 9:53 am


Return to Custom Code