Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

RebuildIndex shows indexComplete message too early #8262

Closed
fritzmg opened this issue Mar 8, 2016 · 2 comments
Closed

RebuildIndex shows indexComplete message too early #8262

fritzmg opened this issue Mar 8, 2016 · 2 comments
Assignees
Labels
Milestone

Comments

@fritzmg
Copy link
Contributor

fritzmg commented Mar 8, 2016

Problem

When you are rebuilding the search index in the maintenance section, the indexComplete message is sometimes shown too early, before all requests for all pages are finished. It's more likely to happen if you either have a lot of pages or at least some pages that take a long time to generate.

Reproduction

  1. create a new file named sleep.php in your /templates directory and insert the following content: <?php session_write_close(); sleep(25); - change the number of seconds to sleep to something sufficiently high, if necessary.
  2. create a new HTML content element on your index page for example and insert {{file::sleep.php}}. If you want, add this script to a few other pages as well.
  3. go to System - Maintenance and click on "Rebuild index"
  4. The message "The search index has been rebuilt. You can now proceed." will be shown, even though not all pages have been processed yet.

si

Cause

The logic of the MooTools script shows the message once the request of the last element in the list of URLs is completed.

          if (i == last) {
            $('index_loading').setStyle('display', 'none');
            $('index_complete').setStyle('display', 'block');
          }

However, the last request in the list of URLs is not necessarily the last request to be finished overall. The requests could be executed out of order by the Browser and, as shown with the reproduction above, some pages may take longer to generate, e.g. longer than the request of the last element in the list.

Fix

Exchange the current script in be_rebuild_index.html5 with this:

<script>
  window.addEvent('domready', function() {
    var urls = $$('.page_url'),
        complete = 0;
    urls.each(function(el, i) {
      el.getAttribute('data-url') && new Request({
        'url': el.getAttribute('data-url'),
        onComplete: function() {
          el.addClass('tl_green');
          complete++;
          if (complete == urls.length) {
            $('index_loading').setStyle('display', 'none');
            $('index_complete').setStyle('display', 'block');
          }
        }
      }).get();
    });
  });
</script>

Or, while you are at it, use the script from #8255 which introduces more feedback.

bytehead added a commit to 1up-lab/contao-cache-warmup that referenced this issue Mar 8, 2016
@leofeyer leofeyer added the defect label Mar 8, 2016
@leofeyer leofeyer added this to the 3.5.9 milestone Mar 8, 2016
@leofeyer
Copy link
Member

leofeyer commented Mar 8, 2016

Good catch!

@leofeyer
Copy link
Member

Fixed in 2664608.

jsonn pushed a commit to jsonn/pkgsrc that referenced this issue Mar 26, 2016
### 4.1.2 (2016-03-22)

 * Handle derived classes in the exception converter (see #462).
 * Prevent the autofocus attribute from being added multiple times (see contao/core#8281).
 * Respect the SSL settings of the root page when generating sitemaps (see contao/core#8270).
 * Read from the temporary file if it has not been closed yet (see contao/core#8269).
 * Always use HTTPS if the target server supports SSL connections (see contao/core#8183).
 * Adjust the meta wizard field length to the column length (see contao/core#8277).
 * Correctly handle custom mime icon paths (see contao/core#8275).
 * Show the 404 error page if an unpublished article is requested (see contao/core#8264).
 * Correctly count the URLs when rebuilding the search index (see contao/core#8262).
 * Ensure that every image has a width and height attribute (see contao/core#8162).
 * Set the correct mime type when embedding SVG images (see contao/core#8245).
 * Handle the "float_left" and "float_right" classes in the back end (see contao/core#8239).
 * Consider the fallback language if a page alias is ambiguous (see contao/core#8142).
 * Fix the error 403/404 redirect (see contao/website#74).
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants