Hi all,

What's this notice about?

Notice: Undefined offset: 0 in views_pdf_plugin_style_unformatted->render_grouping_sets() (line 48 of /sites/default/modules/views_pdf/views_pdf_plugin_style_unformatted.inc).

thanks :)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

killua99’s picture

This is an old code. Can you update to the lasted one? You're using group fields, right? Should be a bad call or setup.

Please update to the lasted 1.x one and test it again.

candelas’s picture

i get a similar notice with the last dev and i use unformated style

Message Notice: Undefined offset: 0 in render_grouping_sets() (line 48 of /xxx/sites/all/modules/contrib/views_pdf/views_pdf_plugin_style_unformatted.inc).

elsteff1385’s picture

I'm using the latest version: 7.x-1.0+25-dev

This is the format setup:
Format: PDF unformatted
Show: PDF Fields

Issue remains, same like candelas

killua99’s picture

Category: support » bug
Status: Active » Needs work

Ok so we have a NOTICE message there to clean up.

Thanks for the report guys.

candelas’s picture

Title: undefined offset in views_pdf_plugin_style_unformatted.inc » notices in views_pdf_plugin_style_unformatted.inc

i also get
Notice: Undefined variable: pdf_display in render() (line 158 of /xxx/sites/all/modules/contrib/views_pdf/modules/views_view_field/views_view_field_handler_include_view.inc).

elsteff1385’s picture

after updating to 7.x-1.0+26-dev, 2 additional notices pop up:

Notice: Undefined offset: 0 in views_pdf_plugin_style_unformatted->render_grouping_sets() (line 48 of /sites/default/modules/views_pdf/views_pdf_plugin_style_unformatted.inc).
Notice: Undefined index: bypass_eval_before in PdfTemplate->renderRow() (line 496 of /sites/default/modules/views_pdf/views_pdf_template.php).
Notice: Undefined index: bypass_eval_after in PdfTemplate->renderRow() (line 530 of /sites/default/modules/views_pdf/views_pdf_template.php).

candelas’s picture

Title: notices in style unformatted » notices in views_pdf_plugin_style_unformatted.inc

mmm i think that this notices come depending what we are doing. maybe we can put the options that we are using...

for this notice:

Message Notice: Undefined offset: 0 in render_grouping_sets() (line 48 of /xxx/sites/all/modules/contrib/views_pdf/views_pdf_plugin_style_unformatted.inc).

i just realized that if in "Format: PDF unformatted | Settings" i dont get a grouping field, i get the notice. if i put a grouping field, i dont.

for this notice:

Notice: Undefined variable: pdf_display in render() (line 158 of /xxx/sites/all/modules/contrib/views_pdf/modules/views_view_field/views_view_field_handler_include_view.inc).

i use a field from a view. i have in that view only the master, not other displays. trying to debug, i have included other view as a field. i choosed a view with different displays besides the master. i save it without going to "Show: PDF Fields | Settings" and then i got the

Notice: Undefined index: bypass_eval_before in PdfTemplate->renderRow() (line 496 of /sites/default/modules/views_pdf/views_pdf_template.php).
Notice: Undefined index: bypass_eval_after in PdfTemplate->renderRow() (line 530 of /sites/default/modules/views_pdf/views_pdf_template.php).

for my experience in views_pdf 6.x i remembered that it didnt run well if i didnt open and save "Show: PDF Fields | Settings" before saving the view. so i did it and the bypass_eval_before and after was gone.
and for my surprise, now i only get one Undefined variable: pdf_display in render() (edit: i have deleted the included view with displays)

can the people that have warnings test this, please? :)

candelas’s picture

Title: notices in views_pdf_plugin_style_unformatted.inc » notices in style unformatted

i correct the name because they are notices from different files but all with the unformatted style.

killua99’s picture

Title: notices in views_pdf_plugin_style_unformatted.inc » notices in style unformatted

Thanks for the report guys. I have to dig with this notices.

guillaumev’s picture

Status: Needs work » Needs review
FileSize
394 bytes

This patch should fix the bypass_eval_before and bypass_eval_after notices.

stevieb’s picture

patch works here --- thanks

killua99’s picture

Status: Needs review » Reviewed & tested by the community

So stevieb say it's works... Lets put this patch into RTBC ... and wait 1 week to push it into 1.x and 2 weeks to release it as stable. ok?

stevieb’s picture

oops spoke too soon - error still there - although no longer in notice ... in error logs

killua99’s picture

Status: Reviewed & tested by the community » Needs review

Anyways this patch has to be commited.

Issue #2042927 by guillaumev | elsteff1385: Fixed notices in style unformatted.

Need revisions ...

UJF-DiSI-Drupal’s picture

Hello,

I had the same message about the bypass unfounded vars.
After testing the first patch, I confirm it didn't solve the problem.
I read the file and I propose the following patch.
I change in line 496 and 530 the 'bypass_eval_before' and 'bypass_eval_after' vars in 'eval_before' and 'eval_after'.
No more messages are now noticed by my Drupal site.

F.T.

killua99’s picture

Did you try the last dev branch? ...

+++ views_pdf_template.php	2013-09-01 15:59:07.000000000 +0200
@@ -527,7 +527,7 @@
-    if ($options['render']['bypass_eval_after'] && !empty($options['render']['eval_alter'])) {
+    if ($options['render']['eval_after'] && !empty($options['render']['eval_alter'])) {

Ok first at all. You didn't see what was the problem. $options['render']['eval_after'] $options['render']['eval_alter'] I commit the patch with this typo ... test the last dev branch. and tell me if this work.

TwilightSparkle’s picture

Patches by guillaumev and by UJF-DiSI-Drupal don't work for me. I'm waiting for better solution.

killua99’s picture

@TwilightSparkle

Which version are you?

Which notice are you seen?

darkodev’s picture

I made the following change and works for us (just added checks for isset() around $options['render']['bypass_eval_before'])

496c496
<     if ($options['render']['bypass_eval_before'] && !empty($options['render']['eval_before'])) {
---
>     if (isset($options['render']['bypass_eval_before']) && !empty($options['render']['eval_before'])) {
530c530
<     if ($options['render']['bypass_eval_after'] && !empty($options['render']['eval_alter'])) {
---
>     if (isset($options['render']['bypass_eval_after']) && !empty($options['render']['eval_alter'])) {
ellen.davis’s picture

I'm using views_pdf 7.x-1.x-dev (2013-Sep-11)

I get this notice in the log.
Notice: Undefined offset: 0 in views_pdf_plugin_style_unformatted->render_grouping_sets() (line 48 of .../sites/all/modules/views_pdf/views_pdf_plugin_style_unformatted.inc).

line 48:

$field_id = $this->options['grouping'][$level]['field'];

Line 48 is in this section of code:

     // Render as a record set.
      else {
        if (isset($set['group'])) {
          $field_id = $this->options['grouping'][$level]['field'];
          $options = array();
          if(isset($this->row_plugin->options['formats'][$field_id])) {
            $options = $this->row_plugin->options['formats'][$field_id];
          }
          $this->view->pdf->drawContent($set['group'], $options, $this->view);
        }

Using dpm, I found that in my case:
$set['group'] is set to empty string
$this->options['grouping'] is empty array

Grouping field is none in my view's settings.

Not sure how to fix though.

sportel’s picture

I'm also having these error messages:

Notice: Undefined variable: pdf_display in views_view_field_handler_include_view->render() (regel 158 van /mydomain/sites/all/modules/views_pdf/modules/views_view_field/views_view_field_handler_include_view.inc).
Notice: Undefined offset: 0 in views_pdf_plugin_style_unformatted->render_grouping_sets() (regel 48 van /mydomain/sites/all/modules/views_pdf/views_pdf_plugin_style_unformatted.inc).
Notice: Undefined variable: pdf_display in views_view_field_handler_include_view->render() (regel 158 van /mydomain/sites/all/modules/views_pdf/modules/views_view_field/views_view_field_handler_include_view.inc).
Notice: Undefined variable: pdf_display in views_view_field_handler_include_view->render() (regel 158 van /mydomain/sites/all/modules/views_pdf/modules/views_view_field/views_view_field_handler_include_view.inc).

I'm using the latest dev version of Views PDF.

killua99’s picture

Ok those are related with the submodule Views view field. I'll open another issue with this one. to make it simple to handle the issue stuff.

killua99’s picture

Ok now you can follow this issue #2098305: Notice and strict warning. with relations of notice.

This will be fixed on the next version. If I want to make a new version aviable I can't fix this ones without patchs because I'm full focus on the next one. If some of you can provide patchs for this notice on the v1 version will be really nice and I can test it really quick.

You can get a lot of info how to make patchs.

http://www.wunderkraut.com/blog/how-to-create-a-patch-for-a-drupal-modul...
https://drupal.org/patch
https://www.youtube.com/watch?v=pFLLDQFC8yo
https://duckduckgo.com/?q=drupal+make+a+patch&t=canonical

So contribute.

Alex Arnaud’s picture

I have the same notices:
Notice: Undefined index: bypass_eval_before in PdfTemplate->renderRow()

Patches above didn't solve the problem.
Here is a patch that works for me.

killua99’s picture

Awesome, I'll test it soon.

CvW’s picture

replace

        if (isset($set['group'])) {

by

        if (!empty($set['group'])) {

That works for me.

Peacog’s picture

Here's a patch that fixes the following errors:

Notice: Undefined offset: 0 in render_grouping_sets() (line 49 and
Notice: Trying to get property of non-object in renderRow() (line 412

I've also included Alex's patch from #24 which fixes

Notice: Undefined index: bypass_eval_before in PdfTemplate->renderRow()

killua99’s picture

This code

if (isset($set['group']) && !empty($set['group'])) {

The empty verify if isset aswell, can you fix it?

if ($key === NULL |

It not better use empty?

if (isset($options['render']['bypass_eval_before']) && !empty($options['render']['eval_before'])) {
Same here, it's not better use empty?

Fix it and I'll commit it after test this patch.

Peacog’s picture

No problem - patch has been updated.

killua99’s picture

+++ b/views_pdf_template.php
@@ -411,7 +411,7 @@ class PdfTemplate extends FPDI {
+    if (empty($key) || !empty($view->field[$key]->options['exclude']) || (empty($content) && $view->field[$key]->options['hide_empty'])) {

the first empty maybe case some fails? I was thinking on !empty

Peacog’s picture

We need to check for empty because sometimes $key is empty. When renderRow is called in drawTable at line 695, $key is not passed in, so it's null. If we don't check for empty $key here, we get the Notice: Trying to get property of non-object in renderRow() error.

killua99’s picture

I still thinking in this result.

if (TRUE or FALSE)

becase if key is empty case TRUE

but this !empty($view->field[$key]...) == FALSE

in that case, I'm wrong?? Maybe I'm tired to see it.

killua99’s picture

Status: Needs review » Needs work
Peacog’s picture

If $key is empty the if statement is true and the function returns without checking the rest of the if statement. If we don't check for empty($key) and $key is empty, then the next part of the if statement throws a php notice because we're trying to use a null variable as an array key.

The logic of renderRow() seems to be saying that if $key is null, we should return nothing. I don't know the code well enough to say if that makes sense or not.

scott.allison’s picture

Patch in #29 fixed several issues for me.

killua99’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.