Skip to content

Commit

Permalink
pencilblue#1056 Updated to ensure that the site service registers its…
Browse files Browse the repository at this point in the history
…elf with the command service before the db migration executes
  • Loading branch information
brianhyder committed Jun 8, 2016
1 parent 630ba66 commit a055f43
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
22 changes: 11 additions & 11 deletions include/service/entities/site_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ module.exports = function SiteServiceModule(pb) {
*/
SiteService.prototype.getAllSites = function(cb) {
var dao = new pb.DAO();
dao.q(SITE_COLL, { select: pb.DAO.SELECT_ALL, where: {} }, cb);
dao.q(SITE_COLL, { select: pb.DAO.PROJECT_ALL, where: {} }, cb);
};

/**
Expand All @@ -132,7 +132,7 @@ module.exports = function SiteServiceModule(pb) {
*/
SiteService.prototype.getActiveSites = function(cb) {
var dao = new pb.DAO();
dao.q(SITE_COLL, { select: pb.DAO.SELECT_ALL, where: {active: true} }, cb);
dao.q(SITE_COLL, { select: pb.DAO.PROJECT_ALL, where: {active: true} }, cb);
};

/**
Expand Down Expand Up @@ -172,7 +172,7 @@ module.exports = function SiteServiceModule(pb) {
*/
SiteService.prototype.getSiteNameByUid = function(uid, cb) {
var dao = new pb.DAO();
dao.q(SITE_COLL, {select: pb.DAO.SELECT_ALL, where: {uid: uid} }, function(err, result) {
dao.q(SITE_COLL, {select: pb.DAO.PROJECT_ALL, where: {uid: uid} }, function(err, result) {
var siteName = (!uid || uid === SiteService.GLOBAL_SITE) ? 'global' : '';

if (pb.util.isError(err)) {
Expand Down Expand Up @@ -491,13 +491,13 @@ module.exports = function SiteServiceModule(pb) {
};

/**
* Returns true if siteid given is global or non-existant (to remain backwards compatible)
* Returns true if siteId given is global or non-existent (to remain backwards compatible)
* @method isGlobal
* @param {String} siteid - the site id to check
* @param {String} siteId - the site id to check
* @return {Boolean} true if global or does not exist
*/
SiteService.isGlobal = function (siteid) {
return (!siteid || siteid === SiteService.GLOBAL_SITE);
SiteService.isGlobal = function (siteId) {
return (!siteId || siteId === SiteService.GLOBAL_SITE);
};

/**
Expand Down Expand Up @@ -566,14 +566,14 @@ module.exports = function SiteServiceModule(pb) {
* @param {String} siteId
* @param {Function} cb
*/
SiteService.prototype.deleteSiteSpecificContent = function (siteid, cb) {
SiteService.prototype.deleteSiteSpecificContent = function (siteId, cb) {
var siteQueryService = new pb.SiteQueryService();
siteQueryService.getCollections(function(err, allCollections) {
var dao = new pb.DAO();

var tasks = util.getTasks(allCollections, function (collections, i) {
return function (taskCallback) {
dao.delete({site: siteid}, collections[i].name, function (err, commandResult) {
dao.delete({site: siteId}, collections[i].name, function (err, commandResult) {
if (util.isError(err) || !commandResult) {
return taskCallback(err);
}
Expand All @@ -587,7 +587,7 @@ module.exports = function SiteServiceModule(pb) {
pb.log.error(err);
return cb(err);
}
pb.log.silly("Successfully deleted site %s from database", siteid);
pb.log.silly("Successfully deleted site %s from database", siteId);
cb(null, results);
});
});
Expand All @@ -604,7 +604,7 @@ module.exports = function SiteServiceModule(pb) {
displayName: pb.config.siteName,
uid: pb.SiteService.GLOBAL_SITE,
hostname: pb.config.multisite.enabled ? url.parse(pb.config.multisite.globalRoot).host : url.parse(pb.config.siteRoot).host,
active: pb.config.multisite.enabled ? false : true,
active: !pb.config.multisite.enabled,
defaultLocale: pb.Localization.getDefaultLocale(),
supportedLocales: util.arrayToObj(pb.Localization.getSupported(), function(a, i) { return a[i]; }, function() { return true; }),
prevHostnames: []
Expand Down
2 changes: 1 addition & 1 deletion include/system/command/command_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ module.exports = function CommandServiceModule(pb) {
* @method sendInResponseTo
* @param {Object} command The command that was sent to ths process
* @param {Object} responseCommand The command to send back to the entity that sent the first command.
* @param {Function} cb A callback that provides two parameters: cb(Error, Command ID)
* @param {Function} [cb] A callback that provides two parameters: cb(Error, Command ID)
*/
CommandService.prototype.sendInResponseTo = function (command, responseCommand, cb) {
if (!util.isObject(command)) {
Expand Down
3 changes: 1 addition & 2 deletions pencilblue.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ function PencilBlue(config){
* @param {Function} cb - callback function
*/
this.initSiteMigration = function(cb) {
pb.SiteService.init();
pb.dbm.processMigration(cb);
};

Expand All @@ -155,8 +156,6 @@ function PencilBlue(config){
* @param {Function} cb - callback function
*/
this.initSites = function(cb) {
pb.SiteService.init();

var siteService = new pb.SiteService();
siteService.initSites(cb);
};
Expand Down

0 comments on commit a055f43

Please sign in to comment.