Jump to content


Photo

Problem installing 0.6.5 with class auditevent-serializeddata

auditevent serializeddata install Bug

  • Please log in to reply
14 replies to this topic

#1 k1000o

k1000o

    Advanced Member

  • Members
  • PipPipPip
  • 112 posts
  • LocationMadrid

Posted 19 May 2012 - 11:49 AM

Hello

I've trying to install the version 0.6.5, but during the install the following error occurs

SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'serializeddata' at row 1

After some investigation I found that the auditevent event table is created with the field serializeddata as VARCHAR(255), if we change it to TEXT the installation works fine.

How can we force the creation of this field as TEXT?

#2 Jason

Jason

    Administrator

  • Administrators
  • 716 posts
  • LocationChicago

Posted 19 May 2012 - 01:45 PM

Strange. It is declared the same way in GlobalMetadata model, and that serializedMetadata is correctly formed as Text in the database. I will investigate and let you know what i find

Jason Green
Zurmo Team
Need support? Upgrade now


#3 Jason

Jason

    Administrator

  • Administrators
  • 716 posts
  • LocationChicago

Posted 19 May 2012 - 02:16 PM

This will be in the release for this upcoming week. However if you look here:
http://hg.zurmo.org/...et/47d85ab204da
You can easily make this change locally. Please let us know if it works. Also check the About page in the app :)

Jason Green
Zurmo Team
Need support? Upgrade now


#4 k1000o

k1000o

    Advanced Member

  • Members
  • PipPipPip
  • 112 posts
  • LocationMadrid

Posted 19 May 2012 - 03:46 PM

The error still appears in this version. It's really strange and I cannot find the issue.
As a workaround only to finish the installation we can change the method protected->modules->zurmo-models->AuditEvent->logAuditEvent as specified below. Doing this change the table have the column as TEXT and the application works.
		public static function logAuditEvent($moduleName, $eventName, $data = null, RedBeanModel $model = null, User $user = null)
		{
			assert('is_string($moduleName) && $moduleName != ""');
			assert('is_string($eventName)  && $eventName  != ""');
			if ($user === null)
			{
				$user = Yii::app()->user->userModel;
				if (!$user instanceof User)
				{
					throw new NoCurrentUserSecurityException();
				}
			}
			if (!AuditEvent::$isTableOptimized && (!AUDITING_OPTIMIZED || !RedBeanDatabase::isFrozen()))
			{
				$tableName  = self::getTableName('AuditEvent');
				RedBean_Plugin_Optimizer_Id::ensureIdColumnIsINT11($tableName, strtolower('modelId'));
				$auditEvent = new AuditEvent();
				$auditEvent->dateTime	   = DateTimeUtil::convertTimestampToDbFormatDateTime(time());
				$auditEvent->moduleName	 = $moduleName;
				$auditEvent->eventName	  = $eventName;
				$auditEvent->user		   = $user;
				$auditEvent->modelClassName = $model !== null ? get_class($model) : null;
				$auditEvent->modelId		= $model !== null ? $model->id		: null;
				$auditEvent->serializedData = serialize($data);
				$saved = $auditEvent->save();
				AuditEvent::$isTableOptimized = true;
			}
			else
			{
				$sql = "insert into auditevent (datetime,
												modulename,
												eventname,
												_user_id,
												modelclassname,
												modelid
												)
						values ('" . DateTimeUtil::convertTimestampToDbFormatDateTime(time()) . "',
								'$moduleName',
								'$eventName',
								{$user->id}, " .
								($model !== null ? "'" . get_class($model) . "', " : 'null, ') .
								($model !== null ? "{$model->id}, "				 : 'null, ') .
								":data)";
				
				$saved = true;
			}
			return $saved;
		}


#5 Jason

Jason

    Administrator

  • Administrators
  • 716 posts
  • LocationChicago

Posted 19 May 2012 - 11:18 PM

Did you try to apply the change i made in bitbucket? You are saying it was still broken even with that change?

Jason Green
Zurmo Team
Need support? Upgrade now


#6 k1000o

k1000o

    Advanced Member

  • Members
  • PipPipPip
  • 112 posts
  • LocationMadrid

Posted 20 May 2012 - 03:59 PM

I cloned the repository and checked the ZurmoModule.php file as described but the error persists. The strange thing is that if the logAuditEvent function is not modified as described above the serializeddata column is generated as VARCHAR 255 and the following error appears.

SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'serializeddata' at row 1

C:\inetpub\wwwroot\zurmo\redbean\rb.php(902)

