TYPO3-Solr / ext-solr

A TYPO3 extension that integrates the Apache Solr search server with TYPO3 CMS. dkd Internet Service GmbH is developing the extension. Community contributions are welcome. See CONTRIBUTING.md for details.
GNU General Public License v3.0
137 stars 253 forks source link

[BUG] IMAGES in indexer configurations handled in BE mode since TYPO3 10.4.12 #2828

Open bigsatchmo opened 3 years ago

bigsatchmo commented 3 years ago

Describe the bug When adding an IMAGE Element on a indexer configuration in TypoScript and start the indexer via backend module, the images are rendert with an backend module URL instead of a image url.

To Reproduce Steps to reproduce the behavior:

  1. build a indexer for a list element
  2. add the use of a image relation like

    defaultimage_stringS = FILES
    defaultimage_stringS {
            references {
                table = tx_rsmbwstdata_domain_model_contact
                uid.field = uid
                fieldName = image_url
            }
    
            begin = 0
            maxItems = 1
    
            renderObj = IMAGE
            renderObj {
    
                file {
                    height = 175c
                    width = 175c
                    import.data = file:current:uid
                    treatIdAsReference = 1
                    cropVariant = standard
                    crop.data = file:current:crop
                }
    
                altText.data = file:current:title
                titleText.field = file:current:title
            }
    
        }
  3. start the indexer in solr backend module
  4. look at the solr admin for the rendered result which is looking like "http:///typo3/index.php?route=%2Fimage%2Fprocess&token=2660f751e190405fd87a4d4aac4b9e9b45ae636a&id=7504"

Expected behavior getting a image url of a processed image

Used versions (please complete the following information):

Quick Fix is to remove the DeferredBackendImageProcessor from config
https://github.com/TYPO3/TYPO3.CMS/blob/307591705fb46fb00fd83a95bcb436011edf3f62/typo3/sysext/core/Configuration/DefaultConfiguration.php#L278

bigsatchmo commented 3 years ago

AdditionalConfiguration.php unset($GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['processors']['DeferredBackendImageProcessor']);

dkd-kaehm commented 2 years ago

@dkd-friedrich Notice: Possibly related to your Projects troubles. We should check that issue under EXT:solr 11.5.x.

dogawaf commented 1 year ago

Instead of globally disabling the DeferredBackendImageProcessor, I use this simple composer patch:

--- a/Classes/Domain/Index/IndexService.php
+++ b/Classes/Domain/Index/IndexService.php
@@ -194,6 +194,10 @@
         $itemChangedDate = $item->getChanged();
         $itemChangedDateAfterIndex = 0;

+        // Disable the DeferredBackendImageProcessor during indexing,
+        // @see https://github.com/TYPO3-Solr/ext-solr/issues/2828
+        unset($GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['processors']['DeferredBackendImageProcessor']);
+
         try {
             $this->initializeHttpServerEnvironment($item);
             $itemIndexed = $indexer->index($item);
DanielSiepmann commented 6 months ago

We solved this in a different way. We don't build a final URL which will be indexed. Instead we index the raw data and use f:image ViewHelper. That way one needs way less code and config and is more flexible. E.g. the cropping, alt etc. from the reference are used. And one can apply custom cropping without the need to re index.

Our TypoScript:

image = FILES
image {
    references {
        table = tx_sitepackage_domain_model_machine
        uid.field = uid
        fieldName = images
    }

    maxItems = 1

    renderObj = TEXT
    renderObj {
        data = file:current:uid
    }
}

And Fluid: <f:image src="{document.image}" maxWidth="500" treatIdAsReference="1"/>. That's probably also way more future proof.

The only downside: The image file path is not searchable, and the file content will not be indexed via tika or something like that. But that's probably not a requirement anyway.

dogawaf commented 6 months ago

Elegant workaround @DanielSiepmann One more drawbacks (for some of my usecases):