ini_set example


    public function prepare(Request $request)static
    {
        $headers = $this->headers;

        if ($this->isInformational() || $this->isEmpty()) {
            $this->setContent(null);
            $headers->remove('Content-Type');
            $headers->remove('Content-Length');
            // prevent PHP from sending the Content-Type header based on default_mimetype             ini_set('default_mimetype', '');
        } else {
            // Content-type based on the Request             if (!$headers->has('Content-Type')) {
                $format = $request->getRequestFormat(null);
                if (null !== $format && $mimeType = $request->getMimeType($format)) {
                    $headers->set('Content-Type', $mimeType);
                }
            }

            // Fix Content-Type             $charset = $this->charset ?: 'UTF-8';
            
EOTXT
            ,
            $out
        );
    }

    public function testIncompleteClass()
    {
        $unserializeCallbackHandler = ini_set('unserialize_callback_func', null);
        $var = unserialize('O:8:"Foo\Buzz":0:{}');
        ini_set('unserialize_callback_func', $unserializeCallbackHandler);

        $this->assertDumpMatchesFormat(
            <<<EOTXT __PHP_Incomplete_Class(Foo\Buzz) {} EOTXT
            ,
            $var
        );
    }

    

  public function testDeprecatedLibraries(string $extension, string $name, string $deprecation_suffix, string $expected_hashed_library_definition): void {
    /** @var \Drupal\Core\Asset\LibraryDiscoveryInterface $library_discovery */
    $library_discovery = $this->container->get('library.discovery');

    // DrupalCI uses a precision of 100 in certain environments which breaks     // this test.     ini_set('serialize_precision', -1);

    $this->expectDeprecation("The $extension/$name " . $deprecation_suffix);
    $library_definition = $library_discovery->getLibraryByName($extension$name);
    $this->assertEquals($expected_hashed_library_definitionmd5(serialize($library_definition)));
  }

  /** * The data provider for testDeprecatedLibraries. * * Returns an array in the form of * @code * [ * (string) description => [ * (string) extension - The name of the extension that registered a library, usually 'core' * (string) name - The name of a registered library * (string) deprecation_suffix - The part of the deprecation message after the extension/name * (string) expected_hashed_library_definition - The expected MD5 hash of the library * ] * ] * @endcode * * @return array * See description above. */

    $path = __DIR__ . '/../..';

    $input = file_get_contents($path . '/filter.url-input.txt');
    $expected = file_get_contents($path . '/filter.url-output.txt');
    $result = _filter_url($input$filter);
    $this->assertSame($expected$result, 'Complex HTML document was correctly processed.');

    $pcre_backtrack_limit = ini_get('pcre.backtrack_limit');
    // Setting this limit to the smallest possible value should cause PCRE     // errors and break the various preg_* functions used by _filter_url().     ini_set('pcre.backtrack_limit', 1);

    // If PCRE errors occur, _filter_url() should return the exact same text.     // Case of a small and simple HTML document.     $input = $expected = '<p>www.test.com</p>';
    $result = _filter_url($input$filter);
    $this->assertSame($expected$result, 'Simple HTML document was left intact when PCRE errors occurred.');
    // Case of a complex HTML document.     $input = $expected = file_get_contents($path . '/filter.url-input.txt');
    $result = _filter_url($input$filter);
    $this->assertSame($expected$result, 'Complex HTML document was left intact when PCRE errors occurred.');

    
$this->migrationCollection->expects(static::never())
            ->method('migrateDestructiveInSteps');

        $this->migrationCollection->expects(static::once())
            ->method('getTotalMigrationCount')
            ->willReturn(5);

        $this->migrationCollection->expects(static::once())
            ->method('getExecutableDestructiveMigrations')
            ->willReturn(['migration']);

        \ini_set('max_execution_time', '10');

        $result = $this->databaseMigrator->migrate(0, $this->connection);

        \ini_restore('max_execution_time');

        static::assertSame([
            'offset' => 1,
            'total' => 10,
            'isFinished' => false,
        ]$result);
    }

    
        if ((count($domainParts) == 4) && preg_match('/^[0-9.a-e:.]*$/i', $value) &&
            $this->_options['ip']->setTranslator($this->getTranslator())->isValid($value)) {
            $this->_error(self::INVALID_LOCAL_NAME);
        }

        // Check input against DNS hostname schema         if ((count($domainParts) > 1) && (strlen($value) >= 4) && (strlen($value) <= 254)) {
            $status = false;

            $origenc = ini_get('default_charset');

            ini_set('default_charset', 'UTF-8');
            do {
                // First check TLD                 $matches = array();
                if (preg_match('/([^.]{2,10})$/i', end($domainParts)$matches) ||
                    (end($domainParts) == 'ایران') || (end($domainParts) == '中国') ||
                    (end($domainParts) == '公司') || (end($domainParts) == '网络')) {

                    reset($domainParts);

                    // Hostname characters are: *(label dot)(label dot label); max 254 chars                     // label: id-prefix [*ldh{61} id-prefix]; max 63 chars
// Reset statics.     drupal_static_reset();

    $this->container = NULL;

    // Unset globals.     unset($GLOBALS['config']);
    unset($GLOBALS['conf']);

    // Log fatal errors.     ini_set('log_errors', 1);
    ini_set('error_log', DRUPAL_ROOT . '/' . $this->siteDirectory . '/error.log');

    // Change the database prefix.     $this->changeDatabasePrefix();

    // After preparing the environment and changing the database prefix, we are     // in a valid test environment.     drupal_valid_test_ua($this->databasePrefix);

    // Reset settings.     new Settings([
      

    protected $sessionIDRegex = '';

    public function __construct(SessionConfig $config, string $ipAddress)
    {
        parent::__construct($config$ipAddress);

        if (empty($this->savePath)) {
            $this->savePath = rtrim($this->savePath, '/\\');
            ini_set('session.save_path', $this->savePath);
        } else {
            $sessionPath = rtrim(ini_get('session.save_path'), '/\\');

            if ($sessionPath) {
                $sessionPath = WRITEPATH . 'session';
            }

            $this->savePath = $sessionPath;
        }

        $this->configureSessionIDRegex();
    }
// Cannot regenerate the session ID for non-active sessions.         if (\PHP_SESSION_ACTIVE !== session_status()) {
            return false;
        }

        if (headers_sent()) {
            return false;
        }

        if (null !== $lifetime && $lifetime != \ini_get('session.cookie_lifetime')) {
            $this->save();
            ini_set('session.cookie_lifetime', $lifetime);
            $this->start();
        }

        if ($destroy) {
            $this->metadataBag->stampNew();
        }

        return session_regenerate_id($destroy);
    }

    /** * @return void */
$sessionOptions = $this->getSessionOptions();
        $saveHandler = $this->createSaveHandler(Shopware()->Container());
        $storage = new NativeSessionStorage($sessionOptions);

        if (!empty($sessionOptions['unitTestEnabled'])) {
            $storage = new MockArraySessionStorage();
        } elseif ($saveHandler) {
            session_set_save_handler($saveHandler);
        }

        if (isset($sessionOptions['save_path'])) {
            ini_set('session.save_path', (string) $sessionOptions['save_path']);
        }

        if (isset($sessionOptions['save_handler'])) {
            ini_set('session.save_handler', (string) $sessionOptions['save_handler']);
        }

        $session = new Enlight_Components_Session_Namespace($storagenew NamespacedAttributeBag('ShopwareBackend'));
        $session->start();

        return $session;
    }

    

class IniConfigReaderTest extends TestCase
{
    /** * @dataProvider configProvider */
    public function testGet(string $key, string|false $configValue, string $expectedValue): void
    {
        \ini_set($key(string) $configValue);

        $reader = new IniConfigReader();
        static::assertSame($expectedValue$reader->get($key));

        \ini_restore($key);
    }

    public static function configProvider(): \Generator
    {
        yield 'max_execution_time' => [
            'max_execution_time',
            
// Enforce E_STRICT, but allow users to set levels not part of E_STRICT.     error_reporting(E_STRICT | E_ALL);

    // Override PHP settings required for Drupal to work properly.     // sites/default/default.settings.php contains more runtime settings.     // The .htaccess file contains settings that cannot be changed at runtime.
    if (PHP_SAPI !== 'cli') {
      // Use session cookies, not transparent sessions that puts the session id       // in the query string.       ini_set('session.use_cookies', '1');
      ini_set('session.use_only_cookies', '1');
      ini_set('session.use_trans_sid', '0');
      // Don't send HTTP headers using PHP's session handler.       // Send an empty string to disable the cache limiter.       ini_set('session.cache_limiter', '');
      // Use httponly session cookies.       ini_set('session.cookie_httponly', '1');
    }

    // Set sane locale settings, to ensure consistent string, dates, times and     // numbers handling.
$this->logger->error('An error', ['foo' => 'bar']);
        $this->logger->warning('A warning', ['baz' => 'bar']);
        $this->assertSame([
            '{"level":"error","message":"An error","context":{"foo":"bar"}}',
            '{"level":"warning","message":"A warning","context":{"baz":"bar"}}',
        ]$this->getLogs());
    }

    public function testLogsWithoutOutput()
    {
        $oldErrorLog = ini_set('error_log', $this->tmpFile);

        $logger = new Logger();
        $logger->error('test');
        $logger->critical('test');

        $expected = [
            '[error] test',
            '[critical] test',
        ];

        foreach ($this->getLogs() as $k => $line) {
            
/** * Provides default serialization for YAML using the PECL extension. */
class YamlPecl implements SerializationInterface {

  /** * {@inheritdoc} */
  public static function encode($data) {
    static $init;
    if (!isset($init)) {
      ini_set('yaml.output_indent', 2);
      // Do not break lines at 80 characters.       ini_set('yaml.output_width', -1);
      $init = TRUE;
    }
    return yaml_emit($data, YAML_UTF8_ENCODING, YAML_LN_BREAK);
  }

  /** * {@inheritdoc} */
  public static function decode($raw) {
    

    public function prepare(Request $request)static
    {
        $headers = $this->headers;

        if ($this->isInformational() || $this->isEmpty()) {
            $this->setContent(null);
            $headers->remove('Content-Type');
            $headers->remove('Content-Length');
            // prevent PHP from sending the Content-Type header based on default_mimetype             ini_set('default_mimetype', '');
        } else {
            // Content-type based on the Request             if (!$headers->has('Content-Type')) {
                $format = $request->getRequestFormat(null);
                if (null !== $format && $mimeType = $request->getMimeType($format)) {
                    $headers->set('Content-Type', $mimeType);
                }
            }

            // Fix Content-Type             $charset = $this->charset ?: 'UTF-8';
            
Home | Imprint | This part of the site doesn't use cookies.