890 $s->execute();
891 }
892 $this->affected_rows=$s->rowCount();
893 return $this->affected_rows;
894 }
895 catch(PDOException $e) {

#7 Jason

Jason

    Administrator

  • Administrators
  • 716 posts
  • LocationChicago

Posted 20 May 2012 - 06:21 PM

Strange. We can't just remove the execution line in logAuditEvent. I am wondering what sql_mode is your MySQL configuration? I am thinking there is something with your MySQL configuration that we have not encountered before. Also on line 101, $saved, is that ever false? can you check if it is false at all and throw an exception?

Jason Green
Zurmo Team
Need support? Upgrade now


#8 Jason

Jason

    Administrator

  • Administrators
  • 716 posts
  • LocationChicago

Posted 20 May 2012 - 06:25 PM

Did you put AuditEvent as the first entry in getRootModelNames() ?

Jason Green
Zurmo Team
Need support? Upgrade now


#9 Sacha Telgenhof

Sacha Telgenhof

    Advanced Member

  • Members
  • PipPipPip
  • 85 posts
  • LocationTokyo, Japan

Posted 20 May 2012 - 06:28 PM

Jason, I had a similar issue on serialized data from the audit table. I was using different Zurmo versions with the same database... I know, not a good idea but I got around the issue by removing some of the audit table entries. Of course the best thing is to start with a clean database :)

#10 k1000o

k1000o

    Advanced Member

  • Members
  • PipPipPip
  • 112 posts
  • LocationMadrid

Posted 20 May 2012 - 09:37 PM

Here it's the sql-mode
# Set the SQL mode to strict
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

and yes AuditEvent is the first entry in getRootModelNames()

	public function getRootModelNames() {
		// ZurmoModule is a special case in that most of its models
		// are non-root models of things that root models in the other
		// modules, and because ZurmoModule is the root of the module
		// dependence hierarchy it needed concern itself, other than
		// with the models that are specific to itself.
		return array('AuditEvent', 'NamedSecurableItem', 'GlobalMetadata', 'PerUserMetadata', 'Portlet', 'CustomFieldData',
			'CalculatedDerivedAttributeMetadata', 'DropDownDependencyDerivedAttributeMetadata');
	}


#11 Jason

Jason

    Administrator

  • Administrators
  • 716 posts
  • LocationChicago

Posted 21 May 2012 - 01:14 AM

Ok i think I know what is going on. If you go into RedBeanDatabaseBuilderUtil.php, and in the function autoBuildModels, what you need to do is make the AuditEvent the first entry in the array $modelClassNames that is coming in as a parameter. I believe that the auditEvent model needs to be created first.

If you can test manipulating the $modelClassNames array right in the beginning of the method, to have AuditEvent first, then let me know if it still breaks. We can go from there.

Actually now that I think about it, can you send the complete output as an attachment. I want to see where this error comes in the autobuild process. Is it in the beginning of the auto build process or later?

Jason Green
Zurmo Team
Need support? Upgrade now


#12 k1000o

k1000o

    Advanced Member

  • Members
  • PipPipPip
  • 112 posts
  • LocationMadrid

Posted 21 May 2012 - 10:22 AM

If we modify RedBeanDatabaseBuilderUtil.php->autoBuildModels as below the installation works fine

..............................
self::$uniqueStrings = array();
 
        if (in_array('AuditEvent', $modelClassNames)) {
            unset($modelClassNames[array_search('AuditEvent', $modelClassNames)]);
            array_unshift($modelClassNames, "AuditEvent");
        }
foreach ($modelClassNames as $modelClassName) {
.................................

#13 Jason

Jason

    Administrator

  • Administrators
  • 716 posts
  • LocationChicago

Posted 21 May 2012 - 05:13 PM

Fixed
https://www.pivotalt...y/show/29936051
http://hg.zurmo.org/...et/e05ae1e0ae94

Please let me know if it works ok, my fix.

Jason Green
Zurmo Team
Need support? Upgrade now


#14 k1000o

k1000o

    Advanced Member

  • Members
  • PipPipPip
  • 112 posts
  • LocationMadrid

Posted 21 May 2012 - 06:26 PM

Yes it works, thanks.....

#15 Jason

Jason

    Administrator

  • Administrators
  • 716 posts
  • LocationChicago

Posted 21 May 2012 - 07:17 PM

Great. Thanks for figuring it out.

Jason Green
Zurmo Team
Need support? Upgrade now






Also tagged with one or more of these keywords: auditevent, serializeddata, install, Bug

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users