Sulu: How to get the exact location of template errors in preview? - symfony

When I develop templates in Sulu 1.6 and an error occurs, where can I find the full error or exact error location? Is there some kind of special log or do I need to change the default location?
The corresponding /admin/websocket/admin response contains only this (basically the same information):
{
"handler":"sulu_preview.preview",
"message":{
"code":9903,
"message":"Unclosed \"block\".",
"type":"Sulu\\Bundle\\PreviewBundle\\Preview\\Exception\\TwigException"
},
"options":[],
"error":true
}
Currently I only see messages like this:
It would be also helpful to know, where the catch block for this is, in case it is not jet implemented.
Thx a lot!

So it turned out, that there is no logging enabled, and because the PreviewRendere throws a new Exception, the original information is pretty much lost. It can be added in this way: https://github.com/sulu/sulu/pull/4363
Best wishes
Andreas

Related

How to locate the method using an error message string?

I would like to know where is this error code located in the AOT. Would like to know the path to understand the structure and develop custom code.
Transaction has been selected, for settlement, although settlement type: none was selected
I generally use one of two methods to locate message strings.
Provided the cross reference is updated (it should be in dev) use the "Label editor" to to search for then string, see this answer.
Put a breakpoint in top of info.add method, disable CIL if needed, then rerun to get the error message invoking the debugger, see this answer.

How to give Httpful a String with double quotes in it?

The idea is to send terms like bob & \\apples to a server. I get this error:
Fatal error: Maximum execution time of 30 seconds exceeded
public function index($request, $response)
{
$uri = 'http://example.org/folder?key=["bob", "\\apples"];
$content = \Httpful\Request::get($uri)->send();
return $content;
}
As user RWC pointed out, it seems to be the library which causes this error.
The mysterious thing is, that it works with only one term (?key="bob") but with two it doesn't. When I put the URL into my browser, I get back the proper results (JSON response) with one and with two terms. So at the end it works but Httpful does something I don't know of yet.
The question you are asking is very specific for the libary you are using, Httpful, and is not a pure PHP question.
This is a valid URL:
https://www.google.com/search?q=\
and so 'http://server/search?key=\' is a valid URL.
If the following command does not work
Request::get($uri)->send()
you have to blame the library (Httpful). You provided a valid URL, so in my opinion if the libary was well written, it should work.
So you have to do something to make it work. What? For that you have to read the documentation of the library.
Good to hear that you find a solution, but is has nothing to do with normal PHP.
ini_set('max_execution_time', 500);
in your script,place this one on the top,its increase the execution time of your code.

Drupal error page

I would like to create a custom error page in Drupal 7. There are things like set_message, but they don't log the errors. So is there any hook or something similar to catch the error, log it and display a human error to my users?
You stated above that your goal is "catch the error, log it and display a human error to my users".
In that case you're probably looking for the functionality Try/Catch which allows you to try to run a block of code and if something goes wrong it will display a message.
In your particular case you can log the error to Drupal's database logging system with the watchdog function http://api.drupal.org/api/drupal/includes--bootstrap.inc/function/watchdog/7
Optionally you could also log this to the PHP error_log as well see http://php.net/manual/en/function.error-log.php
Then you could continue on displaying the message to the user using the drupal_set_message function that you already figured out.
The final code for what you're trying to accomplish would look something like this:
try {
// RUN YOUR CUSTOM CODE HERE
} catch (Exception $e) {
// Record the error Drupal's database log
watchdog('error_page', $e->getMessage());
// Record the error to PHP's error_log
error_log($e->getMessage());
// Display a message to the user
drupal_set_message("We're sorry, but we couldn't find the page you were looking for.", 'error');
}
drupal_get_messages() could be used to fetch an array to iterate through for the the error types of messages.
I'm not sure I made 100% sense of your question, but since you referenced drupal_set_message() i thought this might be what you were looking for.
You could handle it in hook_init(), check for messages there, if you find any, do something with it.
Redirecting on an error though could potentially break default drupal functionality like forms.

Broken JavaScript Registry in Plone 3.1.7

I created a javascript file TTW for a quick fix to something i was working with, and when i went to the portal_javascripts and added it there i was met with this error upon saving:
Exception Type: CompilerError
Exception Value: Path element may not be empty in 'portal/http://www.example.com/portal_skins/cloud.js'
I get that same error every time i attempt to navigate to the portal_javascripts through the ZMI, it's obvious that I incorrectly entered the id of my file, but now I can't even fix it.
I was able to find this example of someone with a similiar issue, but I have no how to go about his fix
http://markmail.org/message/zbjhjoezz2h423yr#query:+page:1+mid:yhgjekdkwnegwqen+state:results
Try this:
http://example.com/portal_javascripts/unregisterResource?id=[your_js_resource_id]

Correct way to force an invoice e-mail to be sent to a user in UberCart?

What is the correct way to force the system to send an invoice to a client. I'm trying to use:
uc_order_action_email($order, $settings);
But I keep getting:
Fatal error: Call to undefined function uc_price() in C:\xampp\htdocs\YourEstablishment\src\sites\all\modules\ubercart\payment\uc_payment\uc_payment.module on line 149
It might be a flaw in the module. The function that it's complaining about, uc_price, is defined in
ubercart/uc_store/includes/uc_price.ini
Since it's located in a ini file, that means that drupal wont include it by it self. I'm not familiar with ubercart, since I've never used it, but it seems like this could be a bug in the module. If no one here can come up with an explanation, you should go to the issue tracker.
A quick fix to your problem would be to add this before you call the function
require_once(drupal_get_path('module', 'uc_store') . '/includes/uc_price.inc');
it will include the needed file.

Resources