Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2017-07-19 13:33:57

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,054
Website GitHub Mastodon Twitter

experimenting with txp on php 7

Hi, I am experimenting with the latest txp on php7 and it feels great!!! The caveat is that we still use slimstat which – when enabled – breaks the whole site causing the pages to only show

 Parse error: syntax error, unexpected 'new' (T_NEW) in /path/to/slimstat/lib/config.php on line 149

Line 149 is the one after the else statement. Would it be too optimistic for me to think that all would work just fine if that line is corrected?

	function &get_instance() {
		static $instance = array();
		if ( empty( $instance ) ) {
			// Assigning the return value of new by reference is deprecated in PHP 5.3
			if ( version_compare( PHP_VERSION, '5.3.0' ) >= 0 ) {
				$instance[] = new SlimStatConfig();
			} else {
				$instance[] =& new SlimStatConfig();
			}
		}
		return $instance[0];
	}
}

Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#2 2017-07-19 13:55:00

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,394
Website GitHub

Re: experimenting with txp on php 7

Not sure why PHP 7 would incorrectly trigger the else branch. It should have used the ‘if’ branch. But since we now require 5.3.3 anyway, you should be able to get away with this:

function &get_instance() {
		static $instance = array();

		if ( empty( $instance ) ) {
			$instance[] = new SlimStatConfig();
		}

		return $instance[0];
	}
}

The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#3 2017-07-19 14:33:51

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,054
Website GitHub Mastodon Twitter

Re: experimenting with txp on php 7

Thanks so much for your reply Stef.

I guess that I was too optimistic as it is now again breaking the site with this error:

 Parse error: syntax error, unexpected 'new' (T_NEW) in /path/to/slimstat/lib/i18n.php on line 40 

which again appears after the else statement:

 	function &get_instance() {
		static $i18n_instance = array();
		if ( empty( $i18n_instance ) ) {
			// Assigning the return value of new by reference is deprecated in PHP 5.3
			if ( version_compare( PHP_VERSION, '5.3.0' ) >= 0 ) {
				$i18n_instance[] = new SlimStatI18n();
			} else {
				$i18n_instance[] =& new SlimStatI18n();
			}
		}
		return $i18n_instance[0];
	}

Following your previous advice I changed it to:

	function &get_instance() {
		static $i18n_instance = array();
		if ( empty( $i18n_instance ) ) {
				$i18n_instance[] = new SlimStatI18n();
			} 
		return $i18n_instance[0];
	}

this actually helped and the site does not through any front end errors any more but going to slimstat I get:

Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /path/to/slimstat/lib/functions.php:31 Stack trace: #0 /path/to/slimstat/index.php(67): SlimStat::connect() #1 {main} thrown in /path/to/slimstat/lib/functions.php on line 31

Which persuaded me that it is time to give up slimstat. I am now considering alternatives and piwik looks good unless of course someone can recommend something better.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#4 2017-07-19 14:40:39

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,394
Website GitHub

Re: experimenting with txp on php 7

MySQL fix if you’re feeling brave.

Otherwise, yeah, drop it. I like piwik, fwiw.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#5 2017-07-19 14:49:05

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,054
Website GitHub Mastodon Twitter

Re: experimenting with txp on php 7

Braveness is one thing, incompetence is another:)


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#6 2017-08-04 13:48:33

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,054
Website GitHub Mastodon Twitter

Re: experimenting with txp on php 7

Coming back to this thread.

I found all mysql_ instances in slimstat as follows

mysql_connect
mysql_query
mysql_real_escape_string( $_str );
mysql_escape_string
mysql_num_rows
mysql_fetch_assoc
mysql_error
mysql_affected_rows 

according to your suggestion I should replace all mysql_ with mysqli_ and in theory all will be OK?


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

Board footer

Powered by FluxBB