Skip to content

Error in v3.2-rc1 and HTTP cache in production #20560

@nunocodex

Description

@nunocodex

I have a small personal project made with the latest dev version but I found a bug with the http cache, this is my sources:

<?php

use Symfony\Component\HttpFoundation\Request;

/** @var \Composer\Autoload\ClassLoader $loader */

# Config autoload
$loader = require __DIR__ . '/../app/autoload.php';
include_once __DIR__ . '/../var/bootstrap.php.cache';

# Cache Loader
if (function_exists('apcu_fetch')) {
    $cache_loader = new \Symfony\Component\ClassLoader\ApcClassLoader(sha1(__DIR__), $loader);
    $cache_loader->register();
    $loader->unregister();
}

# Create kernel instance
$kernel = new MicroKernel('prod', false);
$kernel->loadClassCache();

# Create cache instance
$kernel = new MicroCache($kernel);

# Create request instance
$request = Request::createFromGlobals();

# Setup reverse proxy
Request::enableHttpMethodParameterOverride();
//Request::setTrustedProxies([ '127.0.0.1', $request->server->get('REMOTE_ADDR') ]);
//Request::setTrustedHeaderName(Request::HEADER_FORWARDED, null);

# Give response instance
$response = $kernel->handle($request);
$response->send();

# Bye!
$kernel->terminate($request, $response);

Kernel: https://github.com/nunopress/sf-micro-edition/blob/master/app/MicroKernel.php

If I use $kernel = new MicroCache($kernel); get error:

Cannot declare class Symfony\Component\HttpFoundation\ResponseHeaderBag, because the name is already in use in /var/www/html/var/cache/prod/classes.php on line 3942" while reading response header from upstream

If I enable the AppCache and disable $kernel->loadClassCache(); working but not all 2 in the same time.

For check if is my problem I downgraded to stable version 3.1 and all working fine as expected so I think the problem come with 3.2-rc1 (i not tested with the previous version).

php version:

PHP 7.0.8-0ubuntu0.16.04.3 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.8-0ubuntu0.16.04.3, Copyright (c) 1999-2016, by Zend Technologies

If need more information's ask without problems. Sorry if isn't a good issue post, it's the first time i post one issue for symfony.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions