Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Errare Humanum Est

Errare Humanum Est

Understanding ExpressionEngine's Error Messages.

Lodewijk Schutte

June 12, 2013
Tweet

More Decks by Lodewijk Schutte

Other Decks in Technology

Transcript

  1. Dealing With It - Get the facts. - Never assume,

    always know. - Draw your conclusions. - Deduce the solution.
  2. Native errors - Generated by the application: CI, EE, add-ons

    or your code. - Usually triggered by an action. - Can provide feedback when used for validation. - Can be deliberately cryptic for security reasons.
  3. An Error Was Encountered The name you submitted may only

    contain alpha-numeric characters, underscores, and dashes « Back
  4. The following errors were encountered • You are not authorized

    to perform this action Return to Previous Page
  5. - Well, you’re not authorized to perform this action. -

    What action? Submitting a form. - To be more precise: submitting a form, hitting back, and submitting it again. What are the facts?
  6. You need to know... - ExpressionEngine can “Process form data

    in Secure Mode” to prevent spamming and whatnot. - It generates a hash each time a form is generated. When you submit the form, the hash is checked and deleted. - If the hash is not there, the error is shown.
  7. Conclusion - First the hash and form are generated. -

    You submit the form, deleting the hash. - You hit ‘Back’ and the previous form is reloaded from the browser’s cache; no new hash is generated. - You submit again, but the security hash has already been deleted, ergo: error.
  8. Solution - Disable the Secure Forms setting. - Or, for

    some add-ons like Low Search, disable it on a per-form basis using secure="no"
  9. - EE can’t load the Low Seg2Cat extension file. -

    Works locally, doesn’t work on staging. - Database and files appeared to have been synced without failure. What are the facts?
  10. You need to know... - Enabled extensions, like Low Seg2Cat,

    are registered in the database. - Hooks are triggered and the associated extensions are loaded and fired. - If the extension file can’t be loaded, this error is shown.
  11. Conclusion - Despite that local and staging environments look the

    same, they are not the same. - The hook is triggered and the extension fired, based on its presence in the database. - The file on staging must be either missing or invalid.
  12. Solution - Verify the location of the extension file. -

    Make sure symlinks are followed when syncing environments.
  13. - Generated by PHP itself. - Usually triggered by bugs

    in CI, EE, add-ons or your code. - Will point you to a file and line number. PHP errors
  14. ?

  15. Avoid the WSOD - Log in as SuperAdmin. - Make

    sure the Debug Preference is set to 1. - Open index.php & admin.php - Change $debug  =  0; to $debug  =  1;
  16. <?php //  $live  is  a  var  set  based  on  the

     environment: //  local,  staging  or  production $config['show_profiler']  =  $live  ?  'n'  :  'y'; $config['template_debugging']  =  $live  ?  'n'  :  'y';
  17. Fatal error: Allowed memory size of 16777216 bytes exhausted (tried

    to allocate 262266 bytes) in /Users/low/Sites/ee260/system /expressionengine/controllers/ee.php on line 133
  18. - Allowed memory (16777216 bytes: 16M) is exhausted. Memory is

    full. - The file ee.php, a native file, is still busy writing stuff to memory, but cannot, so it throws a “Fatal” error. What are the facts?
  19. You need to know... - EE is pretty memory intensive

    and requires at least 32M of PHP memory. - This is a guesstimate. Depending on third party add-ons and your own template code, EE may need even more. - Stuff is written to memory all the time, so the error can be triggered in any file.
  20. Conclusion - Most likely: the web server doesn’t have enough

    memory allocated to PHP. - Less likely: there is an infinite loop somewhere flooding the memory.
  21. Solution - Increase the amount of memory in your .htaccess

    or php.ini file. - If that doesn’t help, you might need to: - Refactor your template code; - Check where the error comes from and submit a bug report.
  22. - There’s a PHP syntax error somewhere (unexpected ‘FALSE’). -

    The error is triggered by EE’s Functions.php library. - On line 679, it uses eval() to process code, which contains the error on line 5. - PHP is not enabled in the template. What are the facts?
  23. You need to know... - ExpressionEngine transforms advanced conditionals to

    PHP and then executes them using eval(). - So, strictly speaking, if you use advanced conditionals, you’ve enabled PHP in your template.
  24. Conclusion - An advanced conditional is not formatted correctly in

    a template that’s being called. - Let’s take a look...
  25. {embed="home/_header"  title="Welcome"} <p>   Hello   {if  segment_1  =  'foo'}

        foo   {if:else}     bar   {/if} </p> {embed="home/_footer"}
  26. {embed="home/_header"  title="Welcome"} <p>   Hello   {if  segment_1  ==  'foo'}

        foo   {if:else}     bar   {/if} </p> {embed="home/_footer"}
  27. - A script tries to call the json_encode() method belonging

    to the EE_Javascript class. - That method is undefined. In other words: does not exist. - The script calling it is CodeIgniter’s native Javascript.php library. What are the facts?
  28. You need to know... - EllisLab has deprecated the generate_json()

    method in EE 2.6 in favor of PHP’s json_encode() function. - However, that’s a global function, not a method belonging to a class. - No mention of a json_encode() method in CodeIgniter’s Javascript class.
  29. Conclusion - The Javascript.php library file is not the original

    one. - Let’s ask the client... - Client says “no hacks”.
  30. - Generated by PHP. - Triggered by malformed SQL queries.

    - Will contain the error message and full SQL query. MySQL errors
  31. Error Number: 1054 Unknown column '‘open’' in 'where clause' SELECT

    title FROM exp_channel_titles WHERE channel_id = 1 AND status = ‘open’ LIMIT 10 Filename: modules/query/mod.query.php Line Number: 181
  32. - There’s a non-existent field (unknown column) in the WHERE

    clause of the SQL. - You copy/pasted the query from an online forum, where it was said it was tried and tested. - The query itself looks okay, but isn’t. What are the facts?
  33. You need to know... - The error number given isn’t

    important. - Filename and Line Number refer to the native Query module. - Sometimes, things are not what they seem, especially when copy/pasting.
  34. Conclusion - Something went wrong when copy/ pasting the query.

    - Verify the validity of the query in your code.
  35. Solution - Curly quotes were used instead of regular ones.

    - Don’t just blindly copy/paste code without checking.
  36. Error Number: 1064 You have an error in your SQL

    syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 6 SELECT DISTINCT(t.entry_id), `t`.`channel_id`, `t`.`title`, `t`.`status`, `t`.`url_title` FROM (`exp_channel_titles` t) WHERE `t`.`site_id` = 5 AND `t`.`channel_id` IN ('16') AND `t`.`status` IN ('open', 'closed', 'Home') ORDER BY FIELD(t.entry_id, `147`, `123`, `124`, `122`, `125)` Filename: third_party/low_reorder/base.low_reorder.php Line Number: 407
  37. - A SQL syntax error was triggered because of a

    stray backtick. - Active Record is used to generate the query in the third-party add-on. - I could not reproduce, therefore the error occurs on a different environment. What are the facts?
  38. You need to know... - No software is without bugs,

    so question everything. - Bugs do get fixed, some sooner than others.
  39. Conclusion - There must be a bug in how Active

    Record generates queries. - That bug was fixed in EE2.4.
  40. HTTP errors - Generated by the web server or PHP.

    - Triggered by faulty scripts or web server restrictions. - Come in codes: - 4xx: Client errors (403, 404...) - 5xx: Server errors (500...)
  41. Internal Server Error The server encountered an internal error or

    misconfiguration and was unable to complete your request. Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log.
  42. - The error 500 is triggered before the application, or

    PHP even gets executed. - Most likely then, the error is not caused by a PHP script. - Something else is responsible, most likely something web server related. What are the facts?
  43. You need to know... - HTTP errors are not nearly

    as verbose as PHP errors. - The most common web server related file you are likely to edit is .htaccess. - A syntax error or an unsupported statement in .htaccess will trigger an error 500.
  44. Conclusion - The .htaccess file contains a syntax error or

    unsupported statement. - Check the file or remove it entirely to rule out anything else.
  45. - As seen in the Developer log. - Mostly used

    for notices and warnings about use deprecated code. - These are, in fact, not errors. Other errors