long words and many smilies

Started by blar, August 05, 2003, 12:36:55 PM

Previous topic - Next topic

blar

see in test board for oversized

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

Hans v. M.

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

Joseph

#2
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 :)
Joseph Fung
Co-Founder & CEO, Kiite
Co-Founder TribeHR, Lewis Media, SMF

Grudge

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 :)
I'm only a half geek really...

Joel

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.

Joshua Dickerson

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.
Come work with me at Promenade Group



Need help? See the wiki. Want to help SMF? See the wiki!

Did you know you can help develop SMF? See us on Github.

How have you bettered the world today?

mattsiegman

#6
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....
-- Matt Siegman

Joseph

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.
Joseph Fung
Co-Founder & CEO, Kiite
Co-Founder TribeHR, Lewis Media, SMF

mattsiegman

-- Matt Siegman

Grudge

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
I'm only a half geek really...

Joel

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.  :-\

Joseph

and those users are very few - so we'd be designing the system to accomodate a very small number of people. ;)
Joseph Fung
Co-Founder & CEO, Kiite
Co-Founder TribeHR, Lewis Media, SMF

[Unknown]

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]

Joel

#13
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. ;)

Joshua Dickerson

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 ;)
Come work with me at Promenade Group



Need help? See the wiki. Want to help SMF? See the wiki!

Did you know you can help develop SMF? See us on Github.

How have you bettered the world today?

Joel

#15
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. ;)

[Unknown]

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]

Joel

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.

Joseph

Joel - no need to apologize - and the debating is good - it helps us make a better product :)

Thanks for the points!
Joseph Fung
Co-Founder & CEO, Kiite
Co-Founder TribeHR, Lewis Media, SMF

[Unknown]

You know what is funny?

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

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

-[Unknown]

[Unknown]

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]

Joel

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.

Jeff Lewis

Co-Founder of SMF

[Unknown]

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]

Joseph

what about the series of :) in your post 4 posts up?
Joseph Fung
Co-Founder & CEO, Kiite
Co-Founder TribeHR, Lewis Media, SMF

[Unknown]

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]

blar

please delete the test post, i can't see the last postings from me in my profile

blar

set max of bbc in a post

eg only replace 1000 smilies in a post.

Grudge

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

* Grudge notes the winking grin has been fixed to look less like a constipated mad man!
I'm only a half geek really...

Advertisement: