Replies: 3 comments
-
Thanks for the heads up! I'll get it adjusted for this case. I would assume I did not chose that order arbitrarily & used actual Flarum output as a template, but I don't have my work documented to that level to be sure. My core challenges with finding a broader solution are:
It seems like my only path out of this being an ongoing issue is to use an intermediary format consistently (like TextFormatter's XML). However, that would be double-converting formatting for many forums, which is usually the most expensive part of the migration already. I am not convinced that level of consistency is worth worse performance to that degree. Open to suggestions here, I just don't see a great path out of bespoke bits like this with the current architecture. |
Beta Was this translation helpful? Give feedback.
-
If you post a few rows of Vanilla's data somewhere (in your test suite for future use?) I'll take a look at it. XML files would be nice |
Beta Was this translation helpful? Give feedback.
-
I noticed there was another assumption about the XML, that a post always starts with There's a tool in the library that facilitates a number of manipulations. It also sorts out attributes IIRC and generally tidies up the markup. It's the best way to manipulate the XML safely: $dom = s9e\TextFormatter\Utils\ParsedDOM::loadXML(
'<r><POSTMENTION id="{postid}" discussionid="{discussionid}" number="" displayname="{author}">..</POSTMENTION></r>'
);
$dom->firstOf('//POSTMENTION')->setMarkupStart('@user#123');
echo (string) $dom; <r><POSTMENTION discussionid="{discussionid}" number="" displayname="{author}" id="{postid}"><s>@user#123</s>..</POSTMENTION></r> https://s9e.github.io/TextFormatter/api/s9e/TextFormatter/Utils/ParsedDOM/Element.html |
Beta Was this translation helpful? Give feedback.
-
This is about that part:
nitro-porter/src/Parser/Flarum/QuoteEmbed.php
Lines 83 to 88 in 193b0fd
Without delving into Flarum's internal, it should be impossible to create XML attributes in this order. TextFormatter always sort them in lexicographical order. For instance:
Save for bugs and unforeseen circumstances, all utilities in the s9e\TextFormatter library preserve this order, that's why I strongly advise against modifying its XML with string functions. The library itself transforms XML to HTML via two different renderer, either the XSLT renderer based on PHP's own
ext/xsl
extension, or the library's own PHP renderer which is compiled from the XSL template. The PHP renderer itself has two different modes: one where it loads the XML input in a DOM document and transforms the XML using DOM functions, in which the attribute order doesn't matter at all, and another mode togglable via $enableQuickRenderer which uses string functions rather than DOM methods, which makes it more efficient but has the downside of being sensitive to attribute order.Beta Was this translation helpful? Give feedback.
All reactions