πŸ‡ΊπŸ‡¦Ukraine @SerShevchyk

Lutsk
Account created on 19 June 2015, almost 10 years ago
#

Merge Requests

More

Recent comments

πŸ‡ΊπŸ‡¦Ukraine SerShevchyk Lutsk

@zmintegration you can merge the code and close this issue. I would be grateful for credit on this ticket :)

πŸ‡ΊπŸ‡¦Ukraine SerShevchyk Lutsk

If you use Lando for local development you can add the next lines to the .lando.yml

tooling:
  drush:
    service: appserver
    cmd: /bin/sh -c "drush --root=$LANDO_WEBROOT --uri=https://$LANDO_APP_NAME.lndo.site $@" "$0"
πŸ‡ΊπŸ‡¦Ukraine SerShevchyk Lutsk

SerShevchyk β†’ made their first commit to this issue’s fork.

πŸ‡ΊπŸ‡¦Ukraine SerShevchyk Lutsk

@Berdir I think you can add a command to step 3 in your documentation:

composer require --no-update drupal/core:^10.1 drupal/core-composer-scaffold:^10.1 drupal/core-project-message:^10.1

πŸ‡ΊπŸ‡¦Ukraine SerShevchyk Lutsk

Same in #32

composer.json:

"repositories": [
        {
            "type": "git",
            "url": "https://git.drupalcode.org/issue/adminimal_admin_toolbar-3285987.git"
        },
]

then update in the "require" section:

"drupal/adminimal_admin_toolbar": "dev-3285987-automated-drupal-10"

πŸ‡ΊπŸ‡¦Ukraine SerShevchyk Lutsk

In the patch #6 @paulmckibben added the next code, so you can investigate it and try to add it to the new version of Drupal core:

jQuery.event.special.touchstart={setup:function(e,t,n){this.addEventListener("touchstart",n,{passive:!t.includes("noPreventDefault")})}},jQuery.event.special.touchmove={setup:function(e,t,n){this.addEventListener("touchmove",n,{passive:!t.includes("noPreventDefault")})}};

πŸ‡ΊπŸ‡¦Ukraine SerShevchyk Lutsk

Any of the patches above didn't help with the problem on my project. I have created my own plugin and it helps me with the task, maybe it will be helpful for other developers. But we need to create a patch to this module and search_api.

<?php

namespace Drupal\custom\Plugin\search_api_autocomplete\suggester;

use Drupal\Component\Plugin\Exception\PluginException;
use Drupal\Component\Utility\Xss;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\PluginFormInterface;
use Drupal\Core\Url;
use Drupal\search_api\LoggerTrait;
use Drupal\search_api\Plugin\PluginFormTrait;
use Drupal\search_api\Processor\ProcessorPluginManager;
use Drupal\search_api\Query\QueryInterface;
use Drupal\search_api\SearchApiException;
use Drupal\search_api\Utility\Utility;
use Drupal\search_api_autocomplete\Plugin\search_api_autocomplete\suggester\LiveResults;
use Drupal\search_api_autocomplete\SearchApiAutocompleteException;
use Drupal\search_api_autocomplete\Suggester\SuggesterPluginBase;
use Drupal\search_api_autocomplete\Suggestion\SuggestionFactory;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * Provides a suggester plugin that displays live results.
 *
 * @SearchApiAutocompleteSuggester(
 *   id = "solr_document_live_results",
 *   label = @Translation("Display live results (SolrDocument)"),
 *   description = @Translation("Display live results to visitors as they type. (Unless the server is configured to find partial matches, this will most likely only produce results once the visitor has finished typing.)"),
 * )
 */
class SolrDocumentLiveResults extends LiveResults implements PluginFormInterface {

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    /** @var static $plugin */
    $plugin = parent::create($container, $configuration, $plugin_id, $plugin_definition);

