Development => Bugs => Topic started by: Mike Vail on May 25, 2017, 12:36:22 PM

Title: RSS Feeds on Simple Portal Block Don't Work with PHP 7.0+
Post by: Mike Vail on May 25, 2017, 12:36:22 PM

I'm posting this just to help people who may be in the same boat I am. I'm sure the devs here have better things to deal with so this is more of a heads up to them and anyone else in my shoes.

I recently migrated over to Siteground webhosting. I moved my SMF 2.0.13 SMF forum over to Siteground and initially it didn't work. I received a bunch of PHP errors when trying to access the site. I soon learned that Siteground's default PHP version is 7.0, which doesn't work for SMF 2.0 versions prior to 2.0.14. Thank goodness Siteground allows you to change the PHP version on-the-fly via their control panel. I switched the version back to 5.6.30 and the site worked perfectly again.

Last week I updated from SMF 2.0.13 to 2.0.14. The upgrade went smoothly and my forum was running fine after the upgrade, still under PHP version 5.6.30. I switched to PHP 7.0.19 and later to 7.1.5 and the site continued to load fine, or at least it appeared to. 

This morning I noticed the two RSS Feeds in one of the Simple Portal blocks had stopped working and were reporting the following instead of showing the feeds: "Invalid Feed". After some research, I learned that going back to PHP 5.6.30 fixed the RSS feed block.

I posted this on the SMF Forums thinking it may be related to the recent SMF update and was told it's a Simple Portal bug likely related to PHP 7.0+ usage with the portal. I wanted to let people know in case they run across it. I wouldn't be surprised if other things didn't work if you upgrade to PHP 7.0+, so if you notice something weird on your site , you may wish to check what PHP version you're running. Some hosts are upgrading to PHP 7.0 and are not telling anyone.

Take care and a huge thanks for all the great work you guys do for my favorite portal and forum software. This is my 12th year of running SMF and I can't imagine not having it.

Thanks again,
Mike Vail
Windsor California, USA
Title: Re: RSS Feeds on Simple Portal Block Don't Work with PHP 7.0+
Post by: Chen Zhen on May 29, 2017, 11:11:02 PM
Make sure to use a proper PHP editor such as notepad++ from this link (do not use MicroSoft notepad):

Edit file: ../Sources/PortalBlocks.php

find: (approx. line 2029)
Code: [Select]
$data = preg_replace('~<\!\[CDATA\[(.+?)\]\]>~e' . ($context['utf8'] ? 'u' : ''), '\'#cdata_escape_encode#\' . $smcFunc[\'htmlspecialchars\'](\'$1\')', $data);

replace with:
Code: [Select]
$data = preg_replace_callback('~<\!\[CDATA\[(.+?)\]\]>~' . ($context['utf8'] ? 'u' : ''), function($m) {return "#cdata_escape_encode#" . htmlspecialchars($m[1]);}, $data);

\e modifier is deprecated in PHP 5.5 and removed in PHP 7.

Thank you for the report, however this is already a known issue:

SimplePortal 2.3.7 © 2008-2021, SimplePortal