Simple Machines Community Forum

SMF Development => Bug Reports => Fixed or Bogus Bugs => Topic started by: blar on August 05, 2003, 12:36:55 PM

Title: long words and many smilies
Post by: blar on August 05, 2003, 12:36:55 PM
see in test board for oversized (http://www.simplemachines.org/community/index.php?threadid=346)

and many smilies => Fatal error: Maximum execution time of 30 seconds exceeded in Subs.php on line 999

don't use ereg_, don't use preg_ for smilies
str_replace or strtr are faster
Title: Re:long words and many smilies
Post by: Hans v. M. on August 05, 2003, 12:40:54 PM
I got this warning too:
Fatal error: Maximum execution time of 30 seconds exceeded in /home/simple/public_html/community/Sources/Subs.php on line 999
when opening this thread from an alertmail:
http://www.simplemachines.org/community/index.php?threadid=346;start=new
Title: Re:long words and many smilies
Post by: Joseph on August 05, 2003, 12:44:36 PM
blar, although we appreciate the comments, there are flaws with your assertions.

The reason we don't use str_replace or strtr for smilies is because of the customizability of them and problems caused with special characters.  For example - lets say you end a bracketed phrase with a special character- something like &2345;) - the ; ) would then be translated to ;) and the special character would not be displayed.  Similarly say you had a URL where it had index.php?C=you;D=me in it - then the ; D would be translated to ;D

Similarly, using the code you provided will break long lines of code - for example imagine someone was linking to a long URL using an image which also had a long URL - the addresses would be be split at 80 characters and break the code.

Please, keep up the suggestions though :)
Title: Re:long words and many smilies
Post by: Grudge on August 05, 2003, 05:09:43 PM
Hopefully this is on topic

Will the problem in SE where smilies that say, start a word but don't end it are translated into the image. This is very hard to explain so I'll show it :D

On my board many people like to type up *made up* smilies. For example people will type :owned: . However, YABB SE will always turn the

:o

bit into an image making the typing look silly. there should be checks that the image has nothing either side of it (ie a whitespace either side, or, if at the beginning or end of a post - no character)

It can't be very hard to do and would be a nice fix :)
Title: Re:long words and many smilies
Post by: Joel on August 05, 2003, 05:32:38 PM
You could use str_replace if you simply required a space before each smilie. When you click a smilie to insert it into your post it puts a space first, and 99% of people that manually type smileys put a space between preceding text and a smilie anyway. It seems like this solution wouldn't cause problems with things like URLs or even bracketed phrases. The only common situation (that I can think of) where this doesn't work is if you start a new line with a smilie without a preceding space. I don't think that's a major problem, though, and people will catch on quickly to something this simple.

As it stands (at least in YSE), you take a pretty significant performance hit -- particularly with lots of smilies or high traffic forums -- to accomodate a very small number of people.

I'm might be (probably am) missing a fairly obvious problem here, but I've done this on the YSE forums I run and it works just great.
Title: Re:long words and many smilies
Post by: Joshua Dickerson on August 05, 2003, 05:41:06 PM
grudge: you can turn smilies off in a post

Joel: str_replace() is not always faster. In this case, it probably wouldn't be because there are too many variables to specify when smilies should be displayed. Also, preg_replace() really isn't that slow. You won't notice a difference. Most of the processing time for any page made in SMF is from queries. Actually, probably 90% of it is. That is why we have invested a lot of time into redesigning queries and structure. Try benchmarking how long it takes to parse the bbc.
Title: Re:long words and many smilies
Post by: mattsiegman on August 05, 2003, 05:41:09 PM
well, in perl, with a regex, you could make it match whitespace, smiley, whitespace... I'm not well versed in preg_replace though...


s/(\s+)$smileycode(\s+)/$1<img src="$smileyurl">$2/g;


of course, then we are back to a regex....
Title: Re:long words and many smilies
Post by: Joseph on August 05, 2003, 05:43:13 PM
matt - this is what we currently attempt to do - their point was that using str_replace would be faster than using preg or ereg.  str_replace precludes the use of regular expressions.
Title: Re:long words and many smilies
Post by: mattsiegman on August 05, 2003, 05:52:32 PM
I figured as much....
Title: Re:long words and many smilies
Post by: Grudge on August 05, 2003, 06:00:33 PM
Quote from: groundup on August 05, 2003, 05:41:06 PM
grudge: you can turn smilies off in a post

I know this.

The point is not that it should be one or another but that the smilies should only work when not located next to text on either side. For example/ If I wrote:

The next step was:one step too far

^ That is fine

But:

The next step was :one step too far

^ Is not

Surely it's very easy to check if the next character is alphanumeric and if so not replace the next with a smiley?

I know it's not a major problem but still think it shouldn't act the way it currently does - smilies should be surrounded by spaces either side of the code
Title: Re:long words and many smilies
Post by: Joel on August 05, 2003, 06:26:45 PM
Quote from: groundup on August 05, 2003, 05:41:06 PMMost of the processing time for any page made in SMF is from queries. Actually, probably 90% of it is.

Yeah, it certailnly isn't nearly as big of a deal as queries. It really only becomes an issue when you have a member or two that like to see how many smilies they can use in a post that it becomes a problem.  :-\
Title: Re:long words and many smilies
Post by: Joseph on August 05, 2003, 06:28:33 PM
and those users are very few - so we'd be designing the system to accomodate a very small number of people. ;)
Title: Re:long words and many smilies
Post by: [Unknown] on August 05, 2003, 06:35:13 PM
Hmm.. I'll have to look at it again.  I thought I had fixed the million smilies causing problems issue.

It should only take 3 iterations to parse ALL the smilies.  If not I've done something wrong.

And the word starting thing would only slow it down - but I could add that.

Stickying this too... ugh, there are going to be a lot of stickies before I get home.

-[Unknown]
Title: Re:long words and many smilies
Post by: Joel on August 05, 2003, 07:45:24 PM
Quote from: Joseph Fung on August 05, 2003, 06:28:33 PM
and those users are very few - so we'd be designing the system to accomodate a very small number of people. ;)

But you wouldn't allow complete HTML use in posts just because a very small number of people will abuse them. Same goes for embedded Flash. That's why I always mod the smiley code with the YSE forums I run. The very slight decrease in functionality is worth not having to worry about someone abusing the system.

I can understand why you wouldn't want to change it, but I'm just a "safety first" kind of guy. ;)
Title: Re:long words and many smilies
Post by: Joshua Dickerson on August 05, 2003, 07:47:04 PM
html works in SMF :P

if you don't want people testing what kind of smilies they can use, just delete their posts. Takes some administration to run a forum ;)
Title: Re:long words and many smilies
Post by: Joel on August 05, 2003, 07:57:34 PM
Quote from: groundup on August 05, 2003, 07:47:04 PM
html works in SMF :P

I was talking about letting people post more or less whatever HTML they want. I hope SMF does things like requiring both opening and closing tags and not allowing the script tag.

Quote from: groundup on August 05, 2003, 07:47:04 PMif you don't want people testing what kind of smilies they can use, just delete their posts. Takes some administration to run a forum ;)

Preventative action is often preferable to taking action after the fact.

Real administrators give forum members access to the database. You can always ban them later. ;)
Title: Re:long words and many smilies
Post by: [Unknown] on August 05, 2003, 08:27:33 PM
Please stop arguing.  SMF only allows certain tags with certain attributes.  And I do mean CERTAIN.

This won't be a problem much longer.  I will fix it.  The issue is that, for some reason, it is not parsing all the smilies within 3 iterations.  I will make it parse them in that number of iterations OR ELSE.  So don't worry about it!  (and three iterations is not only more than enough but it's not nearly long enough for the script to time out.)

-[Unknown]
Title: Re:long words and many smilies
Post by: Joel on August 05, 2003, 08:55:54 PM
Sorry. I didn't mean to cause trouble. I just thought it was important to make a note of it, as I have had problems with it even though some believe that it's a non-issue (and it most often is not a problem).

My apologies.
Title: Re:long words and many smilies
Post by: Joseph on August 05, 2003, 10:15:29 PM
Joel - no need to apologize - and the debating is good - it helps us make a better product :)

Thanks for the points!
Title: Re:long words and many smilies
Post by: [Unknown] on August 05, 2003, 10:59:13 PM
You know what is funny?

phpMyAdmin can't even displayed that message and it doesn't parse smilies...

18k of :) :) :) :) :) :) :) :) :) :) :).......... hmph.

-[Unknown]
Title: Re:long words and many smilies
Post by: [Unknown] on August 05, 2003, 11:05:35 PM
There... happy?  :Pdoesn't work any more ;)

Also, I got it much closer to working on that crazy thread because it was timing out trying to check the iamge sizes of all those kabillion images.

-[Unknown]
Title: Re:long words and many smilies
Post by: Joel on August 05, 2003, 11:07:02 PM
Quote from: [Unknown] on August 05, 2003, 11:05:35 PM
There... happy?  :Pdoesn't work any more ;)

Also, I got it much closer to working on that crazy thread because it was timing out trying to check the iamge sizes of all those kabillion images.

-[Unknown]

:owned: :o

Hey, you're right.
Title: Re:long words and many smilies
Post by: Jeff Lewis on August 05, 2003, 11:09:17 PM
Except winks aren't working now:

http://www.simplemachines.org/community/index.php?threadid=302
Title: Re:long words and many smilies
Post by: [Unknown] on August 05, 2003, 11:16:00 PM
Bugger "end of subject".  Alright, now not only do winks at the end of your post work BUT that thread loads!!! (and display should be a lot faster ;).)

-[Unknown]
Title: Re:long words and many smilies
Post by: Joseph on August 05, 2003, 11:20:15 PM
what about the series of :) in your post 4 posts up?
Title: Re:long words and many smilies
Post by: [Unknown] on August 06, 2003, 12:30:26 AM
Quote from: Joseph Fung on August 05, 2003, 11:20:15 PM
what about the series of :) in your post 4 posts up?

Hmmm... that's odd... I copied that from phpMyAdmin, what did it do to it?

-[Unknown]
Title: Re:long words and many smilies
Post by: blar on August 06, 2003, 04:13:53 AM
please delete the test post, i can't see the last postings from me in my profile
Title: Re:long words and many smilies
Post by: blar on August 06, 2003, 04:18:10 AM
set max of bbc in a post

eg only replace 1000 smilies in a post.
Title: Re:long words and many smilies
Post by: Grudge on August 06, 2003, 04:37:53 AM
Quote from: [Unknown] on August 05, 2003, 11:05:35 PM
There... happy?  :Pdoesn't work any more ;)

-[Unknown]

OMG!! [Unknown] you are like the best guy on the planet  :D

Sorry for suggesting such a *tiny* thing and I'm amazed that you sorted it out - this truely will be the best forum ever ;D

/me notes the winking grin has been fixed to look less like a constipated mad man!