- Issue created by @NathLL
- Status changed to Needs review
7 months ago 9:41am 17 May 2024
While I was trying to make an import with entity_share, I've got this error :
The website encountered an unexpected error. Please try again later. ValueError: range(): Argument #3 ($step) must not exceed the specified range in range() (line 212 of modules/contrib/entity_share/modules/entity_share_client/src/Service/ImportService.php). range(0, 49, 50) (Line: 212) Drupal\entity_share_client\Service\ImportService->importChannel(Object) (Line: 335) Drupal\entity_share_client\Form\PullForm->importChannel(Array, Object) call_user_func_array(Array, Array) (Line: 114) Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 52) Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 597) Drupal\Core\Form\FormBuilder->processForm('entity_share_client_pull_form', Array, Object) (Line: 325) Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73) Drupal\Core\Controller\FormController->getContentResult(Object, Object) call_user_func_array(Array, Array) (Line: 123) Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580) Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124) Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97) Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 169) Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81) Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58) Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48) Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106) Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85) Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 130) Drupal\cdn\StackMiddleware\DuplicateContentPreventionMiddleware->handle(Object, 1, 1) (Line: 48) Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51) Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23) Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 718) Drupal\Core\DrupalKernel->handle(Object) (Line: 26)
I've got this error through browser import AND drush import.
After investigation, The problem is due to the following reason :
In entity_share/modules/entity_share_client/src/Service/ImportService.php line 211 if the if ($channel_count >= $step)
is true function range is call with the following params : range(0, $channel_count - 1, $step);
But at this step if $channel_count = $step
then $channel_count - 1
is under $step
and then range() function return an error.
If I understand correctly, when $channel_count = $step
we need only on page to import so we don't have to go inside the if line 211. We have to go inside the else line 224.
So here my proposed resolution :
Change if ($channel_count >= $step) {
line 211
by if ($channel_count > $step) {
I've made some tests and it seems to not have impacts.
Needs review
3.0
Entity Share Client