ebsco / edsapi-drupal-plugin

A Drupal modules for the EBSCO Discovery Services API
Apache License 2.0
1 stars 3 forks source link

Can't get 8.1.1 to work #53

Open abbydrury opened 3 years ago

abbydrury commented 3 years ago

We're running Drupal 8.9.19 and are attempting to upgrade from v0.2 of this module to v8.1.1 of this module. When I execute a search in v8.1.1 that previously worked in v0.2, the search fails and I get a pile of errors (I think 36 for every query). The first one is this:

#0 /app/web/core/includes/bootstrap.inc(600): _drupal_error_handler_real(8, 'Undefined prope...', '/app/web/module...', 896, Array)
#1 /app/web/modules/contrib/edsapi-drupal8-plugin/lib/EBSCOResponse.php(896): _drupal_error_handler(8, 'Undefined prope...', '/app/web/module...', 896, Array)
#2 /app/web/modules/contrib/edsapi-drupal8-plugin/lib/EBSCOResponse.php(95): EBSCOResponse->buildCitationStyles()
#3 /app/web/modules/contrib/edsapi-drupal8-plugin/lib/EBSCOAPI.php(346): EBSCOResponse->result()
#4 /app/web/modules/contrib/edsapi-drupal8-plugin/lib/EBSCOAPI.php(147): EBSCOAPI->apiAuthenticationToken()
#5 /app/web/modules/contrib/edsapi-drupal8-plugin/lib/EBSCOAPI.php(267): EBSCOAPI->authenticationToken()
#6 /app/web/modules/contrib/edsapi-drupal8-plugin/lib/EBSCOAPI.php(711): EBSCOAPI->request('Info')
#7 /app/web/modules/contrib/edsapi-drupal8-plugin/lib/EBSCODocument.php(238): EBSCOAPI->apiInfo()
#8 /app/web/modules/contrib/edsapi-drupal8-plugin/lib/EBSCODocument.php(327): EBSCODocument->info()
#9 /app/web/modules/custom/lits_search/src/EdsapiWrapper.php(197): EBSCODocument->search()
#10 /app/web/modules/custom/lits_search/src/Controller/UnifiedSearchController.php(448): Drupal\lits_search\EdsapiWrapper->search(Array, 'library')
#11 /app/web/modules/custom/lits_search/src/Controller/UnifiedSearchController.php(345): Drupal\lits_search\Controller\UnifiedSearchController->searchLibrary(Object(Symfony\Component\HttpFoundation\Request), 'library')
#12 [internal function]: Drupal\lits_search\Controller\UnifiedSearchController->searchAsynch('library', Object(Symfony\Component\HttpFoundation\Request))
#13 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#14 /app/web/core/lib/Drupal/Core/Render/Renderer.php(573): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#15 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#16 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#17 /app/vendor/symfony/http-kernel/HttpKernel.php(151): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#18 /app/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#19 /app/web/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#20 /app/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#21 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#22 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#23 /app/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#24 /app/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#25 /app/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#26 /app/web/core/lib/Drupal/Core/DrupalKernel.php(708): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#27 /app/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#28 {main}

Here is the summary list of them all: dblog-1 dblog-2

Please help!

kelsonthony commented 3 years ago

Hello @abbydrury

I has been created another release could try to version 8.1.2 https://github.com/ebsco/edsapi-drupal-plugin/releases/tag/8.1.2

Also you can clone from a specific branch. git clone --branch edsapi-drupal8-release git@github.com:ebsco/edsapi-drupal-plugin.git

Thank you.

abbydrury commented 3 years ago

Two things:

  1. Now there isn't a way to set the required autocomplete field, so if that value is required by the API that might be a problem?
  2. Version 8.1.2 has reduced the number of errors in dblog to 6, but still doesn't work.

The errors are

Are you also seeing these errors when you test?

kelsonthony commented 3 years ago

Hello @abbydrury

Please, could you send a email with yours specific environments?

Send a email to me kanthony at ebsco dot com.

Thank you.

abbydrury commented 3 years ago

I guess I'm not sure what you're asking for. We're running Drupal 8.9.19. My development environment is Mac OS X 10.15.7, using Lando's (version 3.3.2) Pantheon recipe for Drupal 8 - Lando is a tool that helps manage Docker-based development environments, and was Pantheon's tool of choice for development when we created this site. We manage Drupal packages with Composer for cross-environment portability.

I don't know why the environment would matter in this case though. I haven't looked deeply at this, but $token, $timeout, $autocompleteUrl, $autoToken, and $autoCustId don't get set if you end up in the else condition at line 146 of EBSCOAPI.php. I don't know what's going on exactly with IncludeImageQuickViewOption in ESBSCOResponse.php, but I'm guessing $this->response->AvailableIncludeImageQuickView->IncludeImageQuickViewOptions returned null - that would cause an inability to read the final property in $this->response->AvailableIncludeImageQuickView->IncludeImageQuickViewOptions->IncludeImageQuickViewOption.

