Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2018-12-22 16:28:40

Anton2
New Member
Registered: 2018-12-22
Posts: 9

Cannot use $this as parameter

I’m moving a Textpattern installation to a new server which runs PHP 7.3. I’m using the most recent Textpattern version 4.7.2.

Upon directing my browser to the admin panel, I get the following message:

Fatal error: Cannot use $this as parameter in /var/www/mysite/textpattern/lib/txplib_misc.php(1870) : eval()'d code on line 2

As far as I understand, this is a PHP 7 related issue. Can somebody please suggest a fix for this? Thx in advance.

Offline

#2 2018-12-22 17:20:51

etc
Developer
Registered: 2010-11-11
Posts: 5,028
Website GitHub

Re: Cannot use $this as parameter

Hello, welcome to the forum. It must be some plugin thing, try to disable them globally or one by one.

Offline

#3 2018-12-22 17:27:52

Anton2
New Member
Registered: 2018-12-22
Posts: 9

Re: Cannot use $this as parameter

Is there a way of doing that without accessing the admin panel?

Otherwise I’d probably need to move files back and forth between two servers until the problem is hit, would not I?

Offline

#4 2018-12-22 17:40:10

etc
Developer
Registered: 2010-11-11
Posts: 5,028
Website GitHub

Re: Cannot use $this as parameter

Anton2 wrote #315684:

Is there a way of doing that without accessing the admin panel?

Try path/to/site/textpattern/index.php?event=plugin or edit use_plugins pref in txp_prefs table.

Offline

#5 2018-12-22 19:24:23

Anton2
New Member
Registered: 2018-12-22
Posts: 9

Re: Cannot use $this as parameter

So I just set the “use_plugins” to 0, but that did not help.

Offline

#6 2018-12-22 19:36:41

etc
Developer
Registered: 2010-11-11
Posts: 5,028
Website GitHub

Re: Cannot use $this as parameter

Then it must be admin_side_plugins, sorry.

Offline

#7 2018-12-22 20:29:41

Anton2
New Member
Registered: 2018-12-22
Posts: 9

Re: Cannot use $this as parameter

Thanks, that worked.

Turning “admin_side_plugins” off, I was able to locate the responsible plugin one by one, and then I switched that setting back on.

Offline

#8 2018-12-22 21:32:19

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

Re: Cannot use $this as parameter

Hi Anton,

Could you tell us which plugin created the issue?


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

Offline

#9 2018-12-23 12:25:48

Anton2
New Member
Registered: 2018-12-22
Posts: 9

Re: Cannot use $this as parameter

Hi colak,

It was tcm_is_this plugin v0.6c

It runs as follows:

function tcm_is_this($atts, $this)
{
        global $pretext, $thisarticle, $pretext;
        if($pretext['s']==$thisarticle['section']
         &&$pretext['id']==$thisarticle['thisid'])
        {
           return $this;
        }
}

After I changed “function tcm_is_this($atts, $this)” to “function tcm_is_this($atts)” the problem was gone. I am zero in PHP though, and I am not sure if this haven’t broken the plugin. But I completely forgot what this plugin is doing, so I’m afraid I’ll see it only in the course of time, when and if something appears broken in the site.

Last edited by Anton2 (2018-12-23 12:26:36)

Offline

#10 2018-12-23 15:25:04

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,578
Website

Re: Cannot use $this as parameter

I couldn’t find any information on that plugin either. Judging by the code it checks whether the current section matches the section assigned to the current article and the current article id matches the article_id of the article and is probably used to output something – like an “active” or “currently showing” marker – in a loop when the item in a list matches the currently showing article (in its own section).

BTW: It only needs referencing $pretext once, so global $pretext, $thisarticle; will suffice.


TXP Builders – finely-crafted code, design and txp

Offline

#11 2018-12-23 15:27:41

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

Re: Cannot use $this as parameter

Yeah you can’t use $this as it’s reserved by PHP. So just swap it out:

function tcm_is_this($atts, $thing)
{
        global $pretext, $thisarticle, $pretext;
        if($pretext['s']==$thisarticle['section']
         &&$pretext['id']==$thisarticle['thisid'])
        {
           return $thing;
        }
}

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

#12 2018-12-23 16:28:28

Anton2
New Member
Registered: 2018-12-22
Posts: 9

Re: Cannot use $this as parameter

Thanks jakob and Bloke.

I figured it out. The description says: “A Simple tag to find out if the listed article is requested”, so digging through my TXP forms I saw that I used this tag to assign a custom class to currently selected menu items (to highlight them, basically).

“Oh that was many moons ago” :)

Offline

Board footer

Powered by FluxBB