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

Errare Humanum Est

Errare Humanum Est

Understanding ExpressionEngine's Error Messages.

A347386377e120e3230403d2558c1a0d?s=128

Lodewijk Schutte

June 12, 2013
Tweet

Transcript

  1. Errare Humanum Est Understanding ExpressionEngine’s Error Messages By Lodewijk Schutte

    ~ Low, June 2013
  2. Hi! I’m Low!

  3. None
  4. Your code Add-ons ExpressionEngine CodeIgniter PHP & MySQL Web Server

  5. Error types - Native - PHP - MySQL - HTTP

  6. The error itself does not matter, it is how you

    deal with it.
  7. Dealing With It - Get the facts. - Never assume,

    always know. - Draw your conclusions. - Deduce the solution.
  8. “When you have eliminated the impossible, whatever remains, however improbable,

    must be the truth.” — Sherlock Holmes
  9. Native errors

  10. 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.
  11. An Error Was Encountered The name you submitted may only

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

    to perform this action Return to Previous Page
  13. - 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?
  14. 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.
  15. 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.
  16. Solution - Disable the Secure Forms setting. - Or, for

    some add-ons like Low Search, disable it on a per-form basis using secure="no"
  17. Error Unable to load the following extension file: ext.low_seg2cat.php

  18. - 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?
  19. 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.
  20. 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.
  21. Solution - Verify the location of the extension file. -

    Make sure symlinks are followed when syncing environments.
  22. PHP errors

  23. - 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
  24. ?

  25. ExpressionEngine® “Shut up!” PHP error “Help! Help! I’m being suppressed!”

  26. 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;
  27. More debugging tools - Enable Output Profiler. - Enable Template

    Debugger. - Pro Tip: use config.php.
  28. <?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';
  29. 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
  30. - 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?
  31. 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.
  32. 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.
  33. 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.
  34. Parse error: syntax error, unexpected 'FALSE' (T_STRING) in /Users/low/Sites/ee260/system/expressionengine/libraries /Functions.php(679)

    : eval()'d code on line 5
  35. - 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?
  36. 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.
  37. Conclusion - An advanced conditional is not formatted correctly in

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

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

        foo   {if:else}     bar   {/if} </p> {embed="home/_footer"}
  40. Fatal error: Call to undefined method EE_Javascript::json_encode() in /Users/low/Sites/ee260 /system/codeigniter/system/libraries/Javascript.php

    on line 797
  41. - 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?
  42. 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.
  43. Conclusion - The Javascript.php library file is not the original

    one. - Let’s ask the client... - Client says “no hacks”.
  44. THE CLIENT ALWAYS LIES

  45. MySQL errors

  46. - Generated by PHP. - Triggered by malformed SQL queries.

    - Will contain the error message and full SQL query. MySQL errors
  47. 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
  48. - 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?
  49. 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.
  50. Conclusion - Something went wrong when copy/ pasting the query.

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

    - Don’t just blindly copy/paste code without checking.
  52. 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
  53. - 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?
  54. You need to know... - No software is without bugs,

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

    Record generates queries. - That bug was fixed in EE2.4.
  56. Solution - Update the software. - Set minimum requirements to

    EE2.4.
  57. HTTP errors

  58. 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...)
  59. Internal Server Error The server encountered an internal error or

    misconfiguration and was unable to complete your request. Please contact the server administrator, you@example.com 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.
  60. - 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?
  61. 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.
  62. Conclusion - The .htaccess file contains a syntax error or

    unsupported statement. - Check the file or remove it entirely to rule out anything else.
  63. Other errors

  64. Deprecated function generate_json() called in /Users/low/Software/low_reorder/ee2/ third_party/low_reorder/mcp.low_reorder.php on line 276.

    Deprecated since 2.6. Use the native JSON extension (json_encode()) instead.
  65. - As seen in the Developer log. - Mostly used

    for notices and warnings about use deprecated code. - These are, in fact, not errors. Other errors
  66. None
  67. Questions?

  68. Thank You! gotolow.com @low