Keyword

K2 - White screen when saving item and php error

More
12 years 7 months ago - 12 years 7 months ago #104758 by D
I have a new, default, unmodified version of joomla 2.5 installed along with k2.

I'm using this as a demo site to teach myself k2.

Overall everything works great, but whenever I attempt to edit an item as a front end user, my screen goes white when I save the item and I get this php error:

Fatal error: Call to a member function getSearchValue() on a non-object in /homepages/7/d123968617/htdocs/public_html/clients/administrator/components/com_k2/models/item.php on line 721

FYI, I can edit and save an item as a back-end admin without any trouble.

I am developing locally using WAMP server on a windows vista machine.

I thought the problem might be with my local server setup so I uploaded everything to a hosting account at 1and1.com. I get the exact same error on the hosting server.

I've searched the forums and run google searches, but nothing I've found solves my problem.

Any help would really be appreciated.

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

More
12 years 7 months ago #104759 by D
I should also mention that I did a complete reinstall of both Joomla and K2 and that didn't solve the problem.

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

More
12 years 7 months ago #104760 by D
Another note...this only happens if I attempt to edit then save an existing item.

I can create and save new items without a problem.

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

More
12 years 7 months ago #104761 by D
And more info...

I commented out the foreach block of code that begins on line 719 in

administrator > components > com_k2 > models > item.php

That solved my problem. But I don't know what the repercussions are for commenting out that code. It solved my immediate problem, but may create more.

Here's the code block as it is now, with my change:

require_once (JPATH_COMPONENT_ADMINISTRATOR.DS.'lib'.DS.'JSON.php');
$json = new Services_JSON;
$row->extra_fields = $json->encode($objects);

$extraFieldModel = K2Model::getInstance('ExtraField', 'K2Model');
$row->extra_fields_search = '';
/* BEGIN MY EDIT HERE TO DISABLE THIS CODE
foreach ($objects as $object)
{
$row->extra_fields_search .= $extraFieldModel->getSearchValue($object->id, $object->value);
$row->extra_fields_search .= ' ';
}
*/ END MY EDIT HERE
//Tags
if ($use

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

More
12 years 7 months ago #104762 by william white
Replied by william white on topic Re: K2 - White screen when saving item and php error
You should not make changes to the file in the k2 core. All changes will be lost when you upgrade.
Try setting javascript in the k2 options layout tab at the top on your localhost version to load local copy and see if that may be the problem.

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

More
12 years 7 months ago #104763 by D
Thanks William.

I am aware of the dangers of editing core files, but I need to put a band-aid on this so I could keep moving.

I tried your suggestion. In Parameters, I went to Layout & Views and change the jquery library handling from

"Load v1.8.x latest (remote copy)

To

"Load v1.8.2 (local copy)

I logged out a frontend user and logged back in.

No change. i still get the error.

I also tried changing "Backend jQuery & jWuery UI handling" to local, but that had no effect.

Any other ideas?

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

More
12 years 7 months ago #104764 by william white
Replied by william white on topic Re: K2 - White screen when saving item and php error
I tested and am getting the same error/s with both the menu item and the add item in this category link
The item is saved even though it throws the error

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

More
12 years 7 months ago #104765 by D
Yea, I've noticed the same thing. The data gets saved, even though the error occurs.

So are you saying that you just discovered this error or did you manipulate your set up in some way to duplicate the error?

Ultimately I'd like to get this resolved without the core hack that I did, but the system has to function, and appear to function properly, when I turn everything over to my client.

I guess the worst case scenario is to leave my core hack in place, make note of it, and hope the hack doesn't create other problems.

Do you think this is a bug? Should I report it as a bug?

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

More
12 years 7 months ago #104766 by william white
Replied by william white on topic Re: K2 - White screen when saving item and php error
I tested in both 2.5 and 3.0 with k2 2.6.1
Got the same error
Applied the hack commenting out the foreach loop complely
and the error went away, but in j30 site the save and close button also went away requiring you to click the x to close the screen.
I think its a bug

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

More
12 years 7 months ago #104767 by Eduardo
yep same here. I was talking about this in another topic: getk2.org/community/New-to-K2-Ask-here-first/163350-260-update-Fatal-error--modelsitemphp

Can you please also check if your tags and extra fields are working? If they appear on the article you save... only new articles, not old ones.

Thanks

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

  • george
  • george's Avatar
  • Offline
  • New Member
  • May The Force be with you.
More
12 years 7 months ago - 12 years 7 months ago #104768 by george
Fatal error: Call to a member function getSearchValue()

The same problem. I confirm it to. It happens only in K2 items with extra fields assigned to them.

I have the latest versions for everyhting ( Joomla 2.5.7, K2 latest)

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

More
12 years 7 months ago - 12 years 6 months ago #104769 by Darren Janeczek
Replied by Darren Janeczek on topic Re: K2 - White screen when saving item and php error
Hello.

I've encountered the same issue, and came up with a solution.
It appears that attempts to find the extrafield.php file fails.

I've added the 'administrator' model location to the include path.

to line 17 of Joomla/administrator/components/com_k2/models/item.php, add
JModel::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'models', 'K2Model');


Below is a print out of the 'diff'.

$ git diff Joomla/administrator/components/com_k2/models/item.php
diff --git a/Joomla/administrator/components/com_k2/models/item.php b/Joomla/administrator/components/com_k2/models/item.php
index 068f283..64afb2c 100644
--- a/Joomla/administrator/components/com_k2/models/item.php
+++ b/Joomla/administrator/components/com_k2/models/item.php
@@ -14,6 +14,9 @@ jimport('joomla.application.component.model');

JTable::addIncludePath(JPATH_COMPONENT.DS.'tables');

+JModel::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'models', 'K2Model');^M
+
+
class K2ModelItem extends K2Model
{

getk2.org/community/New-to-K2-Ask-here-first/163385-Error-after-K2-update#163924

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

More
12 years 7 months ago #104770 by Mk
I'm not sure i've understood correctly

I tried this but no luck.

JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables');
JModel::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'models', 'K2Model');

Info: The item is saved but not its extra field values

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

  • Tomasz Bieliński
  • Tomasz Bieliński's Avatar
  • Offline
  • Senior Member
More
12 years 6 months ago #104771 by Tomasz Bieliński
Replied by Tomasz Bieliński on topic Re: K2 - White screen when saving item and php error
The same here under K2 2.6.1. Any news regarding this bug?
regards Tomek

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

More
12 years 6 months ago - 12 years 6 months ago #104772 by Darren Janeczek
Replied by Darren Janeczek on topic Re: K2 - White screen when saving item and php error
I'm also working with version 2.6.1 of K2.

Only the one line needed to be added at line 17 of the specified file.

Sorry for any confusion.

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

More
12 years 6 months ago #104773 by Eduardo
Darren,

Can you explain clearly, what needs to be changed?

Thanks

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

More
12 years 6 months ago #104774 by Darren Janeczek
Replied by Darren Janeczek on topic Re: K2 - White screen when saving item and php error
Sure

In your Joomla folder, look for the following file:
/administrator/components/com_k2/models/item.php

Inject the following text into a new line 17:
JModel::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'models', 'K2Model');

D.

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

More
12 years 6 months ago #104775 by Rodrigo Emygdio
Replied by Rodrigo Emygdio on topic Re: K2 - White screen when saving item and php error
Hi Darren,
Thanks for your tip! I updated the code and the error is gone. But When I updated the item the information of extra fields type of link lost the information about link, staying just a letter A in text and just one letter of the url in field URL. This happens just when a user update in the item in front end

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

More
12 years 6 months ago #104776 by Lefteris
Issue fixed. Please try the SVN version at getk2.org/assets/svn and provide some feedback.

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

More
12 years 6 months ago #104777 by Mk
tried the svn... fatal error in homepage :

Fatal error: Call to undefined method K2ViewItemlist::buildAliasBasedExtraFields() in \components\com_k2\models\item.php on line 1466

from where can i download 2.5.7 version?

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


Powered by Kunena Forum