Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to 1.6.12 breaks admin #2627

Closed
mfilkov opened this issue Aug 15, 2019 · 5 comments
Closed

update to 1.6.12 breaks admin #2627

mfilkov opened this issue Aug 15, 2019 · 5 comments

Comments

@mfilkov
Copy link

mfilkov commented Aug 15, 2019

On WSL (Windows 10-1903 / Ubuntu 18.04.3 LTS) after update to GRAV 1.6.12 & Admin 1.9.8 I get "Fetch Failed:" on all Admin pages and in the console:

PHP Warning: require(/index.php): failed to open stream: No such file or directory in /path-to-grav/system/router.php on line 38
PHP Fatal error: require(): Failed opening required '/index.php' (include_path='.:/usr/share/php') in /path-to-grav/system/router.php on line 38

All works fine when I revert the changes to system/router.php, so it should be related to the new GRAV_BASEDIR system variable.

@rhukster
Copy link
Member

Are you setting GRAV_BASEDIR ?

@rhukster
Copy link
Member

Actually think i found the bug, please try this for router.php:

<?php

/**
 * @package    Grav\Core
 *
 * @copyright  Copyright (C) 2015 - 2019 Trilby Media, LLC. All rights reserved.
 * @license    MIT License; see LICENSE file for details.
 */

if (PHP_SAPI !== 'cli-server') {
    die('This script cannot be run from browser. Run it from a CLI.');
}

$_SERVER['PHP_CLI_ROUTER'] = true;

if (is_file($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . $_SERVER['SCRIPT_NAME'])) {
    return false;
}

$grav_index = 'index.php';

/* Check the GRAV_BASEDIR environment variable and use if set */
if ($grav_basedir = getenv('GRAV_BASEDIR') ?: '') {
    $grav_index = ltrim($grav_basedir, '/') . DIRECTORY_SEPARATOR . $grav_index;
    $grav_basedir = DIRECTORY_SEPARATOR . trim($grav_basedir, DIRECTORY_SEPARATOR);
    define('GRAV_ROOT', str_replace(DIRECTORY_SEPARATOR, '/', getcwd()) . $grav_basedir);
}

$_SERVER = array_merge($_SERVER, $_ENV);
$_SERVER['SCRIPT_FILENAME'] = $_SERVER['DOCUMENT_ROOT'] . $grav_basedir .DIRECTORY_SEPARATOR . 'index.php';
$_SERVER['SCRIPT_NAME'] = $grav_basedir . DIRECTORY_SEPARATOR . 'index.php';
$_SERVER['PHP_SELF'] = $grav_basedir . DIRECTORY_SEPARATOR . 'index.php';

error_log(sprintf('%s:%d [%d]: %s', $_SERVER['REMOTE_ADDR'], $_SERVER['REMOTE_PORT'], http_response_code(), $_SERVER['REQUEST_URI']), 4);

require $grav_index;

@mfilkov
Copy link
Author

mfilkov commented Aug 16, 2019

Yep, that does it, not even a warning in sight :) Thank you!

GRAV_BASEDIR was not set.

@MichaelJDavies
Copy link

@rhukster I still seem to be getting this issue after trying your fix. Any advice?

@mahagr
Copy link
Member

mahagr commented Aug 17, 2019

@MichaelJDavies Please upgrade Grav to 1.6.13. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants