Drupal version:
branch 8.x
devel version:
branch 8.x-1.x
How to reproduce:
1) Minimal D8 installation
2) enable Devel module
3) enable query log with default settings
4) navigate to homepage.
Displays notices:
Notice: Undefined index: file in Drupal\Core\Database\Log->findCaller() (line 159 of core/lib/Drupal/Core/Database/Log.php).
Notice: Undefined index: line in Drupal\Core\Database\Log->findCaller() (line 160 of core/lib/Drupal/Core/Database/Log.php).
Notice: Undefined index: file in Drupal\Core\Database\Log->findCaller() (line 159 of core/lib/Drupal/Core/Database/Log.php).
Notice: Undefined index: line in Drupal\Core\Database\Log->findCaller() (line 160 of core/lib/Drupal/Core/Database/Log.php).
AND
Doesn't display query log.
Comment | File | Size | Author |
---|---|---|---|
#24 | log-notice-1739808-24.D7.test-only.patch | 1.23 KB | salvis |
#24 | log-notice-1739808-24.D7.patch | 2.59 KB | salvis |
#22 | findCaller_notice.png | 24.71 KB | salvis |
#2 | LogFindCaller.1739808.2.patch | 591 bytes | salvis |
#14 | log-notice-1739808-14.patch | 2.99 KB | Berdir |
Comments
Comment #1
salvisYes, I see that, too. Pretty nasty display...
Comment #2
salvisThis is a bug in core. Log->findCaller() ignores the fact that the debug_backtrace() may not have file/line information for some of the calls on the stack. Here's what we get multiple times in the case that the OP describes:
Specifically, in the call stack above, node_page_default() does not have file/line information (in PHP 5.3.8), and that's what trips up findCaller() .
Another issue presumably caused by this bug:
#1404854: Undefined index/offset error in "DatabaseLog->findCaller"
According to
#1323134: Request ability to have CCK module NOT evaluate (fire) default/allowed value PHP code when editing a field
Unknown error messages due to PHP-script in block.
#1434146: Notice: Undefined index: args en DatabaseLog->findCaller() (line 154 de /includes/database/log.inc
'args' can also be undefined, so we may as well default-initialize that one, too.
The attached tiny patch fixes this issue.
EDIT: Somehow the screenshot got broken and I have to edit the comment to refresh some cache, apparently.
Comment #3
salvis#1397178: Undefined index: args dans DatabaseLog->findCaller() marked as a duplicate of this.
Comment #4
BerdirNoticed this myself as well.
Attaching a patch that improves this a bit by actually ignoring these as well, they are due using call_user_func_array() which is not helpful in any way and also added test coverage.
Comment #6
BerdirTestbot, what are you doing?
Comment #7
salvisThanks, Berdir!
After dropping the 'and' you need a comma now, as well as a comma before the succeeding 'and'.
The last comment line is way too long (>80).
Why is it not a legitimate caller, just because
empty($stack[$i]['file'])
? I think this should remain unchanged.Comment #8
BerdirIt is legitimate, but it is not useful. The purpose of that function is to give you an idea where the query was executed. If there is no file, then we can IMHO be sure that it's not helpful in any way because it's something like call_user_func_array. See the test, without that check it would give you "call_user_func_array" as the caller and not the test method.
Comment #9
salvisAgreed.
Do we also need a DBTNG test for the class case?
Comment #10
BerdirNot sure what you mean, the namespace/class stuff is already covered because db_query() goes through various methods on classes within the database namespace and they are correctly ignored. So this just needs a re-roll for the comment changes.
Comment #11
salvisOk, never mind.
Comment #12
BerdirFixed the comment.
Comment #13
salvisYou posted the wrong patch file.
Comment #14
BerdirTrue. This one should be good. the interdiff was the right now.
Comment #15
salvisLooks good, thanks!
Comment #16
GrzegorzNowak CreditAttribution: GrzegorzNowak commentedI can confirm - that this patch removed the notice and query log is now displayed on "more" pages, but:
there still remains the issue of query log not being displayed on front page (whereas it seems to be displayed elsewhere).
Comment #17
salvisYou're probably referring to #1748082: "Fatal error: [] operator not supported for strings" from the query log. I fixed that yesterday. Be sure to get the very latest -dev of Devel.
If that doesn't help, then open a new issue in the Devel queue. IAC it's unrelated to this issue here.
Comment #18
GrzegorzNowak CreditAttribution: GrzegorzNowak commentedIndeed - pulling the latest from Devel repo resolved the problem. Thanks!
Comment #19
BerdirIt's fixed when it's commited. What you should do is set the status to reviewed and tested by the community, so that it can get commited.
Comment #20
GrzegorzNowak CreditAttribution: GrzegorzNowak commentedRoger that.
ps. great job guys!
Comment #21
corvus_ch CreditAttribution: corvus_ch commentedJep, that one does its job.
Verified with manual testing. Reproduced by following the the steps in the issue description. Then applied the patch an the notice was gone. (Devel version in use 8.x-1.x-dev).
Comment #22
salvis(somehow the image in #2 was lost — here it is again)
Comment #23
webchickCommitted and pushed to 8.x! Thanks!
Moving to 7.x for backport.
Comment #24
salvisBackported to D7.
Comment #25
BerdirBackport looks good.
Comment #26
David_Rothstein CreditAttribution: David_Rothstein commentedCommitted to 7.x - thanks! http://drupalcode.org/project/drupal.git/commit/02cf68d
Comment #28
gielfeldt CreditAttribution: gielfeldt commentedI'm getting this error too now. Looking at the patches, doesn't 'args' reside in $stack[$i + 1] and not $stack[$i] ?
Comment #29
gielfeldt CreditAttribution: gielfeldt commentedComment #30
salvis@gielfeldt: It doesn't make sense to reopen this old issue that was fixed and hasn't received any complaint in 3 years. Please open a new issue with all the relevant information.
Comment #31
kenorb CreditAttribution: kenorb commentedRelated: #2225443: Undefined index: file (line 2017)