Problem/Motivation

I'm submitting this issue because while $row->field return nid instid value was created and marked duplicate of this issue 9 years ago, that issue was initially created for 7.x-1.x and then moved to 7.x-2.x and marked fixed.

It appears this issue appears in both 7.x-1.0-beta1 and 7.x-1.0-alpha3+4-dev (I can confirm that this issue does not occur in 7.x-2.x-dev but now 7.x-2.x-dev is showing as being not supported).

Steps to reproduce

Installing either 7.x-1.0-beta1 or 7.x-1.0-alpha3+4-dev and using a view with a "Global: PHP" field that references $row available variables will result in those fields not returning the proper values for those variables, instead returning entity id's.

Proposed resolution

I upgraded to 7.x-1.0-beta1 but used the same render function in views_php_handler_field.inc as 7.x-2.x-dev and it appears to be rendering properly.

CommentFileSizeAuthor
#4 views_php-3200046-4.patch1.83 KBbduell

Issue fork views_php-3200046

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

BDuell created an issue. See original summary.

bduell’s picture

Title: Variable $row does not contain correct values for » Variable $row does not contain correct values for ($row)
bduell’s picture

Title: Variable $row does not contain correct values for ($row) » Variable $row does not contain correct values
bduell’s picture

Status: Active » Needs review
StatusFileSize
new1.83 KB

Here's my potential fix.

liam morland’s picture

Version: 7.x-1.0-beta1 » 7.x-1.x-dev
Status: Needs review » Needs work

Thanks for the patch. I have committed the spelling correction.

create_function() is deprecated; the solution needs to not use it. Also, please check the coding standards.

If you can identify which issue fixed this in 7.x-2.x, please refer to that ticket.

Please put the fix into an issue fork.

Thanks

bduell’s picture

Version: 7.x-1.x-dev » 7.x-1.0-rc1
Status: Needs work » Needs review

@liam-morland - thank you for your reply.

The issue that was fixed for 7.x-2.x is referenced in the above ticket description and can be found here as well: https://www.drupal.org/project/views_php/issues/1140896

Another issue came up while using the current 7.x-1.x branch: The pager will disappear when including a view using views_php in a pane. I used solutions from 7.x-2.x to ensure that wrapped pagers appear properly as well.

I updated the create_function used in 7.x-2.x-dev and committed my other changes to the fork here: https://git.drupalcode.org/project/views_php/-/merge_requests/3.diff

Feel free to let me know of anything else. Thank you!

wturrell’s picture

A quick +1 having successfully applied @BDuell's 3.diff patch to 7.x-1.0…

francewhoa’s picture

Status: Needs review » Reviewed & tested by the community

This is to confirm that Brad's patch in this comment #7 above resolved both the challenge with the variable $row & the pager

liam morland’s picture

Version: 7.x-1.0-rc1 » 7.x-1.x-dev
Status: Reviewed & tested by the community » Needs work

I have pushed a commit containing automated coding standards fixes. The two new functions still need full documentation. Coding standards problems introduced by this patch:

views_php/plugins/views/views_php_plugin_pager.inc
  42 | ERROR   | Doc comment is empty
  45 | ERROR   | Public method name "views_php_plugin_pager::pre_render" is not in lowerCamel format
  46 | ERROR   | The array declaration extends to column 81 (the limit is 80). The array content should be split up over multiple lines
  47 | WARNING | Unused variable $id.
  57 | ERROR   | Doc comment is empty
  60 | ERROR   | Protected method name "views_php_plugin_pager::update_wrapped_pager" is not in lowerCamel format
k.floyd’s picture

I am hitting this same issue. If I try to use the date field in Global: PHP, it displays the entity ID instead of the date.
I tried applying the patch mentioned in comment #4, but it did not resolve the issue for me.

liquidcms’s picture

its odd they removed the 7.2 version when it is the only one that works properly. But, if you find that version somewhere - it fixes this issue.

joseph.olstad’s picture

@liquidcms, good to know

liam morland’s picture

Issue tags: +Needs reroll