Skip to content

Commit

Permalink
Use http constants where appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
flack committed Feb 22, 2024
1 parent 1154fec commit e155c68
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion lib/midcom/application.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use midcom\bundle\midcomBundle;
use Symfony\Component\HttpFoundation\Response;

/**
* Main controlling instance of the MidCOM Framework
Expand Down Expand Up @@ -315,7 +316,7 @@ public function header(string $header, int $response_code = 0)
* midcom_finish and exit, so it will never return. If the headers have already
* been sent, this will leave you with a partially completed page, so beware.
*/
public function relocate(string $url, int $response_code = 302)
public function relocate(string $url, int $response_code = Response::HTTP_FOUND)
{
$response = new midcom_response_relocate($url, $response_code);
$response->send();
Expand Down
2 changes: 1 addition & 1 deletion lib/midcom/baseclasses/components/handler/rest.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ protected function _process_request() : JsonResponse

// no response has been set
if ($this->_response === null) {
$this->_stop('Could not handle request, unknown method', 405);
$this->_stop('Could not handle request, unknown method', Response::HTTP_METHOD_NOT_ALLOWED);
}
} catch (midcom_error $e) {
$this->_responseStatus = $e->getCode();
Expand Down
2 changes: 1 addition & 1 deletion lib/midcom/core/urlmethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function process_permalink(string $guid) : Response
}

// We use "302 Found" here so that search engines and others will keep using the PermaLink instead of the temporary
return new midcom_response_relocate($destination, 302);
return new midcom_response_relocate($destination, Response::HTTP_FOUND);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/net/nemein/wiki/handler/notfound.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function _handler_notfound(string $wikiword, array &$data)
$result = $qb->execute();
if (!empty($result)) {
// This wiki page actually exists, so go there as "Permanent Redirect"
return new midcom_response_relocate("{$result[0]->name}/", 301);
return new midcom_response_relocate("{$result[0]->name}/", Response::HTTP_MOVED_PERMANENTLY);
}

midcom::get()->head->set_pagetitle(sprintf($this->_l10n->get('"%s" not found'), $wikiword));
Expand Down
3 changes: 2 additions & 1 deletion lib/net/nemein/wiki/handler/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

use midcom\datamanager\datamanager;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

/**
* Wikipage view handler
Expand Down Expand Up @@ -116,7 +117,7 @@ private function _load_page(string $wikiword, bool $autocreate = true)
$result = $qb->execute();
if (!empty($result)) {
// This wiki page actually exists, so go there as "Permanent Redirect"
return new midcom_response_relocate($this->router->generate('view', ['wikipage' => $result[0]->name]), 301);
return new midcom_response_relocate($this->router->generate('view', ['wikipage' => $result[0]->name]), Response::HTTP_MOVED_PERMANENTLY);
}
}
if ($autocreate) {
Expand Down

0 comments on commit e155c68

Please sign in to comment.