Users can't edit profile

6 years 11 months ago - 6 years 11 months ago #293866 by Cluster89
Users can't edit profile was created by Cluster89
Hello,

I am using: Joomla! 3.6.5 Stable, PHP 5.6 and CB 2.1.2. Users login with JMapMyLDAP.
The problem is, when a user tries to edit his profile and changes anything and saves, he gets following error:

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20972558 bytes) in /var/www/html/dev.sitetest.net/libraries/shmanic/ldap/event/debug.php on line 133

The memory usage before save button click when changing profile (Joomla Debug Console): 40.56 MB (42.530.720 Bytes)

On line 133 is:
		SHLog::add(
			JText::sprintf(
				'LIB_SHLDAPEVENTDEBUG_DEBUG_11951',
				preg_replace('/\s+/', ' ', var_export($user, true)),
				preg_replace('/\s+/', ' ', var_export($new, true))
			), 11951, JLog::DEBUG, 'ldap'
		);

Memory usage before this line: 53068656 b
Call stack:
"#0 [internal function]: SHLdapEventDebug->onUserBeforeSave(Array, false, Array) 
#1 /var/www/html/dev.sitetest.net/libraries/joomla/event/event.php(69): call_user_func_array(Array, Array) 
#2 /var/www/html/dev.sitetest.net/libraries/joomla/event/dispatcher.php(159): JEvent->update(Array) 
#3 /var/www/html/dev.sitetest.net/libraries/shmanic/ldap/helper.php(708): JEventDispatcher->trigger('onUserBeforeSav...', Array) 
#4 /var/www/html/dev.sitetest.net/libraries/shmanic/ldap/event/bouncer.php(259): SHLdapHelper::triggerEvent('onUserBeforeSav...', Array) 
#5 [internal function]: SHLdapEventBouncer->onUserBeforeSave(Array, false, Array) 
#6 /var/www/html/dev.sitetest.net/libraries/joomla/event/event.php(69): call_user_func_array(Array, Array) 
#7 /var/www/html/dev.sitetest.net/libraries/joomla/event/dispatcher.php(159): JEvent->update(Array) 
#8 /var/www/html/dev.sitetest.net/libraries/joomla/user/user.php(783): JEventDispatcher->trigger('onUserBeforeSav...', Array) 
#9 /var/www/html/dev.sitetest.net/libraries/CBLib/CB/Database/Table/UserTable.php(574): JUser->save() 
#10 /var/www/html/dev.sitetest.net/libraries/CBLib/CB/Database/Table/UserTable.php(1102): CB\Database\Table\UserTable->store() 
#11 /var/www/html/dev.sitetest.net/components/com_comprofiler/comprofiler.php(488): CB\Database\Table\UserTable->saveSafely(Array, 1, 'edit') 
#12 /var/www/html/dev.sitetest.net/components/com_comprofiler/comprofiler.php(102): userSave('com_comprofiler', 447) 
#13 /var/www/html/dev.sitetest.net/libraries/cms/component/helper.php(405): require_once('/var/www/html/d...') 
#14 /var/www/html/dev.sitetest.net/libraries/cms/component/helper.php(380): JComponentHelper::executeComponent('/var/www/html/d...') 
#15 /var/www/html/dev.sitetest.net/libraries/cms/application/site.php(191): JComponentHelper::renderComponent('com_comprofiler') 
#16 /var/www/html/dev.sitetest.net/libraries/cms/application/site.php(230): JApplicationSite->dispatch() 
#17 /var/www/html/dev.sitetest.net/libraries/cms/application/cms.php(261): JApplicationSite->doExecute()
#18 /var/www/html/dev.sitetest.net/index.php(49): JApplicationCms->execute() #19 {main}" 	

Now if I delete this log line 133 I get the error on a totaly different place:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20972662 bytes) in /var/www/html/dev.sitetest.net/libraries/joomla/database/driver.php on line 1967.
Anyone has an idea what is going on?

Please Log in to join the conversation.

6 years 11 months ago - 6 years 11 months ago #293867 by Cluster89
Replied by Cluster89 on topic Users can't edit profile
I was able to track down the problem more.
Everytime someone saves, slashes get added to the DB:

