mirror of
https://github.com/friendica/friendica
synced 2025-04-22 18:30:13 +00:00
Make BaseModule
a real entity
- Add all dependencies, necessary to run the content (baseUrl, Arguments) - Encapsulate all POST/GET/DELETE/PATCH/PUT methods as protected methods inside the BaseModule - Return Module content ONLY per `BaseModule::run()` (including the Hook logic there as well)
This commit is contained in:
parent
238613fd01
commit
8bdd90066f
252 changed files with 615 additions and 623 deletions
|
@ -27,8 +27,39 @@ use Friendica\Network\HTTPException;
|
|||
|
||||
class PageNotFound extends BaseModule
|
||||
{
|
||||
public function content(): string
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
throw new HTTPException\NotFoundException(DI::l10n()->t('Page not found.'));
|
||||
}
|
||||
|
||||
public function run(array $post = [], array $request = []): string
|
||||
{
|
||||
/* The URL provided does not resolve to a valid module.
|
||||
*
|
||||
* On Dreamhost sites, quite often things go wrong for no apparent reason and they send us to '/internal_error.html'.
|
||||
* We don't like doing this, but as it occasionally accounts for 10-20% or more of all site traffic -
|
||||
* we are going to trap this and redirect back to the requested page. As long as you don't have a critical error on your page
|
||||
* this will often succeed and eventually do the right thing.
|
||||
*
|
||||
* Otherwise we are going to emit a 404 not found.
|
||||
*/
|
||||
$queryString = $this->server['QUERY_STRING'];
|
||||
// Stupid browser tried to pre-fetch our Javascript img template. Don't log the event or return anything - just quietly exit.
|
||||
if (!empty($queryString) && preg_match('/{[0-9]}/', $queryString) !== 0) {
|
||||
exit();
|
||||
}
|
||||
|
||||
if (!empty($queryString) && ($queryString === 'q=internal_error.html') && isset($dreamhost_error_hack)) {
|
||||
$this->logger->info('index.php: dreamhost_error_hack invoked.', ['Original URI' => $this->server['REQUEST_URI']]);
|
||||
$this->baseUrl->redirect($this->server['REQUEST_URI']);
|
||||
}
|
||||
|
||||
$this->logger->debug('index.php: page not found.', [
|
||||
'request_uri' => $this->server['REQUEST_URI'],
|
||||
'address' => $this->server['REMOTE_ADDR'],
|
||||
'query' => $this->server['QUERY_STRING']
|
||||
]);
|
||||
|
||||
return parent::run($post, $request); // TODO: Change the autogenerated stub
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue