Index: trunk/tools/bugzilla/client/bugzilla.php |
— | — | @@ -27,7 +27,6 @@ |
28 | 28 | $this->bz = $bz; |
29 | 29 | if( !$this->inCache( ) && !$noFetch ) { |
30 | 30 | $this->data = $this->bz->search( array( "id" => $id ) ); |
31 | | - $this->data = $this->data['bugs'][0]; |
32 | 31 | self::$bugs[$id] = $this; |
33 | 32 | } else if( $this->inCache( ) ){ |
34 | 33 | $this->fromCache( ); |
— | — | @@ -42,6 +41,10 @@ |
43 | 42 | return $bug; |
44 | 43 | } |
45 | 44 | |
| 45 | + public function getComments() { |
| 46 | + return $this->bz->getBugComments( $this->id ); |
| 47 | + } |
| 48 | + |
46 | 49 | /** |
47 | 50 | * Returns true if the bug is resolvd |
48 | 51 | */ |
— | — | @@ -115,7 +118,7 @@ |
116 | 119 | } |
117 | 120 | } |
118 | 121 | } |
119 | | - foreach($dep as $id => $none) { |
| 122 | + foreach($dep as $id => $none) { |
120 | 123 | $this->dependency[] = new BugzillaBug( $id, $this->bz ); |
121 | 124 | } |
122 | 125 | } |
— | — | @@ -138,6 +141,39 @@ |
139 | 142 | } |
140 | 143 | } |
141 | 144 | |
| 145 | + public function findCommentByRegexp( $regexp ) { |
| 146 | + foreach( $this->getComments() as $comment ) { |
| 147 | + $hasMatch = preg_match( $regexp, $comment['text'] ); |
| 148 | + if( $hasMatch >= 1 ) { |
| 149 | + return $comment; |
| 150 | + } |
| 151 | + if( $hasMatch === false ) { |
| 152 | + if (preg_last_error() == PREG_INTERNAL_ERROR) { |
| 153 | + print 'There is an internal error!'; |
| 154 | + exit; |
| 155 | + } |
| 156 | + else if (preg_last_error() == PREG_BACKTRACK_LIMIT_ERROR) { |
| 157 | + print 'Backtrack limit was exhausted!'; |
| 158 | + exit; |
| 159 | + } |
| 160 | + else if (preg_last_error() == PREG_RECURSION_LIMIT_ERROR) { |
| 161 | + print 'Recursion limit was exhausted!'; |
| 162 | + exit; |
| 163 | + } |
| 164 | + else if (preg_last_error() == PREG_BAD_UTF8_ERROR) { |
| 165 | + print 'Bad UTF8 error!'; |
| 166 | + exit; |
| 167 | + } |
| 168 | + else if (preg_last_error() == PREG_BAD_UTF8_OFFSET_ERROR) { |
| 169 | + print 'Bad UTF8 offset error!'; |
| 170 | + exit; |
| 171 | + } |
| 172 | + } |
| 173 | + } |
| 174 | + |
| 175 | + return null; |
| 176 | + } |
| 177 | + |
142 | 178 | public function addResetField( $changeLog ) { |
143 | 179 | if( $this->bz->isListField( $changeLog['field_name'] ) ) { |
144 | 180 | return array( $changeLog['field_name'] => |
— | — | @@ -258,10 +294,6 @@ |
259 | 295 | return $this->bz->__call( "Bug.fields", array( "" => "" ) ); |
260 | 296 | } |
261 | 297 | |
262 | | - public function getState( $id ) { |
263 | | - $this->bz->__call( "Bug.get", array( "id" => (array)$id ) ); |
264 | | - } |
265 | | - |
266 | 298 | public function search( $conditions ) { |
267 | 299 | if(is_array($conditions)) { |
268 | 300 | return $this->bz->__call( "Bug.search", $conditions ); |
— | — | @@ -270,6 +302,17 @@ |
271 | 303 | } |
272 | 304 | } |
273 | 305 | |
| 306 | + public function getBugComments( $id ) { |
| 307 | + $ret = $this->bz->__call( |
| 308 | + "Bug.comments", array( "ids" => (array)$id ) ); |
| 309 | + if( !is_array( $id ) ) { |
| 310 | + $ret = $ret['bugs'][$id]['comments']; |
| 311 | + } else { |
| 312 | + throw new Exception("ugh!"); |
| 313 | + } |
| 314 | + return $ret; |
| 315 | + } |
| 316 | + |
274 | 317 | public function getBugHistory( $id ) { |
275 | 318 | return $this->getHistory( $id ); |
276 | 319 | } |