I use a taxonomy argument in two views:
Views #1:
- Argument: "Taxonomy: Term"
- Validator: Taxonomy term / Argument type: Term name
- Action to take if argument does not validate: Display emtpy text

Views #2:
- Argument: "Taxonomy: Term"
- Validator: PHP Code
- Action to take if argument does not validate: Display emtpy text

If the taxonomy argument is valid / not there everything works great.

If the taxonomy argument is not valid, I get the empty text message and the error

Notice: Undefined index: nid in views_handler_field_term_node_tid->pre_render() (Line 80 of ./sites/all/modules/views/modules/taxonomy/views_handler_field_term_node_tid.inc).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

DeepBlack’s picture

Same error: taxonomy argument not valid =>
Notice: Undefined index: nid in views_handler_field_term_node_tid->pre_render() (Line 80 of publicweb/sites/all/modules/views/modules/taxonomy/views_handler_field_term_node_tid.inc).

dawehner’s picture

Version: 7.x-3.x-dev » 6.x-3.x-dev
Status: Active » Needs review
FileSize
2.25 KB

pre_render shouldn't be runned for empty views.

SvenLu’s picture

Hi!

Just a quick Question. Is this patch for Views 7.x or 6.x?
I have this problem with Views 7.x. Just asking because you changed the Version "7.x-3.x-dev » 6.x-3.x-dev"

dawehner’s picture

The real bug behind this issue should be solved in 6.x-3.x first and ported later.

The patch was created against 7.x, but the changes was in a file which shouldn't have changed.
You can mark this issue as "needs work" if the patch didn't applied.

DeepBlack’s picture

Works great - no more errors.
Thanks

MJH’s picture

I have the same problem with Views 7.x-3.x-dev.
Is the mentioned patch already in the newer devs or do I have to use the patch?

dawehner’s picture

Before asking whether this patch is for 7.x-3.x, too you should

a) Test the patch with 7.x-3.x
b) If the patch applies you could mention it
If the patch doesn't apply you could mention it too.

MJH’s picture

Patch tested with Views 7.x-3.x-dev from Mar-14:
Error message "Undefined index: nid in views_handler_field_term_node_tid->pre_render()" is gone.
No other negative effects found.

Apfel007’s picture

when will be this patch committed?

dawehner’s picture

Assigned: Unassigned » merlinofchaos

Assign to review.

RYL’s picture

Hi,

I'm also having this problem and will apply the patch.

However, for all new users of this module, do we have a date to get this patch committed ?
How can we help to make this happen ?

Thanks

dawehner’s picture

Just in general there is no a HARD date when something is commited but sure you can help.

  • Test the patch, whether it works as expected
  • Review the patch and have a look whether the code looks right
  • Make it easy to reproduce the bug, for example by providing a detailed step-by-step guide.

You know there are SOOO many issues in views, a notice, which is not an php error, isn't that mission critical :)

dynamicdan’s picture

I love the idea that it's a notice and harmless but I also love the idea that it's easy to fix... => quick win?

This is the only patch I have to manually merge to ensure our system doesn't break due to the 'notice'. It's an incredibly bad experience for users/admins to see 'error looking' messages whenever editing or creating a view.

Note: this also happens on the latest dev version (7.x-3.x-dev).

johnv’s picture

Status: Needs review » Reviewed & tested by the community

I have tested this patch on 7.x-3.x-dev and it works fine.
Works for #13 , #8 and #5 ==> RTBC

@dynamicdan #13: at admin/config/development/logging (path for D7) , you can set the watchdog-messages that appear on screen - so you can avoid notices showing up.

@dereine #4: IMO bugs should be fixed against latest version ,and then backported? You state otherway around.

dawehner’s picture

Status: Reviewed & tested by the community » Needs work

Sadly the patch doesn't apply for me to 6.x-3.x anymore.

joshmiller’s picture

I don't have time to setup a clean diff, but here's how to manually fix this based on the patch supplied by deriene in #2

Note: Tested and works marvelously with views-7.x-3.1

1) Open up /views/includes/view.inc

2) Search for the lines
"// Initialize the style plugin.
$this->init_style();"

3) Add this statement directly below:

if (!empty($this->result)) {

4) Search for "$this->display_handler->output = $this->display_handler->render();"

5) Add this curly bracket directly above

}

6) Hit reload on your view. If you get a white screen of death, you haven't put the if statement in the right spot. Try again.

Josh

astro87’s picture

Version: 6.x-3.x-dev » 7.x-3.3

Thanks joshmiller, it's working for me

johnv’s picture

Version: 7.x-3.3 » 7.x-3.x-dev
Status: Needs work » Needs review

The patch from #2 is outdated with latest -dev.
I am not sure if it is necessary anymore, given the fact that is is from March 2, 2011.

Status: Needs review » Needs work

The last submitted patch, 1074768-pre_render-empty.patch, failed testing.

joshmiller’s picture

Status: Needs work » Closed (cannot reproduce)

This appears to be fixed in 7.x-3.x -- can't reproduce the error and I find more logic here than last I saw...

see Line 985 in views/includes/view.inc:

   // Arguments can, in fact, cause this whole thing to abort.
    if (!$this->_build_arguments()) {
      $this->build_time = microtime(TRUE) - $start;
      $this->attach_displays();
      return $this->built;
    }

I believe this fixed the original issue.

Apfel007’s picture

Version: 7.x-3.x-dev » 7.x-3.3

error still there

SilviaT’s picture

Same here, choosing as Action to take if filter value does not validate Display content of "No results found"

Anonymous’s picture

Version: 7.x-3.3 » 7.x-3.5

Have the same bug in 7.x-3.5.

The strange thing is though I didn't have it at first.

