How can I solve error of unexpected } in php - php-parse-error

When I was running a process in ProcessMaker, I got error message "Fatal error in trigger", then I checked the error logs and found this
PHP Parse error: syntax error, unexpected '}' in /opt/processmaker/workflow/engine/classes/class.pmScript.php(216) : eval()'d code on line 9.
Could anyone tell me please what should I do?
Thank you so much for your help.
Here's the code :
public function executeAndCatchErrors($sScript, $sCode)
{
ob_start('handleFatalErrors');
set_error_handler('handleErrors');
$_SESSION['_CODE_'] = $sCode;
eval($sScript );
$this->evaluateVariable();
unset( $_SESSION['_CODE_'] );
ob_end_flush();
}

ProcessMaker supports Triggers, where you can embed PHP code directly into a workflow process.
The code you have pasted is actually part of the ProcessMaker source code, which evaluates the triggers during the execution of a workflow process.
It appears though there is a PHP syntax error in a trigger rather than the source code itself.
In order to fix this issue, I would look at the process triggers and check for PHP syntax errors. I would also try and run through the process and see at what point you get the error and then check the triggers that are defined around the task that caused the error.
For more information on triggers, see:
https://wiki.processmaker.com/3.0/Triggers

Related

'Invalid hdr' error when exporting Batch Payment (Export Scenario process)

I am trying to create an export scenario, but I get an 'invalid hdr' error when i try to 'Export' the Batch Payment.
the screenshot for the error is as follows:
I do not know why this error occur or what it means.
The error suggest something wrong with your export scenario. Carefully look for any mistakes in fieldnames and/or expressions.

UWP Windows 10 app crashes in release mode but works fine in debug mode

