Skip to content

Commit

Permalink
Add debugging output for bad cache result
Browse files Browse the repository at this point in the history
The $result should only ever be an EngineResult, but in some
circumstances it's returning an array. This adds some debugging
output for this, so we can track down what's going on.

Bug: T345035
  • Loading branch information
samwilson authored Sep 11, 2023
1 parent b139f0c commit a81195a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Controller/OcrController.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ private function getResult( string $invalidLangsMode ): EngineResult {
]
) );

return $this->cache->get( $cacheKey, function ( ItemInterface $item ) use ( $invalidLangsMode ) {
$result = $this->cache->get( $cacheKey, function ( ItemInterface $item ) use ( $invalidLangsMode ) {
$item->expiresAfter( (int)$this->getParameter( 'cache_ttl' ) );
return $this->engine->getResult(
static::$params['image'],
Expand All @@ -361,5 +361,9 @@ private function getResult( string $invalidLangsMode ): EngineResult {
static::$params['langs']
);
} );
if ( !$result instanceof EngineResult ) {
throw new Exception( 'Incorrect (possibly cached) result: ' . var_export( $result, true ) );
}
return $result;
}
}

0 comments on commit a81195a

Please sign in to comment.