It only happened during development and testing when I shut down a few modules keeping a lean install, as well as going from pretty URL's to normal URL's and deinstalling PathAuto and Global Redirect. I have also been configuring panels. As well as building additional panes within the same view.

It's not much to go on, for now, but maybe it rings a bell with someone, and we can hopefully find the common denominator(s) for this bug.

Anonymous’s picture

Status: Closed (cannot reproduce) » Active
Anonymous’s picture

Status: Active » Closed (cannot reproduce)

By the way I get the error on line 88 instead of line 80. Let me post the error code here:


    Notice: Undefined index: nid in views_handler_field_term_node_tid->pre_render() (line 88 of /path/sites/all/modules/views/modules/taxonomy/views_handler_field_term_node_tid.inc).
    Notice: Undefined index: nid in views_handler_field_term_node_tid->pre_render() (line 88 of /path/sites/all/modules/views/modules/taxonomy/views_handler_field_term_node_tid.inc).
    Notice: Undefined index: nid in views_handler_field_term_node_tid->pre_render() (line 88 of /path/sites/all/modules/views/modules/taxonomy/views_handler_field_term_node_tid.inc).

By the way does it strike anyone else as odd that it's complaining about the node id (nid) on a taxonomy term page?

That could mean it may have something to do with a field or relationship that is looking up information for a node.

Edit:

Additionally the error doesn't occur on:

  • The panel edit admin page,
  • The taxonomy term edit admin page, or when adding a taxonomy term id in the 'Preview with contextual filters' field in the views admin and pressing the 'Update Preview' button. I have automatic preview turned off when the error has not been triggered through the front end.

Edit 2:

  • The error occurs when clicking on a link in a page from one view in a node panel to go to page with another view with a panel.
  • The error does not occur when I click in the node on a term and then go to the taxonomy term page.
  • The error appears to possibly be caused by one view in a content pane in particular. After the error is triggered, the error appears in the front end on all pages.
  • The error is also sometimes shown in my views admin screen in the overview listing of views after the error is triggered.
  • It also shows sometimes when editing the view directly after the error is stated in the front end.
  • The error message dissapears in the views admin after a refresh of the page is done manually. A refresh in the front end regardless of the page visited does not make the error go away (update: Sometimes it does dissapear after a refresh). This is for a logged in admin user. The error also dissapears on the front end then, until the taxonomy/term page visited again through the problem page which is a node panel with a view.

Edit 3

  • Turning off the panel for taxonomy terms did not make a difference on it's own. Turning off the the built views additionally, and enabling the standard taxonomy term views that comes with views gets rid of the error. So the error appears to be possibly occuring in one of the built views. It does not appear to happen in a standard taxonomy term views. So the question remains what is the difference..

Edit 4

Possible cause found. It appeared to be one of the fields or a custom rewrite within a field in the master display of the view that was also being used on some other content panes, that may have been the cause of the problem. The error message has dissappeared. I'll try to reproduce the error. This may take a while.

Anonymous’s picture

Version: 7.x-3.5 » 7.x-3.3

My bad. Switched accidentally.

Anonymous’s picture

Status: Closed (cannot reproduce) » Active

Question

Did anyone have this happen on a cloned view? Where the original view does not give the error but the cloned one does? Or are people having this on original views as well?

dianacastillo’s picture

#16 This works for me . Is it going to be commited?
thanks

pbusch’s picture

Status: Active » Needs review
FileSize
2.55 KB

I created a patch based on #16.

I have tested the patch for 7.x-3.x-dev and 7.x-3.5.

danharper’s picture

I seem to be getting this error message when trying to write a custom validation function for an exposed taxonomy term in a view.

The error is the same as above and having googled it this is the only thread I can find with the same error and the above patch doesn't solve on views 7.x-3.7+22-dev

Thanks

axiom3279’s picture

Issue summary: View changes

Getting same error on taxonomy term view page. I looked at patch #16 and for version 7.x-3.8 the if statement in view.inc is not necessary. A simple check took care of this issue.

if(isset($this->aliases['nid'])){
      $this->field_alias = $this->aliases['nid'];
    }
eelkeblok’s picture

Version: 7.x-3.3 » 7.x-3.11
Assigned: merlinofchaos » Unassigned
Status: Needs review » Reviewed & tested by the community

Although this is the less intrusive approach, dawehner explicitly says in #2 that pre_render should not run at all for empty results.

The patch from #29 still applies to the latest release (and solves the issue for me), so setting to RTBC.

eelkeblok’s picture

Status: Reviewed & tested by the community » Needs work

I ran into issues with #29 on a site. Views pages that did not return any results turned into white pages. I haven't fully debugged yet, but the result for the menu callback was null with the patch, resulting in the entire page to not be generated.

eelkeblok’s picture

Actually, #29 does *not* implement #16. #16 says to put the line $this->display_handler->output = $this->display_handler->render(); outside the if statement, thus executing this line also when the result set is empty. The patch puts this line within the if(), hence the empty page callback result, presumably. Attached is an alternative patch that puts the render-line outside the if. It solves my issue.

Gixxernutter’s picture

+1 on #34 - worked for me - thanks

Chris Matthews’s picture

The 3 year old patch in #34 to view.inc applied cleanly to the latest views 7.x-3.x-dev

Chris Matthews’s picture

Version: 7.x-3.11 » 7.x-3.x-dev

Version change only

sathish.redcrackle’s picture

preethy211’s picture

i am getting this error on exposed_validate() function and not pre-render() function

Notice: Undefined index: field_study_project_tid in views_handler_filter_term_node_tid->exposed_validate() (line 340 of /var/www/html/sites/all/modules/contrib/views/modules/taxonomy/views_handler_filter_term_node_tid.inc).