Page 1 of 1

Reindex Search.module CMSMS 1.3

Posted: Sun Jun 08, 2008 8:12 pm
by pb
To spare RAM (550KB with the default content) and a little time  you change the function Redindex to this:

Code: Select all

function Reindex()
  {
    $db =& $this->GetDb();

    $db_prefix = cms_db_prefix();
    $db->Execute('DROP TABLE '.cms_db_prefix().'module_search_items');
    $db->Execute('DROP TABLE '.cms_db_prefix().'module_search_index');
    $dict = NewDataDictionary($db);
    $flds= "
		id I KEY,
		module_name C(100),
		content_id I,
		extra_attr C(100),
		expires " . CMS_ADODB_DT;

    $taboptarray = array('mysql' => 'TYPE=MyISAM');
    $sqlarray = $dict->CreateTableSQL(cms_db_prefix().'module_search_items', $flds, $taboptarray);
    $dict->ExecuteSQLArray($sqlarray);

    $db->CreateSequence(cms_db_prefix()."module_search_items_seq");
    $flds= "
		item_id I,
		word C(255),
		count I
	";
  $taboptarray = array('mysql' => 'TYPE=MyISAM');
  $sqlarray = $dict->CreateTableSQL(cms_db_prefix().'module_search_index', $flds, $taboptarray);
  $dict->ExecuteSQLArray($sqlarray);

  $sqlarray = $dict->CreateIndexSQL('count', $db_prefix."module_search_index", 'count');
  $dict->ExecuteSQLArray($sqlarray);
 
  
    global $gCms;
    $templateops =& $gCms->GetTemplateOperations();
    $alltemplates = $templateops->LoadTemplates();
    reset($alltemplates);
    while (list($key) = each($alltemplates))
      {
	$onetemplate =& $alltemplates[$key];
	//$this->EditTemplatePost($onetemplate);
	$params = array('template' => &$onetemplate,
                        'forceindexcontent'=>1);
	$this->DoEvent('Core', 'EditTemplatePost', $params);
      }

    $gcbops =& $gCms->GetGlobalContentOperations();
    $allblobs = $gcbops->LoadHtmlBlobs();
    reset($allblobs);
    while (list($key) = each($allblobs))
      {
	$oneblob =& $allblobs[$key];
	//$this->EditHtmlBlobPost($oneblob);
	$params = array('global_content' => &$oneblob);
	$this->DoEvent('Core', 'EditHtmlBlobPost', $params);
      }
		
    global $gCms;
    foreach($gCms->modules as $key=>$value)
      {
	if ($gCms->modules[$key]['installed'] == true &&
	    $gCms->modules[$key]['active'] == true)
	  {
	    if (method_exists($gCms->modules[$key]['object'], 'SearchReindex'))
	      {
		$gCms->modules[$key]['object']->SearchReindex($this);
	      }
	  }
      }
  }
It is better to drop tables and make new one  as to delete all of items and than write it all.

Re: Reindex Search.module CMSMS 1.3

Posted: Sun Jun 08, 2008 8:20 pm
by calguy1000
pb, please read the appropriate sticky posts about how to contribute

essentially, submit svn diffs against current svn

please

Re: Reindex Search.module CMSMS 1.3

Posted: Mon Jun 09, 2008 7:30 am
by pb
I never have worked with svn and why i should do this ?

These  are all tips and tricks and everyone can use it or not here and directly.

Why i should do more work for this ?

Re: Reindex Search.module CMSMS 1.3

Posted: Mon Jun 09, 2008 11:17 am
by thoms
You obviously have good ideas, good knowledge and the willingness to contribute to CMSMS.

Posting patches here in the forum brings some major problems:

1. Many users won't find it, especially in some weeks and months
2. Everytime I make an upgrade/update of CMSms, I have to change your patches again (if it is still possible and working in upcoming versions)

If you would submit your patches to the SVN, they could get part of CMSms and would be integrated in further versions.

So, your work would not be "lost in space", but make CMSms a still better CMS.

You find an explanation of a SVN client at
http://dev.cmsmadesimple.org/docman/vie ... isesvn.htm

thoms

Re: Reindex Search.module CMSMS 1.3

Posted: Mon Jun 09, 2008 11:38 am
by pb
and would be integrated in further versions
Everyone can use the tricks , developers too and so as soon as possible and at once or they can take it in further versions.

But 1.3 seems to be the last version before 2.0.
So, your work would not be "lost in space",
Tricks from me are made for my own use, i am not interested to have more work.

And as long as very old  bugs has only a device to nobody i think the tricks are "lost in space".

Re: Reindex Search.module CMSMS 1.3

Posted: Mon Jun 09, 2008 4:07 pm
by Pierre M.
Hello,

I agree with thoms : when patches are good they are better merged to benefit to everybody with the next release. This way all users of official packages get them, use them, like them and the support team supports them.

And I understand Calguy1000 asking for "submit svn diffs against current svn" : I'm sure it is pain for the DevTeam to merge uncurrent diffs.

"pb", if you can't checkout the current SVN to make your diffs against it, may be someone can volunteer as your svn-forge mate ?

Have fun contributing and improving CMSms :-)

Pierre

Re: Reindex Search.module CMSMS 1.3

Posted: Mon Jun 09, 2008 4:13 pm
by pb
By the friendly words of Calguy1000 i decided  to do nothing more in this way.

I use CMSMS only for one customer who wanted this but it was to slow - so i must do this work.

So the site is ready and my work is done.