The Coffee window gives when triggered this message : Could not load data, please refresh the page.
The page reload doesn't change it.

Comments

andrimont created an issue. See original summary.

michaelmol’s picture

What is the result of admin/coffee/get-data

andrimont’s picture

I get a long liste of values :

[
…
{"value":"\/en\/admin\/structure\/taxonomy_manager\/voc","label":"Taxonomy manager","command":null},{"value":"\/en\/admin\/structure\/views","label":"Views","command":null},{"value":"\/en\/admin\/structure\/webform","label":"Webforms","command":null},{"value":"\/en\/admin\/config\/content\/amp\/metadata","label":"AMP Metadata","command":null},{"value":"\/en\/admin\/structure\/classy_paragraphs_style","label":"Classy paragraphs style","command":null},{"value":"\/en\/block\/add","label":"Add custom block","command":null},{"value":"\/en\/admin\/structure\/block\/block-content\/types","label":"Block types","command":null},{"value":"\/en\/admin\/structure\/block\/block-content","label":"Custom block library","command":null},{"value":"\/en\/admin\/structure\/civicrm-entity\/civicrm-case","label":"CiviCRM Case","command":null},{"value":"\/en\/admin\/structure\/civicrm-entity\/civicrm-contact","label":"CiviCRM Contact","command":null},{"value":"\/en\/admin\/structure\/civicrm-entity\/civicrm-email","label":"CiviCRM Email","command":null},
…
]
mr.baileys’s picture

aporie’s picture

Status: Active » Needs review
StatusFileSize
new651 bytes

It's a duplicate from the other issue, problem is maintainer just released a stable version which has a completely different js.
Quick patch, need to be tested.

[EDIT] It seems it's already in dev actually.

aiphes’s picture

same issue as mine: https://www.drupal.org/project/coffee/issues/3069537
dev and stable versions don't fix this and are unusable.

andrimont’s picture

Bonjour @aiphes,
This seems to be ok now with Drupal 8.8.5 and the lates dev version. SOLVED for me.

aiphes’s picture

@andrimont, ok I'll do an update because actually website is on D884

aiphes’s picture

Hi, after upgrade to D885 I get the same message and in watchdog it seem the path is wrong:
/fr/fr/admin/coffee/get-data instead of /fr/admin/coffee/get-data
with Coffee 8.1.
probably more a Drupal missetting ? but which one ? or coffee dev version would be better ?

andrimont’s picture

@aiphes I would get the coffee dev version. In my setting the path /fr/… or /en/… are fine.
Would the trouble be in the URL language detection configuration ?
Home Administration Configuration Regional and language Languages Detection and selection
Is the ENGLISH (EN) PATH PREFIX (DEFAULT LANGUAGE) set to en (not blank) ?

aiphes’s picture

hi
after visiting /admin/config/regional/language/detection I get for selected language:
default language French (selected), other choice are English or French
Change to French only (not default one) >> no change

On admin/config/regional/language/detection/url , prefix are good.
This is on a dev website, on the production one, beta2 work (higlight, not ctrl + click).Weird thing.

andrimont’s picture

It might no be related to Coffee, but check that English prefix is set to en. By default it is blank (not for the other like French the prefix is fr) and gives issues.
Otherwise the Coffee issue disappeared. I thought that it was the dev version.
Have you a strong cache clear with Devel ?

aiphes’s picture

I just dump a copy of the Prod DB onto Dev, and I get the same error.
Here the difference is between coffee version only and D884 vs D885, but I can't force to use beta2 like on prod.
composer require 'drupal/coffee:^1.0-beta2' say nothing to install.

 composer remove drupal/coffee
  - Removing drupal/coffee (1.0.0)
Deleting modules/contrib/coffee - deleted
/drupal-8 $ composer require 'drupal/coffee:^1.0-beta2'
Package operations: 1 install, 0 updates, 0 removals
  - Installing drupal/coffee (1.0.0): Loading from cache
rajab natshah’s picture

Title: Could not load data » Fix Could not load data for internal links
rajab natshah’s picture

StatusFileSize
new595 bytes

Update the patch for the 8.x-1.x-dev

rajab natshah’s picture

StatusFileSize
new574 bytes

Update the patch for the 8.x-1.0 release

rajab natshah’s picture

Not sure why the patch is not applying!!!

$data_path = ltrim($data_path, '/');

It is one line after the fix. in the release and the dev

