adminer icon indicating copy to clipboard operation
adminer copied to clipboard

Fix elasticsearch(>=7.11) does not support body in GET request

Open tauh33dkhan opened this issue 4 years ago • 3 comments

Elasticsearch(>=7.11) does not support the body in GET request and returns an error message when making GET request with body such as the login request, For more details read this elasticsearch issue and the pull request that introduced this change 66043.

To fix this I made changes in the rootQuery function of elasticsearch driver to only send the request body and content-type header if the request method is not GET.

Fix tested on:

  • Elasticsearch Version: 7.14.0
  • Elasticsearch Version: 7.7.0

tauh33dkhan avatar Aug 22 '21 12:08 tauh33dkhan

Condition for non-GET request is not sufficient in general. For example POST /_flush with empty body also fails.

The real problem is the default value $content = array() together with null checking: $opts['http']['content'] = $content === null ? $content : json_encode($content);

I created a merge request for Elasic long time ago with multiple fixes and this is my solution for 7.14 compatibility: https://github.com/vrana/adminer/pull/420/commits/920a11c3954b9f3187bab5bc9aab7d6ee399879d

Than I created a new driver for Elasticsearch 7 (fix for 7.14 included) https://github.com/vrana/adminer/pull/440

peterpp avatar Sep 18 '21 21:09 peterpp