#105 Bugfix/domain based caching

Open Michael Strong micmania1 Pseudo commit used to compare (513f660...d591e1d)
Missing base report.

Unable to compare commits because the base of the pull request did not upload a coverage report.

Changes found in between 513f660...d591e1d (pseudo...base) which prevent comparing this pull request.

Showing 3 of 4 files from the diff.

@@ -68,7 +68,14 @@
Loading
68 68
        }
69 69
        if (empty($this->jobData->URLsToProcess)) {
70 70
            $trimSlashes = function ($value) {
71 -
                return trim($value, '/');
71 +
                $value = trim($value, '/');
72 +
73 +
                // We want to trim the schema from the beginning as they map to the same place
74 +
                // anyway.
75 +
                $value = ltrim($value, 'http://');
76 +
                $value = ltrim($value, 'https://');
77 +
78 +
                return $value;
72 79
            };
73 80
            $this->jobData->publishedURLs = array_map($trimSlashes, Publisher::singleton()->getPublishedURLs());
74 81
            $this->jobData->ProcessedURLs = array_map($trimSlashes, $this->jobData->ProcessedURLs);

@@ -207,6 +207,9 @@
Loading
207 207
208 208
        if (FilesystemPublisher::config()->get('domain_based_caching')) {
209 209
            // factor in the domain as the top dir
210 +
            if (substr($relativeURL, -6) === '/index') {
211 +
                $relativeURL = substr($relativeURL, 0, strlen($relativeURL) - 5);
212 +
            }
210 213
            return Director::protocol() . $relativeURL;
211 214
        }
212 215

@@ -2,23 +2,24 @@
Loading
2 2
3 3
namespace SilverStripe\StaticPublishQueue;
4 4
5 +
use SilverStripe\View\SSViewer;
6 +
use SilverStripe\ORM\DataObject;
7 +
use SilverStripe\View\ArrayData;
8 +
use SilverStripe\Core\CoreKernel;
5 9
use SilverStripe\Control\Director;
6 -
use SilverStripe\Control\HTTPApplication;
7 -
use SilverStripe\Control\HTTPRequestBuilder;
10 +
use SilverStripe\Core\Environment;
11 +
use SilverStripe\View\Requirements;
8 12
use SilverStripe\Control\HTTPResponse;
9 -
use SilverStripe\Control\HTTPResponse_Exception;
13 +
use SilverStripe\ORM\FieldType\DBField;
14 +
use SilverStripe\Control\HTTPApplication;
10 15
use SilverStripe\Core\Config\Configurable;
11 -
use SilverStripe\Core\CoreKernel;
12 16
use SilverStripe\Core\Injector\Injectable;
13 -
use SilverStripe\Core\Manifest\ModuleLoader;
14 -
use SilverStripe\ORM\DataObject;
15 17
use SilverStripe\ORM\FieldType\DBDatetime;
16 -
use SilverStripe\ORM\FieldType\DBField;
17 -
use SilverStripe\StaticPublishQueue\Contract\StaticPublisher;
18 -
use SilverStripe\View\ArrayData;
19 -
use SilverStripe\View\Requirements;
20 18
use SilverStripe\View\Requirements_Backend;
21 -
use SilverStripe\View\SSViewer;
19 +
use SilverStripe\Control\HTTPRequestBuilder;
20 +
use SilverStripe\Core\Manifest\ModuleLoader;
21 +
use SilverStripe\Control\HTTPResponse_Exception;
22 +
use SilverStripe\StaticPublishQueue\Contract\StaticPublisher;
22 23
23 24
abstract class Publisher implements StaticPublisher
24 25
{
@@ -78,14 +79,19 @@
Loading
78 79
            SSViewer::set_themes($rawThemes);
79 80
        }
80 81
        try {
82 +
            $ssl = Environment::getEnv('SS_STATIC_FORCE_SSL');
83 +
            if (is_null($ssl)) {
84 +
                $ssl = $urlParts['scheme'] == 'https' ? true : false;
85 +
            }
86 +
81 87
            // try to add all the server vars that would be needed to create a static cache
82 88
            $request = HTTPRequestBuilder::createFromVariables(
83 89
                [
84 90
                    '_SERVER' => [
85 91
                        'REQUEST_URI' => isset($urlParts['path']) ? $urlParts['path'] : '',
86 92
                        'REQUEST_METHOD' => 'GET',
87 93
                        'REMOTE_ADDR' => '127.0.0.1',
88 -
                        'HTTPS' => $urlParts['scheme'] == 'https' ? 'on' : 'off',
94 +
                        'HTTPS' => $ssl ? 'on' : 'off',
89 95
                        'QUERY_STRING' => isset($urlParts['query']) ? $urlParts['query'] : '',
90 96
                        'REQUEST_TIME' => DBDatetime::now()->getTimestamp(),
91 97
                        'REQUEST_TIME_FLOAT' => (float)DBDatetime::now()->getTimestamp(),

Unable to process changes.

No base report to compare against.

Files Complexity Coverage
src 131 56.73%
Project Totals (9 files) 131 56.73%
Loading