3128583-15.patch for latest DEV
3128583-16.patch for latest release 8.x-1.0

kbeck303’s picture

The patch in comment #16 is working for me with Drupal Core 8.8.8 and Coffee 8.x-1.0

a.milkovsky’s picture

Status: Needs review » Reviewed & tested by the community

I have a multilingual setup with a different domain per language. The URLs are always absolute in this case.
The patch #7 fixes the issue for me as well.

rar9’s picture

Using official version with path does not fix the issue.

Could be related to coffee if coffee extra is also used

ebremner’s picture

We have multisite with subdomains and none of the patches worked in our case.

rajab natshah’s picture

Priority: Normal » Critical
Ralf Eisler’s picture

Patch #16 works here on for the Administration menu but not for the Main navigation or a Custom navigation.
Coffee 8.x-1.0, PHP is 7.4.10, Core 8.9.6

aiphes’s picture

Patch #16 work for me on D897 + PHP 7.3, migrated website from D6.

michaelmol’s picture

Status: Reviewed & tested by the community » Fixed

Thanks all for resolving this issue!

steveoriol’s picture

Status: Fixed » Needs review

Hello, by update the drupal/coffee (1.0.0 => 1.1.0) I get les message "Could not load data, please refresh the page"
all caches cleaned
and if I downgrade to 1.0.0, It is works back again...
My config: D9.1.5 php7.4

laborouge’s picture

Same for me for Cofee 8.x-1.1

My config: D9.1.5 php7.3.15

alison’s picture

Status: Needs review » Needs work

(probably not "needs review" right now -- they might ask us to create a new issue, but if we keep this thread, it'll be needs work, I think?)

I have the same issue as the last couple commenters -- updating from 1.0 to 1.1 has resulted in the "could not load data" message, plus a "page not found" on every admin page load (doesn't seem to happen when I'm on the site itself, while logged-in as an administrator):

Type 	page not found
Date 	Monday, March 22, 2021 - 04:25
User 	alison
Location 	https://mysite.com/admin/config/development/admin/coffee/get-data
Referrer 	https://mysite.com/admin/config/development/configuration
Message 	/admin/config/development/admin/coffee/get-data
Severity 	Warning
Hostname 	123.123.123.123
Operations 	

Drupal 8.9.13, PHP 7.3

paperscenery’s picture

Same as previous commenters. D8.9.13 / php7.3.27 / Coffee 8.x-1.1

-Works as expected on frontend of site
-On admin pages I get "Could not load data, please refresh the page"

Error logged on every page load:

Type php
Date Monday, March 22, 9:30 am
User [adminuser]
Location https://[site.domain]/admin/coffee/get-data
Referrer https://[site.domain]/
Message Warning: array_flip(): Can only flip STRING and INTEGER values! in Drupal\Core\Entity\EntityStorageBase->loadMultiple() (line 266 of /mnt/www/html/sitename/docroot/core/lib/Drupal/Core/Entity/EntityStorageBase.php)
#0 /mnt/www/html/sitename/docroot/core/includes/bootstrap.inc(600): _drupal_error_handler_real(2, 'array_flip(): C...', '/mnt/www/html/e...', 266, Array)
#1 [internal function]: _drupal_error_handler(2, 'array_flip(): C...', '/mnt/www/html/e...', 266, Array)
#2 /mnt/www/html/sitename/docroot/core/lib/Drupal/Core/Entity/EntityStorageBase.php(266): array_flip(Array)
#3 /mnt/www/html/sitename/docroot/core/lib/Drupal/Core/Entity/EntityStorageBase.php(250): Drupal\Core\Entity\EntityStorageBase->loadMultiple(Array)
#4 /mnt/www/html/sitename/docroot/core/lib/Drupal/Core/Entity/EntityBase.php(544): Drupal\Core\Entity\EntityStorageBase->load(NULL)
#5 /mnt/www/html/sitename/docroot/modules/contrib/publishcontent/src/Plugin/Menu/LocalTask/PublishContentLocalTask.php(28): Drupal\Core\Entity\EntityBase::load(NULL)
#6 /mnt/www/html/sitename/docroot/modules/contrib/coffee/src/Controller/CoffeeController.php(195): Drupal\publishcontent\Plugin\Menu\LocalTask\PublishContentLocalTask->getRouteParameters(Object(Drupal\Core\Routing\CurrentRouteMatch))
#7 /mnt/www/html/sitename/docroot/modules/contrib/coffee/src/Controller/CoffeeController.php(104): Drupal\coffee\Controller\CoffeeController->getLocalTasksForRoute('entity.node.can...', Array)
#8 [internal function]: Drupal\coffee\Controller\CoffeeController->coffeeData()
#9 /mnt/www/html/sitename/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#10 /mnt/www/html/sitename/docroot/core/lib/Drupal/Core/Render/Renderer.php(573): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#11 /mnt/www/html/sitename/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/sitename/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#13 /mnt/www/html/sitename/vendor/symfony/http-kernel/HttpKernel.php(151): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#14 /mnt/www/html/sitename/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#15 /mnt/www/html/sitename/docroot/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#16 /mnt/www/html/sitename/docroot/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#17 /mnt/www/html/sitename/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#18 /mnt/www/html/sitename/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#19 /mnt/www/html/sitename/docroot/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#20 /mnt/www/html/sitename/docroot/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#21 /mnt/www/html/sitename/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#22 /mnt/www/html/sitename/docroot/core/lib/Drupal/Core/DrupalKernel.php(708): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#23 /mnt/www/html/sitename/docroot/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#24 {main}
.
Severity Warning
Hostname [IP address]
Operations

paperscenery’s picture

Further testing shows that it's not strictly divided between frontend and backend or one them vs. another. MOST (but not all) frontend pages work / NO backend pages work.

No difference when testing with php7.4 vs php 7.3

rar9’s picture

+1 front-page works
/admin pages doesn't D9.15 php 7.4.16

paperscenery’s picture

@michaelmol

Tested with the new commit on the dev branch, but still no luck. Error logs suggest admin/coffee/get-data is being appended to the end of the current url rather than to the root URL of the site, thereby causing a Page Not Found. This might explain why it work fine from the front page.

I should also mention that reverting to Coffee 8.x-1.0 did not resolve the issue, so this may be a bug in Core. Again, testing on D8.9.13.

aporie’s picture

Status: Needs work » Needs review
StatusFileSize
new419 bytes

Somehow url passed to ajax got relative.
Fix attached

  • michaelmol committed 5209832 on 8.x-1.x authored by Aporie
    Issue #3128583 by RajabNatshah, Aporie, michaelmol: Fix Could not load...
michaelmol’s picture

Status: Needs review » Fixed
wturrell’s picture

Just to say the dev branch (with patch 35) working well on with D8.9.13 :)

paperscenery’s picture

Confirming dev branch release in #36 corrects the errors. No need to patch separately for me.

Drupal 8.9.13 / 7.3.27 / coffee 8.x-1.x-dev

@Aporie @michaelmol — thank you.

saschaeggi’s picture

Would be cool if we can get a new release with this fix soon
Cheers

solideogloria’s picture

Um, can someone verify this fix is correct when it's using Drupal.url('/admin/coffee/get-data')?

var url = drupalSettings.coffee.dataPath || Drupal.url('/admin/coffee/get-data');

console.log(drupalSettings.path.baseUrl + drupalSettings.coffee.dataPath); // CORRECT
console.log(drupalSettings.path.baseUrl + Drupal.url('admin/coffee/get-data'));  // BROKEN
console.log(drupalSettings.path.baseUrl + Drupal.url('/admin/coffee/get-data')); // BROKEN

Result:

/admin/coffee/get-data
//admin/coffee/get-data
///admin/coffee/get-data

This shows that the baseUrl shouldn't be added in front in some cases. Specifically, when it's using Drupal.url, and in that case, the string should NOT have a leading /, either.

I think it should be this:

        var url;
        if (drupalSettings.coffee.dataPath) {
          url = drupalSettings.path.baseUrl + drupalSettings.coffee.dataPath;
        }
        else {
          url = Drupal.url('admin/coffee/get-data');
        }
        $.ajax({
          url: url,
solideogloria’s picture

Status: Fixed » Needs review
StatusFileSize
new718 bytes

This applies on top of dev (which includes #36).

michaelmol’s picture

Status: Needs review » Fixed

Thanks!

laborouge’s picture

Patch 42 rejected on Drupal 9.1.5

solideogloria’s picture

@laborouge It's not supposed to apply on 9.1.5. It applies on dev, because #35 was already committed to dev.

If you want the fix, you'll have to use the dev version of the module, or create a patch that applies so that you can use it in composer.patches.json.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.