Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Slim 3 usage error #452

Closed
jiaojie1989 opened this issue Dec 2, 2020 · 3 comments · Fixed by #460
Closed

BUG: Slim 3 usage error #452

jiaojie1989 opened this issue Dec 2, 2020 · 3 comments · Fixed by #460

Comments

@jiaojie1989
Copy link

jiaojie1989 commented Dec 2, 2020

When I use clockwork version 5.0.4 with slim 3.8.4,

$app = new Slim\App(...);
$app->add(new Clockwork\Support\Slim\Legacy\ClockworkMiddleware(__DIR__ . '/storage/clockwork'));

I find errors as following:

1 /srv/proj/pass/vendor/itsgoingd/clockwork/Clockwork/Clockwork.php:233 - 0.108 - 
[message] => Call to undefined method Clockwork\Request\Request::getTimeline() [debugtrace] => 

#0 /srv/proj/pass/vendor/itsgoingd/clockwork/Clockwork/Support/Slim/Legacy/ClockworkMiddleware.php(85): 
Clockwork\Clockwork->__call('getTimeline', Array) 
#1 /srv/proj/pass/vendor/itsgoingd/clockwork/Clockwork/Support/Slim/Legacy/ClockworkMiddleware.php(45): 
Clockwork\Support\Slim\Legacy\ClockworkMiddleware->logRequest(Object(Slim\Http\Request), Object(Slim\Http\Response)) 

#2 /srv/proj/pass/vendor/itsgoingd/clockwork/Clockwork/Support/Slim/Legacy/ClockworkMiddleware.php(27): 
Clockwork\Support\Slim\Legacy\ClockworkMiddleware->process(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Slim\App)) 

#3 [internal function]: Clockwork\Support\Slim\Legacy\ClockworkMiddleware->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Slim\App)) 

#4 /srv/proj/pass/vendor/slim/slim/DeferredCallable.php(43): 
call_user_func_array(Object(Clockwork\Support\Slim\Legacy\ClockworkMiddleware), Array) 

#5 [internal function]: Slim\DeferredCallable->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Slim\App)) 

#6 /srv/proj/pass/vendor/slim/slim/MiddlewareAwareTrait.php(73): 
call_user_func(Object(Slim\DeferredCallable), Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Slim\App)) 

#7 /srv/proj/pass/vendor/slim/slim/MiddlewareAwareTrait.php(122): 
Slim\App->Slim\{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response)) 

#8 /srv/proj/pass/vendor/slim/slim/App.php(375): 
Slim\App->callMiddlewareStack(Object(Slim\Http\Request), Object(Slim\Http\Response)) 

#9 /srv/proj/pass/vendor/slim/slim/App.php(301): 
Slim\App->process(Object(Slim\Http\Request), Object(Slim\Http\Response)) 

#10 /srv/proj/pass/Public/index.php(18): Slim\App->run() 

#11 {main} 

File Clockwork\Support\Slim\Legacy\ClockworkMiddleware.php, Line 85

protected function logRequest(Request $request, Response $response)
	{
		$this->clockwork->getTimeline()->finalize($this->startTime);
		$this->clockwork->addDataSource(new PsrMessageDataSource($request, $response));

		$this->clockwork->resolveRequest();
		$this->clockwork->storeRequest();

		$clockworkRequest = $this->clockwork->request();

		$response = $response
			->withHeader('X-Clockwork-Id', $clockworkRequest->id)
			->withHeader('X-Clockwork-Version', Clockwork::VERSION);

		if ($basePath = $request->getUri()->getBasePath()) {
			$response = $response->withHeader('X-Clockwork-Path', $basePath);
		}

		return $response->withHeader('Server-Timing', ServerTiming::fromRequest($clockworkRequest)->value());
	}

SHOULD be $this->clockwork->timeline()->finalize($this->startTime);

@jiaojie1989 jiaojie1989 changed the title Slim 3 usage error BUG: Slim 3 usage error Dec 2, 2020
@itsgoingd
Copy link
Owner

Hey, yes indeed, this should be changed in all Slim middleware. Would you like to make a PR or let me fix it?

@jiaojie1989
Copy link
Author

You may fix it in next version, many thanks to you.

@seanhamlin
Copy link
Contributor

seanhamlin commented Dec 14, 2020

Just found this same issue in Slim 4.7.1:

Call to undefined method Clockwork\\Request\\Request::getTimeline()

I might have a crack at a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants