Skip to content

Commit

Permalink
Don't load tiddlers that don't have a title
Browse files Browse the repository at this point in the history
We were getting problems (eg, adding a `readme.md` to a plugin without
an accompanying `readme.md.meta` would end up creating a tiddler called
“undefined”)
  • Loading branch information
Jermolene committed Jan 12, 2014
1 parent 19080f9 commit b04141f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
20 changes: 13 additions & 7 deletions boot/boot.js
Expand Up @@ -779,7 +779,9 @@ $tw.Wiki.prototype.addTiddler = function(tiddler) {
if(!(tiddler instanceof $tw.Tiddler)) {
tiddler = new $tw.Tiddler(tiddler);
}
this.tiddlers[tiddler.fields.title] = tiddler;
if(tiddler.fields.title) {
this.tiddlers[tiddler.fields.title] = tiddler;
}
};

$tw.Wiki.prototype.addTiddlers = function(tiddlers) {
Expand Down Expand Up @@ -859,10 +861,12 @@ $tw.Wiki.prototype.unpackPluginTiddlers = function() {
// Extract the constituent tiddlers
$tw.utils.each(pluginInfo.tiddlers,function(constituentTiddler,constituentTitle) {
// Save the tiddler object
self.shadowTiddlers[constituentTitle] = {
source: tiddler.fields.title,
tiddler: new $tw.Tiddler(constituentTiddler,{title: constituentTitle})
};
if(constituentTitle) {
self.shadowTiddlers[constituentTitle] = {
source: tiddler.fields.title,
tiddler: new $tw.Tiddler(constituentTiddler,{title: constituentTitle})
};
}
});
});
};
Expand Down Expand Up @@ -911,7 +915,7 @@ $tw.Wiki.prototype.getTiddler = function(title) {
var t = this.tiddlers[title];
if(t instanceof $tw.Tiddler) {
return t;
} else if($tw.utils.hop(this.shadowTiddlers,title)) {
} else if(title !== undefined && $tw.utils.hop(this.shadowTiddlers,title)) {
return this.shadowTiddlers[title].tiddler;
} else {
return undefined;
Expand Down Expand Up @@ -1226,7 +1230,9 @@ $tw.loadPluginFolder = function(filepath,excludeRegExp) {
// Save the plugin tiddlers into the plugin info
pluginInfo.tiddlers = pluginInfo.tiddlers || {};
for(t=0; t<pluginTiddlers.length; t++) {
pluginInfo.tiddlers[pluginTiddlers[t].title] = pluginTiddlers[t];
if(pluginTiddlers[t].title) {
pluginInfo.tiddlers[pluginTiddlers[t].title] = pluginTiddlers[t];
}
}
}
}
Expand Down
10 changes: 6 additions & 4 deletions core/modules/wiki.js
Expand Up @@ -204,10 +204,12 @@ exports.addTiddler = function(tiddler) {
// Get the title
var title = tiddler.fields.title;
// Save the tiddler
this.tiddlers[title] = tiddler;
this.clearCache(title);
this.clearGlobalCache();
this.enqueueTiddlerEvent(title);
if(title) {
this.tiddlers[title] = tiddler;
this.clearCache(title);
this.clearGlobalCache();
this.enqueueTiddlerEvent(title);
}
};

/*
Expand Down

0 comments on commit b04141f

Please sign in to comment.