"\\\\\\\\\\\\\\\\
\\\\\":\\\\\\\\\\
\\\\\\\\\\\\\\\\\
\\\\"{\\\\\\\\\\
\\\\\\\\\\\\\\\\\
\\\\\\\\\\\\\\\\\
\\\\\\\\\\\\\\\\\
\\"auth_typ
e\\\\\\\\\\\\\\\
\\\\\\\\\\\\\\\\\
\\\\\\\\\\\\\\\\\
\\\\\\\\\\\\\\":\
\\\\\\\\\\\\\\\\\
\\\\\\\\\\\\\\\\\
\\\\\\\\\\\\\\\\\
\\\\\\\\\\\"LD
AP\\\\\\\\\\\\\
\\\\\\\\\\\\\\\\\
\\\\\\\\\\\\\\\\\
\\\\\\\\\\\\\\\\"
,\\\\\\\\\\\\\\\\
\\\\\\\\\\\\\\\\\
\\\\\\\\\\\\\\\\\
\\\\\\\\\\\\\"a
uth_domai
n\\\\\\\\\\\\\\\
\\\\\\\\\\\\\\\\\
\\\\\\\\\\\\\\\\\
\\\\\\\\\\\\\\""

Now after sometime it gets so much that PHP can't handle it anymore, because of memory issues. Now I need to find out, why it is doing this.

Please Log in to join the conversation.

6 years 11 months ago - 6 years 11 months ago #293890 by krileon
Replied by krileon on topic Users can't edit profile
Your LDAP plugin is acting on Joomla save and is where your issue is coming from. I'm guessing there's something in the plugin getting stuck in a loop. Specifically in class SHLdapEventDebug of function onUserBeforeSave. Try putting a return at the top of the onUserBeforeSave function to stop its functionality and see if that resolves it. I recommend contacting the developer of your LDAP plugin for further support. The slashes issue is likely a bad escaping on the params that that plugin is doing before the user is saved.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: Cluster89

Please Log in to join the conversation.

6 years 11 months ago - 6 years 11 months ago #293934 by Cluster89
Replied by Cluster89 on topic Users can't edit profile
Hello,
where does CB json_decode the params column (in users table) when it does load a user in usertable::load?

Similar Problem:
www.joomlapolis.com/forum/149-usage/233722-params-field-in-users-to-long-to-be-editable#281770

I have modified now like this and my problem seems to be gone. bindThisUserFromDbArray called shortly after load
public function bindThisUserFromDbArray( $arr, $oid = null  ) {
		foreach ( $arr as $kk => $v ) {
			$this->$kk		=	$v;
			if (trim($kk) === 'params' && trim($v) !== '') {
				$this->$kk = json_decode($this->$kk);
			}
		}

When the user is saved the param is getting json_encoded again, so it has to be decoded before, or it grows and grows.

Please Log in to join the conversation.

6 years 11 months ago #293944 by krileon
Replied by krileon on topic Users can't edit profile
Params storage is done in cb.core when storing the userparams field. The loading is done by Joomlas own user object. We use Joomlas own registry API to handle parsing the params for storage. There are also zero issues in my local tests or on our demosite. Nothing should be calling json_decode or json_encode on Joomla user params. They should be passed through Joomlas Registry class, which will handle them accordingly. My guess is your LDAP plugin is not doing that.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: Cluster89

Please Log in to join the conversation.

6 years 11 months ago #293955 by Cluster89
Replied by Cluster89 on topic Users can't edit profile
hm thanks for your answer.
Yes I agree that json_decode should not be called directly, but I guess I will have no other choice if I can't find the root problem...
Just like the other guy I saw it happen also with the {"admin_style":"","admin_language":"","language":"","editor":"","helpsite":"","timezone":"Europe\/Vienna"}"
but happens very rarely in this case. Thats why I think it might not be the LDAP plugin.
I'll try to find where joomla loads the params from the db and then creates the registry class with it or why it is not doing it in my case.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.169 seconds

Facebook Twitter LinkedIn