Commit 6edf1d63 authored by tim.plunkett's avatar tim.plunkett
Browse files

Issue #1758788 by tim.plunkett: Throw named exceptions instead of random debug messages.

parent f918e44f
......@@ -5181,7 +5181,6 @@ function views_fetch_fields($base, $type, $grouping = FALSE) {
}
}
}
// vsm('Views UI data build time: ' . (views_microtime() - $start) * 1000 . ' ms');
}
// If we have an array of base tables available, go through them
......
......@@ -107,9 +107,6 @@ function views_get_table_join($table, $base_table) {
return $handler;
}
// DEBUG -- identify missing handlers
vpr("Missing join: @table @base_table", array('@table' => $table, '@base_table' => $base_table));
}
/**
......
......@@ -526,10 +526,6 @@ function set_relationship() {
*/
function ensure_my_table() {
if (!isset($this->table_alias)) {
if (!method_exists($this->query, 'ensure_table')) {
vpr(t('Ensure my table called but query has no ensure_table method.'));
return;
}
$this->table_alias = $this->query->ensure_table($this->table, $this->relationship);
}
return $this->table_alias;
......
......@@ -92,9 +92,6 @@ function init(&$view, &$display, $options = NULL) {
$plugin->init($this->view, $this);
$this->extender[$extender] = $plugin;
}
else {
vpr('Invalid display extender @extender', array('@handler' => $extender));
}
}
}
......
......@@ -8,8 +8,8 @@
namespace Drupal\views\Plugin\views\query;
use Drupal\Core\Database\Database;
use Drupal\Core\Database\DatabaseExceptionWrapper;
use Drupal\views\Plugin\views\join\JoinPluginBase;
use Exception;
use Drupal\Core\Annotation\Plugin;
use Drupal\Core\Annotation\Translation;
......@@ -1191,10 +1191,6 @@ function compile_fields($fields_array, $query) {
$string .= $field['field'];
$fieldname = (!empty($field['alias']) ? $field['alias'] : $string);
if (!empty($field['distinct'])) {
throw new Exception("Column-level distinct is not supported anymore.");
}
if (!empty($field['count'])) {
// Retained for compatibility
$field['function'] = 'count';
......@@ -1472,7 +1468,6 @@ function execute(&$view) {
$start = microtime(TRUE);
try {
if ($view->pager->use_count_query() || !empty($view->get_total_rows)) {
$view->pager->execute_count_query($count_query);
......@@ -1501,13 +1496,13 @@ function execute(&$view) {
$view->total_rows = $view->pager->get_total_items();
}
}
catch (Exception $e) {
catch (DatabaseExceptionWrapper $e) {
$view->result = array();
if (!empty($view->live_preview)) {
drupal_set_message($e->getMessage(), 'error');
}
else {
vpr('Exception in @human_name[@view_name]: @message', array('@human_name' => $view->human_name, '@view_name' => $view->name, '@message' => $e->getMessage()));
throw new DatabaseExceptionWrapper(format_string('Exception in @human_name[@view_name]: @message', array('@human_name' => $view->human_name, '@view_name' => $view->name, '@message' => $e->getMessage())));
}
}
......
......@@ -109,7 +109,7 @@ function get_description() {
function render() {
if (empty($this->row_plugin)) {
vpr('Drupal\views\Plugin\views\style\Rss: Missing row plugin');
debug('Drupal\views\Plugin\views\style\Rss: Missing row plugin');
return;
}
$rows = '';
......
......@@ -403,7 +403,7 @@ function pre_render($result) {
*/
function render() {
if ($this->usesRowPlugin() && empty($this->row_plugin)) {
vpr('Drupal\views\Plugin\views\style\StylePluginBase: Missing row plugin');
debug('Drupal\views\Plugin\views\style\StylePluginBase: Missing row plugin');
return;
}
......
......@@ -552,7 +552,7 @@ function set_display($display_id = NULL) {
if (empty($this->display[$display_id])) {
$display_id = 'default';
if (empty($this->display[$display_id])) {
vpr('set_display() called with invalid display id @display.', array('@display' => $display_id));
debug('set_display() called with invalid display ID @display.', array('@display' => $display_id));
return FALSE;
}
}
......@@ -1179,7 +1179,6 @@ function execute($display_id = NULL) {
$this->pager->total_items = $this->total_rows;
$this->pager->update_page_info();
}
vpr('Used cached results');
}
else {
$this->query->execute($this);
......
......@@ -1328,7 +1328,7 @@ function views_get_handler($table, $field, $key, $override = NULL) {
}
// DEBUG -- identify missing handlers
vpr("Missing handler: @table @field @key", array('@table' => $table, '@field' => $field, '@key' => $key));
debug(t("Missing handler: @table @field @key", array('@table' => $table, '@field' => $field, '@key' => $key)));
$broken = array(
'title' => t('Broken handler @table.@field', array('@table' => $table, '@field' => $field)),
'id' => 'broken',
......@@ -1537,7 +1537,6 @@ function views_get_applicable_views($type) {
if (empty($view->display)) {
// Skip this view as it is broken.
vsm(t("Skipping broken view @view", array('@view' => $view->name)));
continue;
}
......@@ -1800,84 +1799,6 @@ function views_export_status($view, $status) {
views_invalidate_cache();
}
// ------------------------------------------------------------------
// Views debug helper functions
/**
* Provide debug output for Views.
*
* This relies on devel.module
* or on the debug() function if you use a simpletest.
*
* @param $message
* The message/variable which should be debugged.
* This either could be
* * an array/object which is converted to pretty output
* * a translation source string which is used together with the parameter placeholders.
*
* @param $placeholder
* The placeholders which are used for the translation source string.
*/
function views_debug($message, $placeholders = array()) {
if (!is_string($message)) {
$output = '<pre>' . var_export($message, TRUE) . '</pre>';
}
$config = config('views.settings');
if (module_exists('devel') && $config->get('debug.output') && user_access('access devel information')) {
$devel_region = $config->get('debug.region');
if ($devel_region == 'watchdog') {
$output = $message;
watchdog('views_logging', $output, $placeholders);
}
elseif ($devel_region == 'drupal_debug') {
$output = empty($output) ? t($message, $placeholders) : $output;
dd($output);
}
else {
$output = empty($output) ? t($message, $placeholders) : $output;
dpm($output);
}
}
elseif (isset($GLOBALS['drupal_test_info'])) {
$output = empty($output) ? t($message, $placeholders) : $output;
debug($output);
}
}
/**
* Shortcut to views_debug()
*/
function vpr($message, $placeholders = array()) {
views_debug($message, $placeholders);
}
/**
* Debug messages
*/
function vsm($message) {
if (module_exists('devel')) {
dpm($message);
}
}
function views_trace() {
$message = '';
foreach (debug_backtrace() as $item) {
if (!empty($item['file']) && !in_array($item['function'], array('vsm_trace', 'vpr_trace', 'views_trace'))) {
$message .= basename($item['file']) . ": " . (empty($item['class']) ? '' : ($item['class'] . '->')) . "$item[function] line $item[line]" . "\n";
}
}
return $message;
}
function vsm_trace() {
vsm(views_trace());
}
function vpr_trace() {
dpr(views_trace());
}
// ------------------------------------------------------------------
// Views form (View with form elements)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment