php7 issues?

Permalink
I am running Arch Linux, which now has php7 as their standard install... but when the php got upgraded started getting errors in my c57 like...

Declaration of Concrete\Core\Permission\Access\EditPagePropertiesPageAccess::save($args) should be compatible with Concrete\Core\Permission\Access\Access::save()

I have no idea where this is coming from or where I might look to fix, ort why this is happening.

Sorry for the cluelessness, but any feedback would be helpful. thanks

ntisithoj
 
MrKDilkington replied on at Permalink Reply
MrKDilkington
Hi ntisithoj,

Each version of concrete5 improves support for PHP 7. I recommend using the latest 5.7.5.6 release.
ntisithoj replied on at Permalink Reply
ntisithoj
just fyi, i am running 5.7.5.6 ... also updated all plugins and did a composer update
ntisithoj replied on at Permalink Reply
ntisithoj
ok, i fixed the problem by ensuring the argument types were the same on both sides... for example, if I had the error

Declaration of Application\Attribute\ImageFile\Controller::exportValue(Application\Attribute\ImageFile\SimpleXMLElement $akv) should be compatible with Concrete\Core\Attribute\Controller::exportValue(SimpleXMLElement $akv)


then I changed Application\Attribute\ImageFile\Controller::exportValue from
public function exportValue($akv)

to
public function exportValue(\SimpleXMLElement $akv)


or, in some cases, just commenting out the entire registerViewAssets() in my own blocks (as registerViewAssets() was causing the crash in a few places)

Regarding registerViewAssets(), my code was
public function registerViewAssets() {
      $this->requireAsset('swfobject');
   }

but the core registerViewAssets() was
public function registerViewAssets() {
   }


I thought this would break videos, but it seems to have no negative effect on the videos. hmm... no idea
MrKDilkington replied on at Permalink Reply
MrKDilkington
@ntisithoj

Can you list the steps required to recreate the errors, please.
ntisithoj replied on at Permalink Reply
ntisithoj
to test make a copy of concrete/blocks/youtube.php to application/blocks/youtube_test.php

make the necessary minimal changes to install a a new block type.

go to Stacks & Blocks->Block Types and you get the error

comment out registerViewAssets() in application/blocks/youtube_test.php and it works
MrKDilkington replied on at Permalink Reply
MrKDilkington
If someone else running PHP 7 can recreate this, then we can make a note of it on GitHub, so it can it be patched.
ntisithoj replied on at Permalink Reply
ntisithoj
on a related note, how critical is IonCube?

...
PHP7 is not supported by ionCube and Zend Guard Loader yet.

Please check the following thread for more information about ionCube loaders for PHP7:
http://forum.ioncube.com/viewtopic.php?p=10733...
mesuva replied on at Permalink Reply
mesuva
I'm pretty certain that IonCube is only needed if you are running commercial PHP that has been encrypted.

As neither concrete5 or its add-ons encrypt PHP, I doubt that it would be needed.
mesuva replied on at Permalink Reply
mesuva
I've heard about an issue where registerViewAssets needs to have a slightly different function signature.
Instead of
public function registerViewAssets() { ...

it may need to be
public function registerViewAssets($outputContent = '') { ..

I've not actually hit this problem myself, I think it might be to do with a particular recent version of concrete5, where it's been then fixed.
Looking through the core, all registerViewAssets calls appear in this format, so I'm thinking it doesn't hurt to have it the same.

So this particular issue might not be a PHP7 one. Someone else might be able to shed more light on it.
ntisithoj replied on at Permalink Reply
ntisithoj
indded you are right! when I changed my declaration in web/application/blocks/youtube_test/controller.php to
public function registerViewAssets($outputContent = '')
    {
        $this->requireAsset('swfobject');
    }


the error did not appear.

thanks
mesuva replied on at Permalink Reply
mesuva
What version of c5 are you using, with what PHP version?

I'm hoping this has been fixed in the most recent release, otherwise it's a bit of a dangerous issue - the official docs don't mention that that parameter is required.
ntisithoj replied on at Permalink Reply
ntisithoj
5.7.5.6 & php7
okapi replied on at Permalink Best Answer Reply
okapi
I have experienced the same issue after upgrading to PHP 7.

Some Add-Ons are causing fatal errors in PHP 7 environments, which can break the hole site!

As mentioned above, the solution is to open:

packages/[name_of_package]/blocks/[name_of_block]/controller.php

search for:

public function registerViewAssets()


and change it to:

public function registerViewAssets($outputContent = '')


Examples:
Easy Image Gallery 1.3.1
Honest Websites Back To Top 0.9.4
Concrete5.7.5.6, PHP 7
MrKDilkington replied on at Permalink Reply
MrKDilkington
@okapi

I recommend contacting add-on developers directly when you find that their add-ons requires the updated code. This should quickly reduce the number of add-ons with the outstanding issue.
okapi replied on at Permalink Reply
okapi
That's what my intention was, but of course i only can do this for Add-Ons that i'm using on a PHP 7 environment, and there seem to be a lot of add-ons that have to get updated.

I think all add-on developers should consider updating their products if necessary in order to avoid problems with PHP 7.
okapi replied on at Permalink Reply
okapi
By the way, the same is true for

public function validate()

which should be:
public function validate($args)

in order to work properly in PHP 7.

Example: Whale Grid Gallery 2 v.2.0.0
nando replied on at Permalink Reply
nando
Thanks for your solution.
I was experiencing the same issue with Whale Bootstrap Carousel in C5 8.1 and fixed by changing
/packages/whale_bootstrap_carousel/blocks/whale_bootstrap_carousel/controller.php
line 367
public function validate()
    {

to
public function validate($args)
    {

as per your suggestion
PaiviK replied on at Permalink Reply
PaiviK
THANK YOU!
I ran into this problem after PHP had to be upgraded. Several sites broke but they were easy to fix with your tip!