Ensure _serialize is set in the view

@return void
556090
protected function _ensureSerialize()
    {
        $controller = $this->_controller();

        if (isset($controller->viewVars['_serialize'])) {
            return;
        }

        $serialize = [];
        $serialize[] = 'success';

        $action = $this->_action();
        if (method_exists($action, 'viewVar')) {
            $serialize['data'] = $action->viewVar();
        } else {
            $serialize[] = 'data';
        }

        $serialize = array_merge($serialize, (array)$action->getConfig('serialize'));
        $controller->set('_serialize', $serialize);
    }
1167525
public function serialize()
    {
        return serialize(array(
            'autoNumber'              =>  $this->autoNumber,
            'byteLength'              =>  $this->byteLength,
            'calculated'              =>  $this->calculated,
            'calculatedFormula'       =>  $this->calculatedFormula,
            'caseSensitive'           =>  $this->caseSensitive,
            'controllerName'          =>  $this->controllerName,
            'createable'              =>  $this->createable,
            'custom'                  =>  $this->custom,
            'defaultValueFormula'     =>  $this->defaultValueFormula,
            'defaultedOnCreate'       =>  $this->defaultedOnCreate,
            'dependentPicklist'       =>  $this->dependentPicklist,
            'deprecatedAndHidden'     =>  $this->deprecatedAndHidden,
            'digits'                  =>  $this->digits,
            'externalId'              =>  $this->externalId,
            'filterable'              =>  $this->filterable,
            'groupable'               =>  $this->groupable,
            'htmlFormatted'           =>  $this->htmlFormatted,
            'idLookup'                =>  $this->idLookup,
            'inlineHelpText'          =>  $this->inlineHelpText,
            'label'                   =>  $this->label,
            'length'                  =>  $this->length,
            'name'                    =>  $this->name,
            'nameField'               =>  $this->nameField,
            'namePointing'            =>  $this->namePointing,
            'nillable'                =>  $this->nillable,
            'permissionable'          =>  $this->permissionable,
            'picklistValues'          =>  $this->picklistValues,
            'precision'               =>  $this->precision,
            'referenceTo'             =>  $this->referenceTo,
            'relationshipName'        =>  $this->relationshipName,
            'relationshipOrder'       =>  $this->relationshipOrder,
            'restrictedPicklist'      =>  $this->restrictedPicklist,
            'scale'                   =>  $this->scale,
            'soapType'                =>  $this->soapType,
            'sortable'                =>  $this->sortable,
            'type'                    =>  $this->type,
            'unique'                  =>  $this->unique,
            'updateable'              =>  $this->updateable,
            'writeRequiresMasterRead' =>  $this->writeRequiresMasterRead
        ));
    }
1126087
public function serialize()
    {
        return serialize(array(
            'name' => $this->name,
            'type' => $this->type,
            'picklistEntries' => $this->picklistEntries,
            'fieldMetadata' => $this->fieldMetadata,
            'required' => $this->required,
            'readonly' => $this->readonly,
            'label' => $this->label
        ));
    }
1128094
public function unserialize($serialized)
    {
        parent::unserialize($serialized);
        foreach ( $this->getMethods() as $item ) {
            $item->setBelongsTo($this);
        }
//        foreach ( $this->getConstants() as $item ) {
//            $item->setBelongsTo($this);
//        }
        foreach ( $this->getProperties() as $item ) {
            $item->setBelongsTo($this);
        }
        foreach ( $this->getTags() as $item ) {
            $item->setBelongsTo($this);
        }
//        return;
//        foreach ( [ $this->getMethods(), $this->getProperties(), $this->getConstants(), $this->getTags() ] as $collection ) {
//            /** @var Collection|AbstractStructure[] $collection */
//            foreach ( $collection as $item ) {
//                $item->setBelongsTo($this);
//            }
//        }
    }
907597
final public function serialize(): string
    {
        $vars = array_filter(get_object_vars($this));
        $vars['adviceMethod'] = static::serializeAdvice($this->adviceMethod);

        return serialize($vars);
    }
34795
protected function _storeData() {
		if ($this->_currentCellIsDirty) {
			$this->_currentObject->detach();

			$this->_cellCache[$this->_currentObjectID] = igbinary_serialize($this->_currentObject);
			$this->_currentCellIsDirty = false;
		}
		$this->_currentObjectID = $this->_currentObject = null;
	}
584792
public function serialize()
    {
        $row = array();
        $row = $this->_data->getRowData();
        $row = array_merge($row, $this->getAffectedRowData());

        return serialize(array('row' => $row, 'identifier' => (string) $this->getIdentifier()));
    }
1211294
public static function setSerializeHandler() {
		$formats = [
			'php_serialize',
			'php',
			'php_binary',
		];

		// First, try php_serialize since that's the only one that doesn't suck in some way.
		\Wikimedia\suppressWarnings();
		ini_set( 'session.serialize_handler', 'php_serialize' );
		\Wikimedia\restoreWarnings();
		if ( ini_get( 'session.serialize_handler' ) === 'php_serialize' ) {
			return 'php_serialize';
		}

		// Next, just use the current format if it's supported.
		$format = ini_get( 'session.serialize_handler' );
		if ( in_array( $format, $formats, true ) ) {
			return $format;
		}

		// Last chance, see if any of our supported formats are accepted.
		foreach ( $formats as $format ) {
			\Wikimedia\suppressWarnings();
			ini_set( 'session.serialize_handler', $format );
			\Wikimedia\restoreWarnings();
			if ( ini_get( 'session.serialize_handler' ) === $format ) {
				return $format;
			}
		}

		throw new \DomainException(
			'Failed to set serialize handler to a supported format.' .
				' Supported formats are: ' . implode( ', ', $formats ) . '.'
		);
	}
616232
public function postAction()
    {
        $data = json_decode($this->getRequest()->getRawBody());
        if (!is_array($data)) $data = array($data);

        $ret = array();
        foreach ($data as $d) {
            $row = $this->_model->createRow();
            if (isset($d->id) && $d->id) {
                $row->id = $d->id;
            }

            $this->_validateInsert((array)$d);
            $this->_validateSave((array)$d);
            $this->_fillRowInsert($row, $d);
            $this->_beforeInsert($row);
            $this->_beforeSave($row);
            $row->save();
            $this->_afterSave($row, $d);
            $this->_afterInsert($row, $d);

            $ret[] = $this->_loadDataFromRow($row);
        }
        if (count($ret) == 1) $ret = reset($ret);

        $this->view->data = $ret;
    }
16807
public function preSave()
    {
        if (!isset($this->revisionEnabled) || $this->revisionEnabled) {
            // if there's no revisionEnabled. Or if there is, if it's true

            $this->originalData = $this->original;
            $this->updatedData  = $this->attributes;

            // we can only safely compare basic items,
            // so for now we drop any object based items, like DateTime
            foreach ($this->updatedData as $key => $val) {
                if (gettype($val) == 'object' && ! method_exists($val, '__toString')) {
                    unset($this->originalData[$key]);
                    unset($this->updatedData[$key]);
                }
            }

            // the below is ugly, for sure, but it's required so we can save the standard model
            // then use the keep / dontkeep values for later, in the isRevisionable method
            $this->dontKeep = isset($this->dontKeepRevisionOf) ?
                array_merge($this->dontKeepRevisionOf, $this->dontKeep)
                : $this->dontKeep;

            $this->doKeep = isset($this->keepRevisionOf) ?
                array_merge($this->keepRevisionOf, $this->doKeep)
                : $this->doKeep;

            unset($this->attributes['dontKeepRevisionOf']);
            unset($this->attributes['keepRevisionOf']);

            $this->dirtyData = $this->getDirty();
            $this->updating = $this->exists;
        }
    }
1215255
public function serialize()
    {
        $frame = $this->frame;
        if (!empty($this->comments)) {
            $frame['_comments'] = $this->comments;
        }

        return serialize($frame);
    }
535861
public function unserialize($serialized)
    {
        foreach (unserialize($serialized) as $item => $value) {
            $this->$item = $value;
        }
    }
1014320
protected function _getDataToSerializeFromViewVars($serialize = true)
    {
        if (is_object($serialize)) {
            throw new CrudException('Assigning an object to JsonApiListener "_serialize" is deprecated, assign the object to its own variable and assign "_serialize" = true instead.');
        }

        if ($serialize === true) {
            $data = array_diff_key(
                $this->viewVars,
                array_flip($this->_getSpecialVars())
            );

            if (empty($data)) {
                return null;
            }

            return current($data);
        }

        if (is_array($serialize)) {
            $serialize = current($serialize);
        }

        return isset($this->viewVars[$serialize]) ? $this->viewVars[$serialize] : null;
    }
660119
public function unserialize($serialized)
    {
        $list = unserialize($serialized);
        if (is_array($list)) {
            foreach ($list as $index => $value) {
                $this[$index] = $value;
            }
        }
    }
1366464
public function serializeAttributes()
    {
        foreach ($this->attributes as $attribute) {
            if (isset($this->oldAttributes[$attribute])) {
                $this->owner->setOldAttribute($attribute, $this->oldAttributes[$attribute]);
            }
            if (is_array($this->owner->{$attribute}) && count($this->owner->{$attribute}) > 0) {
                $this->owner->$attribute = serialize($this->owner->{$attribute});
                if ($this->encode) {
                    $this->owner->{$attribute} = base64_encode($this->owner->{$attribute});
                }
            } elseif (empty($this->owner->{$attribute})) {
                $this->owner->{$attribute} = null;
            } else {
                throw new \Exception('Can’t serialize attribute "' . $attribute . '" of "' . $this->owner->className() . '".');
            }
        }
    }
584580
public function unserialize($serialized)
    {
        $data = unserialize($serialized);
        
        $this->autoNumber              =  $data['autoNumber'];            
        $this->byteLength              =  $data['byteLength'];            
        $this->calculated              =  $data['calculated'];            
        $this->calculatedFormula       =  $data['calculatedFormula'];     
        $this->caseSensitive           =  $data['caseSensitive'];         
        $this->controllerName          =  $data['controllerName'];        
        $this->createable              =  $data['createable'];            
        $this->custom                  =  $data['custom'];                
        $this->defaultValueFormula     =  $data['defaultValueFormula'];   
        $this->defaultedOnCreate       =  $data['defaultedOnCreate'];     
        $this->dependentPicklist       =  $data['dependentPicklist'];     
        $this->deprecatedAndHidden     =  $data['deprecatedAndHidden'];   
        $this->digits                  =  $data['digits'];                
        $this->externalId              =  $data['externalId'];            
        $this->filterable              =  $data['filterable'];            
        $this->groupable               =  $data['groupable'];             
        $this->htmlFormatted           =  $data['htmlFormatted'];         
        $this->idLookup                =  $data['idLookup'];              
        $this->inlineHelpText          =  $data['inlineHelpText'];        
        $this->label                   =  $data['label'];                 
        $this->length                  =  $data['length'];                
        $this->name                    =  $data['name'];                  
        $this->nameField               =  $data['nameField'];             
        $this->namePointing            =  $data['namePointing'];          
        $this->nillable                =  $data['nillable'];              
        $this->permissionable          =  $data['permissionable'];        
        $this->picklistValues          =  $data['picklistValues'];        
        $this->precision               =  $data['precision'];             
        $this->referenceTo             =  $data['referenceTo'];           
        $this->relationshipName        =  $data['relationshipName'];      
        $this->relationshipOrder       =  $data['relationshipOrder'];     
        $this->restrictedPicklist      =  $data['restrictedPicklist'];    
        $this->scale                   =  $data['scale'];                 
        $this->soapType                =  $data['soapType'];              
        $this->sortable                =  $data['sortable'];              
        $this->type                    =  $data['type'];                  
        $this->unique                  =  $data['unique'];                
        $this->updateable              =  $data['updateable'];            
        $this->writeRequiresMasterRead =  $data['writeRequiresMasterRead'];
    }
181883
public function unserialize($serialized)
    {
        $unserialized = unserialize($serialized);
        $this->__construct($unserialized['tokens']);
        $this->seek($unserialized['index']);
    }