NCIOCPL / cgov-digital-platform

The Cancer.gov Digital Communications Platform
GNU General Public License v2.0
11 stars 33 forks source link

Blog Post: Cannot add category before internal links #3184

Open VictoriaSunNIH opened 2 years ago

VictoriaSunNIH commented 2 years ago

Issue description

On Production, if I select a blog category, I run into an issue with adding an internal link, where an "Illegal choice has been made" I should be able to add a blog category and internal links, and they should not be inter-related.

image

NOTE: there is a workaround, users can add internal links FIRST before selecting one or more categories.

ESTIMATE TBD

Steps to reproduce the issue

  1. Create or edit a blog post
  2. Select a blog series, and a blog category
  3. Once you select a blog category, try to add an internal link to related resources. You will get the error.
  4. Similarly, try to add an internal featured post. You will also get the error.

What's the expected result?

We should be able to add internal links and cards, regardless if there is a blog category selected.

What's the actual result?

Right now, once the blog category is selected, we cannot add internal links.

Additional details / screenshot

Looks like this might have been introduced in #2382

Related Tickets

bryanpizzillo commented 2 years ago

The stack trace below is appearing in the logs. It looks like this code was added in #2382. This probably has something to do with how the entity_embed button works -- I believe it does a post-back for the page.

Notice: Undefined offset: 0 in cgov_blog_form_alter() (line 44 of /mnt/www/html/ncigov01dev/docroot/profiles/custom/cgov_site/modules/custom/cgov_blog/cgov_blog.module)
#0 /mnt/www/html/ncigov01dev/docroot/core/includes/bootstrap.inc(600): _drupal_error_handler_real(8, 'Undefined offse...', '/mnt/www/html/n...', 44, Array)
#1 /mnt/www/html/ncigov01dev/docroot/profiles/custom/cgov_site/modules/custom/cgov_blog/cgov_blog.module(44): _drupal_error_handler(8, 'Undefined offse...', '/mnt/www/html/n...', 44, Array)
#2 /mnt/www/html/ncigov01dev/docroot/core/lib/Drupal/Core/Extension/ModuleHandler.php(539): cgov_blog_form_alter(Array, Object(Drupal\Core\Form\FormState), 'node_cgov_blog_...')
#3 /mnt/www/html/ncigov01dev/docroot/core/lib/Drupal/Core/Form/FormBuilder.php(836): Drupal\Core\Extension\ModuleHandler->alter('form', Array, Object(Drupal\Core\Form\FormState), 'node_cgov_blog_...')
#4 /mnt/www/html/ncigov01dev/docroot/core/lib/Drupal/Core/Form/FormBuilder.php(430): Drupal\Core\Form\FormBuilder->prepareForm('node_cgov_blog_...', Array, Object(Drupal\Core\Form\FormState))
#5 /mnt/www/html/ncigov01dev/docroot/core/lib/Drupal/Core/Form/FormBuilder.php(629): Drupal\Core\Form\FormBuilder->rebuildForm('node_cgov_blog_...', Object(Drupal\Core\Form\FormState), Array)
#6 /mnt/www/html/ncigov01dev/docroot/core/lib/Drupal/Core/Form/FormBuilder.php(321): Drupal\Core\Form\FormBuilder->processForm('node_cgov_blog_...', Array, Object(Drupal\Core\Form\FormState))
#7 /mnt/www/html/ncigov01dev/docroot/core/lib/Drupal/Core/Controller/FormController.php(91): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\node\NodeForm), Object(Drupal\Core\Form\FormState))
#8 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch))
#9 /mnt/www/html/ncigov01dev/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#10 /mnt/www/html/ncigov01dev/docroot/core/lib/Drupal/Core/Render/Renderer.php(573): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#11 /mnt/www/html/ncigov01dev/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#12 /mnt/www/html/ncigov01dev/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#13 [internal function]: Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#14 /mnt/www/html/ncigov01dev/vendor/symfony/http-kernel/HttpKernel.php(151): call_user_func_array(Object(Closure), Array)
#15 /mnt/www/html/ncigov01dev/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#16 /mnt/www/html/ncigov01dev/docroot/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#17 /mnt/www/html/ncigov01dev/docroot/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#18 /mnt/www/html/ncigov01dev/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#19 /mnt/www/html/ncigov01dev/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#20 /mnt/www/html/ncigov01dev/docroot/modules/contrib/shield/src/ShieldMiddleware.php(91): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#21 /mnt/www/html/ncigov01dev/docroot/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\shield\ShieldMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#22 /mnt/www/html/ncigov01dev/docroot/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#23 /mnt/www/html/ncigov01dev/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#24 /mnt/www/html/ncigov01dev/docroot/core/lib/Drupal/Core/DrupalKernel.php(708): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#25 /mnt/www/html/ncigov01dev/docroot/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#26 {main}
andyvanavery31 commented 1 month ago

Unable to reproduce the issue with the internal link to related resources, but the error with blog category is still happening.