summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrpayanm2018-07-09 12:51:01 (GMT)
committerDaniel Wehner2018-07-09 12:51:01 (GMT)
commit0a2696728b23217bc19287e82b291c34266d4ba2 (patch)
tree65d837ddc883b6f60d76f503b7439b144d9a8d79
parent481b5c28302b277cdd3ae45424cf4e501aba3eac (diff)
Issue #1609088 by JvE, johnv, rpayanm, matthias_mo, klausi, jasom, hillmore, boabjohn: Undefined index: uid in views_handler_field->get_value() (line 375 of views_handler_field.inc)HEAD7.x-3.x
-rw-r--r--modules/user/views_handler_field_user.inc4
-rw-r--r--modules/user/views_handler_field_user_language.inc8
-rw-r--r--modules/user/views_handler_field_user_name.inc10
-rw-r--r--tests/user/views_handler_field_user_name.test59
4 files changed, 60 insertions, 21 deletions
diff --git a/modules/user/views_handler_field_user.inc b/modules/user/views_handler_field_user.inc
index 7939612..8856c4a 100644
--- a/modules/user/views_handler_field_user.inc
+++ b/modules/user/views_handler_field_user.inc
@@ -17,9 +17,7 @@ class views_handler_field_user extends views_handler_field {
*/
public function init(&$view, &$data) {
parent::init($view, $data);
- if (!empty($this->options['link_to_user'])) {
- $this->additional_fields['uid'] = 'uid';
- }
+ $this->additional_fields['uid'] = 'uid';
}
/**
diff --git a/modules/user/views_handler_field_user_language.inc b/modules/user/views_handler_field_user_language.inc
index b96963d..9f2ae4f 100644
--- a/modules/user/views_handler_field_user_language.inc
+++ b/modules/user/views_handler_field_user_language.inc
@@ -35,12 +35,4 @@ class views_handler_field_user_language extends views_handler_field_user {
return $this->sanitize_value($lang->name);
}
- /**
- * {@inheritdoc}
- */
- public function render($values) {
- $value = $this->get_value($values);
- return $this->render_link($this->sanitize_value($value), $values);
- }
-
}
diff --git a/modules/user/views_handler_field_user_name.inc b/modules/user/views_handler_field_user_name.inc
index 7043718..5cad65a 100644
--- a/modules/user/views_handler_field_user_name.inc
+++ b/modules/user/views_handler_field_user_name.inc
@@ -13,16 +13,6 @@
class views_handler_field_user_name extends views_handler_field_user {
/**
- * Add uid in the query so we can test for anonymous if needed.
- */
- public function init(&$view, &$data) {
- parent::init($view, $data);
- if (!empty($this->options['overwrite_anonymous']) || !empty($this->options['format_username'])) {
- $this->additional_fields['uid'] = 'uid';
- }
- }
-
- /**
* {@inheritdoc}
*/
public function option_definition() {
diff --git a/tests/user/views_handler_field_user_name.test b/tests/user/views_handler_field_user_name.test
index 60ec3b2..73a8ac1 100644
--- a/tests/user/views_handler_field_user_name.test
+++ b/tests/user/views_handler_field_user_name.test
@@ -51,6 +51,23 @@ class viewsHandlerFieldUserNameTest extends ViewsSqlTest {
$this->assertIdentical($render, $anon_name, 'For user0 it should use the configured anonymous text if overwrite_anonymous is checked.');
}
+
+ /**
+ * Tests that deselecting 'link_to_user' and 'format_username' works.
+ */
+ public function testOptions() {
+ $view = $this->view_raw_user_name();
+ $view->init_display();
+ $this->executeView($view);
+
+ $view->row_index = 0;
+
+ $username = $view->result[0]->users_name = 'test';
+ $view->result[0]->uid = 1;
+ $render = $view->field['name']->advanced_render($view->result[0]);
+ $this->assertTrue(strpos($render, $username) !== FALSE, 'If link to user is checked the username should be part of the output.');
+ }
+
function view_user_name() {
$view = new view();
$view->name = 'test_views_handler_field_user_name';
@@ -93,4 +110,46 @@ class viewsHandlerFieldUserNameTest extends ViewsSqlTest {
return $view;
}
+ function view_raw_user_name() {
+ $view = new view;
+ $view->name = 'test_views_handler_field_user_name';
+ $view->description = '';
+ $view->tag = 'default';
+ $view->base_table = 'users';
+ $view->human_name = 'test_views_handler_field_user_name';
+ $view->core = 7;
+ $view->api_version = '3.0';
+ $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
+
+ /* Display: Master */
+ $handler = $view->new_display('default', 'Master', 'default');
+ $handler->display->display_options['access']['type'] = 'none';
+ $handler->display->display_options['cache']['type'] = 'none';
+ $handler->display->display_options['query']['type'] = 'views_query';
+ $handler->display->display_options['query']['options']['query_comment'] = FALSE;
+ $handler->display->display_options['exposed_form']['type'] = 'basic';
+ $handler->display->display_options['pager']['type'] = 'full';
+ $handler->display->display_options['style_plugin'] = 'default';
+ $handler->display->display_options['row_plugin'] = 'fields';
+ /* Field: User: Name */
+ $handler->display->display_options['fields']['name']['id'] = 'name';
+ $handler->display->display_options['fields']['name']['table'] = 'users';
+ $handler->display->display_options['fields']['name']['field'] = 'name';
+ $handler->display->display_options['fields']['name']['label'] = '';
+ $handler->display->display_options['fields']['name']['alter']['alter_text'] = 0;
+ $handler->display->display_options['fields']['name']['alter']['make_link'] = 0;
+ $handler->display->display_options['fields']['name']['alter']['absolute'] = 0;
+ $handler->display->display_options['fields']['name']['alter']['word_boundary'] = 0;
+ $handler->display->display_options['fields']['name']['alter']['ellipsis'] = 0;
+ $handler->display->display_options['fields']['name']['alter']['strip_tags'] = 0;
+ $handler->display->display_options['fields']['name']['alter']['trim'] = 0;
+ $handler->display->display_options['fields']['name']['alter']['html'] = 0;
+ $handler->display->display_options['fields']['name']['hide_empty'] = 0;
+ $handler->display->display_options['fields']['name']['empty_zero'] = 0;
+ $handler->display->display_options['fields']['name']['link_to_user'] = 0;
+ $handler->display->display_options['fields']['name']['format_username'] = 0;
+ $handler->display->display_options['fields']['name']['overwrite_anonymous'] = 0;
+
+ return $view;
+ }
}