@@ -609,30 +609,30 @@ |
||
| 609 | 609 | * @param QueryResult $queryResult |
| 610 | 610 | * @param string $methodName |
| 611 | 611 | */ |
| 612 | - private function ValidateQueryResult($queryResult, QueryType $queryType, $methodName){ |
|
| 612 | + private function ValidateQueryResult($queryResult, QueryType $queryType, $methodName) { |
|
| 613 | 613 | if (!$queryResult instanceof QueryResult) { |
| 614 | 614 | throw ODataException::createInternalServerError( |
| 615 | 615 | Messages::queryProviderReturnsNonQueryResult($methodName) |
| 616 | 616 | ); |
| 617 | 617 | } |
| 618 | 618 | |
| 619 | - if($queryType == QueryType::COUNT() || $queryType == QueryType::ENTITIES_WITH_COUNT()){ |
|
| 619 | + if ($queryType == QueryType::COUNT() || $queryType == QueryType::ENTITIES_WITH_COUNT()) { |
|
| 620 | 620 | //and the provider is supposed to handle the ordered paging they must return a count! |
| 621 | - if($this->queryProvider->handlesOrderedPaging() && !is_numeric($queryResult->count)){ |
|
| 621 | + if ($this->queryProvider->handlesOrderedPaging() && !is_numeric($queryResult->count)) { |
|
| 622 | 622 | throw ODataException::createInternalServerError( |
| 623 | 623 | Messages::queryProviderResultCountMissing($methodName, $queryType) |
| 624 | 624 | ); |
| 625 | 625 | } |
| 626 | 626 | |
| 627 | 627 | //If POData is supposed to handle the ordered aging they must return results! (possibly empty) |
| 628 | - if(!$this->queryProvider->handlesOrderedPaging() && !is_array($queryResult->results)){ |
|
| 628 | + if (!$this->queryProvider->handlesOrderedPaging() && !is_array($queryResult->results)) { |
|
| 629 | 629 | throw ODataException::createInternalServerError( |
| 630 | 630 | Messages::queryProviderResultsMissing($methodName, $queryType) |
| 631 | 631 | ); |
| 632 | 632 | } |
| 633 | 633 | } |
| 634 | 634 | |
| 635 | - if(($queryType == QueryType::ENTITIES() || $queryType == QueryType::ENTITIES_WITH_COUNT()) && !is_array($queryResult->results)){ |
|
| 635 | + if (($queryType == QueryType::ENTITIES() || $queryType == QueryType::ENTITIES_WITH_COUNT()) && !is_array($queryResult->results)) { |
|
| 636 | 636 | throw ODataException::createInternalServerError( |
| 637 | 637 | Messages::queryProviderResultsMissing($methodName, $queryType) |
| 638 | 638 | ); |
@@ -25,16 +25,26 @@ |
||
| 25 | 25 | */ |
| 26 | 26 | public static function adjustCountForPaging($count, $top, $skip) { |
| 27 | 27 | |
| 28 | - if (!is_numeric($count)) throw new \InvalidArgumentException('$count'); |
|
| 28 | + if (!is_numeric($count)) { |
|
| 29 | + throw new \InvalidArgumentException('$count'); |
|
| 30 | + } |
|
| 29 | 31 | |
| 30 | 32 | //treat nulls like 0 |
| 31 | - if (is_null($skip)) $skip = 0; |
|
| 33 | + if (is_null($skip)) { |
|
| 34 | + $skip = 0; |
|
| 35 | + } |
|
| 32 | 36 | |
| 33 | 37 | |
| 34 | 38 | $count = $count - $skip; //eliminate the skipped records |
| 35 | - if ($count < 0) return 0; //if there aren't enough to skip, the count is 0 |
|
| 36 | - |
|
| 37 | - if (is_null($top)) return $count; //if there's no top, then it's the count as is |
|
| 39 | + if ($count < 0) { |
|
| 40 | + return 0; |
|
| 41 | + } |
|
| 42 | + //if there aren't enough to skip, the count is 0 |
|
| 43 | + |
|
| 44 | + if (is_null($top)) { |
|
| 45 | + return $count; |
|
| 46 | + } |
|
| 47 | + //if there's no top, then it's the count as is |
|
| 38 | 48 | |
| 39 | 49 | return min($count, $top); //count is top, unless there aren't enough records |
| 40 | 50 | |
@@ -67,12 +67,13 @@ |
||
| 67 | 67 | } else { |
| 68 | 68 | $writer = $service->getODataWriterRegistry()->getWriter($request->getResponseVersion(), $responseContentType); |
| 69 | 69 | //TODO: move ot Messages |
| 70 | - if (is_null($writer)) throw new \Exception("no writer can handle the request"); |
|
| 70 | + if (is_null($writer)) { |
|
| 71 | + throw new \Exception("no writer can handle the request"); |
|
| 72 | + } |
|
| 71 | 73 | |
| 72 | 74 | if (is_null($entityModel)) { //TODO: this seems like a weird way to know that the request is for a service document..i'd think we know this some other way |
| 73 | 75 | $responseBody = $writer->writeServiceDocument($service->getProvidersWrapper())->getOutput(); |
| 74 | - } |
|
| 75 | - else { |
|
| 76 | + } else { |
|
| 76 | 77 | $responseBody = $writer->write($entityModel)->getOutput(); |
| 77 | 78 | } |
| 78 | 79 | } |
@@ -98,7 +98,9 @@ |
||
| 98 | 98 | */ |
| 99 | 99 | public function decreaseIndent() |
| 100 | 100 | { |
| 101 | - if ($this->indentLevel > 0) $this->indentLevel--; |
|
| 101 | + if ($this->indentLevel > 0) { |
|
| 102 | + $this->indentLevel--; |
|
| 103 | + } |
|
| 102 | 104 | return $this; |
| 103 | 105 | } |
| 104 | 106 | |
@@ -273,8 +273,7 @@ |
||
| 273 | 273 | if ($link->isExpanded) { |
| 274 | 274 | if (is_null($link->expandedResult)) { |
| 275 | 275 | $this->_writer->writeValue("null"); |
| 276 | - } |
|
| 277 | - else { |
|
| 276 | + } else { |
|
| 278 | 277 | $this->writeExpandedLink($link); |
| 279 | 278 | } |
| 280 | 279 | } else { |
@@ -36,7 +36,9 @@ |
||
| 36 | 36 | |
| 37 | 37 | foreach ($this->writers as $writer) |
| 38 | 38 | { |
| 39 | - if ($writer->canHandle($responseVersion, $contentType)) return $writer; |
|
| 39 | + if ($writer->canHandle($responseVersion, $contentType)) { |
|
| 40 | + return $writer; |
|
| 41 | + } |
|
| 40 | 42 | } |
| 41 | 43 | |
| 42 | 44 | return null; |
@@ -625,7 +625,7 @@ |
||
| 625 | 625 | if (!empty($result)) { |
| 626 | 626 | $top = $this->request->getTopCount(); |
| 627 | 627 | $skip = $this->request->getSkipCount(); |
| 628 | - if(is_null($skip)) { |
|
| 628 | + if (is_null($skip)) { |
|
| 629 | 629 | $skip = 0; |
| 630 | 630 | } |
| 631 | 631 | |
@@ -296,7 +296,9 @@ |
||
| 296 | 296 | $inlineCount = $this->service->getHost()->getQueryStringItem(ODataConstants::HTTPQUERY_STRING_INLINECOUNT); |
| 297 | 297 | |
| 298 | 298 | //If it's not specified, we're done |
| 299 | - if (is_null($inlineCount)) return; |
|
| 299 | + if (is_null($inlineCount)) { |
|
| 300 | + return; |
|
| 301 | + } |
|
| 300 | 302 | |
| 301 | 303 | //If the service doesn't allow count requests..then throw an exception |
| 302 | 304 | if (!$this->service->getConfiguration()->getAcceptCountRequests()) { |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | $query = "SELECT * FROM `wp_posts` WHERE" |
| 189 | 189 | ." wp_posts.post_type = 'post'" |
| 190 | 190 | ." AND wp_posts.post_status = 'publish'" |
| 191 | - ." AND wp_posts.ID = ".$namedKeyValues['PostID'][0]; |
|
| 191 | + ." AND wp_posts.ID = " . $namedKeyValues['PostID'][0]; |
|
| 192 | 192 | $stmt = mysql_query($query); |
| 193 | 193 | |
| 194 | 194 | //If resource not found return null to the library |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | ." FROM `wp_terms` AS t INNER JOIN `wp_term_taxonomy` as tt" |
| 205 | 205 | ." ON tt.term_id = t.term_id" |
| 206 | 206 | ." WHERE tt.taxonomy = 'post_tag'" |
| 207 | - ." AND t.term_id = ".$namedKeyValues['TagID'][0]; |
|
| 207 | + ." AND t.term_id = " . $namedKeyValues['TagID'][0]; |
|
| 208 | 208 | $stmt = mysql_query($query); |
| 209 | 209 | |
| 210 | 210 | //If resource not found return null to the library |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | ." FROM `wp_terms` AS t INNER JOIN `wp_term_taxonomy` as tt" |
| 221 | 221 | ." ON tt.term_id = t.term_id" |
| 222 | 222 | ." WHERE tt.taxonomy = 'category'" |
| 223 | - ." AND t.term_id = ".$namedKeyValues['CategoryID'][0]; |
|
| 223 | + ." AND t.term_id = " . $namedKeyValues['CategoryID'][0]; |
|
| 224 | 224 | $stmt = mysql_query($query); |
| 225 | 225 | |
| 226 | 226 | //If resource not found return null to the library |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | case 'Comments': |
| 235 | 235 | $query = "SELECT * FROM `wp_comments`" |
| 236 | 236 | ." WHERE comment_approved = 1" |
| 237 | - ." AND comment_ID = ".$namedKeyValues['CommentID'][0]; |
|
| 237 | + ." AND comment_ID = " . $namedKeyValues['CommentID'][0]; |
|
| 238 | 238 | $stmt = mysql_query($query); |
| 239 | 239 | |
| 240 | 240 | //If resource not found return null to the library |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | $query .= " AND $filter"; |
| 324 | 324 | } |
| 325 | 325 | $stmt = mysql_query($query); |
| 326 | - if ( $stmt === false) { |
|
| 326 | + if ($stmt === false) { |
|
| 327 | 327 | die(mysql_error()); |
| 328 | 328 | } |
| 329 | 329 | |
@@ -481,7 +481,7 @@ discard block |
||
| 481 | 481 | ." ON tr.term_taxonomy_id = tt.term_taxonomy_id" |
| 482 | 482 | ." WHERE tt.taxonomy IN ('post_tag')" |
| 483 | 483 | ." AND tr.object_id IN ($sourceEntityInstance->PostID)" |
| 484 | - ." AND tt.term_id = ".$namedKeyValues['TagID'][0]; |
|
| 484 | + ." AND tt.term_id = " . $namedKeyValues['TagID'][0]; |
|
| 485 | 485 | $stmt = mysql_query($query); |
| 486 | 486 | $result = $this->_serializeTags($stmt); |
| 487 | 487 | } elseif ($navigationPropName == 'Categories') { |
@@ -493,14 +493,14 @@ discard block |
||
| 493 | 493 | ." ON tr.term_taxonomy_id = tt.term_taxonomy_id" |
| 494 | 494 | ." WHERE tt.taxonomy IN ('category')" |
| 495 | 495 | ." AND tr.object_id IN ($sourceEntityInstance->PostID)" |
| 496 | - ." AND tt.term_id = ".$namedKeyValues['CategoryID'][0]; |
|
| 496 | + ." AND tt.term_id = " . $namedKeyValues['CategoryID'][0]; |
|
| 497 | 497 | $stmt = mysql_query($query); |
| 498 | 498 | $result = $this->_serializeCategories($stmt); |
| 499 | 499 | } else if ($navigationPropName == 'Comments') { |
| 500 | 500 | $query = "SELECT * FROM `wp_comments`" |
| 501 | 501 | ." WHERE comment_approved = 1" |
| 502 | 502 | ." AND comment_post_ID = $sourceEntityInstance->PostID" |
| 503 | - ." AND comment_ID = ".$namedKeyValues['CommentID'][0]; |
|
| 503 | + ." AND comment_ID = " . $namedKeyValues['CommentID'][0]; |
|
| 504 | 504 | $stmt = mysql_query($query); |
| 505 | 505 | $result = $this->_serializeComments($stmt); |
| 506 | 506 | } else { |
@@ -519,7 +519,7 @@ discard block |
||
| 519 | 519 | ." WHERE tt.term_id = $sourceEntityInstance->TagID" |
| 520 | 520 | ." AND p.post_type = 'post'" |
| 521 | 521 | ." AND p.post_status = 'publish'" |
| 522 | - ." AND p.ID = ".$namedKeyValues['PostID'][0]; |
|
| 522 | + ." AND p.ID = " . $namedKeyValues['PostID'][0]; |
|
| 523 | 523 | $stmt = mysql_query($query); |
| 524 | 524 | $result = $this->_serializePosts($stmt); |
| 525 | 525 | } else { |
@@ -538,7 +538,7 @@ discard block |
||
| 538 | 538 | ." WHERE tt.term_id = $sourceEntityInstance->CategoryID" |
| 539 | 539 | ." AND p.post_type = 'post'" |
| 540 | 540 | ." AND p.post_status = 'publish'" |
| 541 | - ." AND p.ID = ".$namedKeyValues['PostID'][0]; |
|
| 541 | + ." AND p.ID = " . $namedKeyValues['PostID'][0]; |
|
| 542 | 542 | $stmt = mysql_query($query); |
| 543 | 543 | $result = $this->_serializePosts($stmt); |
| 544 | 544 | } else { |
@@ -556,14 +556,14 @@ discard block |
||
| 556 | 556 | ." wp_posts.post_type = 'post'" |
| 557 | 557 | ." AND wp_posts.post_status = 'publish'" |
| 558 | 558 | ." AND wp_posts.post_author = $sourceEntityInstance->UserID" |
| 559 | - ." AND wp_posts.ID = ".$namedKeyValues['PostID'][0]; |
|
| 559 | + ." AND wp_posts.ID = " . $namedKeyValues['PostID'][0]; |
|
| 560 | 560 | $stmt = mysql_query($query); |
| 561 | 561 | $result = $this->_serializePosts($stmt); |
| 562 | 562 | } elseif ($navigationPropName == 'Comments') { |
| 563 | 563 | $query = "SELECT * FROM `wp_comments`" |
| 564 | 564 | ." WHERE comment_approved = 1" |
| 565 | 565 | ." AND wp_comments.user_id = $sourceEntityInstance->UserID" |
| 566 | - ." AND wp_comments.comment_ID = ".$namedKeyValues['CommentID'][0]; |
|
| 566 | + ." AND wp_comments.comment_ID = " . $namedKeyValues['CommentID'][0]; |
|
| 567 | 567 | $stmt = mysql_query($query); |
| 568 | 568 | $result = $this->_serializeComments($stmt); |
| 569 | 569 | } else { |