- πΊπΈUnited States museumboy
I'm using this script in rules to add a view to an email. It is no longer working now that I'm on php 8.0
- πΊπΈUnited States DamienMcKenna NH, USA
@museumboy: I suggest reviewing your custom code, there might be something that needs to be fixed in it.
- Status changed to Postponed: needs info
about 1 year ago 2:15pm 12 September 2023 - πΊπΈUnited States DamienMcKenna NH, USA
@JOINSO: please test the latest dev release, see if it resolves the problem.
- πͺπΈSpain JOINSO Sabadell
@DamienMcKenna:
Thanks for the tip.
Few months ago, we released the new version of our site that is working with PHP 8.0 and D7.
Our solution was change this:
echo views_embed_view('usercomments', 'block');
To this:$view = views_get_view('usercomments'); $view->set_display('block'); $view->pre_execute(); $view->execute(); if(count($view->result)>0) { ?> <div class="view-content"> <br/><br/><strong><?php echo t('My Reviews');?></strong><br/><br/> <table> <tr> <td> <?php echo t('Review Id');?> </td> <td> <?php echo t('Edition Date');?> </td> <td> <?php echo t('Review Preview');?> </td> <td> <?php echo t('Published on');?> </td> <td> <?php echo t('Type');?> </td> <td> <?php echo t('Subscription');?> </td> <td> <?php echo t('Actions');?> </td> </tr> <?php foreach($view->result as $key => $row) { $nodeComment=node_load($row->comment_nid); $commentNotify=array(); $commentNotify[$row->cid]=(object)[]; comment_notify_comment_load($commentNotify); ?> <tr> <td> <?php echo $row->cid;?> </td> <td> <?php echo date("Y-m-d h:i:s",$row->comment_changed);?> </td> <td> <?php echo f4r_tools_truncate_html($row->_field_data['cid']['entity']->comment_body['und'][0]['value'],20);?> </td> <td> <?php echo $nodeComment->title; ?> </td> <td> <?php echo $nodeComment->type;?> </td> <td> <?php if($commentNotify[$row->cid]->notify) { echo t('Subscribed'); } else { echo t('Unsubscribed'); } ?> </td> <td> <a class='linkMyContent' href="/comment/<?php echo $row->cid;?>" target="_new"><?php echo t('View');?></a> | <a class='linkMyContent' href="/comment/<?php echo $row->cid;?>/edit" target="_new"><?php echo t('Edit');?></a> </td> </tr> <?php } ?> </table> <?php echo theme('pager'); }
At the moment I am not going to make more test because I am focused in migrating D7 to D10.
Hope this workaround can help other ones to fix the issue.
Regards,
Jordi
JOINSO - πΊπΈUnited States DamienMcKenna NH, USA
I noticed that there's no test coverage for views_embed_view(), so let's add some.
- Status changed to Active
about 1 year ago 2:20pm 13 September 2023 - Status changed to Needs review
about 1 year ago 5:28pm 13 September 2023 - last update
about 1 year ago 230 pass - πΊπΈUnited States DamienMcKenna NH, USA
A starting point for test coverage on views_embed_view().
- last update
about 1 year ago 230 pass - πΊπΈUnited States DamienMcKenna NH, USA
I've set the tests to run against both PHP 7.4 and 8.0, so we'll see if a basic view works as expected.
- πΊπΈUnited States DamienMcKenna NH, USA
The test coverage shows the same output working for both PHP 7.4 and 8.0. I suggest you both look into the specific views that are failing for you and see if any of them include custom PHP code, that could be the culprit.
- Status changed to RTBC
11 months ago 7:01pm 20 December 2023 - Status changed to Needs review
11 months ago 11:26pm 20 December 2023