My UWP app is crashing in Release mode and works fine in Debug mode but I can't put my finger on what the issue is but I know it's related to a combination of raising an event from System.Threading.Timer and MVVMLight.
I created an new dummy application and use the same code (ZXing.net.mobile where I used 2 portable libraries and I used my own user control which is a simplified version of theirs - I'm using events instead of <Action>). This works fine and I'm currently trying to put more steps into it i.e. include mvvmlight and navigation but so far, I can't reproduce the problem in this dummy app.
The error I'm getting is:
Unhandled exception at 0x58C1AF0B (mrt100_app.dll) in Company.MyApp.App.exe:
0xC0000602: A fail fast exception occurred. Exception handlers will not be
invoked and the process will be terminated immediately.
Followed by:
Unhandled exception at 0x0107D201 (SharedLibrary.dll) in
Company.MyApp.App.exe: 0x00001007.
When looking at the Threads window, one of the worker thread has the following information if that's of help.
Not Flagged > 4012 0 Worker Thread <No Name>
System.Private.Interop.dll!System.Runtime.InteropServices.
ExceptionHelpers.ReportUnhandledError Normal
[External Code]
System.Private.Interop.dll!System.Runtime.InteropServices.ExceptionHelpers.
ReportUnhandledError(System.Exception e) Line 885
System.Private.Interop.dll!Internal.Interop.InteropCallbacks.ReportUnhandledError
(System.Exception ex) Line 17
System.Private.WinRTInterop.CoreLib.dll!Internal.WinRT.Interop.WinRTCallbacks.
ReportUnhandledError(System.Exception ex) Line 274
System.Private.CoreLib.dll!System.RuntimeExceptionHelpers.ReportUnhandledException
(System.Exception exception) Line 152
System.Private.Threading.dll!System.Threading.Tasks.AwaitTaskContinuation.
ThrowAsyncIfNecessary(System.Exception exc) Line 784
System.Private.Threading.dll!System.Threading.WinRTSynchronizationContext.Invoker.
InvokeCore() Line 182
System.Private.Threading.dll!System.Threading.WinRTSynchronizationContext.Invoker.
Invoke(object thisObj) Line 162
System.Private.CoreLib.dll!System.Action<System.__Canon>.
InvokeOpenStaticThunk(System.__Canon obj)
System.Private.WinRTInterop.CoreLib.dll!Internal.WinRT.Interop.WinRTCallbacks.PostToCoreDispatcher.AnonymousMethod__0() Line 266
MyCompany.MyApp.App.exe
MyCompany.MyApp.App.ViewModels.ValidateHandler.Invoke(string pin)
MyCompany.MyApp.App.McgInterop.dll!McgInterop.ReverseComSharedStubs
.Proc_(object __this, System.IntPtr __methodPtr) Line 6163
MyCompany.MyApp.App.McgInterop.dll!Windows.UI.Core.DispatchedHandler__Impl.Vtbl.Invoke__STUB(System.IntPtr pComThis) Line 45147
[External Code]
Within my QR Code UserControl, it's using a System.Threading.Timer and it raises an event when a QR Code is found:
timerPreview = new Timer(async (state) =>
{
....
// Check if a result was found
if (result != null && !string.IsNullOrEmpty(result.Text))
{
Debug.WriteLine("Barcode Found: " + result.Text);
if (!this.ContinuousScanning)
{
delay = Timeout.Infinite;
await StopScanningAsync();
}
else
{
delay = this.ScanningOptions.DelayBetweenContinuousScans;
}
OnBarcodeFound(result.Text);
}
timerPreview.Change(delay, Timeout.Infinite);
}, null,
this.ScanningOptions.InitialDelayBeforeAnalyzingFrames,
Timeout.Infinite);
In the page that host the QRCode UserControl, I've got the following code:
private async void ScannerControl_BarcodeFound(string barcodeValue)
{
var dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher;
await dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => {
Debug.WriteLine(barcodeValue);
GetViewModel.BarcodeFound(barcodeValue);
});
}
As you can see, I'm passing the QrCode value to my ViewModel and from there, I sent a message and then re-direct to another page:
public void BarcodeFound(string barcodeData)
{
Messenger.Default.Send<string>(barcodeData, MessengerTokens.QrCodeFound);
this.NavigationFacade.NavigateToMyOtherPage();
}
I could keep going and provide additional code, but as I add additional breakpoints I can see that the code and passing the correct value and going to the correct location but eventually it throws this error. If I add additional error handlers or dispatcher code, it eventually works and goes to the next page as expected but when I click on a button in my CommandBar, it then takes a while and it eventually throws the same error, so by adding these additional bits of code, I feel I'm just pushing down the problem further down the line.
Anyone got any suggestions on how I get around this problem. I wish I could share the full app but definitely can't. So I know it will be hard to provide a solution, but if anyone has suggestions I'd appreciate them.
As I said, I think the issue is a result of a combination of threading and mvvmlight but it's driving me nuts that my test app so far is working exactly as expected, so I'm pretty sure it's not Zxing or my UserControl.
Any help, suggestions would be greatly appreciated or if you need me to provide additional info, please let me know what and I'll try to provide it.
Thanks.
Well, this was a painstaking exercise and a huge waste of my time!
It was down to a few things!!
I was using a different DataService in Releasemode which wasn't implemented. By implemented, I mean all my functions were returning the NotImplementedException or null values.
When passing my model to my ViewModel, I did not check if it was null, thus causing unhandled exceptions.
I had a chain of mvvmlight events (Messenger.Default.Send<>) being triggered and none were checking for error or null values.
While all of these were caused by poor validation from my part, these errors are extremely poorly reported in Release mode! if from the get go, I had received a NullReferenceException or any kind of exceptions, it would have put me in the right direction immediately, but throwing errors such as the one I've had were totally useless but it didn't but lesson learned!!
All I can say is that if this problem ever happens to you, don't waste your time rewriting code or trying to find workarounds. First work your way through your workflow/chain of events and hopefully, you'll eventually catch the culprit.
Hope this helps.
Sadly we were facing a similar issue, ours was involved with setting the qualifier values for changing localization on the fly in the app but came up with mystery fail fast/SharedLibrary native errors. Upgrading the Microsoft.NETCore.UniversalWindowPlatform package from 6.0.4 to 6.0.7 seems to have resolved the issue.
Only thought of this because another place I was researching this error involved someone solving a SharedLibrary problem by upgrading their NETCore package, that case was an earlier one (5.x), but figured it was worth a shot.

