2

I use IPage. I got the website from the old provider and copied the files to IPage server and dumped the db. Both websites (in old and new server) are the same versions, but the old one is working fine and the new one throws that error:

Using $this when not in object context

I chatted with IPage technical support and they told me that:

Our technical specialist checked and told problem is with Joomla applicatoin related error.

Does anyone know how I can fix that error?

Found out that php version on old server (working one) is 5.3.29 but in the new server is 7.1.1

EDIT

It was Content - Booking Calendar extension. I disabled it and worked... But how I can fix this extension?

This is the message I get when I disable the extension. The message is in the place where the extension took place

  • 2
    Joomla 3.7.5 is compatible with php7.1 so the error will be from an extension. Does the error occur on a specific page? And also, open you error log file and it should give you the location of the offending $this. – jamesgarrett Dec 9 '17 at 23:39
  • Thank you! It was Content - Booking Calendar extension. I disabled it and worked... But how I can fix this extension? – TakoG Dec 10 '17 at 11:50
  • 1
    Check if there is an update for the extension. If not, perhaps the developer is working to make it compatible with PHP 7+. – Lodder Dec 10 '17 at 12:45
1

PHP7 throws an error when $this is used in a static called function.

The error should give you a file and a line number. It will probably be something inside a static function like:

class ExampleClass {

    public static function exampleFunction() {
        // ...
        $this->someOtherFunction();
        // ...
    }
    public static function someOtherFunction() {
        // ...
    }
}

change

$this->someOtherFunction();

to

static::someOtherFunction();

In the above case we assume ExampleClass::someOtherFunction is a static fucntion. If it is, we are done. If it is not a static function, you may have to either change it to one (if it is not used elsewhere in the code) or initialize the class and call it:

$instance = new static::class;
$instance->someOtherFunction();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.