TablePress Tables don’t get searched/replaced
-
Among the sources listed for me in Search Regex are TablePress tables, but attempts to search and replace in them fail. Does a plugin like that need to be written to support Search Regex for it to work?
-
The case where simply trying to search replace in a table found nothing and had no effect was a regex search.
Now I’ve tried a simple word search/replace with a nonsense word I put in the table. This did find it, but when I replaced with the correct word (manually in Search Regex, not globally), the table become corrupted. When I try to open it in TablePress I get:
Attention: Unfortunately, an error occurred.
The internal data of table “Major Groups of Fungi” (ID 1) is corrupted. The following error was registered: Syntax error.
Because of this error, the table can not be edited at this time, to prevent possible further data loss. Please see the TablePress FAQ page for further instructions.
I went into the database, couldn’t see what was wrong, but copied the table content from an earlier revision and got the table working again.
How did it fail?
TablePress uses an encoded format so you will need to careful when making replacements.
When I looked into the sql database after the corruption, it looked like my original nonsense word in the TablePress table was still there, not replaced, but TablePress couldn’t open it (failing with the message quoted previously). It is barely human readable, and I couldn’t find what had changed.
Again, I was simply replacing one text word with another – no symbols or characters other than a-z.
Perhaps I’ll try making a very simple test table and changing it with Search Regex to see if I can find what is happening.
I made a very simple test table and tried to replace a word; it worked without corruption. So whatever the problem is it involves some complexity beyond that.
OK, I redid the change in the complex table and found what is happening. Search Regex is removing all the escape characters (\) from the content of the table while it is making the simple edit. The first is in <span class=\”sansGr10\”>, the rest are newline characters \n.
Here is the content of the table. The first is the original, valid table.
[["Phylum","Subgroup","Some major genera"],["<b>Oomycota</b>","Oomycetes","<i>Phytophthora, Pythium</i> (water molds and downy mildews)"],["<strong>Glomeromycota</strong>","Glomeromycetes","<i>Acaulospora, Gigaspora, Glomus</i> (arbuscular/endomycorrhizal fungi)"],["<b>Zygomycota</b>","Endogonales","<i>Endogone</i> (ectomycorrhizal fungi, saprobes)"],["","Mucorales","<i>Mucor, Rhizopus</i> (mostly common saprobes)"],["<b>Ascomycota</b>","<span class=\"sansGr10\">Classification of the Ascomycota is so complex, it is better for the beginning student to focus instead on forms of fruiting as presented here","#colspan#"],["","naked asci","<i>Taphrina</i>"],["","perithecia","<i>Nectria, Ceratocystis, Ophiostoma, Valsa</i>"],["","cleistothecia","<i>Microsphaera</i>"],["","apothecia","<i>Peziza, Rhizina, Rhytisma</i> (saprobes, root pathogens, ectomycorrhizal fungi)"],["","pseudothecia","<i>Apiosporina, Phaeocryptopus</i>"],["","<b>Asexual forms of Ascomycota</b>","#colspan#"],["","simple conidiophores","<i>Verticillium\nPenicillium</i>"],["","coremium","<i>Graphium</i>"],["","sporodochium","<i>Fusarium</i>"],["","acervulus","<i>Gloeosporium\nMarssonina</i>"],["","pycnidium","<i>Sphaeropsis\nCytospora</i>"],["","",""],["<b>Basidiomycota</b>","Agaricales","Mushrooms (<i>Armillaria</i>), puffballs and bird's nest fungi (<i>Lycoperdon, Crucibulum</i>), and coral fungi (<i>Clavaria</i>)"],["","Boletales","Poroid mushrooms (<i>Boletus</i>), gasteroid fungi (<i>Pisolithus, Scleroderma</i>) and merulioid crust fungi (<i>Coniophora, Serpula</i>)"],["","Corticiales","A small residual group of mostly corticioid fungi; not important in forest pathology (<i>Corticium, Vuilleminia</i>)"],["","Hymenochaetales","Polypores (<i>Inonotus, Onnia, Oxyporus, Phellinus, Trichaptum</i>) and crust fungi (<i>Hymenochaete, Hyphoderma, Hyphodontia</i>)"],["","Polyporales","Polypores (<i>Fomitopsis, Ganoderma, Oligoporus, Phaeolus, Polyporus</i>) and corticioid fungi (<i>Phanerochaete, Pulcherricium</i>)"],["","Russulales","Polypores (<i>Albatrellus, Bondarzewia, Heterobasidion</i>), tooth fungi (<i>Echinodontium, Hericium</i>), crust/stereoid fungi (<i>Peniophora, Scytinostroma, Stereum</i>) and mushrooms (<i>Lactarius, Russula</i>)"],["","Pucciniomycetes","<i>Cronartium </i>(rusts), <i>Helicobasidium</i>"]]
Then, I used Search Regex to replace the word Oomycota, in the first row, with the word replacement. I copied the content from both in the sql database and compared them using BBEdit. It did that change, but you see it also stripped out the escape characters from elsewhere in the content.
[["Phylum","Subgroup","Some major genera"],["<b>replacement</b>","Oomycetes","<i>Phytophthora, Pythium</i> (water molds and downy mildews)"],["<strong>Glomeromycota</strong>","Glomeromycetes","<i>Acaulospora, Gigaspora, Glomus</i> (arbuscular/endomycorrhizal fungi)"],["<b>Zygomycota</b>","Endogonales","<i>Endogone</i> (ectomycorrhizal fungi, saprobes)"],["","Mucorales","<i>Mucor, Rhizopus</i> (mostly common saprobes)"],["<b>Ascomycota</b>","<span class="sansGr10">Classification of the Ascomycota is so complex, it is better for the beginning student to focus instead on forms of fruiting as presented here","#colspan#"],["","naked asci","<i>Taphrina</i>"],["","perithecia","<i>Nectria, Ceratocystis, Ophiostoma, Valsa</i>"],["","cleistothecia","<i>Microsphaera</i>"],["","apothecia","<i>Peziza, Rhizina, Rhytisma</i> (saprobes, root pathogens, ectomycorrhizal fungi)"],["","pseudothecia","<i>Apiosporina, Phaeocryptopus</i>"],["","<b>Asexual forms of Ascomycota</b>","#colspan#"],["","simple conidiophores","<i>VerticilliumnPenicillium</i>"],["","coremium","<i>Graphium</i>"],["","sporodochium","<i>Fusarium</i>"],["","acervulus","<i>GloeosporiumnMarssonina</i>"],["","pycnidium","<i>SphaeropsisnCytospora</i>"],["","",""],["<b>Basidiomycota</b>","Agaricales","Mushrooms (<i>Armillaria</i>), puffballs and bird's nest fungi (<i>Lycoperdon, Crucibulum</i>), and coral fungi (<i>Clavaria</i>)"],["","Boletales","Poroid mushrooms (<i>Boletus</i>), gasteroid fungi (<i>Pisolithus, Scleroderma</i>) and merulioid crust fungi (<i>Coniophora, Serpula</i>)"],["","Corticiales","A small residual group of mostly corticioid fungi; not important in forest pathology (<i>Corticium, Vuilleminia</i>)"],["","Hymenochaetales","Polypores (<i>Inonotus, Onnia, Oxyporus, Phellinus, Trichaptum</i>) and crust fungi (<i>Hymenochaete, Hyphoderma, Hyphodontia</i>)"],["","Polyporales","Polypores (<i>Fomitopsis, Ganoderma, Oligoporus, Phaeolus, Polyporus</i>) and corticioid fungi (<i>Phanerochaete, Pulcherricium</i>)"],["","Russulales","Polypores (<i>Albatrellus, Bondarzewia, Heterobasidion</i>), tooth fungi (<i>Echinodontium, Hericium</i>), crust/stereoid fungi (<i>Peniophora, Scytinostroma, Stereum</i>) and mushrooms (<i>Lactarius, Russula</i>)"],["","Pucciniomycetes","<i>Cronartium </i>(rusts), <i>Helicobasidium</i>"]]
Sure, Search Regex uses the standard WordPress functions to save changes, and this sanitises content so it meets the standard post requirements. Tablepress seems to store data in JSON, and has additional code to stop WordPress sanitising the content. Search Regex doesn’t use this.
There’s no easy way around this. For now I would suggest that you open the search results in Tablepress itself (follow the result link) and make your changes in context.
- The topic ‘TablePress Tables don’t get searched/replaced’ is closed to new replies.