- Issue created by @solideogloria
- Status changed to Needs review
over 1 year ago 7:42am 27 July 2023 - last update
over 1 year ago 86 pass - 🇮🇳India sahil.goyal
Creating and updating the patch, now after getting config import when we try to save/submit the config from, it saves without notifying any error, and works as expected, Moving to NeedsReview. Thanx
- Status changed to Needs work
over 1 year ago 2:21pm 27 July 2023 This doesn't fix the issue completely. Submitting the form calls this code:
public function submitForm(array &$form, FormStateInterface $form_state) { $config = $this->config('linkchecker.settings'); // @todo Move it to setting save hook. if ((int) $config->get('check.connections_max') != (int) $form_state->getValue('linkchecker_check_connections_max')) { $this->linkCheckerService->queueLinks(TRUE); }
Because the config was deleted prior to saving the form,
queueLinks
will be called, becausecheck.connections_max
will returnNULL
.In the LinkcheckerService, it will then run this:
$linkIds = array_column($linkIds, 'lid_min'); $maxConnections = $this->linkcheckerSetting->get('check.connections_max'); // Split ids by max connection amount to make possible send concurrent // requests. $linkIds = array_chunk($linkIds, $maxConnections);
Since
$maxConnections
will beNULL
, it throws an error, becausearray_chunk
requires an array.This change fixes it:
if (!empty($config->get('check.connections_max')) && (int) $config->get('check.connections_max') != (int) $form_state->getValue('linkchecker_check_connections_max')) { $this->linkCheckerService->queueLinks(TRUE); }
- Merge request !50Issue #3377179: PHP errors when saving settings form → (Open) created by solideogloria
- last update
over 1 year ago 86 pass - Status changed to Needs review
over 1 year ago 2:41pm 27 July 2023 - last update
over 1 year ago 86 pass This is just the same as above, for linking in a composer.patches.json file.
- First commit to issue fork.
- Merge request !61Issue #3377179: PHP errors when saving settings form → (Open) created by maskedjellybean
- last update
about 1 year ago 86 pass - Status changed to Needs work
about 1 year ago 8:30pm 22 February 2024 @maskedjellybean You wrongly removed the for loop.
Compare your changes with the prior MR.
- last update
about 1 year ago 86 pass - Status changed to Needs review
about 1 year ago 8:47pm 22 February 2024 - 🇺🇸United States maskedjellybean Portland, OR
Oops, fixed the accidental foreach loop deletion.
The patch from #7 does not apply cleanly against branch 2.0.x because it's based on 8.x.1.x. For those needing a fix for branch 2.0.x (I tested against module version 2.0.0-alpha2), see the MR I created which replicates/rerolls the changes against 2.0.x, or here's a link to the patch:
https://git.drupalcode.org/project/linkchecker/-/merge_requests/61.patch
Thank you for the fix!
For those applying these patches: After applying, you need to save the form at /admin/config/content/linkchecker before the fixes will take affect. I came to this thread because cron was failing with:
ValueError: array_chunk(): Argument #2 ($length) must be greater than 0 in array_chunk() (line 132 of /app/docroot/modules/contrib/linkchecker/src/LinkCheckerService.php).
So this wasn't obvious to me.
Once you have saved the form once with the patch applied, if you remove the patch does it still work? That was my experience, so I don't need the patch anymore.