Editing anything on my block views triggers the following logs:
Notice: Undefined index: allow in Drupal\ctools_views\Plugin\Display\Block->buildOptionsForm() (regel 50 van C:\xampp\htdocs\myproject\modules\ctools\modules\ctools_views\src\Plugin\Display\Block.php).
Notice: Undefined index: #default_value in Drupal\ctools_views\Plugin\Display\Block->buildOptionsForm() (regel 59 van C:\xampp\htdocs\myproject\modules\ctools\modules\ctools_views\src\Plugin\Display\Block.php).
Warning: array_filter() expects parameter 1 to be array, null given in Drupal\ctools_views\Plugin\Display\Block->buildOptionsForm() (regel 59 van C:\xampp\htdocs\myproject\modules\ctools\modules\ctools_views\src\Plugin\Display\Block.php).
Very simple view with the following settings:
- Block
- HTML-list
- Teaser format
- Filter: Publishing status (=Yes)
- Filter: Content type (= Testimonials)
- Relation: Entity Queue - Testimonials - required
- Sort: Entity Queue - Position - Ascending
- Pagination - limit to 5 items
| Comment | File | Size | Author |
|---|---|---|---|
| #53 | ctools-Block.php_notices_and_warnings-2820783-53-D8.patch | 1.48 KB | thalles |
| #41 | fixblockpager-2820783-41.patch | 1.84 KB | t-lo |
Comments
Comment #2
Joram commentedComment #3
Joram commentedComment #4
Joram commentedComment #5
jzavrl commentedI got this as well, even with a very simple views block. After investigating I've seen that the function gets called when you are opening the options form for every section in the view config. Checked how the default core views block display plugin works and adjusted the code accordingly. Attached is a patch with the changes.
Comment #6
jzavrl commentedReattached to submit for testing.
Comment #7
darrenwh commentedRemoved #5 file from view
Comment #8
japerryComment #9
hongpong commentedThis is good but I had to add
if (isset($defaults)) {
$form['allow']['#default_value'] = $defaults;
}
after the switch. when i was trying to switch around 'pagerer' in block controls. Also had trouble applying patch. but got ahead with this (error was that $defaults was undefined after I applied the patch):
Comment #11
hongpong commentedBoo hoo trailing whitespace. deleted that line.
Comment #12
hongpong commentednot sure why that didn't trigger tests. come on now.
Comment #14
jzavrl commentedNot sure that's the correct play there. The
$defaultsare only being set inside theswitchstatement, so there might be a better way to do this. What were the steps to reproduce your issue?Comment #15
hongpong commentedjzavrl I have not had time to reproduce this, but it was a view with a block and a page. I couldn't get to the view's pager controls popup on the block display ( to switch the pager off, as it was turned on) without getting back ajax 500 errors like those above. Being unclear on the nature of the function I just kept the isset as a separate statement from the switch, but yes I bet they could go together. Just conveying how the patch helped me get around the fatal error successfully, and save the results from the popup.
Comment #16
darrenwh commentedCould this array declaration be set out as per DCS https://www.drupal.org/docs/develop/standards/coding-standards#array
Somthing like:
Then
Comment #17
damienmckennaPunting this to beta2.
Comment #18
damienmckennaLets bump this so that beta2 can be rolled out.
Comment #19
t-loComment #20
darrenwh commentedTidy up
Comment #21
t-loThis was blocking me today so here's a re-roll and an update:
Changed the array declaration as per suggestion by @darrenwh, and as $form['allow']['#options'] is fully overwritten anyway.
Comment #22
t-loComment #23
t-loComment #25
t-loPassed testing second time around, seems to have been an issue with the test server
Comment #26
darrenwh commentedThe indentation is slightly off here
The interdiff is giving an error when previewed (Unexpected request?)
Comment #27
t-loComment #28
t-loIndentation fixed and new interdiff created.
Comment #29
me5h commentedTested in preproduction and is working as expected.
Comment #30
rvanderh1 commentedI'm also getting this error:
Notice: Undefined index: allow in Drupal\ctools_views\Plugin\Display\Block->buildOptionsForm() (line 46...
Whenever I go to edit a block view, even though I'm using ctools 8.x-3.0+3-dev (dated 11 July 2017).
Comment #31
t-lo@rvanderh1 This fix hasn't been committed yet, apply the patch in comment #28 and it should resolve the issue.
Comment #32
rvanderh1 commentedOK, thanks. The patch resolved the issue. When do you think the fix will be committed?
Comment #33
mattltPatch fixed multiple issues we were having with ajax and editing multiple options inside a block view.
Thanks,
•• matt
Comment #34
Christopher Riley commentedPatched fixed multiple issues for me as well I will be glad when this is committed.
Comment #35
adriancid+1 RTBC for me too.
Comment #36
dunebl#28 solve my problem too...
Comment #37
sneo commented#28 solve it for me too, would be great if this could be up soon :D
Comment #38
markpavlitski commented+1 for RTBC. Patch applies cleanly and fixes a number of interface issues.
Comment #39
joelpittetThanks for testing this out, I'm looking to commit this but want to check on a small thing.
nit: this should likely be a an if statement don't you think, or is there plans to break off other section's?
Comment #40
t-loComment #41
t-lo@joelpittet good point, I've swapped that for an if statement. If other sections need breaking out in the future, a switch can be implemented then.
Comment #42
t-loComment #43
renrhafPatch from #41 fixed the issue for me (Drupal 8.6.1)
Comment #44
mattltHello,
Patch from #41 no longer applies cleanly due to this similar issue that was recently committed…
https://www.drupal.org/node/2978750
Thanks,
•• matt
Comment #45
joelpittetAh didn't see they were touching, this needs a reroll.
Comment #46
suit4 commentedSame here, got ajax error undefined index: allow in Drupal\ctools views\Plugin\Display\Block->buildOptionsForm() ...
#41 seems to fix the issue, if Block.php is unpatched.
Comment #47
suit4 commentedTried to build a combined patch.
Comment #48
thallesFollow the patch!
Comment #49
joelpittet!empty() does an implicit isset(), so calling isset() before !empty() is a bit redundant.
I've lost track what this patch is fixing, can anybody tell me?
Comment #50
thallesYou're right!
On php.net
"empty() is the opposite of (boolean) var, except that no warning is generated when the variable is not set."
So essentially
is the same as
doesn't it? :)
!empty() mimics the chk() function posted before.
Comment #51
thallesFollow the patch!
Comment #52
joelpittetI could see how this could still produce a warning and notice and the patch doesn't seem to fix that possiblitity.
This code
$options = $form['allow']['#options'];before copied the allow options passed in (when they exist) and the new code$form['allow']['#options'] = [...]clobbers any options that are passed in already.The original issue is
Notice: Undefined index: allowSo we could just set those values individually:
$form['allow']['#options']['offset'] = $this->t('Pager offset');Comment #53
thallesFollow!
Comment #54
joelpittet@thalles and I can't seem to find where this original notice stems from. Could someone help by letting us know where or at least running across this issue and letting us know if the patch in #53 resolves it?
Thanks for the patch @thalles!
Comment #55
AnaSwin commentedPatch worked for me (Drupal 8.6.10, PHP 7.2) Thx :)
Comment #56
thallesHow can I test?
Comment #57
seros-me commentedPatch worked for me too!!
Thanks for the patch @thalles!
Drupal 8.6.10, PHP 7.2
Comment #58
thalles@seros-me, how can I test?
Comment #59
hongpong commented@thalles in my case, originally, with "pagerer" module enabled, and a block set to be paginated, i could trigger the error by attempting to disable the pager. Attached to a view was a block and a page. Inside Views UI: I couldn't get to the view's pager controls popup on the block display ( to switch the pager off, as it was turned on) without getting back ajax 500 errors like those above.
Comment #60
thalles@HongPong, after the patch the bug has been fixed?
Comment #61
thallesComment #62
joelpittetIdeally it would be nice to know "what" was fixed with this patch but I could imagine. Thanks for helping @thalles, I've committed this to the latest dev release.
Comment #64
thallesThanks @joelpittet!
Thanks all!
Comment #66
eblue commentedI'm still experiencing this issue as referenced in https://www.drupal.org/project/ctools/issues/3038160. I only get the AJAX error on new views I create on my local, not ones from core.
Undefined index: allow in /Users/digitalechidna/Sites/caaspr/docroot/modules/contrib/ctools/modules/ctools_views/src/Plugin/Display/Block.php on line 57
Comment #67
t-lo@eblue this was committed after the most recent release, so it's only fixed in the development branch currently.
You can apply the patch above to fix the issue until there's a new release