kookma/TW-Commander

Adding new field "chapter" wipes the text field

Closed this issue ยท 32 comments

I was enjoying using the power of Commander until this happened. For a batch of tiddlers, I tried to add a new field "chapter". Commander erased all contents of all tiddlers (it wiped the text field). Thankfully, I had made a back up.

I restored the tiddlers, tried again, same result - batch of empty tiddlers. :(

TC 2.1.0
TW 5.1.21
Firefox 79.0

I think this is a bug in Tiddlywiki and not in Commander, but let to ask this for double check and I will inform you!

See Jermolene/TiddlyWiki5#4848
I think I can add exception handling to ignore operation when $field is empty!

@CodaCodr the attached file is a patched Tiddler Commander 2.1 for test. Please give a try and let me know if it works.
commander-2.1.x.zip

One of two things is wrong:

1 - Import (drag/drop) didn't work, The $:/Import tiddler contains nothing. Even if I select the file, nothing is imported.

2- Testing it proved nothing (perhaps dure to #1).

Inspecting the supplied index.html I found it to be the pre-release of 5.1.23 - is that a good idea? Maybe TW rejects upstream versions when importing? Try applying the proposed fix to v5.1.21 (the reported TW distribution).

image

The tag "toc-times-disabled" was successfully added.
The field "chapter" was not added and the content (text field) was wiped.

I just read the bug you linked above. That's not the problem. As you can see, the field is given a value.

One of two things is wrong:

1 - Import (drag/drop) didn't work, The $:/Import tiddler contains nothing. Even if I select the file, nothing is imported.

Drag and drop of what? The zip contains an entire TW file with the patch. I unzipped and extracted it for testing.

I dragged and dropped the "HelloThere" tiddlers from TiddlyWiki.com into the TC 2.1 file. Then I used TC to add a field "chapter" to all the items tagged HelloThere. It worked as expected and the text fields were left intact.

I don't know if it makes a difference, but I note that the TC 2.1 file uses TW 5.1.23-prerelease.

Drag and drop of what?

I downloaded the zip.
I unzipped the zip.
I opened the index.html file.
I dragged the Commander plugin to my TW (5.1.21)
It didn't work.

  • The S:/Import tiddler does not auto-select the Commander plugin tiddler
  • I tried selecting the tiddler manually
  • that didn't work either
    TW silently refuses to import the plugin.

I exported the plugin from index.html as JSON.
I imported the JSON (drag-drop from the OS)
That failed too.

but I note that the TC 2.1 file uses TW 5.1.23-prerelease.

As I said. I think 5.1.21 rejects (silently) to import plugins marked with future release numbers, or, possibly, refuses prerelease plugins?

@CodaCodr The latest version of TC (e.g 2.1) works with TW 5.1.22 above. It does not support 5.1.21. The reason is some filter operators used in TC 2.1 introduced in TW 5.1.22.

Please note that, the trial version I uploaded above is just for testing purpose, please import some tiddlers from tiddlywiki.com or other resources and make some experiments on that. I hopefully push a new release after addressing some other issues.

Excellent. Thank you!

@CodaCodr Please give a try and let me know if it works! Also I appreciate to submit other issues if any.

Upgraded my wiki to 5.1.22.

Retried with TC 2.1.x

BTW, I had to REMOVE the old commander to get it to upgrade to 2.1.x :/

image

My observation of TW is that sometimes the browser memory retains old information even after a reload. Do you encounter the same problem after reloading 2 or 3 times?

@Marxsal No. This browser instance is started from from a fresh, newly created profile, ensuring all cookies are virgin/killed in the process. I sincerely doubt that was the problem.

If you meant the wiki is hanging on to the old TC version, well, yes, it certainly is and refusing to load the newer one. Only when I disabled then deleted the old version was I able to drag in the new TC successfully. But, as you can see above, still doesn't work (though the bug has changed in that the text field is now overwritten with the new field's content instead of being wiped).

@kookma To be clear, the new field is NOT created. The new field's content replaces the text field's content.

@CodaCodr no worry! It has a very little settings will be deleted on TC removal.
Would you please give a try on the html file I sent you above. Do not install TC on your own wiki, just make some experiments and let me know if it works for you or not!

@kookma Damn. That works!

I guess that means I have a conflict with another plugin. It's going to take me a while to find the time to go through them. If you happen to know any known clashes with other plugins, please let me know.

Thanks for your help on this!

@CodaCodr so it works! I will try to push a new release next week. I will wok on this at the weekend and then you should be able to install the new release on your own wiki. Tiddlywiki uses the plugin version number to install a new release on an old one.

I have not heard any clashes by now, but if send your old wiki (clear everything but keep the plugins) I will have a look.

FWIW this problem occurred for me after I added Tobias Beer's split plugin.

Could you give a link to that plugin! and let me know what happen when you use both plugin at the same time!

http://tobibeer.github.io/tw5-plugins/#split

What happens: as described in the OP. "For a batch of tiddlers, I tried to add a new field "chapter". Commander erased all contents of all tiddlers (it wiped the text field)." Although I'm not sure if it's all tiddlers or just the tiddlers that were filtered.

@davout1806 thank you!
I will do some experiments on an empty TW 5.1.23 + Commander + Split and let you know the results.

Hi @davout1806
I have investigated the isue. Tobias split has overwritten the core split filter operator, that is the reason of reported issue by you. I have no solution for TW 5.123 by now! But TW 5.1.24 has new rules for field name and I will modify this later! By the way please keep in mind that, those plugins overwrite core functionality cannot be supported!

I think @saqimtiaz can give us some explanation here.

Commander uses the below code to create a new field:

<$action-setfield $tiddler=<<newTitle>> 
 $field={{{ [<newField>trim[]lowercase[]split[ ]join[_]]  }}}
 $value={{{ [<datafieldsTid>getindex<id_fldValue>] }}} />
</$list>

This valid for TW 5.1.23 and 5.1.22. I think split is introduced in TW 5.1.22. Commander uses split filter operator. When you install the Tobias Beer split plugin, it seems the split plugin gets priority over the core split filter operator!

Well for me Commander takes priority. The split plugin for more of a nice to have. But thank you for looking into it.

@davout1806 please see the new split operator introduced in TW 5.1.22 and also splitregexp

Also examples in TW-Scripts. I think these new filter operator can be very handy for many of your daily operation you did with Tobias Beer's split plugin.

It's always unfortunate when an older plugin clashes with a new core feature. I would definitely recommend that no one use that split plugin as there can be any number of issues when you least expect it. The core expects the filter it implements to behave exactly in that manner.

I was going to recommend a simple tweak to make Tobias' split filter available under a different name but.... the code is minified and illegible with no link to readable source code. So... chuck it in the bin please. My recommendation: DO NOT USE.

If you have a need that that was met by that plugin that you need to find an alternative for, let us know.

I use split:before from Tobias' plugin. The TW splitbefore takes the delimiter/separator, too.

split:before[-] -> splitbefore[-]removesuffix[-]

There might be a few more I use, but that's the one that leapt out on my initial search.

@kookma This might explain my OP.

Thank you @saqimtiaz for clarification!
@CodaCodr : I will revise the filed operation when 5.2.0 is available and the split will not be used anymore as 5.2.0 has no restriction on naming fields! By the as Saq recommended I do not recommend to use Tobias split as it overwrites core split operator!

@kookma

Tobias' plugin was written and produced at a time when the core operator did less. Overwriting anything in the core is a valid thing to do -- TW is SOFTware and therefore designed to be malleable AND allows overwriting of core elements. Whether it is wise to do so in any particular case is a matter for the user at the time of import.

In fact, Tobias' plugin is still far superior to the core implementation. However, having looked more closely at the places I'm using it, in this instance, I can relatively easily rewrite my filters without it.

Although the code is minified, the name is at the top right after the exports term. So just change exports.split into exports.splitbeer and then change your existing code to use filter splitbeer . Save. Reload. And you're back in business.

I see @twMat's @ttention plugin uses Tobias' split operator, too.

http://attention.tiddlyspot.com/

twMat commented

I see @twMat's @ttention plugin uses Tobias' split operator, too.

@CodaCodr - thanks for heads-up!

@kookma

Tobias' plugin was written and produced at a time when the core operator did less. Overwriting anything in the core is a valid thing to do -- TW is SOFTware and therefore designed to be malleable AND allows overwriting of core elements. Whether it is wise to do so in any particular case is a matter for the user at the time of import.

Well yes, that's correct! but if another person write another filter and overwrite the core, then the plugin maintainer (like commander) has to change the code to also support it and it is impossible to do for more and more codes and plugins around! So, I think the best strategy is to give the core the higher priority!

Although the code is minified, the name is at the top right after the exports term. So just change exports.split into exports.splitbeer and then change your existing code to use filter splitbeer . Save. Reload. And you're back in business.

This is very wise solution, specially as we know Tobias has not maintained his plugins recently while they are among the best!