Problem/Motivation
In FinalExceptionSubscriber I see this code which removes the first backtrace item for output:
$backtrace = $backtrace_exception->getTrace();
// First trace is the error itself, already contained in the message.
// While the second trace is the error source and also contained in the
// message, the message doesn't contain argument values, so we output it
// once more in the backtrace.
array_shift($backtrace);
The problem: The first backtrace item contains a line number which is _not_ present in the message.
The reason is that the file name and line number of a backtrace item is not where the function is defined, but where it is called.
Steps to reproduce
Inject a bug that triggers the exception handler.
Enable full error reporting.
Expected message (example):
InvalidArgumentException: A valid cache entry key is required. Use getAll() to get all table data. in Drupal\views\ViewsData->get() (line 128 of core/modules/views/src/ViewsData.php).
Drupal\views\ViewsData->get() (Line: 311)
Drupal\views\Plugin\views\query\QueryPluginBase->getEntityTableInfo() (Line: 105)
Actual message (example):
InvalidArgumentException: A valid cache entry key is required. Use getAll() to get all table data. in Drupal\views\ViewsData->get() (line 128 of core/modules/views/src/ViewsData.php).
Drupal\views\Plugin\views\query\QueryPluginBase->getEntityTableInfo() (Line: 105)
We see that line number 311 is nowhere to be found in the "actual" part.
Proposed resolution
Don't call array_shift() on the backtrace.
Optionally remove the function name from the message to avoid redundancy.
Check if there are more places like this.
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
Issue fork drupal-3564356
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
donquixote commentedI find these other places with a very simple search:
Comment #4
donquixote commentedLet's see what CI says.
Comment #5
quietone commentedJust updating version.
Comment #6
smustgrave commentedThis broke some functional tests which may show why this is needed?
Looking at the expected message though isn't it just repeating what's in the error?
Comment #7
donquixote commentedThe fail is inherent to 11.0.x branch. Changed the base to 11.x now.