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.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | views_php-3200046-4.patch | 1.83 KB | bduell |
Issue fork views_php-3200046
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:
- 3200046-variable-row-does-not-contain
changes, plain diff MR !3
Comments
Comment #2
bduell commentedComment #3
bduell commentedComment #4
bduell commentedHere's my potential fix.
Comment #5
liam morlandThanks 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
Comment #7
bduell commented@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!
Comment #8
wturrell commentedA quick +1 having successfully applied @BDuell's 3.diff patch to 7.x-1.0…
Comment #9
francewhoaThis is to confirm that Brad's patch in this comment #7 above resolved both the challenge with the variable $row & the pager
Comment #10
liam morlandI have pushed a commit containing automated coding standards fixes. The two new functions still need full documentation. Coding standards problems introduced by this patch:
Comment #11
k.floyd commentedI 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.
Comment #12
liquidcms commentedits 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.
Comment #13
joseph.olstad@liquidcms, good to know
Comment #14
liam morland