Index: trunk/extensions/LiquidThreads/classes/Thread.php |
— | — | @@ -851,8 +851,27 @@ |
852 | 852 | $this->decrementReplyCount( 1 + $threadObj->replyCount() ); |
853 | 853 | } |
854 | 854 | |
| 855 | + function checkReplies( $replies ) { |
| 856 | + foreach( $replies as $reply ) { |
| 857 | + if ( ! $reply->hasSuperthread() ) { |
| 858 | + throw new MWException( "Post ".$this->id(). |
| 859 | + " has contaminated reply ".$reply->id()."\n" ); |
| 860 | + } |
| 861 | + |
| 862 | + if ( $reply->superthread()->id() != $this->id() ) { |
| 863 | + throw new MWException( "Post ". $this->id() . |
| 864 | + " has contaminated reply ".$reply->id()."\n" ); |
| 865 | + } |
| 866 | + } |
| 867 | + } |
| 868 | + |
855 | 869 | function replies() { |
| 870 | + if ( !$this->id() ) { |
| 871 | + return array(); |
| 872 | + } |
| 873 | + |
856 | 874 | if ( !is_null( $this->replies ) ) { |
| 875 | + $this->checkReplies( $this->replies ); |
857 | 876 | return $this->replies; |
858 | 877 | } |
859 | 878 | |
— | — | @@ -879,6 +898,8 @@ |
880 | 899 | |
881 | 900 | $this->replies = Thread::bulkLoad( $rows ); |
882 | 901 | |
| 902 | + $this->checkReplies( $this->replies ); |
| 903 | + |
883 | 904 | return $this->replies; |
884 | 905 | } |
885 | 906 | |
— | — | @@ -1172,11 +1193,11 @@ |
1173 | 1194 | // |
1174 | 1195 | // // Insert a revision into the database. |
1175 | 1196 | // $rev = ThreadRevision::create( $historical_thread, |
1176 | | -// $historical_thread->changeType(), |
1177 | | -// $historical_thread->changeObject(), |
1178 | | -// $historical_thread->changeComment(), |
1179 | | -// $historical_thread->changeUser(), |
1180 | | -// $historical_thread->modified() ); |
| 1197 | +// $historical_thread->changeType(), |
| 1198 | +// $historical_thread->changeObject(), |
| 1199 | +// $historical_thread->changeComment(), |
| 1200 | +// $historical_thread->changeUser(), |
| 1201 | +// $historical_thread->modified() ); |
1181 | 1202 | // } |
1182 | 1203 | } |
1183 | 1204 | |