Actually made the "prevent search indexing" switch work. Needs to be merged with stable.
authorDan
Mon, 09 Jun 2008 20:52:34 -0400
changeset 567 7f196509bf78
parent 566 06d241de3151
child 568 3700f7124c2b
Actually made the "prevent search indexing" switch work. Needs to be merged with stable.
includes/paths.php
includes/search.php
--- a/includes/paths.php	Sat Jun 07 22:50:31 2008 -0400
+++ b/includes/paths.php	Mon Jun 09 20:52:34 2008 -0400
@@ -702,7 +702,8 @@
         echo "Running indexing round $j of $loops (offset $offset)\n" . ( isset($_SERVER['REQUEST_URI']) ? '<br />' : '' );
       }
       
-      $texts = $db->sql_query('SELECT p.name, t.page_id, t.namespace, t.page_text FROM ' . table_prefix . "page_text AS t\n"
+      // this is friendly to both MySQL and PostgreSQL.
+      $texts = $db->sql_query('SELECT p.name, p.visible, t.page_id, t.namespace, t.page_text FROM ' . table_prefix . "page_text AS t\n"
                             . "  LEFT JOIN " . table_prefix . "pages AS p\n"
                             . "    ON ( p.urlname = t.page_id AND p.namespace = t.namespace )\n"
                             . "  WHERE ( p.password = '' OR p.password = '$sha1_blank' )\n"
@@ -727,6 +728,19 @@
             flush();
           }
           
+          // skip this page if it's not supposed to be indexed
+          if ( $row['visible'] == 0 )
+          {
+            if ( $verbose )
+            {
+              echo "skipped";
+              if ( isset($_SERVER['REQUEST_URI']) )
+                echo '<br />';
+              echo "\n";
+            }
+            continue;
+          }
+          
           // Indexing identifier for the page in the DB
           $page_uniqid = "ns={$row['namespace']};pid=" . sanitize_page_id($row['page_id']);
           $page_uniqid = $db->escape($page_uniqid);
--- a/includes/search.php	Sat Jun 07 22:50:31 2008 -0400
+++ b/includes/search.php	Mon Jun 09 20:52:34 2008 -0400
@@ -394,7 +394,7 @@
     $sql = 'SELECT ' . $concat_column . ' AS id, p.name FROM ' . table_prefix . "page_text AS t\n"
             . "  LEFT JOIN " . table_prefix . "pages AS p\n"
             . "    ON ( p.urlname = t.page_id AND p.namespace = t.namespace )\n"
-            . "  WHERE\n  $where_any\n  $where_req;";
+            . "  WHERE p.visible = 1 AND (\n    $where_any\n    $where_req\n  );";
     if ( !($q = $db->sql_unbuffered_query($sql)) )
       $db->_die('Error is in perform_search(), includes/search.php, query 2. Parsed query dump follows:<pre>(indexable) ' . htmlspecialchars(print_r($query, true)) . '(non-indexable) ' . htmlspecialchars(print_r($query_phrase, true)) . '</pre>');
 
@@ -466,7 +466,7 @@
   $sql = 'SELECT ' . $concat_column . ' AS id, t.page_id, t.namespace, CHAR_LENGTH(t.page_text) AS page_length, t.page_text, p.name AS page_name FROM ' . table_prefix . "page_text AS t
             LEFT JOIN " . table_prefix . "pages AS p
               ON ( p.urlname = t.page_id AND p.namespace = t.namespace )
-            WHERE $text_where $where_not;";
+            WHERE p.visible = 1 AND ( $text_where $where_not );";
   if ( !($q = $db->sql_unbuffered_query($sql)) )
     $db->_die('Error is in perform_search(), includes/search.php, query 3');
 
@@ -499,7 +499,7 @@
 
   foreach ( $paths->pages as $id => $page )
   {
-    if ( $page['namespace'] != 'Special' )
+    if ( $page['namespace'] != 'Special' || $page['visible'] == 0 )
       continue;
     if ( !is_int($id) )
       continue;