What I Learned Today: Views Plugin Debugging
What I Learned Today: Views Plugin Debugging
May 24th, 2016
As I've said before in my custom views filter handlers tutorial, views is amazing. Today I was writing a custom style plugin. I got the plugin to show up in the list of available formats, but whenever I saved the form, it wouldn't stick.
My Typical Method of Debugging in Drupal
Typically I would throw dpm's to debug, so I started walking through the callstack trying to find where things were going wrong. Then I ran into a line in views that called vpr()
. It looked like a print_r debug statement, so I knew this was either being logged or there was a setting somewhere.
A Better Way to Debug Views Plugins
Sure enough it is part of the "Enable views performance statistics" setting to have these messages logged with watchdog. To turn it on go to /admin/structure/views/settings/advanced. Even better, when you turn Devel on, you can have them dpm'ed instead. Now I get exactly the information I need to figure out what I was doing wrong, without having to throw my own dpm's in views or ctools.
Other Views Settings for Debugging
Also, if you are just looking to debug your views query the "Show the SQL query" and "Show performance statistics" options on /admin/structure/views/settings are invaluable.
This post is part of my challenge to never stop learning.