Keyword

K2 Edit Profile shows Error in Frontend after change to PHP 7.2.7

  • Andreas Schrader
  • Andreas Schrader's Avatar Topic Author
  • Offline
  • New Member
More
6 years 9 months ago #168486 by Andreas Schrader
I have a Website with a K2 Profile Edit Site in the Frontend. When I click on the save Button, the Site throws the Error "Using $this when not in object context".
The Site and Function worked fine with PHP 7.0 but throws this Error when I changed the PHP Version to 7.1 or higher.

Do you have any suggestions, what I have to change in the Code to fix this? Changing the PHP Version back to 7.0 is not an option, because my Client wants to change the PHP Version directly to 7.2.

Thanks for your Feedback :)

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
6 years 9 months ago #168495 by Krikor Boghossian
Are you using any overrides?
Also can you send me the line where this error occurs ?
It must have been printed or recorded in your error log.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Andreas Schrader
  • Andreas Schrader's Avatar Topic Author
  • Offline
  • New Member
More
6 years 9 months ago #168499 by Andreas Schrader
I checked the Code and there is no Override for the Profile edit Page.
I enabled the Debug Mode and it show the following Error:
Attachments:

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
6 years 9 months ago #168522 by Krikor Boghossian

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Andreas Schrader
  • Andreas Schrader's Avatar Topic Author
  • Offline
  • New Member
More
6 years 9 months ago #168527 by Andreas Schrader
I removed the file and now it works fine. Thanks.

I also changed the Code in line 142 to: $menu = $application->getMenu(); because the JSite will no longer work
github.com/getk2/k2/blob/master/plugins/user/k2.php#L142

Please Log in or Create an account to join the conversation.

  • Andreas Schrader
  • Andreas Schrader's Avatar Topic Author
  • Offline
  • New Member
More
6 years 9 months ago #168528 by Andreas Schrader
I removed the line and now it works fine. Thanks.

I also changed the Code in line 142 to: $menu = $application->getMenu(); because the JSite will no longer work
github.com/getk2/k2/blob/master/plugins/user/k2.php#L142

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
6 years 9 months ago #168530 by Krikor Boghossian
Nice :)
I will investigate why PHP 7.2 does not like this.
Care to make a PR for $menu = $application->getMenu(); ?

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Andreas Schrader
  • Andreas Schrader's Avatar Topic Author
  • Offline
  • New Member
More
6 years 9 months ago #168595 by Andreas Schrader
Shure I will create a PR for you :)

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
6 years 9 months ago #168602 by Krikor Boghossian
Thank you Andreas :)

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

More
6 years 8 months ago - 6 years 8 months ago #168619 by burnyourears
I have the same problem (mentioned here – sorry, did not see that there's already this topic ...) and also deleted the line in the k2.php. The result: Error-Message is fixed BUT changes are not saved any more ... :/

The weird thing: When I get the error, changes are saved though ...

Andreas, after you changed the code – are changes in the user profile still saved?
Last edit: 6 years 8 months ago by burnyourears.

Please Log in or Create an account to join the conversation.

More
6 years 3 months ago #170725 by Aram
Had the same issue.
Andreas suggestion seems to work! I'm able to save profile changes.

Please Log in or Create an account to join the conversation.

More
6 years 3 months ago #170731 by Asim Gill
Im having the same issue. Running 7.2 and the latest Joomla right now. All of a sudden saving profile as a user was resulting in an Error 0. After deleting the line suggested here, the page successfully "saves" and reloads, but none of the changes are saved.

User can't edit anything including description and avatar image. Even deletion of avatar doesnt work.
Would really appreciate some help as this is a core feature I'm hoping to use!

I can make changes from the back-end as an administrator, but not as a user on the front-end.

Please Log in or Create an account to join the conversation.

More
6 years 3 months ago #170754 by JoomlaWorks
Although I'm sure this was fixed prior to the release of K2 v2.9.0, you can always get the latest dev version installed on your site: github.com/getk2/k2/archive/master.zip

Let us know.

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

More
5 years 6 months ago #173275 by Dan Carroll
I can confirm that this is *somewhat* of a problem still...

I've installed the latest version as per Fotis' suggestion.
I no longer receive the Error 0, however the changes will only save under some conditions..

It has to do with the password/password verify fields.

If you do not supply a password, or supply the password in both password+verify fields, the k2 profile as well as any other custom user plugins save.
If you only put the password in the password field (a lot of browsers pre-fill this for you) then only some of the data saves.
In this case:
* The basic user data saves.
* The user.profile plugin data saves.
* The k2 plugin data does not save.
* My own custom user plugin (same code as user profile, just extra fields) does not save.

Please Log in or Create an account to join the conversation.

More
5 years 6 months ago #173330 by JoomlaWorks
What happens if you disable the custom K2 and user plugins?

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

More
5 years 6 months ago #173351 by Dan Carroll
Thanks for coming back to this Fotis...

I found the problem after a day or two..
It seems my joomla template was missing the messages definition:

<jdoc:include type="message" />

When you only put one password in (even it if is correct) then Joomla thinks you are trying to change the password and fails because the passwords don't match.

I did not know this was the reason because I did not see the error message.

The strange thing is that without the messages definition, the save does not work, but when you include the message definition the save *does* work fine..

Either way, my conclusions are:

1. It's a joomla core issue.
2. It's not an issue when you properly build the template...

Please Log in or Create an account to join the conversation.

More
5 years 6 months ago #173353 by JoomlaWorks
Glad it's resolved then :)

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum