protected static function getTempParentFolder($base)
    {
        // first, try finding a silverstripe-cache dir built off the base path
        $localPath = Path::join($base, 'silverstripe-cache');
        if (@file_exists($localPath)) {
            if ((fileperms($localPath) & 0777) != 0777) {
                @chmod($localPath, 0777);
            }
            return $localPath;
        }

        // failing the above, try finding a namespaced silverstripe-cache dir in the system temp
        $tempPath = Path::join(
            sys_get_temp_dir(),
            'silverstripe-cache-php' . preg_replace('/[^\w\-\.+]+/', '-', PHP_VERSION) .
            str_replace(array(' ', '/', ':', '\\'), '-', $base)
        );
        if (!@file_exists($tempPath)) {
            $oldUMask = umask(0);
            @mkdir($tempPath, 0777);
            umask($oldUMask);

        // if the folder already exists, correct perms
        } else {
            if ((fileperms($tempPath) & 0777) != 0777) {
                @chmod($tempPath, 0777);
            }
        }

        $worked = @file_exists($tempPath) && @is_writable($tempPath);

        // failing to use the system path, attempt to create a local silverstripe-cache dir
        if (!$worked) {
            $tempPath = $localPath;
            if (!@file_exists($tempPath)) {
                $oldUMask = umask(0);
                @mkdir($tempPath, 0777);
                umask($oldUMask);
            }

            $worked = @file_exists($tempPath) && @is_writable($tempPath);
        }

        if (!$worked) {
            throw new Exception(
                'Permission problem gaining access to a temp folder. ' . 'Please create a folder named silverstripe-cache in the base folder ' . 'of the installation and ensure it has the correct permissions'
            );
        }

        return $tempPath;
    }