Page Index Toggle Pages: 1
Topic Tools
Normal Topic Convert from 2.1: newlines in sigs turn to && (Read 3,928 times)
Matt Siegman
YaBB Legends (Inactive)
*
Offline



Posts: 3,380
Location: Wichita, KS
Re: Convert from 2.1: newlines in sigs turn to &&
Reply #8 - Jul 19th, 2009 at 3:49pm
Post Tools
good point, I hadn't considered that people might actually want a && in their sig
  

-- Matt Siegman 8) Wish List
Back to top
 
IP Logged
 
deti
Legacy Dev Team
Development Team
****
Offline



Posts: 2,650
Location: Prien am Chiemsee, Germany
Re: Convert from 2.1: newlines in sigs turn to &&
Reply #7 - Jul 19th, 2009 at 1:31pm
Post Tools
Hmmmm, I don't like this "Fix".

We must stop adding fixes into the main code for errors from earlier versions or we will end with the code full of, mostly undocumented (!!!), fixes for errors we made before. In my opinion the main code is not the right place for this kind of fixes.

For this one we have a nice subroutine in the Maintenance.pl called RebuildMemList. This is the right place to build in a fix, because all signatures of all members can there be examined and re-saved, if necessary, in one run.

Personally I also wouldn't do it there, because this problem only affects a minor amount of forums. Therefore it should be build as a Mod that can be inserted and removed after the Maintenance was run through once.
I remember we had already a problem with something like &quote; somewhere in the code that must be removed. JetLi and I made a Mod to solve this problem. This is, in my opinion, the best way to handle this kind of mistakes from earlier versions if the users aren't able to fix their Profile by themselves.

Further more:
I have seen users inserting Perl code in their signatures. What if someone wants to have a "&&" in it, what is rather common in Perl? He can't do it with cephs code.

So please remove it Matt and ceph, don't get angry about me, but try to write a Mod for it.  Wink

Thanks!
  

Was immer Du tun kannst
oder erträumst tun zu können,
beginne es.
Kühnheit besitzt Genie,
Macht und magische Kraft.
Beginne es jetzt.
Whatever you can do
or dream you can,
begin it.
Boldness has genius,
power and magic in it.
Begin it now.
J. W. Goethe
Back to top
WWW  
IP Logged
 
Matt Siegman
YaBB Legends (Inactive)
*
Offline



Posts: 3,380
Location: Wichita, KS
Re: Convert from 2.1: newlines in sigs turn to &&
Reply #6 - Jul 18th, 2009 at 1:30am
Post Tools
Applied to trunk.
  

-- Matt Siegman 8) Wish List
Back to top
 
IP Logged
 
cepheid
Senior Member
****
Offline



Posts: 516
Re: Convert from 2.1: newlines in sigs turn to &&
Reply #5 - Jul 15th, 2009 at 4:59am
Post Tools
batchman wrote on Jul 15th, 2009 at 4:20am:
Nah ... I figured out BoardMod, but I don't know how to use these diff patch things.

If you know how to use BoardMod, it's pretty easy to figure out these diffs.  BoardMod is really just a version of diff/patch with different syntax.

To read these diff files:
A line prefaced with --- indicates the old file; a line with +++ indicates the new file.  Generally, these will both have the same (or similar) filename.  Note that there may be more than one ---/+++ line per file, because multiple files may be modified.  For your purposes, you want to just pay attention to the +++ line, which indicates the file you want to edit.

Then, the @@ lines indicate the line number at which to start looking (the - number is the line in the old file, the + is for the new file).  Go to that line number, then:

Any line WITHOUT a - or + in front of it is a "context" line, i.e. it tells you what surrounds (before and after) the area you need to change; these lines are unchanged between the files.  Lines prefaced with a - or + differ between the files, where the - indicates the line in the old file, and the + indicates the line in the new file.

To put it more simply:
The +++ lines indicate the file to edit.  Go to the line number indicated by the @@ lines, and look for the code that looks like what's in the patch.  Remove any lines prefaced by -, and add lines prefaced by +.  Then, save.  (Be aware that in more complicated files, "context" lines may come between the - and + lines... the trick is just to remove - lines and add + lines, in the same order they appear in relation to the context lines.)

It's pretty much the same as reading a BoardMod file and applying those changes by hand... you just have to understand the syntax.

Now, the reason a patch may not apply cleanly is if the context lines don't match, or if the line number (in the @@ line) is too different from what's specified there.  That's why using "patch" may not work, even if one can apply the patch manually.  In the case of this patch, "patch" works fine on the SVN code but fails on the 2.4 release not because of the context lines, which happen to be the same, but because the line numbers are radically different - the SVN version of Load.pl, for example, adds a LOT of code early in the file, so "patch" doesn't work because it doesn't want to look too far away from the specified line numbers.

But, the patch can be manually applied - it works well.  Armed with the knowledge above, hopefully you now know how to apply it manually and can do it on your board... This particular diff file is pretty simple, so it's a good way to get started, if you're interested. Smiley
« Last Edit: Jul 15th, 2009 at 5:08am by cepheid »  
Back to top
WWW  
IP Logged
 
batchman
Support Team
****
Offline



Posts: 371
Location: Orlando, FL
Re: Convert from 2.1: newlines in sigs turn to &&
Reply #4 - Jul 15th, 2009 at 4:20am
Post Tools
Nah ... I figured out BoardMod, but I don't know how to use these diff patch things.

Anything simple enough to just be a couple of lines of replace this with this?
  
Back to top
 
IP Logged
 
cepheid
Senior Member
****
Offline



Posts: 516
Re: Convert from 2.1: newlines in sigs turn to &&
Reply #3 - Jul 15th, 2009 at 2:12am
Post Tools
batchman wrote on Jul 15th, 2009 at 1:57am:
(Now if you'd just make a tiny mod to fix the problem for 2.2 - 2.4, I'd be smiling! But even if it is just for future versions, I still like.)

For 2.4 release (instead of SVN), you can apply the patch manually, if you know how to read unified diff files.  I can also make a patch that will work on the 2.4 release; I am not quite familiar with BoardMod code so I can't code it up as a true Mod.

You may be able to apply the patch for 2.2-2.3 manually.  I don't have installations of that code available at the moment; I'll try to install those and code up a patch for it when I have time.
« Last Edit: Jul 15th, 2009 at 2:13am by cepheid »  
Back to top
WWW  
IP Logged
 
batchman
Support Team
****
Offline



Posts: 371
Location: Orlando, FL
Re: Convert from 2.1: newlines in sigs turn to &&
Reply #2 - Jul 15th, 2009 at 1:57am
Post Tools
A solution! I like!

For the last couple of years it has just been "Tell your users to edit their sigs." Which, admittedly, does work ... bu if your users don't listen, those stupid && everywhere can really tick you off!

(Now if you'd just make a tiny mod to fix the problem for 2.2 - 2.4, I'd be smiling! But even if it is just for future versions, I still like.)
  
Back to top
 
IP Logged
 
cepheid
Senior Member
****
Offline



Posts: 516
Re: Convert from 2.1: newlines in sigs turn to &&
Reply #1 - Jul 15th, 2009 at 1:47am
Post Tools
And, since I prefer contributing rather than just complaining Wink, here is the first (easy) method of fixing this, by reinserting the code to convert && or && into newlines:

http://dev.3phase.com/yabb/patches/newline_sig.patch

This doesn't do any actual conversion in the .vars file; it merely turns the && or &amp;&amp; into newlines for display.  When a user edits the profile, the && are turned into \n and then saved as <br /> using the existing code.

I'll try to code up the more complicated method (a Rebuild option) when I have the chance.
  
Back to top
WWW  
IP Logged
 
cepheid
Senior Member
****
Offline



Posts: 516
Convert from 2.1: newlines in sigs turn to &&
Jul 15th, 2009 at 1:21am
Post Tools
I just noticed that in a couple of production forums that I converted from 2.1 to 2.4 (using the official 2.4 release, not SVN/CVS), that signatures that previously included newlines now don't display properly.

It appears that v2.4 no longer considers "&amp;&amp;" or "&&" to be the "code" for a newline.  In v2.1, Load.pl::LoadUserDisplay converted the && (or &amp;&amp;) into <br /> ... that does not happen in v2.4.

Creating a new signature or manually editing the signature works fine, of course, because newlines are now encoded as <br /> directly... but for users whose signatures contain && or &amp;&amp;, the newlines don't display properly anymore.  There is currently no conversion routine to convert && to <br /> within the .vars files, so all member signatures that contained newlines now don't display properly unless they are manually edited.

The easy fix for this would be to reinsert the code into Load.pl::LoadUserDisplay that converts && or &amp;&amp; into <br /> ... that would allow everything to display properly without touching the user signatures.  Of course, Profile.pl would also have to be modified to convert && or &amp;&amp; into <br />, as well, when it loads the profile for editing.

Even better would be to auto-convert all user signatures with a little script in the Admin Center, under the Rebuild options, so that it can be done for every user permanently and would only have to be done once.  This way, conversion of signatures would be automatically handled during the initial setup/upgrade from an older version, as the admin runs through all the Rebuild options.  Users who have already deployed existing v2.4 installations would need to be notified to run this conversion manually.

I looked through the CVS and SVN code, and this error appears to still be there.  I would recommend treating any fix the same way we treated the Quick-Guide upgrade, because I consider this a form of "data loss" during upgrade (even though no actual data is lost, it's just not displayed/stored properly).
  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Topic Tools
 
  « Board Index ‹ Board  ^Top