Results 1 to 7 of 7

Thread: unserialized ()

  1. #1
    karl578 is offline Junior Member
    Join Date
    Apr 2010
    Posts
    3

    Default unserialized ()

    Hi,

    I'm receiving the following error when trying to import around 700 leads.

    NOTICE: [8] unserialize() [function.unserialize]: Error at offset 0 of 2 bytes on line 129 in file /var/www/modules/DynamicFields/templates/Fields/TemplateMultiEnum.php

    The error is repeated on the page it seems for each lead which SugarCRM tries to import. It seems that 100 or so leads do indeed get imported. however the rest fail.

    When importing, I am trying to add a custom field (database name).

    Regards

    Karl.

  2. #2
    karl578 is offline Junior Member
    Join Date
    Apr 2010
    Posts
    3

    Default Re: unserialized ()

    any ideas?


    anyone?

  3. #3
    andopes's Avatar
    andopes is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Jul 2006
    Location
    São Paulo - Brazil
    Posts
    8,335

    Default Re: unserialized ()

    Please, attach into your next post the script /var/www/modules/DynamicFields/templates/Fields/TemplateMultiEnum.php.

    Cheers
    André Lopes
    DevToolKit / Project of the Month - June 2009
    Lampada Global Services- Open Source Solutions
    Avenida Ipiranga, 318
    Bloco B - CJ 1602
    São Paulo, SP 01046-010
    Brazil
    Office: +55 11 3237-3110
    Mobile: +55 11 7636-5859
    e-mail: andre@lampadaglobal.com

    Lampada Global delivers offshore software development and support services to customers around the world.
    Lampada is proud to be a SugarCRM Gold Partner, revolutionizing Customer Relationship Management.

    I DO NOT answer questions through PM and Email. If you need some help post your question into SugarForum.

  4. #4
    Ledboards.co.uk is offline Junior Member
    Join Date
    May 2010
    Posts
    2

    Default Re: unserialized ()

    I'm having exactly the same problem when trying to create and update in contacts this is the full error

    NOTICE: [8] unserialize() [function.unserialize]: Error at offset 0 of 2 bytes on line 129 in file /var/www/vhosts/domain/httpdocs/modules/DynamicFields/templates/Fields/TemplateMultiEnum.php

    any ideas?

  5. #5
    Ledboards.co.uk is offline Junior Member
    Join Date
    May 2010
    Posts
    2

    Default Re: unserialized ()

    did you get any where with this? be very interested in the outcome if you did

  6. #6
    alefbejt is offline Junior Member
    Join Date
    Oct 2008
    Posts
    1

    Default Re: unserialized ()

    Quote Originally Posted by andopes View Post
    Please, attach into your next post the script /var/www/modules/DynamicFields/templates/Fields/TemplateMultiEnum.php.

    Cheers
    Hi, I have the same problem during the importing (there are the custm fields in my sugarcrm)

    here is the code:

    require_once('modules/DynamicFields/templates/Fields/TemplateEnum.php');
    require_once('include/utils/array_utils.php');
    class TemplateMultiEnum extends TemplateEnum{
    var $type = 'text';

    function get_html_edit(){
    $this->prepare();
    $xtpl_var = strtoupper( $this->name);
    // MFH BUG#13645
    return "<input type='hidden' name='". $this->name. "' value='0'><select name='". $this->name . "[]' size='5' title='{" . $xtpl_var ."_HELP}' MULTIPLE=true>{OPTIONS_".$xtpl_var. "}</select>";
    }

    function get_db_type(){
    if ($GLOBALS['db']->dbType=='oci8') {
    return " CLOB ";
    } else {
    return " TEXT ";
    }
    }

    function get_xtpl_edit(){
    $name = $this->name;
    $value = '';
    if(isset($this->bean->$name)){
    $value = $this->bean->$name;
    }else{
    if(empty($this->bean->id)){
    $value= $this->default_value;
    }
    }
    if(!empty($this->help)){
    $returnXTPL[strtoupper($this->name . '_help')] = translate($this->help, $this->bean->module_dir);
    }

    global $app_list_strings;
    $returnXTPL = array();

    $returnXTPL[strtoupper($this->name)] = str_replace('^,^', ',', $value);
    if(empty($this->ext1)){
    $this->ext1 = $this->options;
    }
    $returnXTPL[strtoupper('options_'.$this->name)] = get_select_options_with_id($app_list_strings[$this->ext1], unencodeMultienum( $value));

    return $returnXTPL;


    }
    function prepSave(){

    }
    function get_xtpl_list(){
    return $this->get_xtpl_detail();

    }
    function get_xtpl_detail(){

    $name = $this->name;
    $value = '';
    if(isset($this->bean->$name)){
    $value = $this->bean->$name;
    }else{
    if(empty($this->bean->id)){
    $value= $this->default_value;
    }
    }
    $returnXTPL = array();
    if(empty($value)) return $returnXTPL;
    global $app_list_strings;

    $values = unencodeMultienum( $value);
    $translatedValues = array();

    foreach($values as $val){
    $translated = translate($this->options, '', $val);
    if(is_string($translated))$translatedValues[] = $translated;
    }

    $returnXTPL[strtoupper($this->name)] = implode(', ', $translatedValues);
    return $returnXTPL;




    }

    function get_field_def(){
    $def = parent::get_field_def();
    if ( isset ( $this->ext4 ) )
    {
    // turn off error reporting in case we are unpacking a value that hasn't been packed...
    // this is kludgy, but unserialize doesn't throw exceptions correctly
    $oldErrorReporting = error_reporting ( 0 );
    $unpacked = unserialize ( $this->ext4 ) ;
    error_reporting ( $oldErrorReporting ) ;

    // if we have a new error, then unserialize must have failed => we don't have a packed ext4
    // safe to assume that false means the unpack failed, as ext4 will either contain an imploded string of default values, or an array, not a boolean false value
    if ( $unpacked === false )
    $def [ 'default' ] = $this->ext4 ;
    else
    {
    // we have a packed representation containing one or both of default and dependency
    if ( isset ( $unpacked [ 'default' ] ) )
    $def [ 'default' ] = $unpacked [ 'default' ] ;
    if ( isset ( $unpacked [ 'dependency' ] ) )
    $def [ 'dependency' ] = $unpacked [ 'dependency' ] ;
    }
    }
    //$def['default'] = isset($this->ext4)? $this->ext4 : $def['default'];
    $def['isMultiSelect'] = true;
    unset($def['len']);
    return $def;
    }

    function get_db_default(){
    return '';
    }

    function save($df) {
    if ( isset ( $this->default ) )
    {
    if ( is_array ( $this->default ) )
    $this->default = encodeMultienumValue($this->default);
    $this->ext4 = ( isset ( $this->dependency ) ) ? serialize ( array ( 'default' => $this->default , 'dependency' => $this->dependency ) ) : $this->default ;
    } else
    {
    if ( isset ( $this->dependency ) )
    $this->ext4 = serialize ( array ( 'dependency' => $this->dependency ) ) ;
    }
    parent::save($df);
    }
    }


    ?>

  7. #7
    Toioc is offline Junior Member
    Join Date
    Jul 2010
    Posts
    1

    Default Re: unserialized ()

    You can replace line 129:

    Code:
    $unpacked = unserialize ( $this->ext4 ) ;
    by

    Code:
    //Patch
    if( preg_match("/[:;]+/",$this->ext4 ) ){
    	$unpacked = unserialize ( $this->ext4 ) ;
    }else{
    	$unpacked = false;
    }

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •