Skip to content

Commit

Permalink
Fix bootstrap.php.cache loading. Don't load when in CLI (to prevent e…
Browse files Browse the repository at this point in the history
…rrors when generating the bootstrap file). Remove deprecated and unused APC class loader in index files.
  • Loading branch information
dongilbert committed Dec 19, 2019
1 parent 9621859 commit e907134
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 46 deletions.
12 changes: 4 additions & 8 deletions app/autoload.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
<?php

$bootstrap = __DIR__.'/bootstrap.php.cache';

if (file_exists($bootstrap)) {
require_once __DIR__.'/bootstrap.php.cache';
if ('cli' !== PHP_SAPI && file_exists(dirname(__DIR__).'/var/bootstrap.php.cache')) {
require_once dirname(__DIR__).'/var/bootstrap.php.cache';
}

use Composer\Autoload\ClassLoader;
use Doctrine\Common\Annotations\AnnotationRegistry;

/**
* @var ClassLoader
*/
$loader = require __DIR__.'/../vendor/autoload.php';
/** @var ClassLoader $loader */
$loader = require dirname(__DIR__).'/vendor/autoload.php';

AnnotationRegistry::registerLoader([$loader, 'loadClass']);

Expand Down
26 changes: 6 additions & 20 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,12 @@
// Fix for hosts that do not have date.timezone set, it will be reset based on users settings
date_default_timezone_set('UTC');

use Mautic\Middleware\MiddlewareBuilder;
use Symfony\Component\ClassLoader\ApcClassLoader;

$loader = require_once __DIR__.'/app/autoload.php';
//include_once __DIR__.'/var/bootstrap.php.cache';
require_once __DIR__.'/app/autoload.php';

/*
* Use APC for autoloading to improve performance. Change 'sf2' to a unique prefix
* in order to prevent cache key conflicts with other applications also using APC.
*/
//$apcLoader = new ApcClassLoader('sf2', $loader);
//$loader->unregister();
//$apcLoader->register(true);

\Mautic\CoreBundle\ErrorHandler\ErrorHandler::register('prod');

$kernel = new AppKernel('prod', false);
use Mautic\CoreBundle\ErrorHandler\ErrorHandler;
use Mautic\Middleware\MiddlewareBuilder;
use function Stack\run;

if (version_compare(PHP_VERSION, '7.0.0', '<')) {
$kernel->loadClassCache();
}
ErrorHandler::register('prod');

Stack\run((new MiddlewareBuilder('prod'))->resolve($kernel));
run((new MiddlewareBuilder('prod'))->resolve(new AppKernel('prod', false)));
24 changes: 6 additions & 18 deletions index_dev.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,12 @@
// Fix for hosts that do not have date.timezone set, it will be reset based on users settings
date_default_timezone_set('UTC');

use Mautic\Middleware\MiddlewareBuilder;

$loader = require_once __DIR__.'/vendor/autoload.php';
require_once __DIR__.'/vendor/autoload.php';

/*
* If you don't want to setup permissions the proper way, just uncomment the following PHP line
* read http://symfony.com/doc/current/book/installation.html#configuration-and-setup for more information
*/
umask(0000);

if (extension_loaded('apc') && in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1', '172.17.0.1'])) {
@apc_clear_cache();
@apc_clear_cache('user');
@apc_clear_cache('opcode');
}

\Mautic\CoreBundle\ErrorHandler\ErrorHandler::register('dev');
use Mautic\CoreBundle\ErrorHandler\ErrorHandler;
use Mautic\Middleware\MiddlewareBuilder;
use function Stack\run;

$kernel = new AppKernel('dev', true);
ErrorHandler::register('dev');

Stack\run((new MiddlewareBuilder('dev'))->resolve($kernel));
run((new MiddlewareBuilder('dev'))->resolve(new AppKernel('dev', true)));

0 comments on commit e907134

Please # to comment.