Index: trunk/extensions/LiquidThreads/i18n/Lqt.i18n.php |
— | — | @@ -55,6 +55,7 @@ |
56 | 56 | 'lqt_hist_tooltip_older_disabled' => 'This link is disabled because you are on the last page.', |
57 | 57 | 'lqt_hist_split' => 'Reply split to a new thread', |
58 | 58 | 'lqt_hist_edited_subject' => 'Changed subject from "$2" to "$3"', |
| 59 | + 'lqt_hist_edited_subject_corrupt' => 'Changed subject', |
59 | 60 | 'lqt_hist_merged_from' => '[[$1|Reply]] moved to another thread', |
60 | 61 | 'lqt_hist_merged_to' => '[[$1|Reply]] moved from another thread', |
61 | 62 | 'lqt_hist_split_from' => 'Split to a new thread', |
— | — | @@ -280,6 +281,9 @@ |
281 | 282 | |
282 | 283 | 'lqt-edit-bump' => 'Bump this thread', |
283 | 284 | 'lqt-edit-bump-tooltip' => 'Move this thread to the top of its discussion page', |
| 285 | + |
| 286 | + 'lqt-historicalrevision-error' => 'The revision you have selected is corrupt, '. |
| 287 | + ' and cannot be viewed.', |
284 | 288 | ); |
285 | 289 | |
286 | 290 | /** Message documentation (Message documentation) |
Index: trunk/extensions/LiquidThreads/classes/ThreadRevision.php |
— | — | @@ -25,10 +25,14 @@ |
26 | 26 | $dbr = wfGetDB( DB_SLAVE ); |
27 | 27 | $row = $dbr->selectRow( 'thread_history', '*', array( 'th_id' => $id ), __METHOD__ ); |
28 | 28 | |
| 29 | + if (!$row) return null; |
| 30 | + |
29 | 31 | return self::loadFromRow( $row ); |
30 | 32 | } |
31 | 33 | |
32 | 34 | static function loadFromRow( $row ) { |
| 35 | + if (!$row) return null; |
| 36 | + |
33 | 37 | $rev = new ThreadRevision; |
34 | 38 | |
35 | 39 | foreach ( self::$load as $col => $field ) { |
— | — | @@ -133,13 +137,16 @@ |
134 | 138 | } |
135 | 139 | |
136 | 140 | function getChangeObject() { |
137 | | - if ( !$this->mChangeObject && $this->mChangeObjectId ) { |
| 141 | + if ( is_null($this->mChangeObject) && $this->mChangeObjectId ) { |
138 | 142 | $threadObj = $this->getThreadObj(); |
139 | | - $objectId = $this->mChangeObjectId; |
140 | | - $this->mChangeObject = $threadObj->replyWithId( $objectId ); |
141 | 143 | |
| 144 | + if ( $threadObj instanceof Thread ) { |
| 145 | + $objectId = $this->mChangeObjectId; |
| 146 | + $this->mChangeObject = $threadObj->replyWithId( $objectId ); |
| 147 | + } |
| 148 | + |
142 | 149 | if ( !$this->mChangeObject ) { |
143 | | - $this->mChangeObject = Threads::withId( $objectId ); |
| 150 | + $this->mChangeObject = false; |
144 | 151 | } |
145 | 152 | } |
146 | 153 | |
— | — | @@ -155,16 +162,16 @@ |
156 | 163 | } |
157 | 164 | |
158 | 165 | function getThreadObj() { |
159 | | - if ( !$this->mThreadObj && $this->mObjSer ) { |
| 166 | + if ( is_null($this->mThreadObj) && !is_null($this->mObjSer) ) { |
160 | 167 | $this->mThreadObj = unserialize( $this->mObjSer ); |
161 | | - } elseif ( !$this->mThreadObj ) { |
| 168 | + } elseif ( is_null($this->mThreadObj) && is_null($this->mObjSer) ) { |
| 169 | + var_dump($this); |
162 | 170 | throw new MWException( "Missing mObjSer" ); |
163 | 171 | } |
164 | 172 | |
165 | 173 | if ( !($this->mThreadObj instanceof Thread) ) { |
166 | | - throw new MWException( "Expected mThreadObj for rev ".$this->getId(). |
167 | | - "to be a Thread, but it is actually a ". |
168 | | - gettype($this->mThreadObj) ); |
| 174 | + $this->mThreadObj = false; |
| 175 | + return false; |
169 | 176 | } |
170 | 177 | |
171 | 178 | $this->mThreadObj->threadRevision = $this; |
Index: trunk/extensions/LiquidThreads/classes/ThreadHistoryPager.php |
— | — | @@ -102,25 +102,35 @@ |
103 | 103 | |
104 | 104 | $args = array(); |
105 | 105 | $revision = ThreadRevision::loadFromRow( $this->mCurrentRow ); |
| 106 | + $changeObject = $revision->getChangeObject(); |
106 | 107 | |
107 | | - if ( $revision->getChangeObject()->title() ) { |
108 | | - $args[] = $revision->getChangeObject()->title()->getPrefixedText(); |
| 108 | + if ( $revision && $revision->prev() ) { |
| 109 | + $lastChangeObject = $revision->prev()->getChangeObject(); |
| 110 | + } |
| 111 | + |
| 112 | + if ( $changeObject && $changeObject->title() ) { |
| 113 | + $args[] = $changeObject->title()->getPrefixedText(); |
109 | 114 | } else { |
110 | 115 | $args[] = ''; |
111 | 116 | } |
112 | 117 | |
| 118 | + $msg = self::$change_names[$type]; |
| 119 | + |
113 | 120 | switch( $type ) { |
114 | 121 | case Threads::CHANGE_EDITED_SUBJECT: |
115 | | - $args[] = $revision->prev()->getChangeObject()->subject(); |
116 | | - $args[] = $revision->getChangeObject()->subject(); |
| 122 | + if ($changeObject && $lastChangeObject) { |
| 123 | + $args[] = $lastChangeObject->subject(); |
| 124 | + $args[] = $changeObject->subject(); |
| 125 | + } else { |
| 126 | + $msg = wfMsg( 'lqt_hist_edited_subject_corrupt', 'parseinline' ); |
| 127 | + } |
117 | 128 | break; |
118 | 129 | case Threads::CHANGE_EDITED_ROOT: |
119 | 130 | case Threads::CHANGE_ROOT_BLANKED: |
120 | | - $post = $revision->getChangeObject(); |
121 | 131 | $view = $this->view; |
122 | 132 | |
123 | | - if ( $post->title() ) { |
124 | | - $diffLink = $view->diffPermalinkURL( $post, $revision ); |
| 133 | + if ( $changeObject && $changeObject->title() ) { |
| 134 | + $diffLink = $view->diffPermalinkURL( $changeObject, $revision ); |
125 | 135 | $args[] = $diffLink; |
126 | 136 | } else { |
127 | 137 | $args[] = ''; |
— | — | @@ -128,7 +138,7 @@ |
129 | 139 | break; |
130 | 140 | } |
131 | 141 | |
132 | | - $content = wfMsgReplaceArgs( self::$change_names[$type], $args ); |
| 142 | + $content = wfMsgReplaceArgs( $msg, $args ); |
133 | 143 | return $wgOut->parseInline( $content ); |
134 | 144 | } |
135 | 145 | |
Index: trunk/extensions/LiquidThreads/pages/ThreadHistoricalRevisionView.php |
— | — | @@ -112,12 +112,15 @@ |
113 | 113 | |
114 | 114 | $this->thread = $this->mDisplayRevision->getThreadObj(); |
115 | 115 | |
116 | | - $this->showHistoryInfo(); |
117 | | - |
118 | | - if ( !$this->thread ) { |
| 116 | + if (!$this->mDisplayRevision) { |
119 | 117 | $this->showMissingThreadPage(); |
120 | 118 | return false; |
| 119 | + } elseif ( !$this->thread ) { |
| 120 | + $this->output->addWikiMsg( 'lqt-historicalrevision-error' ); |
| 121 | + return false; |
121 | 122 | } |
| 123 | + |
| 124 | + $this->showHistoryInfo(); |
122 | 125 | |
123 | 126 | self::addJSandCSS(); |
124 | 127 | $this->output->setSubtitle( $this->getSubtitle() ); |