Netsuite: ReferenceError functionName is not defined

This is probably a stupid one but I have tried all the things I can think of. I am currently getting the below error on my client side script when I try and execute it.
Error: ReferenceError acvt_serialNumber_saveRecord is not defined
On the Script record in Netsuite I have set the saveRecord function as follows:
acvt_serialNumber_saveRecord
The code in the file is:
function acvt_serialNumber_saveRecord(){
/**do stuff */
}
I have reuploaded to code to make sure the right version was in NetSuite. I have added one character to both the script fn name and the fn name on the Script record (as a shot in the dark). I have seen in the Javascript console at runtime that the correct code is in there and I can see the exact function name (I did a ctrl+f for the "undefined" function in the code in the console to make sure spelling was all the same).
NOTHING has worked. I had this code working earlier, but the changes I made were not to this function at all.
Any help is appreciated
Another thing to check is the code that you recently changed. In particular, check for a hanging comma. IE:
var someObj = {
someProp:'somevalue',
};
The comma at the end of 'somevalue' will cause the script to fail, throwing 'undefined' errors.
Have you tried deleting the Script record in NetSuite and re-creating it?
Do you have any library included for that Client Script in netsuite ?
Provide a screen shot of your Netsuite script page
I encounter similar problem like this before, but it was because i called a function which is inside a library file
Thanks

User Exit CONFPP05 (T-code co11n) Exception condition "DUPREC" raised

I'm currently working on the user exit CONFPP05 (T-code co11n)
and I'm facing a problem, when i give error message with type E.
When the program execute that error, the program succesfully run the error message, but after that, when I press ENTER or SAVE button, it gives me a runtime error
here I catch some error
Exception condition "DUPREC" raised.
Error analysis
A RAISE statement in the program "SAPLCORB" raised the exception
condition "DUPREC".
Since the exception was not intercepted by a superior
program, processing was terminated.
Short description of exception condition:
For detailed documentation of the exception condition, use
Transaction SE37 (Function Library). You can take the called
function module from the display of active calls.
-
Trigger Location of Runtime Error
Program SAPLCORB
Include LCORBU08
Row 100
Module type (FUNCTION)
Module Name CO_RU_DI_AFRU_INSERT
It would be easier to confirm if we had access to your code.
However, the export parameters for the user exit are CAUVD_TAB (table of orders) and AFRUD_TAB (table of confirmations). I think that when you are showing your error message, you are not exiting the function properly and are still appending either or both of these tables. This means that when the database tries to update, it ends up with a duplicate key which results in the runtime error.

PHP - One last call

Is there a way to tell PHP to run one last function, or somehow override some error handler in the event of a fatal error? I have a cron that has a main entry point of:
$obj = new obj();
$obj->run();
exit;
Would wrapping that in a try catch do the trick if I'm not explicitly throwing errors? All I want is for PHP to do something as simple as create a txt file containing the fatal error, or even just create an empty file named 'failed.txt', or something.
Thanks!
error_handler might help you here
Or this for fatal errors: http://insomanic.me.uk/post/229851073/php-trick-catching-fatal-errors-e-error-with-a
You write it's cron. Call the script with a path to a new php.ini file wherein you make PHP to log the errors to STDERR or STDOUT.
php -h
will give you all commandline options.
Cron will send you the reports then if something failed by email.
Alternatively you can set this up to log into your own log as it's a new php.ini. In case that's easier for you to review.
You can set a custom error handler for most errors, and execute some code there.
But cannot handle an E_ERROR which is what your fatal error is likely to be.
Imagine if that error was for running out of memory. You try to handle that error, and end up using more memory. Which just throws another error, and you're right where you started.
Use register_shutdown_function() to register a function to execute as the last call. This will get call whether there was an error or not.
See http://php.net/manual/function.register-shutdown-function.php for more information.
You can do custom error handling in PHP. Check the manual at: http://php.net/function.set-error-handler. This is a fairly straightforward application of that.
Use
try
{
//Code
}
catch(Exception $e)
{
//Execute on error
}

Resources