Bitcoin Forum
October 03, 2024, 04:30:33 AM *
News: Latest Bitcoin Core release: 27.1 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Squishing the squashed-column bug (SMF patch)  (Read 194 times)
PowerGlove (OP)
Hero Member
*****
hacker
Offline Offline

Activity: 582
Merit: 4995



View Profile
August 28, 2024, 01:54:10 AM
Merited by LoyceV (42), Mitchell (20), ABCbits (8), Foxpup (6), Welsh (5), dkbit98 (5), hugeblack (4), Halab (2), joker_josue (2), Cricktor (2), vapourminer (1), Cyrus (1), hd49728 (1), Helena Yu (1)
 #1

So, there's this really annoying and long-standing forum bug that "squashes" the first column in tables (but only after you've posted; it doesn't present during preview).

For example, here's a table from one of theymos' old posts, as it would appear if not for the presence of this bug:



And here's how that table actually displays:



The earliest mention of this bug (that I could find) is from 2014:

the table above is shown correctly in the previewwindow for the post, but after posting the spacing of first column is squashed.

In that same topic, Foxpup pointed out this hinky bit of CSS:

Code:
/* prevent gap between post icon and subject */
div#bodyarea table.bordercolor td td td.td_headerandpost td:first-child
{
width: 26px;
}

I don't know who added that CSS, or when it was added, but here's what I think happened:

(*) There's a flaw in original SMF 1.1.19 that makes a variable-length gap appear between a post's icon and its subject (beyond the comment in the CSS, I know this to be the case because that same flaw is present in my own branch of SMF, which is also based on 1.1.19).

(*) Someone attempted repair of that flaw by coming up with a CSS selector to (try to) isolate just the <td>s that contain each rendered post's icon, so that they could fix the width of those <td>s to 26px (which does succeed in repairing the "gap" flaw).

(*) The problem is that the selector they came up with has a flaw of its own: it selects more than just the <td>s with post icons in them, reaching into the post itself and affecting first-child <td>s there, too (it does this, by accident, because of an apparent misunderstanding of descendant selectors: because descendants are a less specific concept than children, there's actually nothing in that selector that prevents it from reaching deeper into the post, affecting <td>s that it was never meant to affect).

I've come up with three ways to fix this bug (I mean, there are many ways, with various pros and cons, but the below three are the ones that make the most sense to me):

Fix A

This just fixes the CSS selector so that it does what the original author clearly intended. I can see an argument for simplifying the selector around a new class added to the relevant <td>s, but, there's also something to be said for just leaving everything the way it is (except for one tiny little selector tweak, that is).

Code:
--- baseline/Themes/custom1/style.css	2024-08-27 09:53:04.000000000 +0000
+++ modified/Themes/custom1/style.css 2024-08-27 23:11:37.000000000 +0000
@@ -551,7 +551,7 @@
 }
 
 /* prevent gap between post icon and subject */
-div#bodyarea table.bordercolor td td td.td_headerandpost td:first-child
+div#bodyarea table.bordercolor td td td.td_headerandpost > table td:first-child
 {
  width: 26px;
 }

Fix B

This removes the buggy CSS entirely, and then fixes the now-exposed "gap" flaw in a less brittle way. I mean, I get that putting a width attribute on the <td> probably gives modern web devs the heebie-jeebies, but, there's plenty of precedent for that in SMF's ancient markup, and there's no real value in having a very small handful of spots in the markup/styling that try to do things "the right way". I think era-appropriate fixes are fine for SMF, and that any serious attempt to modernize the frontend should be done independently of the legacy frontend.

Code:
--- baseline/Themes/custom1/style.css	2024-08-27 09:53:04.000000000 +0000
+++ modified/Themes/custom1/style.css 2024-08-27 23:24:18.000000000 +0000
@@ -553,6 +552,0 @@
-/* prevent gap between post icon and subject */
-div#bodyarea table.bordercolor td td td.td_headerandpost td:first-child
-{
- width: 26px;
-}
-

Code:
--- baseline/Themes/default/Display.template.php	2010-10-22 01:38:35.000000000 +0000
+++ modified/Themes/default/Display.template.php 2024-08-27 23:32:38.000000000 +0000
@@ -372,9 +372,9 @@
  </div>
  </td>
  <td valign="top" width="85%" height="100%">
  <table width="100%" border="0"><tr>
- <td valign="middle"><a href="', $message['href'], '"><img src="', $message['icon_url'] . '" alt="" border="0" /></a></td>
+ <td valign="middle" width="26"><a href="', $message['href'], '"><img src="', $message['icon_url'] . '" alt="" border="0" /></a></td>
  <td valign="middle">
  <div style="font-weight: bold;" id="subject_', $message['id'], '">
  <a href="', $message['href'], '">', $message['subject'], '</a>
  </div>';

Fix C

The problem (as I see it) with either of the previous fixes is that they repair the bug for all posts (old and new). I guess most people won't really see eye-to-eye with me on this one, but, I'd prefer it if new posts weren't affected by this bug (obviously) but that older posts were. My thinking is that people have for 10+ years been using all sorts of workarounds and tricks to avoid this bug, and those workaround-remnants are inevitably going to display slightly differently post-fix. From a history-preservation perspective, I like the idea that posts that were constructed in the presence of this bug will not appearance-wise be affected by the fix.

Code:
--- baseline/Themes/custom1/style.css	2024-08-27 09:53:04.000000000 +0000
+++ modified/Themes/custom1/style.css 2024-08-27 23:44:01.000000000 +0000
@@ -550,8 +550,8 @@
  display: none;
 }
 
-/* prevent gap between post icon and subject */
-div#bodyarea table.bordercolor td td td.td_headerandpost td:first-child
+/* This is an adaptation of an older, buggy CSS selector. It's being kept so that certain posts will display in a bug-for-bug compatible way. */
+div#bodyarea table.bordercolor td td td.td_headerandpost.with_column_bug td:first-child
 {
  width: 26px;
 }

Code:
--- baseline/Themes/default/Display.template.php	2010-10-22 01:38:35.000000000 +0000
+++ modified/Themes/default/Display.template.php 2024-08-27 23:55:37.000000000 +0000
@@ -372,7 +372,7 @@
  </div>
  </td>
- <td valign="top" width="85%" height="100%">
+ <td valign="top" width="85%" height="100%" class="td_headerandpost', $message['id'] < 64471000 ? ' with_column_bug' : '', '">
  <table width="100%" border="0"><tr>
- <td valign="middle"><a href="', $message['href'], '"><img src="', $message['icon_url'] . '" alt="" border="0" /></a></td>
+ <td valign="middle" width="26"><a href="', $message['href'], '"><img src="', $message['icon_url'] . '" alt="" border="0" /></a></td>
  <td valign="middle">
  <div style="font-weight: bold;" id="subject_', $message['id'], '">

@theymos: That last diff is a little confusing because class="td_headerandpost" is something that's already present in your branch. The relevant change is just to make sure that the icon-containing <td> has a width="26" (same as with Fix B), and that the td_headerandpost <td> comes out either with two classes (class="td_headerandpost with_column_bug") or one (class="td_headerandpost") depending on some predicate that separates old posts from new. If you can pinpoint when this bug was introduced, then you might also consider changing the predicate to account for that (e.g. $message['id'] > 8800000 && $message['id'] < 64471000), so that posts that displayed correctly before this bug, will return to displaying correctly. (Obviously, the message IDs I've used are just examples that need to be replaced with more precise ones.)
joker_josue
Legendary
*
Offline Offline

Activity: 1806
Merit: 4896


**In BTC since 2013**


View Profile WWW
August 28, 2024, 06:58:54 AM
Merited by vapourminer (1), PowerGlove (1)
 #2

Fix C

The problem (as I see it) with either of the previous fixes is that they repair the bug for all posts (old and new). I guess most people won't really see eye-to-eye with me on this one, but, I'd prefer it if new posts weren't affected by this bug (obviously) but that older posts were. My thinking is that people have for 10+ years been using all sorts of workarounds and tricks to avoid this bug, and those workaround-remnants are inevitably going to display slightly differently post-fix. From a history-preservation perspective, I like the idea that posts that were constructed in the presence of this bug will not appearance-wise be affected by the fix.

I think fix C is the most suitable, without a doubt. Pots from the last 10 years, with tables, were designed to support this bug. No one will keep changing thousands of posts to readjust to the new table paradigm. Therefore, a mixed solution is most recommended.

But you know @PowerGlove, one thing I always found strange is that this error didn't always occur. For example, I have tables that are created automatically via Excel formulas, and when I place the generated BBCode here, the bug does not occur. Did you understand why?

Other than that, another excellent job, congratulations!  Wink

PowerGlove (OP)
Hero Member
*****
hacker
Offline Offline

Activity: 582
Merit: 4995



View Profile
August 28, 2024, 12:35:43 PM
 #3

But you know @PowerGlove, one thing I always found strange is that this error didn't always occur. For example, I have tables that are created automatically via Excel formulas, and when I place the generated BBCode here, the bug does not occur. Did you understand why?
Yep, I can see what's happening with the two tables in that post: their first columns happen to only contain "rigid" things. If, for example, you changed the second table so that the "POS" column had values in it with spaces (like "No. 1", "No. 2", etc.), then the bug would be visible.

Other than that, another excellent job, congratulations!  Wink
Thanks!

In Katy Perry's singing voice: "I squished a bug, and I liked it; the crunch of its meaty thorax. I squished a bug, just to try it: I hope that theymos don't mind it." Cheesy
joker_josue
Legendary
*
Offline Offline

Activity: 1806
Merit: 4896


**In BTC since 2013**


View Profile WWW
August 28, 2024, 06:40:54 PM
 #4

But you know @PowerGlove, one thing I always found strange is that this error didn't always occur. For example, I have tables that are created automatically via Excel formulas, and when I place the generated BBCode here, the bug does not occur. Did you understand why?
Yep, I can see what's happening with the two tables in that post: their first columns happen to only contain "rigid" things. If, for example, you changed the second table so that the "POS" column had values in it with spaces (like "No. 1", "No. 2", etc.), then the bug would be visible.

OK. This explains the situation a little.
But, I think I've already made other tables where the content has "spaces" and it doesn't happen. Now I don't remember where...  Lips sealed

Either way, we have the solution ready to be implemented. Now we just have to wait for the "borucracy of the authorities".  Tongue

dkbit98
Legendary
*
Offline Offline

Activity: 2380
Merit: 7466



View Profile WWW
August 28, 2024, 07:50:29 PM
Merited by PowerGlove (1)
 #5

I think Fix C is the best option.
If I understand correctly this fix won't mess around and change anything in old posts, and I like that more than having old tables looking broken.
All I can say is that every time I tried to make a post with tables I run into problems, and previews almost never look the same as the actual post.

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
PowerGlove (OP)
Hero Member
*****
hacker
Offline Offline

Activity: 582
Merit: 4995



View Profile
August 28, 2024, 10:06:57 PM
 #6

But, I think I've already made other tables where the content has "spaces" and it doesn't happen. Now I don't remember where...  Lips sealed
If you find examples that you can't explain then please share them with me.

I can tell you ahead of time, though, that if you find an example of a table that isn't trying to work around this bug, yet still manages to display correctly while having non-rigid items in its first column, then what's likely happening is that each of those items is the same width or narrower than either 26px or some other rigid item that is defining an effective minimum width for the entire column. (After all, one of the workarounds is to intentionally create some kind of width-defining thing for the first column, and sometimes that just happens by chance, like when the column title is a long word that ends up being wider than anything else in the column.)
NotATether
Legendary
*
Offline Offline

Activity: 1736
Merit: 7298


In memory of o_e_l_e_o


View Profile WWW
August 29, 2024, 01:18:22 PM
 #7

I don't really care which option is chosen, as long as the result allows for an acceptable width for the Crypto Cards List topic I've got in the Service Discussion though.

It's always weird for the first column to be squished together so that the each word is on a different column. Anyhow, I expect one of these patches to get merged soon, whichever one works best.

Cricktor
Legendary
*
Offline Offline

Activity: 910
Merit: 1356


Crypto Swap Exchange


View Profile
September 25, 2024, 08:33:25 AM
 #8

I don't construct tables often, but this formatting bug is one that would drive me crazy, if I were not aware of it. I stumbled over this bug only maybe a few months ago. It's especially nasty when the post preview is just fine but the end-result isn't.

I prefer fix C and hope @theymos approves your patch! Squish it soon, please!

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
fillippone
Legendary
*
Online Online

Activity: 2310
Merit: 16471


Fully fledged Merit Cycler - Golden Feather 22-23


View Profile WWW
September 28, 2024, 12:00:06 PM
 #9

I highly hope this patch gets put in production.
I usually post some convoluted tables in my posts.
I often encountered the bug, and the solution is neither simple nor effective.
I have tried to solve one instance of this bad formatting for months, and I found help by 1miau, but it would be much better if the source of the problem could be fixed.





█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!