Jump to content

Site Profile Exporter creates incomplete config.php


wbmnfktr
 Share

Recommended Posts

While moving some sites from one hoster to another I have had some issues over at the new hosting company as the installation stopped at Step 3 with an almost empty page - similar to problem discussed here: 

I always migrate sites with the Site Profile Exporter (https://modules.processwire.com/modules/process-export-profile/) and never had any issues before but today.

Just when I had checked the hosting, php.ini, PHP version, PHP modules and almost everything else I found the option to enable TEST MODE* in install.php which told me:

Parse error: syntax error, unexpected end of file in the line 99

I went through the whole config.php just to find this:

$config->sessionAllow = function($session) {

    // if there is a session cookie, chances are user is logged in
    if($session->hasCookie()) {
        return true;

I knew I put this into place but comparing the new (exported) version with the one on the old system it shows a huge difference. Most of it was missing.

$config->sessionAllow = function($session) {

    // if there is a session cookie, chances are user is logged in
    if($session->hasCookie()) {
        return true;
    }

    // if requested URL is an admin URL, allow session
    if(strpos($_SERVER['REQUEST_URI'], $session->config->urls->admin) === 0) {
        return true;
    }

    // otherwise disallow session
    return false;
    
};

Removing the whole incomplete part did the job and the installation ended as expected. The site is up and running again.

So if you plan to migrate or move sites with Site Profile Exporter you might want to take a closer look at the exported config.php.

Before you ask:

  • ProcessWire 3.0.104
  • Site Profile Exporter 3.0.0
  • 5 exports all with incomplete config.php

Maybe one of you can confirm this (as some of us implemented that sessionAllow feature in the last days due to GDPR) or finds this helpful.

 

 

 

* ProcessWire Installation TEST MODE: 

 

Link to comment
Share on other sites

Just a short update on this.

I migrated 10 more sites in the last few days and all sites with $config->sessionAllow couldn't be exported error-free.

Either those exports fail on installation or while ProcessWire creates the export ZIP.

It's not a real problem unless you skip the setting $config->sessionAllow in your export.

Attached to this post you will find a screenshot showing one extreme example of export difference.

@ryan can you confirm this issue?

exportspe.png

Link to comment
Share on other sites

Site Profile Exporter doesn't account for function code in config.php, as it has very limited line parsing capabilities. Basically, it concatenates lines until it encounters a ";" at the end of the line.

I don't think there's a quick fix to the exporter, but perhaps setting $config->sessionAllow in the init method of an autoload module might work.

  • Like 1
Link to comment
Share on other sites

I think you are right with that.

While Site Profile Exporter recognizes $config->sessionAllow it seems it can't handle the full (more than one line) statement.

I don't need a fix for that issue right now as I know about it.

So this thread is more of a good-to-know or maybe someone has this issue, too thread than a I need help here thread.

I haven't tried your module-solution yet but this could be a good solution for upcoming sites.

speset.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...