3.x - 'PANTHEON_ENVIRONMENT' Is Not Detected from the Environment

Created on 19 March 2022, over 2 years ago
Updated 11 March 2023, over 1 year ago

Problem/Motivation

The 3.x version of this module appears to rely on Pantheon's prepend script to supply the environment as a constant. Without this, search is broken.

<!--break-->

I know that the project page says that all versions before 8.x are now obsolete, but for those of us who are still running Solr 3.6 on Pantheon (especially since Solr 8.x isn't yet officially supported for local development on Lando), we're stuck. With that in mind, in the 3.x version of this module, it looks like \Drupal\search_api_pantheon\Solarium\PantheonCurl::createHandle() only detects the Pantheon environment if it has been provided as a constant (i.e., it uses defined('PANTHEON_ENVIRONMENT')), rather than picking it up from environment variables. The rest of the module uses $_ENV['PANTHEON_ENVIRONMENT'], leading to inconsistent behavior among components in the same project.

It appears that the constant is normally provided by a PHP prepend file, /srv/includes/prepend.php that is loaded via auto_prepend_file = '/srv/includes/prepend.php' in the system-default php.ini file. This is not an issue on Pantheon itself but is an issue for local development on Lando if you are using a custom PHP config for XDEBUG support.

Steps to reproduce

  1. Create a Pantheon-based Drupal site, if you don't have one.
  2. Follow the Quick Start instructions to create a new Lando project from the Drupal site.
  3. Create a blank custom php.ini file under you project, located under .lando/php.ini.
  4. Modify your .lando.yml so that it includes the following section:
    services:
      appserver:
        config:
          php: .lando/php.ini
    
  5. Install the Search API Pantheon 3.x module and its dependencies via Composer.
  6. Start the Lando app.
  7. Enable the Search API Pantheon module.
  8. Attempt to create a new Search API server that uses the Pantheon Solr connector.

With this configuration, on the /admin/config/search/search-api/server/YOUR_SERVER_NAME page, you will get the following errors:

  • "The Solr server could not be reached or is protected by your service provider."
  • "The Solr core could not be accessed. Further data is therefore unavailable."

When performing searches, you will get 404 errors as status messages:

An error occurred while trying to search with Solr: HTTP Status 404 – Not Found
body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} 
h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} 
a {color:black;} .line {height:1px;background-color:#525D76;border:none;}
HTTP Status 404 – Not FoundType Status ReportMessage 
/sites/self/environments/lando/index/solr/selectDescription 
The origin server did not find a current representation for the target resource or is not 
willing to disclose that one exists.Apache Tomcat/7.0.100 (Debian)

Proposed resolution

\Drupal\search_api_pantheon\Solarium\PantheonCurl::createHandle() should be modified to detect the Pantheon environment using $_ENV['PANTHEON_ENVIRONMENT'].

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States GuyPaddock

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024