Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-75108

HTML block: Search tries to index directory entries

    XMLWordPrintable

Details

    • MOODLE_311_STABLE
    • MOODLE_311_STABLE, MOODLE_400_STABLE
    • MDL-75108-master
    • Hide

      You need a system configured to use Solr for global search. Indexing should be up-to-date.

      1. On the Site administration / Server / Tasks / Scheduled tasks page, find the Global search indexing task and temporarily set it to disabled, to ensure it doesn't run during the test.
      2. Using a text editor tool on your computer, create a file called search.txt containing the word 'Bananasplit'. (It can have other text as well if you like, the point is just to make up a unique word that's easy to search for. Make sure you don't type it anywhere else.)
      3. Go to any website and add an HTML block (turn editing on, expand the block drawer at the right, click 'Add a block', and choose 'Text' option which corresponds to the HTML block).
      4. Edit the block (click the cogwheel icon and choose Configure).
      5. Type a title for the block (doesn't matter what).
      6. In the 'Content' form field, type some text then click the 'Manage files' icon.
      7. Drag and drop the text file from your desktop to add it to the files.
      8. Close the file manager and click 'Save changes'.
      9. Back in Site administration / Server / Tasks / Scheduled tasks, find Global search indexing task and turn it on again (you might want to configure it to run right away).
      10. Go to Site administration / Server / Tasks / Task logs.
      11. Filter the logs e.g. on class name 'search' to show only the global search indexing runs.
      12. Wait for the indexing task to run (you can hit reload on this page to see when it appears). You need to check the first run after you un-disabled it.
      13. Click to view the logs for this first run.
        • EXPECTED: Under the heading 'Processing area: HTML block content' you should see a document indexed, e.g. 'Processed 1 records containing 1 documents...'
        • EXPECTED: Under that heading you should not see any error lines of the form 'Error while indexing file...InputStream must have > 0 bytes'.
      14. Using the search box at the top of the page, search for 'bananasplit'.
        • Expected: It should show one result in your text file in the block.
      Show
      You need a system configured to use Solr for global search. Indexing should be up-to-date. On the Site administration / Server / Tasks / Scheduled tasks page, find the Global search indexing task and temporarily set it to disabled, to ensure it doesn't run during the test. Using a text editor tool on your computer, create a file called search.txt containing the word 'Bananasplit'. (It can have other text as well if you like, the point is just to make up a unique word that's easy to search for. Make sure you don't type it anywhere else.) Go to any website and add an HTML block (turn editing on, expand the block drawer at the right, click 'Add a block', and choose 'Text' option which corresponds to the HTML block). Edit the block (click the cogwheel icon and choose Configure). Type a title for the block (doesn't matter what). In the 'Content' form field, type some text then click the 'Manage files' icon. Drag and drop the text file from your desktop to add it to the files. Close the file manager and click 'Save changes'. Back in Site administration / Server / Tasks / Scheduled tasks , find Global search indexing task and turn it on again (you might want to configure it to run right away). Go to Site administration / Server / Tasks / Task logs . Filter the logs e.g. on class name 'search' to show only the global search indexing runs. Wait for the indexing task to run (you can hit reload on this page to see when it appears). You need to check the first run after you un-disabled it. Click to view the logs for this first run. EXPECTED: Under the heading 'Processing area: HTML block content' you should see a document indexed, e.g. 'Processed 1 records containing 1 documents...' EXPECTED: Under that heading you should not see any error lines of the form 'Error while indexing file...InputStream must have > 0 bytes'. Using the search box at the top of the page, search for 'bananasplit'. Expected: It should show one result in your text file in the block.

    Description

      In the HTML block, if there are attached files, the system will pass them to the search engine to index.

      This is correct behaviour (the index might catch metadata in images, or you might have attached a PDF or something) but in the attach_files function, the HTML block will also pass the directory entries to the search engine. As these are 0 bytes they cannot contain any data, and Solr will output an error indexing them.

      I searched and all other implementations of attach_files do exclude directories, it's only this one that doesn't.

      Attachments

        1. 1_MDL-75108_master.png
          1_MDL-75108_master.png
          30 kB
        2. 1_MDL-75108_v311.png
          1_MDL-75108_v311.png
          60 kB
        3. 1_MDL-75108_v400.png
          1_MDL-75108_v400.png
          25 kB
        4. 2_MDL-75108_master.png
          2_MDL-75108_master.png
          24 kB
        5. 2_MDL-75108_v311.png
          2_MDL-75108_v311.png
          18 kB
        6. 2_MDL-75108_v400.png
          2_MDL-75108_v400.png
          32 kB

        Activity

          People

            quen Sam Marshall
            quen Sam Marshall
            Tim Hunt Tim Hunt
            Simey Lameze Simey Lameze
            John Edward Pedregosa John Edward Pedregosa
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              14/Nov/22

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 day, 29 minutes
                1d 29m