Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
general-topic
Duplicate code in class
Avatar
Lee H
Coastal New England (USA)
Member
Free Members
sp_UserOfflineSmall Offline
Jul 27, 2011 - 8:25 pm

In sp-topic-view-class.php

Within sp_topicview_query(), lines 270-296

The "Is this post to be edited" code is repeated. The second instance goes a bit further and adds edit history.

                    # Is this post to be edited? 
                    if ($sfvars['displaymode'] == 'edit' && $sfvars['postedit'] == $r->post_id) { 
                        $t[$tidx]->editmode                        = 1; 
                        $t[$tidx]->editpost_id                    = $r->post_id; 
                        $t[$tidx]->editpost_content                = sp_filter_content_edit($r->post_content); 
                        $t[$tidx]->posts[$pidx]->editmode        = 1; 
                    } 
 
                    # Add edit history 
                    if ($r->post_edit) { 
                        $edits = unserialize($r->post_edit); 
                        $eidx = 0; 
                        foreach ($edits as $e) { 
                            $t[$tidx]->posts[$pidx]->edits[$eidx]->by = $e['by']; 
                            $t[$tidx]->posts[$pidx]->edits[$eidx]->at = $e['at']; 
                            $eidx++; 
                        } 
                    } 
 
                    # Is this post to be edited? 
                    if ($sfvars['displaymode'] == 'edit' && $sfvars['postedit'] == $r->post_id) { 
                        $t[$tidx]->editmode                        = 1; 
                        $t[$tidx]->editpost_id                    = $r->post_id; 
                        $t[$tidx]->editpost_content                = sp_filter_content_edit($r->post_content); 
                        $t[$tidx]->editpost_history                = $r->post_edit; 
                        $t[$tidx]->posts[$pidx]->editmode        = 1; 
                    }
Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Jul 28, 2011 - 11:08 am

Gosh - thanks Lee. Looks like a copy and paste job that wasn't cleaned up in the rush.
Good find and I will cleanse it immediately.

andy-signature.png
YELLOW
SWORDFISH
Avatar
Lee H
Coastal New England (USA)
Member
Free Members
sp_UserOfflineSmall Offline
Jul 28, 2011 - 11:24 am

@YS

I just came from snooping the svn and noticed you commented out the second instance. I was thinking it was the first instance that should be commented out as the second one, and the code right above handle edit history?

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Jul 28, 2011 - 11:35 am

The database column is called 'post_edits' and in the first cut of the code (the bit I commented out) I was passing that column. But is is a serialized array and I wanted to explode it to a normal array and format it along the way which is what the bit in the middle does. I then pass it as 'edits' instead of 'post_edits'. I could pass both but it seems redundant.

Reckon I copied the block - pasted it above - removed the post_edits line and then wrote the new piece below. Just forgot to remove the old block.

But... that is why the code is commented out and not removed. Just in case I am wrong... 🙂

andy-signature.png
YELLOW
SWORDFISH
Avatar
Lee H
Coastal New England (USA)
Member
Free Members
sp_UserOfflineSmall Offline
Jul 28, 2011 - 11:45 am

Thanks for the explanation! I only questioned as I'm trying to learn and understand. I've learned a lot from you guys and appreciate the patience and the time you've given me 🙂

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Jul 28, 2011 - 8:58 pm

hey, we appreciate your help around here!

Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 649
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 618
Members: 17357
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10123
Posts: 79616