kelsonthony commented 3 years ago

Something changes on Drupal 8.9.19 core. I'm abble to see the issue now! i'll working on it. Thank you.

kelsonthony commented 3 years ago

Hello,

The version 8 is okay now from my end

Could you try this way?

git clone --branch edsapi-drupal8-release git@github.com:ebsco/edsapi-drupal-plugin.git

image

image

We still have a warning but i'm check, probably it is something from drupal core and not the app itself.

Thank you.

abbydrury commented 3 years ago

I can't get this to work, even using the "standard" install option to create a brand-new instance of Drupal 8.9.19 and cloning the EBSCO module with git clone --branch edsapi-drupal8-release git@github.com:ebsco/edsapi-drupal-plugin.git: Screen Shot 2021-10-19 at 9 27 17 AM

That's clearly not correct: Screen Shot 2021-10-19 at 9 49 52 AM

With the same configuration values in version 0.2 of the module, we do get the correct results even with our custom code to tweak the display surrounding it (the ESBCO results are the center "Library materials" column): Screen Shot 2021-10-19 at 9 51 51 AM

I do see this error in dblog. It does look like it's from core, and it looks like the value it's having trouble with is "autocomplete". It might be coincidental, but that is one of the API fields - is it possible that there's a string object somewhere that should be part of an array instead?

Warning: array_merge(): Expected parameter 1 to be an array, string given in Drupal\Core\Render\Element\RenderElement::setAttributes() (line 134 of /app/drupal-8.9.19/core/lib/Drupal/Core/Render/Element/RenderElement.php)
#0 /app/drupal-8.9.19/core/includes/bootstrap.inc(600): _drupal_error_handler_real(2, 'array_merge(): ...', '/app/drupal-8.9...', 134, Array)
#1 [internal function]: _drupal_error_handler(2, 'array_merge(): ...', '/app/drupal-8.9...', 134, Array)
#2 /app/drupal-8.9.19/core/lib/Drupal/Core/Render/Element/RenderElement.php(134): array_merge('autocomplete', Array)
#3 /app/drupal-8.9.19/core/lib/Drupal/Core/Render/Element/Textfield.php(101): Drupal\Core\Render\Element\RenderElement::setAttributes(Array, Array)
#4 [internal function]: Drupal\Core\Render\Element\Textfield::preRenderTextfield(Array)
#5 /app/drupal-8.9.19/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php(100): call_user_func_array(Array, Array)
#6 /app/drupal-8.9.19/core/lib/Drupal/Core/Render/Renderer.php(781): Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_ren...', 'silenced_deprec...', 'Drupal\\Core\\Ren...')
....

Or, are there additional or different configuration expectations/values in this newer version of the module?

kelsonthony commented 3 years ago

Do you clean the drupal cache after installation and the cookies and cache from the browser?

I can see some warning from the drupal core but there are nothing regards to the app.

Version Drupal 8.9.19.

image

abbydrury commented 3 years ago

Yes, I cleared the Drupal cache and the browser cache.

jproctor commented 3 years ago

Hi, I’m working on the same codebase as @abbydrury .

1. Deprecated function call

You still have not fixed the deprecated call to create_function mentioned in issue #22 . A fix was merged then overwritten. Here’s a patch rolled against v8.1.3:

diff --git a/ebsco.module b/ebsco.module
index 3a6cb52..ebd727a 100755
--- a/ebsco.module
+++ b/ebsco.module
@@ -1741,10 +1741,9 @@ function auto_link($string)
 {
     $linkedString = preg_replace_callback(
         "/\b(https?):\/\/([-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|]*)\b/i",
-        create_function(
-            '$matches',
-            'return "<a href=\'".($matches[0])."\'>".($matches[0])."</a>";'
-        ),
+        function ($matches) {
+            return "<a href='".($matches[0])."'>".($matches[0])."</a>";
+        },
         $string
     );

2. Invalid argument value

Abby did some more digging and found that the EBSCOConnector->request() function was throwing an exception for “Invalid argument value” relating to includeimagequickview. We were passing false, which I think is the default. I tried removing it entirely (commented out line 561 in EBSCOAPI.php), since it’s also set at line 584 if it’s true, and I get results now.

3. Code for displaying errors

In chasing that, I noticed the EBSCOAPI->handleError() function has comments like it’s intending to display something to the user, but it does not; that case is falling through to the default. Either way, it wouldn’t be a terrible idea to log an actual error message so administrators can see what’s going on, using something like

\Drupal::logger('my_module')->error($message);

4. New warning when processing results

When I try to render the results, the module logs this for each entry in the result set: Warning: Invalid argument supplied for foreach() in EBSCOResponse->buildRetrieve() (line 773 of /app/web/modules/contrib/edsapi-drupal-plugin/lib/EBSCOResponse.php)

Changing line 771 to this removes the problem:

if ($record->IllustrationInfo && $record->IllustrationInfo->Images) {
jproctor commented 3 years ago

Two more updates: