php 7 + cms 1.6.9 + Twocents 1.0beta2 (and other modules?) not working

A place to report and discuss bugs - please mention CMSimple-version, server, platform and browser version
Post Reply
chrinux
Posts: 3
Joined: Sun Apr 23, 2017 10:23 am

php 7 + cms 1.6.9 + Twocents 1.0beta2 (and other modules?) not working

Post by chrinux » Sun Apr 23, 2017 10:50 am

Dear Board!

I'm getting php errors when I try to use php 7 with the latest version of cmsimple_xh (1.6.9) and commentary module Twocents (1.0beta2). This is probably also true for other modules.

It looks like this issue is related to cmsimple_xh and not to the module.

Can anybody please reproduce the failure?

Christoph, is php 7 fully supported with latest cmsimple & latest approved modules?

Many thanks, Christian

Setup:
<h1>Gästebuch</h1>
<p>#CMSimple $output.=twocents();#</p>

Error messages:
Fatal error: Uncaught ArgumentCountError: Too few arguments to function twocents(), 0 passed in <path>/cmsimple/functions.php(184) : eval()'d code on line 1 and exactly 1 expected in <path>/plugins/twocents/index.php:44
Stack trace:
#0 <path>/cmsimple/functions.php(184) : eval()'d code(1): twocents()
#1 <path>/cmsimple/functions.php(184): eval()
#2 <path>/cmsimple/functions.php(343): evaluate_cmsimple_scripting('<h1>G\xC3\xA4stebuch<...', true)
#3 <path>/cmsimple/cms.php(1333): evaluate_scripting('<h1>G\xC3\xA4stebuch<...')
#4 <path>/index.php(12): include('/var in <path>/plugins/twocents/index.php on line 44

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: php 7 + cms 1.6.9 + Twocents 1.0beta2 (and other modules?) not working

Post by cmb » Sun Apr 23, 2017 11:16 am

chrinux wrote:Fatal error: Uncaught ArgumentCountError: Too few arguments to function twocents(), 0 passed in <path>/cmsimple/functions.php(184) : eval()'d code on line 1 and exactly 1 expected in <path>/plugins/twocents/index.php:44
Thanks for reporting this issue. Quickfix for your case: change this line to:

Code: Select all

function twocents($topicname = '')
From what I can tell from a quick look, $topicname is unused in Twocents_XH 1.0beta2, though, what would be another bug (no problem in your case).
chrinux wrote:Christoph, is php 7 fully supported with latest cmsimple & latest approved modules?
There is at least one known issue regarding the core. There may be more issues regarding plugins. The fatal error you reported isn't a PHP 7.0 issue, though, but rather happens only with PHP 7.1.
Christoph M. Becker – Plugins for CMSimple_XH

chrinux
Posts: 3
Joined: Sun Apr 23, 2017 10:23 am

Re: php 7 + cms 1.6.9 + Twocents 1.0beta2 (and other modules?) not working

Post by chrinux » Wed Apr 26, 2017 6:02 pm

Hi Christoph,

many thanks for your fast reply!

First of all I could have avoided the failure by reading your manual: ;-)

If you call

<h1>Gästebuch</h1>
<p>#CMSimple $output.=twocents('guestbook');#</p>

the plugin works in php 7. This is also true for an other very old plugin:

<p>#CMSimple $output.= GBlist('guestbook');#</p> (returns a lot different error due to missing php functions, though)

It seems the big difference in php 7 is it's intolerance to missing function input parameters even though they may be validated later in the code.

So e.g. this works in php 5:
<p>#CMSimple $output.=twocents();#</p> because 'guestbook' is set in the code as a default. But it does not work in php 7.

In php 7 this would also solve the issue:
Change:
function gblist($gb_filename){...}
into
function gblist($gb_filename = "guestbook"){...}

Anyways, many thanks for your great cms!

Christian

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: php 7 + cms 1.6.9 + Twocents 1.0beta2 (and other modules?) not working

Post by cmb » Wed Apr 26, 2017 6:37 pm

chrinux wrote:It seems the big difference in php 7 is it's intolerance to missing function input parameters even though they may be validated later in the code.
It is because missing argument raise an exception instead of a warning as of PHP 7.1.0. I still think that this shouldn't have been changed in a minor version, but well. :)
chrinux wrote:Anyways, many thanks for your great cms!
You're welcome! It's not my CMS, though. :)
Christoph M. Becker – Plugins for CMSimple_XH

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: php 7 + cms 1.6.9 + Twocents 1.0beta2 (and other modules?) not working

Post by cmb » Sun Jun 25, 2017 11:54 am

I finally had a closer look at this issue. Indeed, it is not a bug in Twocents_XH, since the $topicname parameter is mandatory.

However, I wonder whether we should handle this case generally in the core of CMSimple_XH. We already took countermeasures regarding the changed handling of parse errors in eval'd code. OTOH, a missing argument in a function call from within the template will also result in a fatal PHP error.

I presume that switching to PHP 7.1 will break a lot of CMSimple(_XH) sites.
Christoph M. Becker – Plugins for CMSimple_XH

Post Reply