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 ) . '.'
		);
	}
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 ) . '.'
		);
	}
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 ) . '.' ) ; }
Try to set session.serialize_handler to a supported format

This may change the format even if the current format is also supported.

@return string Format set
@throws \\DomainException
Try to set session . serialize_handler to a supported format