0

I've been using GRAV as a CMS for a small experimental site. I recently updated the git-sync plugin, and am suddenly stuck with a website that produces only errors, with no way to enter the admin gui (all web access to the site crashes with same errors), to downgrade the git-sync module, or for that matter, to upgrade the git-sync plugin if there is a fix.

I'm a developer that hasn't really thought much about web development in decades (my, how it's changed), so there are a few things I have to admit upfront. I don't know sht about php, and really don't care to if I don't have to.

The message I get (below) indicates that this is a php error. If this is a simple syntax fix please give me a heads up.

If you have any advice on a "cli" way to use the git-sync plugin to upgrade or downgrade, revert the git-sync, or any other hints, advise away. I'll dig in to more documentation and see if I end up answering my own question.

/[pathToUserHome]/grav/user/plugins/git-sync/classes/GitSync.php

        */

        $paths = ['.'];

        if (version_compare($version, '2.0', '<')) {
            $add .= ' --all';
        }

        return $this->execute($add . ' ' . implode(' ', $paths));
    }

    public function commit($message = '(Grav GitSync) Automatic Commit')
    {
        $authorType = $this->getGitConfig('author', 'gituser');
        if (defined('GRAV_CLI') && in_array($authorType, ['gravuser', 'gravfull'])) {
            $authorType = 'gituser';
        }

        // get message from config, it any, or stick to the default one
        $message = $this->getConfig('git', null)['message'] ?? $message;

        // get Page Title and Route from Post
        $pageTitle = $_POST['data']['header']['title']??'NO TITLE FOUND';
        $pageRoute = $_POST['data']['route']??'NO ROUTE FOUND';

        ...

 Arguments
    1) "syntax error, unexpected '?'"

 Whoops\Exception\ErrorException…
     /user/plugins/git-sync/classes/GitSync.php : 223

     $message = $this->getConfig('git', null)['message'] ?? $message;
martshal
  • 43
  • 4

1 Answers1

1

Your new version of GRAV is using php7.0 features, like ?? operator, which is Null coalescing. Try to upgrade your php version to support new features, or downgrade GRAV.

Make a compatible version is also an option, but it could be time consumption idea. However, if your problems only in this particular file, you could replace:

// $message = $this->getConfig('git', null)['message'] ?? $message;
$message = isset($this->getConfig('git', null)['message']) ? $this->getConfig('git', null)['message'] : $message;
// $pageTitle = $_POST['data']['header']['title']??'NO TITLE FOUND';
$pageTitle = isset($_POST['data']['header']['title']) ? $_POST['data']['header']['title'] : 'NO TITLE FOUND';
// $pageRoute = $_POST['data']['route']??'NO ROUTE FOUND';
$pageRoute = isset($_POST['data']['route']) ? $_POST['data']['route'] : 'NO ROUTE FOUND';
Victor Perov
  • 1,697
  • 18
  • 37
  • Stellar! Updated the php version through cpanel on the service I am using, and all seems well once again. Thank you for the heads-up. – martshal Feb 27 '19 at 00:16