    return $plugin;
  }

  /**
   * {@inheritdoc}
   */
  public function getAutocompleteSuggestions(QueryInterface $query, $incomplete_key, $user_input) {
    $fulltext_fields = $this->configuration['fields'];
    $index = $query->getIndex();
    if ($fulltext_fields) {
      // Take care only to set fields that are still indexed fulltext fields.
      $index_fields = $index->getFulltextFields();
      $fulltext_fields = array_intersect($fulltext_fields, $index_fields);
      if ($fulltext_fields) {
        $query->setFulltextFields($fulltext_fields);
      }
      else {
        $args = [
          '@suggester' => $this->label(),
          '@search' => $this->getSearch()->label(),
          '@index' => $index->label(),
        ];
        $this->getLogger()->warning('Only invalid fulltext fields set for suggester "@suggester" in autocomplete settings for search "@search" on index "@index".', $args);
      }
    }
    $query->keys($user_input);

    try {
      $results = $query->execute();
    }
    catch (SearchApiException $e) {
      // If the query fails, there's nothing we can do about that.
      return [];
    }

    // Pre-load the result items for performance reasons.
    $item_ids = array_keys($results->getResultItems());

    // Group the requested items by datasource. This will also later be used to
    // determine whether all items were loaded successfully.
    $ids = [];
    foreach ($item_ids as $item_id) {
      [$datasource_id, $raw_id] = Utility::splitCombinedId($item_id);
      $ids[$raw_id] = $item_id;
    }

    $objects = [];
    try {
      // Query the index for the Solr documents.
      $results = $index->query()
        ->addCondition('search_api_id', array_keys($ids), 'IN')
        ->execute()
        ->getResultItems();
      foreach ($results as $id => $result) {
        $objects[$id] = \Drupal::getContainer()->get('solr_document.factory')->create($result);
      }
    }
    catch (SearchApiException $e) {
      // Couldn't load items from server, return an empty array.
    }

    $factory = new SuggestionFactory($user_input);

    $suggestions = [];
    foreach ($results as $item_id => $item) {
      // If the result object could not be loaded, there's little we can do
      // here.
      if (empty($objects[$item_id])) {
        continue;
      }

      $object = $objects[$item_id];
      $item->setOriginalObject($object);

      $label = $object->get('label')->getValue()[0];
      $id = $object->get('id')->getValue()[0];
      $url = Url::fromUserInput("/other-recognized-documents/$id");

      $suggestions[] = $factory->createUrlSuggestion($url, $label);
    }

    return $suggestions;
  }



}

πŸ‡ΊπŸ‡¦Ukraine SerShevchyk Lutsk

The last patch applied well but autocomplete doesn't work and in the logs, I can see a new error:

Could not load the following items on index Remote Data: "solr_document/1000740", "solr_document/1000713", "solr_document/1000608", "solr_document/1000634", "solr_document/1000699", "solr_document/1000633", "solr_document/1000548", "solr_document/1000547", "solr_document/1000534", "solr_document/1000530".

πŸ‡ΊπŸ‡¦Ukraine SerShevchyk Lutsk

The patch worked fine but some functionality like autosubmit doesn't work as expected. I think need more work with the patch.

πŸ‡ΊπŸ‡¦Ukraine SerShevchyk Lutsk

My bad with applying the patch. The patch was applied successfully but not worked as expected. After using exposed filters the facets values are gone.

πŸ‡ΊπŸ‡¦Ukraine SerShevchyk Lutsk

I can't apply the patch with Drupal 9.5.9.

πŸ‡ΊπŸ‡¦Ukraine SerShevchyk Lutsk

I had an error:
Error: Call to undefined method Drupal\search_api_solr\TypedData\SolrFieldDefinition::getFieldDefinition() in Drupal\facets_range_datepicker_widget\Plugin\facets\processor\DatepickerProcessor->supportsFacet() (line 84 of /app/web/modules/contrib/facets_range_datepicker_widget/src/Plugin/facets/processor/DatepickerProcessor.php)

and the patch helps me.

πŸ‡ΊπŸ‡¦Ukraine SerShevchyk Lutsk

I still have the same issue. I tried to reinstall the modules but the problem still exists.

πŸ‡ΊπŸ‡¦Ukraine SerShevchyk Lutsk

I have the same problem with updating Panopoly:

Distro Update Manager: admin_views version 7.x-1.7 does not match .make file version 7.x-1.8 from panopoly.
Distro Update Manager: ctools version 7.x-1.15 does not match .make file version 7.x-1.20 from panopoly.
Distro Update Manager: panels_breadcrumbs version 7.x-2.4 does not match .make file version 7.x-2.6 from panopoly.
Distro Update Manager: date version 7.x-2.10 does not match .make file version 7.x-2.12 from panopoly.
Distro Update Manager: simple_gmap version 7.x-1.4 does not match .make file version 7.x-1.5 from panopoly.
Distro Update Manager: media_youtube version 7.x-3.9 does not match .make file version 7.x-3.11 from panopoly.
Distro Update Manager: wysiwyg version 7.x-2.6 does not match .make file version 7.x-2.9 from panopoly.
Includes: Panopoly
πŸ‡ΊπŸ‡¦Ukraine SerShevchyk Lutsk

Installing the dev version of the module fixed the problem on the project.

Production build 0.71.5 2024