mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
🐛 Fixed crash on startup when no active theme (#10426)
closes #10416 - Updated to use default theme engine values when no active theme is found
This commit is contained in:
parent
eb49fdcb8f
commit
3200ede8b1
5 changed files with 23 additions and 14 deletions
2
core/server/services/routing/bootstrap.js
vendored
2
core/server/services/routing/bootstrap.js
vendored
|
@ -38,7 +38,7 @@ module.exports.init = (options = {start: false}) => {
|
|||
* - is the PreviewRouter an app?
|
||||
*/
|
||||
module.exports.start = () => {
|
||||
const apiVersion = themeService.getActive().engine('ghost-api');
|
||||
const apiVersion = themeService.getApiVersion();
|
||||
const RESOURCE_CONFIG = require(`../../services/routing/config/${apiVersion}`);
|
||||
|
||||
const previewRouter = new PreviewRouter(RESOURCE_CONFIG);
|
||||
|
|
|
@ -392,7 +392,7 @@ module.exports = function validate(object) {
|
|||
object.taxonomies = {};
|
||||
}
|
||||
|
||||
const apiVersion = themeService.getActive().engine('ghost-api');
|
||||
const apiVersion = themeService.getApiVersion();
|
||||
|
||||
debug('api version', apiVersion);
|
||||
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
var debug = require('ghost-ignition').debug('themes'),
|
||||
common = require('../../lib/common'),
|
||||
themeLoader = require('./loader'),
|
||||
active = require('./active'),
|
||||
validate = require('./validate'),
|
||||
Storage = require('./Storage'),
|
||||
settingsCache = require('../settings/cache'),
|
||||
themeStorage;
|
||||
const debug = require('ghost-ignition').debug('themes');
|
||||
const common = require('../../lib/common');
|
||||
const themeLoader = require('./loader');
|
||||
const active = require('./active');
|
||||
const validate = require('./validate');
|
||||
const Storage = require('./Storage');
|
||||
const settingsCache = require('../settings/cache');
|
||||
const engineDefaults = require('./engines/defaults');
|
||||
|
||||
let themeStorage;
|
||||
|
||||
// @TODO: reduce the amount of things we expose to the outside world
|
||||
// Make this a nice clean sensible API we can all understand!
|
||||
|
@ -79,6 +81,13 @@ module.exports = {
|
|||
validate: validate,
|
||||
toJSON: require('./to-json'),
|
||||
getActive: active.get,
|
||||
getApiVersion: function getApiVersion() {
|
||||
if (this.getActive()) {
|
||||
return this.getActive().engine('ghost-api');
|
||||
} else {
|
||||
return engineDefaults['ghost-api'];
|
||||
}
|
||||
},
|
||||
activate: function activate(loadedTheme, checkedTheme, error) {
|
||||
// no need to check the score, activation should be used in combination with validate.check
|
||||
// Use the two theme objects to set the current active theme
|
||||
|
@ -86,11 +95,11 @@ module.exports = {
|
|||
let previousGhostAPI;
|
||||
|
||||
if (this.getActive()) {
|
||||
previousGhostAPI = this.getActive().engine('ghost-api');
|
||||
previousGhostAPI = this.getApiVersion();
|
||||
}
|
||||
|
||||
active.set(loadedTheme, checkedTheme, error);
|
||||
const currentGhostAPI = this.getActive().engine('ghost-api');
|
||||
const currentGhostAPI = this.getApiVersion();
|
||||
|
||||
common.events.emit('services.themes.activated');
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ class Resources {
|
|||
return this.resourceConfig;
|
||||
}
|
||||
|
||||
this.resourcesAPIVersion = require('../themes').getActive().engine('ghost-api') || 'v0.1';
|
||||
this.resourcesAPIVersion = require('../themes').getApiVersion();
|
||||
this.resourcesConfig = require(`./configs/${this.resourcesAPIVersion}`);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ module.exports = function ghostLocals(req, res, next) {
|
|||
// relative path from the URL
|
||||
res.locals.relativeUrl = req.path;
|
||||
// make ghost api version available for the theme + routing
|
||||
res.locals.apiVersion = themeService.getActive().engine('ghost-api');
|
||||
res.locals.apiVersion = themeService.getApiVersion();
|
||||
|
||||
next();
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue