This issue is created to make 2.x-dev reworks available of patches that are contributed to "[PHP 7.2] Remove usage of deprecated create_function()" at https://www.drupal.org/project/views_php/issues/2274543. I'll do my best to keep contributed patches for 1.x-dev from the related issue updated to work with 2.x-dev.

For clarity, I'll attempt to keep the filenames the same as the corresponding patches from 2274543.

Issue fork views_php-3055655

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

spelcheck created an issue. See original summary.

spelcheck’s picture

Title: [PHP 7.2] Remove usage of deprecated create_function() - 2.x port » [PHP 7.2] Remove usage of deprecated create_function() - 2.x-dev port
spelcheck’s picture

StatusFileSize
new11.83 KB
kinmen’s picture

After applying that patch, I get:

Error: Class 'Opis\Closure\SerializableClosure' not found in views_php_create_function() (line 197 of /mypath/sites/all/modules/views_php/views_php.module).

I saw https://www.drupal.org/project/views_php/issues/2274543 therefore I think you should write here too that we need to install https://github.com/opis/closure/archive/master.zip into the libraries folder too (sites/all/libraries/closure)

spelcheck’s picture

Note: known issues when using in conjunction with Views Bulk Operations (VBO).

See: https://www.drupal.org/project/views_php/issues/2274543 #5 & #39

spelcheck’s picture

StatusFileSize
new13.03 KB
liquidcms’s picture

applied patch -68 and added closure library and my create_function() after switching to PHP 7.2 is now gone.. except for this notice:

Notice: Undefined offset: 0 in {closure}() (line 3 of /mnt/www/html/cppenvdev/docroot/sites/all/modules/views_php/views_php.module(197) : eval()'d code).

joseph.olstad’s picture

Assigned: spelcheck » Unassigned
Status: Active » Needs review
StatusFileSize
new535 bytes
new13.06 KB

patch 6 (incorrectly named patch 68) is missing one backwards compatibility change.

This patch (patch 8) provides backwards compatibility with php 5.6.x (does not break backwards compat).

see patch and interdiff.

for an explanation, please see #2274543-63: [7.x-1.x] Remove usage of deprecated create_function()

joseph.olstad’s picture

If you experience issues using this above patch and in combination with views_bulk_operations you may need to use the patch I just created for the closure library :
I have also forked the closure library and this patch is included in my forked version.
https://github.com/joejoseph00/closure

joseph.olstad’s picture

StatusFileSize
new11.22 KB
new1.76 KB

ok, another patch, this time it requires version 3.4.0 or newer version of the opis/closure library.
Download the opis/closure library from github and extract it in your sites/all/libraries/
rename the closure folder (whatever zip calls it) and rename it to closure (lower case)

make sure your libraries module is enabled

then patch the views_php module version 2.x with this patch:

spelcheck’s picture

@joseph.olstad thank you for taking this on! I am running into an issue with the latest patch though with a clean D7 installation.

Using views_php:2.x-dev, patched with views_php-3055655-10.patch and using closure:3.4.0 I receive the following error per view result:

Warning: Parameter 3 to Opis\Closure\SerializableClosure::{closure}() expected to be a reference, value given in Opis\Closure\SerializableClosure->__invoke() (line 109 of /webroot/sandbox-7/web/sites/all/libraries/closure/src/SerializableClosure.php).

The only php I'm using within the views_php field is value: <?php print "foo"; ?>

--

Note: When NOT using VBO, views_php-3055655-8.patch appears to work aok.

spelcheck’s picture

StatusFileSize
new13.66 KB
new6.47 KB

Rolled views_php-2274543-95.patch from https://www.drupal.org/project/views_php/issues/2274543 for views_php:2.x-dev and included interdiff.

Working for me with no warnings on views_php:2.x-dev, VBO, PHP7.2. Great work @joseph.olstad!

joseph.olstad’s picture

Hi ya, extensive testing proves that the 7.x-1.x patch I created works well, thanks for fixing the 7.x-2.x patch!

ethomas08’s picture

StatusFileSize
new14.88 KB

Weird but the rerolled patch in comment 12 did not apply for me when using the 7.x-2.x branch. I am attaching the patch that was successful for me in case that helps anyone else.

joseph.olstad’s picture

note: this patch requires the 'closure' library installed.

Download the opis/closure library from github and extract it in your sites/all/libraries/
rename the closure folder (whatever zip calls it) and rename it to closure (lower case)

make sure your libraries module is enabled

then patch the views_php module version 2.x with this patch

clear caches

allsite’s picture

Any chance a working patch could get rolled into a dev branch? I'd really appreciate it.

joseph.olstad’s picture

**BEGIN EDIT** removed my own comment for clarity purposes **END EDIT**

liam morland’s picture

Title: [PHP 7.2] Remove usage of deprecated create_function() - 2.x-dev port » [7.x-2.x] Remove usage of deprecated create_function()
SilviuChingaru’s picture

StatusFileSize
new8.66 KB

The patch from #2274543-193: [7.x-1.x] Remove usage of deprecated create_function() for branch 7.x-2.x which is RTBC.

leducdubleuet’s picture

Status: Needs review » Reviewed & tested by the community

Latest patch views_php-remove_create_function-2274543-193-7.x-2.x.patch applies cleanly, works well and does not need the external 'closure' library.

I believe this is ready to roll, thank you!

liam morland’s picture

If someone creates an issue fork and merge request, I will commit this.

leducdubleuet’s picture

What do you mean by "...an issue fork and merge request..."?

Isn't the current issue and the patch above in comment #19 enough?

Also why is the 2.x-dev now marked as unsupported?

liam morland’s picture

You can read about Issue forks & merge requests.

I am working to get a 7.x-1.0 release. No one is actively maintaining any other branch. I doubt there will ever be a release.

leducdubleuet’s picture

Ok thanks for the info, I am not yet familiar with forks and merge requests here, I'll conform when need be, no problem.

But I am not convinced it is worth the effort here with 2.x? I do not remember why I switched to version 2.x in the past but I just did a quick comparison between 1.x and 2.x and there are not many significant differences in my opinion. Maybe some things should be backported to 1.x so 2.x could be simply deleted and forgotten about?

Personally, I will simply do what it takes to switch back to version 1.x in my projects currently using 2.x.

Thanks for your time, it's great to see this module maintained again!

liam morland’s picture

7.x-2.x was intended to be a branch with more feature development. At this point, it is not being developed and won't be unless someone comes on board as maintainer for this branch. All I am doing is getting final release of 7.x-1.0.

danyg made their first commit to this issue’s fork.

danyg’s picture

Issue fork and merge request have been created. I tested the patch at #19 and it works like a charm.

  • Liam Morland committed 134485d on 7.x-2.x authored by danyg
    Issue #3055655: Remove usage of deprecated create_function()
    
liam morland’s picture

Status: Reviewed & tested by the community » Fixed

I've committed this. Most people would probably be better off used 7.x-1.x. It is not much different from 7.x-2.x. 7.x-2.x does not have a maintainer and is not being developed.

danyg’s picture

Thanks @Liam! I'll check soon what happens on downgrading the module to 7.x-1.x

liquidcms’s picture

@Liam: " Most people would probably be better off used 7.x-1.x. It is not much different from 7.x-2.x. "

- huh? 7.2 and 7.1 are completely different.. and 7.2 works much better.

joseph.olstad’s picture

@Liam, maybe republish 7.x-2.x , I had no idea it was better than 1.x?

liam morland’s picture

A user should come on board as the 7.x-2.x branch maintainer.

jan-e’s picture

@liquidcms

- huh? 7.2 and 7.1 are completely different.. and 7.2 works much better.

Aren't you mixing up PHP 7.2 and PHP 7.1 with the 7.x-2.x and 7.x-1.x branches of this project?

liam morland’s picture

Let's move this discussion to #3210986: [Meta] Maintenance for 7.x-2.x and keep the present issue only for discussing any problems with the removal of create_function().

liquidcms’s picture

@Jan-e. Definitely not.

In version 1.x you specify fields something like this:
$data->field_[field_name][0]['rendered']['#markup']

and the description text states there are variables like $row->field_name when in fact none of those work and only spit out NID

in version 2.x you specify fields as they are listed in the description text:
$row->field_name

but yes, I agree with Liam, this issue should just be about removing the deprecated function.. sorry..

Status: Fixed » Closed (fixed)

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