reverted: --- fusionforge-5.1.1/deb-specific/gforge.logrotate +++ fusionforge-5.1.1.orig/deb-specific/gforge.logrotate @@ -1,10 +0,0 @@ -/var/log/gforge/vhosts/*/access.log { - weekly - missingok - rotate 52 - compress - delaycompress - notifempty - create 640 root adm - sharedscripts -} diff -u fusionforge-5.1.1/deb-specific/dsf-helper.pl fusionforge-5.1.1/deb-specific/dsf-helper.pl --- fusionforge-5.1.1/deb-specific/dsf-helper.pl +++ fusionforge-5.1.1/deb-specific/dsf-helper.pl @@ -15,7 +15,7 @@ ### # STATIC DATA -@known_files = qw/ config templates preinst postinst prerm postrm links init.d / ; +@known_files = qw/ config templates preinst postinst prerm postrm links init.d logrotate / ; ### # HELPER FUNCTIONS diff -u fusionforge-5.1.1/deb-specific/db-upgrade.pl fusionforge-5.1.1/deb-specific/db-upgrade.pl --- fusionforge-5.1.1/deb-specific/db-upgrade.pl +++ fusionforge-5.1.1/deb-specific/db-upgrade.pl @@ -1954,6 +1954,9 @@ &update_with_sql("FTI-20050530","5.1-6"); &update_with_sql("FTI-20060130","5.1-7"); &update_with_sql("FTI-20061025","5.1-8"); + &update_with_sql("20111007-fti-aggregate-functions","5.1-9"); + &update_with_sql("20111007-add-fti-for-task-messages","5.1-10"); + &update_with_sql("20111009-string-aggregate-function","5.1-11"); ########################### INSERT HERE ################################# diff -u fusionforge-5.1.1/debian/changelog fusionforge-5.1.1/debian/changelog --- fusionforge-5.1.1/debian/changelog +++ fusionforge-5.1.1/debian/changelog @@ -1,3 +1,10 @@ +fusionforge (5.1.1-2) unstable; urgency=low + + * New upstream SVN snapshot. + * Added logrotate config file for web-apache2. + + -- Roland Mas Tue, 25 Oct 2011 10:42:19 +0200 + fusionforge (5.1.1-1) unstable; urgency=low * New upstream release. diff -u fusionforge-5.1.1/debian/README.source fusionforge-5.1.1/debian/README.source --- fusionforge-5.1.1/debian/README.source +++ fusionforge-5.1.1/debian/README.source @@ -15,6 +15,7 @@ outside debian/ too, as direct patches to upstream sources. More precisely : + - fusionforge-5.1.1-2 is in sync with upstream SVN contents as of rev. 14705; - fusionforge-5.1.1-1 is in sync with upstream SVN contents as of rev. 14498; - fusionforge-5.1-7 is in sync with upstream SVN contents as of rev. 14445; - fusionforge-5.1-6 is in sync with upstream SVN contents as of rev. 14319; @@ -36 +37 @@ - -- Roland Mas , Thu, 29 Sep 2011 14:07:27 +0200 + -- Roland Mas , Tue, 25 Oct 2011 10:42:39 +0200 diff -u fusionforge-5.1.1/debian/rules fusionforge-5.1.1/debian/rules --- fusionforge-5.1.1/debian/rules +++ fusionforge-5.1.1/debian/rules @@ -208,7 +208,8 @@ # Remove Windows files rm -rf $(CURDIR)/debian/$(OLDPACKAGE)-web-apache2/usr/share/*/www/scm/viewvc/windows - rm -f $(CURDIR)/debian/$(OLDPACKAGE)-web-apache2/usr/share/*/www/themes/$(OLDPACKAGE)/COPYING +# Remove extra copies of the GNU GPLv2 + rm -f $(CURDIR)/debian/$(OLDPACKAGE)-web-apache2/usr/share/*/www/themes/*/COPYING # Remove Snoopy class from binary packages (provided by libphp-snoopy) find $(addprefix $(CURDIR)/debian/,$(shell dh_listpackages)) -name Snoopy.class.php | xargs -r rm only in patch2: unchanged: --- fusionforge-5.1.1.orig/plugins/projectlabels/www/index.php +++ fusionforge-5.1.1/plugins/projectlabels/www/index.php @@ -15,7 +15,7 @@ if ($func == 'addlabel') { $label_name = addslashes (getStringFromRequest ('label_name')) ; - $label_text = addslashes (getStringFromRequest ('label_text')) ; + $label_text = getStringFromRequest ('label_text') ; $res = db_query_params ('INSERT INTO plugin_projectlabels_labels (label_name, label_text) VALUES($1,$2)', array($label_name, @@ -93,7 +93,7 @@ if ($func == 'editlabel') { $label_id = getIntFromRequest ('label_id', 0) ; $label_name = addslashes (getStringFromRequest ('label_name')) ; - $label_text = addslashes (getStringFromRequest ('label_text')) ; + $label_text = getStringFromRequest ('label_text') ; $res = db_query_params ('UPDATE plugin_projectlabels_labels SET label_name = $1, label_text = $2 WHERE label_id=$3', array($label_name, @@ -121,8 +121,8 @@


- + cols='80'>
+ ".stripslashes ($row['label_name'])."" ; echo "
" . _('This label currently looks like this:') ." "; - echo stripslashes ($row['label_text']) . "
" ; + echo $row['label_text'] . "
" ; $res2 = db_query_params ('SELECT groups.unix_group_name, groups.group_name, groups.group_id FROM groups, plugin_projectlabels_group_labels WHERE plugin_projectlabels_group_labels.group_id = groups.group_id only in patch2: unchanged: --- fusionforge-5.1.1.orig/plugins/projectlabels/common/ProjectLabelsPlugin.class.php +++ fusionforge-5.1.1/plugins/projectlabels/common/ProjectLabelsPlugin.class.php @@ -5,7 +5,7 @@ $this->Plugin() ; $this->name = "projectlabels" ; $this->text = "Project labels"; - $this->hooks[] = "project_before_description" ; + $this->hooks[] = "project_before_widgets" ; $this->hooks[] = "site_admin_option_hook" ; } @@ -15,7 +15,7 @@ if ($hookname == "site_admin_option_hook") { echo '
  • ' . util_make_link ('/plugins/projectlabels/index.php', _('Project labels')) . '
  • '; - } elseif ($hookname == "project_before_description") { + } elseif ($hookname == "project_before_widgets") { $group_id=$params['group_id']; $project = &group_get_object($group_id); if (!$project || !is_object($project)) only in patch2: unchanged: --- fusionforge-5.1.1.orig/plugins/scmsvn/common/SVNPlugin.class.php +++ fusionforge-5.1.1/plugins/scmsvn/common/SVNPlugin.class.php @@ -547,7 +547,7 @@ $params['group_id'] = $group->getID(); $params['repos'] = $repos; $params['hooks'] = &$hooks; - plugin_hook('cmd_for_post_commit_hook', $params); + plugin_hook_by_reference('cmd_for_post_commit_hook', $params); foreach ($params['hooks'] as $plugin => $cmd ) { if (getenv('sys_localinc')) { only in patch2: unchanged: --- fusionforge-5.1.1.orig/packaging/dirs/web-apache2 +++ fusionforge-5.1.1/packaging/dirs/web-apache2 @@ -1,7 +1,6 @@ etc/@OLDPACKAGE@/custom etc/@OLDPACKAGE@/languages-local etc/@OLDPACKAGE@/templates -etc/logrotate.d usr/share/@OLDPACKAGE@/bin usr/share/@OLDPACKAGE@/plugins usr/share/@OLDPACKAGE@/www only in patch2: unchanged: --- fusionforge-5.1.1.orig/packaging/dirs/web-apache2-vhosts +++ fusionforge-5.1.1/packaging/dirs/web-apache2-vhosts @@ -3,4 +3,3 @@ var/lib/@OLDPACKAGE@/etc var/lib/@OLDPACKAGE@/etc/templates etc/@OLDPACKAGE@/templates -etc/logrotate.d only in patch2: unchanged: --- fusionforge-5.1.1.orig/packaging/install/web-apache2-vhosts +++ fusionforge-5.1.1/packaging/install/web-apache2-vhosts @@ -1,4 +1,3 @@ etc/httpd.d/[4-5][0-9]* usr/share/@OLDPACKAGE@/etc/httpd.d/ deb-specific/create-vhosts.sh usr/share/@OLDPACKAGE@/bin/ deb-specific/prepare-vhosts-file.pl usr/share/@OLDPACKAGE@/bin/ -deb-specific/@OLDPACKAGE@.logrotate etc/logrotate.d/@OLDPACKAGE@-web-apache2 only in patch2: unchanged: --- fusionforge-5.1.1.orig/packaging/control/040web-apache.shortdesc +++ fusionforge-5.1.1/packaging/control/040web-apache.shortdesc @@ -1,2 +1,2 @@ - This package exists only as a means to make transitions to apache2 - easier. You can safely uninstall it. + This dummy package exists only as a means to make transitions + to apache2 easier. You can safely uninstall it. only in patch2: unchanged: --- fusionforge-5.1.1.orig/packaging/control/040web-apache +++ fusionforge-5.1.1/packaging/control/040web-apache @@ -1,4 +1,4 @@ Package: @OLDPACKAGE@-web-apache Architecture: all Depends: @OLDPACKAGE@-web-apache2, ${misc:Depends} -Description: transition package to @OLDPACKAGE@-web-apache2 +Description: transitional package to @OLDPACKAGE@-web-apache2 only in patch2: unchanged: --- fusionforge-5.1.1.orig/www/include/project_home.php +++ fusionforge-5.1.1/www/include/project_home.php @@ -79,6 +79,9 @@ site_project_header(array('title'=>$title, 'h1' => '', 'group'=>$group_id, 'toptab' => 'home', 'submenu' => $params['submenu'])); +$params = array('group_id' => $group_id); +plugin_hook('project_before_widgets', $params); + $lm = new WidgetLayoutManager(); $lm->displayLayout($group_id, WidgetLayoutManager::OWNER_TYPE_GROUP); only in patch2: unchanged: --- fusionforge-5.1.1.orig/www/search/include/renderers/HtmlSearchRenderer.class.php +++ fusionforge-5.1.1/www/search/include/renderers/HtmlSearchRenderer.class.php @@ -182,7 +182,13 @@ if (empty($text)) { return ' '; } - $regexp = implode($this->searchQuery->getWords(), '|'); + $words = $this->searchQuery->getWords(); + foreach ($this->searchQuery->getPhrases() as $p) { + foreach (explode(' ',$p) as $w) { + $words[] = $w; + } + } + $regexp = implode('|',$words); return preg_replace('/('.str_replace('/', '\/', $regexp).')/i','\1', $text); } only in patch2: unchanged: --- fusionforge-5.1.1.orig/www/search/include/renderers/AdvancedSearchHtmlSearchRenderer.class.php +++ fusionforge-5.1.1/www/search/include/renderers/AdvancedSearchHtmlSearchRenderer.class.php @@ -110,7 +110,7 @@ */ function getResult() { $html = ''; - + if (in_array('short_forum', $this->selectedParentSections)) { $renderer = new ForumsHtmlSearchRenderer($this->words, $this->offset, $this->isExact, $this->groupId, $this->getSelectedChildSections('short_forum')); $html .= $this->getPartResult($renderer, 'short_forum', _('Forum Search Results')); @@ -191,9 +191,9 @@ $result .= $renderer->getRows(); $result .= $GLOBALS['HTML']->listTableBottom(); } elseif(method_exists($renderer, 'getSections') && (count($renderer->getSections($this->groupId)) == 0)) { - $result .= '

    '.sprintf(_('No matches found for %s - No sections available (check your permissions)'), $query['words']).'

    '; + $result .= '

    '.sprintf(_('No matches found for %s - No sections available (check your permissions)'), $this->words).'

    '; } else { - $result .= '

    '.sprintf(_('No matches found for %s'), $query['words']).'

    '; + $result .= '

    '.sprintf(_('No matches found for %s'), $this->words).'

    '; } return $result; } only in patch2: unchanged: --- fusionforge-5.1.1.orig/www/frs/index.php +++ fusionforge-5.1.1/www/frs/index.php @@ -135,7 +135,7 @@ // Switch whether release_id exists and/or release_id is current one if ( ! $release_id || $release_id==$package_release['release_id'] ) { // no release_id OR release_id is current one - $release_title = util_make_link ( 'frs/shownotes.php?release_id=' . $package_release['release_id'], $package_name.' '.$package_release['name']); + $release_title = util_make_link ( 'frs/shownotes.php?release_id=' . $package_release['release_id'], $package_name.' '.$package_release['name'].' ('.date(_('Y-m-d H:i'),$package_release['release_date']).')'); echo $GLOBALS['HTML']->boxTop($release_title, $package_name . '_' . $package_release['name'])."\n"; } elseif ( $release_id!=$package_release['release_id'] ) { // release_id but not current one @@ -193,7 +193,7 @@ $file_release = db_fetch_array( $res_file ); $tmp_col1 = util_make_link ('/frs/download.php/'.$file_release['file_id'].'/'.$file_release['filename'], $file_release['filename']); - $tmp_col2 = date(_('Y-m-d H:i'), $package_release['release_date'] ); + $tmp_col2 = date(_('Y-m-d H:i'), $file_release['release_time'] ); $tmp_col3 = human_readable_bytes($file_release['file_size']); $tmp_col4 = ($file_release['downloads'] ? number_format($file_release['downloads'], 0) : '0'); $tmp_col5 = $file_release['processor']; only in patch2: unchanged: --- fusionforge-5.1.1.orig/db/20111007-fti-aggregate-functions.sql +++ fusionforge-5.1.1/db/20111007-fti-aggregate-functions.sql @@ -0,0 +1,15 @@ +CREATE OR REPLACE FUNCTION ff_tsvector_add (v1 tsvector, v2 tsvector) +RETURNS tsvector +AS $$ +BEGIN + RETURN v1 || v2 ; +END; +$$ LANGUAGE plpgsql +IMMUTABLE +RETURNS NULL ON NULL INPUT; + +CREATE AGGREGATE ff_tsvector_agg ( + basetype = tsvector, + sfunc = ff_tsvector_add, + stype = tsvector +); only in patch2: unchanged: --- fusionforge-5.1.1.orig/db/20111007-add-fti-for-task-messages.sql +++ fusionforge-5.1.1/db/20111007-add-fti-for-task-messages.sql @@ -0,0 +1,135 @@ +CREATE TABLE project_messages_idx ( + id integer, + project_task_id integer, + vectors tsvector +); + +CREATE OR REPLACE FUNCTION update_vectors() RETURNS TRIGGER AS ' +DECLARE +table_name TEXT; +BEGIN + table_name := TG_ARGV[0]; + -- **** artifact table **** + IF table_name = ''artifact'' THEN + IF TG_OP = ''INSERT'' THEN + INSERT INTO artifact_idx (artifact_id, group_artifact_id, vectors) VALUES (NEW.artifact_id, NEW.group_artifact_id, to_tsvector(coalesce(NEW.details,\'\') ||\' \'|| coalesce(NEW.summary,\'\'))); + ELSIF TG_OP = ''UPDATE'' THEN + UPDATE artifact_idx SET group_artifact_id=NEW.group_artifact_id, vectors=to_tsvector(coalesce(NEW.details,\'\') ||\' \'|| coalesce(NEW.summary,\'\')) WHERE artifact_id=NEW.artifact_id; + ELSIF TG_OP = ''DELETE'' THEN + DELETE FROM artifact_idx WHERE artifact_id=OLD.artifact_id; + END IF; + -- **** artifact_message table **** + ELSIF table_name = ''artifact_message'' THEN + IF TG_OP = ''INSERT'' THEN + INSERT INTO artifact_message_idx (id, artifact_id, vectors) VALUES (NEW.id, NEW.artifact_id, to_tsvector(coalesce(NEW.body,\'\'))); + ELSIF TG_OP = ''UPDATE'' THEN + UPDATE artifact_message_idx SET artifact_id=NEW.artifact_id, vectors=to_tsvector(coalesce(NEW.body,\'\')) WHERE id=NEW.id; + ELSIF TG_OP = ''DELETE'' THEN + DELETE FROM artifact_message_idx WHERE id=OLD.id; + END IF; + -- **** doc_data table **** + ELSIF table_name = ''doc_data'' THEN + IF TG_OP = ''INSERT'' THEN + INSERT INTO doc_data_idx (docid, group_id, vectors) VALUES (NEW.docid, NEW.group_id, to_tsvector(coalesce(NEW.title,\'\') ||\' \'|| coalesce(NEW.description,\'\'))); + ELSIF TG_OP = ''UPDATE'' THEN + UPDATE doc_data_idx SET group_id=NEW.group_id, vectors=to_tsvector(coalesce(NEW.title,\'\') ||\' \'|| coalesce(NEW.description,\'\')) WHERE docid=NEW.docid; + ELSIF TG_OP = ''DELETE'' THEN + DELETE FROM doc_data_idx WHERE docid=OLD.docid; + END IF; + -- **** forum table **** + ELSIF table_name = ''forum'' THEN + IF TG_OP = ''INSERT'' THEN + INSERT INTO forum_idx (msg_id, group_id, vectors) (SELECT f.msg_id, g.group_id, to_tsvector(coalesce(f.subject,\'\') ||\' \'|| + coalesce(f.body,\'\')) AS vectors FROM forum f, forum_group_list g WHERE f.group_forum_id = g.group_forum_id AND f.msg_id = NEW.msg_id); + ELSIF TG_OP = ''UPDATE'' THEN + UPDATE forum_idx SET vectors=to_tsvector(coalesce(NEW.subject,\'\') ||\' \'|| coalesce(NEW.body,\'\')) WHERE msg_id=NEW.msg_id; + ELSIF TG_OP = ''DELETE'' THEN + DELETE FROM forum_idx WHERE msg_id=OLD.msg_id; + END IF; + -- **** frs_file table **** + ELSIF table_name = ''frs_file'' THEN + IF TG_OP = ''INSERT'' THEN + INSERT INTO frs_file_idx (file_id, release_id, vectors) VALUES (NEW.file_id, NEW.release_id, to_tsvector(coalesce(NEW.filename,\'\'))); + ELSIF TG_OP = ''UPDATE'' THEN + UPDATE frs_file_idx SET vectors=to_tsvector(coalesce(NEW.filename,\'\')), release_id=NEW.release_id WHERE file_id=NEW.file_id; + ELSIF TG_OP = ''DELETE'' THEN + DELETE FROM frs_file_idx WHERE file_id=OLD.file_id; + END IF; + -- **** frs_release table **** + ELSIF table_name = ''frs_release'' THEN + IF TG_OP = ''INSERT'' THEN + INSERT INTO frs_release_idx (release_id, vectors) VALUES (NEW.release_id, to_tsvector(coalesce(NEW.changes,\'\') ||\' \'|| coalesce(NEW.notes,\'\') ||\' \'|| coalesce(NEW.name,\'\'))); + ELSIF TG_OP = ''UPDATE'' THEN + UPDATE frs_release_idx SET vectors=to_tsvector(coalesce(NEW.changes,\'\') ||\' \'|| coalesce(NEW.notes,\'\') ||\' \'|| coalesce(NEW.name,\'\')) WHERE release_id=NEW.release_id; + ELSIF TG_OP = ''DELETE'' THEN + DELETE FROM frs_release_idx WHERE release_id=OLD.release_id; + DELETE FROM frs_file_idx WHERE release_id=OLD.release_id; + END IF; + -- **** groups table **** + ELSIF table_name = ''groups'' THEN + IF TG_OP = ''INSERT'' THEN + INSERT INTO groups_idx (group_id, vectors) VALUES (NEW.group_id, to_tsvector(coalesce(NEW.group_name,\'\') ||\' \'|| coalesce(NEW.short_description,\'\') ||\' \'|| coalesce(NEW.unix_group_name,\'\'))); + ELSIF TG_OP = ''UPDATE'' THEN + UPDATE groups_idx SET vectors=to_tsvector(coalesce(NEW.group_name,\'\') ||\' \'|| coalesce(NEW.short_description,\'\') ||\' \'|| coalesce(NEW.unix_group_name,\'\')) WHERE group_id=NEW.group_id; + ELSIF TG_OP = ''DELETE'' THEN + DELETE FROM groups_idx WHERE group_id=OLD.group_id; + END IF; + -- **** news_bytes table **** + ELSIF table_name = ''news_bytes'' THEN + IF TG_OP = ''INSERT'' THEN + INSERT INTO news_bytes_idx (id, vectors) VALUES (NEW.id, to_tsvector(coalesce(NEW.summary,\'\') ||\' \'|| coalesce(NEW.details,\'\'))); + ELSIF TG_OP = ''UPDATE'' THEN + UPDATE news_bytes_idx SET vectors=to_tsvector(coalesce(NEW.summary,\'\') ||\' \'|| coalesce(NEW.details,\'\')) WHERE id=NEW.id; + ELSIF TG_OP = ''DELETE'' THEN + DELETE FROM news_bytes_idx WHERE id=OLD.id; + END IF; + -- **** project_task table **** + ELSIF table_name = ''project_task'' THEN + IF TG_OP = ''INSERT'' THEN + INSERT INTO project_task_idx (project_task_id, vectors) VALUES (NEW.project_task_id, to_tsvector(coalesce(NEW.summary,\'\') ||\' \'|| coalesce(NEW.details,\'\'))); + ELSIF TG_OP = ''UPDATE'' THEN + UPDATE project_task_idx SET vectors=to_tsvector(coalesce(NEW.summary,\'\') ||\' \'|| coalesce(NEW.details,\'\')) WHERE project_task_id=NEW.project_task_id; + ELSIF TG_OP = ''DELETE'' THEN + DELETE FROM project_task_idx WHERE project_task_id=OLD.project_task_id; + END IF; + -- **** project_messages table **** + ELSIF table_name = ''project_messages'' THEN + IF TG_OP = ''INSERT'' THEN + INSERT INTO project_messages_idx (id, project_task_id, vectors) VALUES (NEW.project_message_id, NEW.project_task_id, to_tsvector(coalesce(NEW.body,\'\'))); + ELSIF TG_OP = ''UPDATE'' THEN + UPDATE project_messages_idx SET project_task_id=NEW.project_task_id, vectors=to_tsvector(coalesce(NEW.body,\'\')) WHERE id=NEW.project_message_id; + ELSIF TG_OP = ''DELETE'' THEN + DELETE FROM project_messages_idx WHERE id=OLD.project_message_id; + END IF; + -- **** skills_data table **** + ELSIF table_name = ''skills_data'' THEN + IF TG_OP = ''INSERT'' THEN + INSERT INTO skills_data_idx (skills_data_id, vectors) VALUES (NEW.skill_data_id, to_tsvector(coalesce(NEW.title,\'\') ||\' \'|| coalesce(NEW.keywords,\'\'))); + ELSIF TG_OP = ''UPDATE'' THEN + UPDATE skills_data_idx SET vectors=to_tsvector(coalesce(NEW.title,\'\') ||\' \'|| coalesce(NEW.keywords,\'\')) WHERE skills_data_id=NEW.skills_data_id; + ELSIF TG_OP = ''DELETE'' THEN + DELETE FROM skills_data_idx WHERE skills_data_id=OLD.skills_data_id; + END IF; + -- **** users table **** + ELSIF table_name = ''users'' THEN + IF TG_OP = ''INSERT'' THEN + INSERT INTO users_idx (user_id, vectors) VALUES (NEW.user_id, to_tsvector(coalesce(NEW.user_name,\'\') ||\' \'|| coalesce(NEW.realname,\'\'))); + ELSIF TG_OP = ''UPDATE'' THEN + UPDATE users_idx SET vectors=to_tsvector(coalesce(NEW.user_name,\'\') ||\' \'|| coalesce(NEW.realname,\'\')) WHERE user_id=NEW.user_id; + ELSIF TG_OP = ''DELETE'' THEN + DELETE FROM users_idx WHERE user_id=OLD.user_id; + END IF; + END IF; + + RETURN NEW; +END;' +LANGUAGE 'plpgsql'; + +CREATE TRIGGER projectmessage_ts_update AFTER UPDATE OR INSERT OR DELETE ON project_messages +FOR EACH ROW EXECUTE PROCEDURE update_vectors('project_messages'); + +DELETE FROM project_messages_idx; + +INSERT INTO project_messages_idx (id, project_task_id, vectors) +SELECT project_message_id, project_task_id, to_tsvector(coalesce(body,'')) AS vectors +FROM project_messages ORDER BY project_message_id; only in patch2: unchanged: --- fusionforge-5.1.1.orig/db/20111009-string-aggregate-function.sql +++ fusionforge-5.1.1/db/20111009-string-aggregate-function.sql @@ -0,0 +1,15 @@ +CREATE OR REPLACE FUNCTION ff_string_add (t1 text, t2 text) +RETURNS text +AS $$ +BEGIN + RETURN t1 || ' ioM0Thu6_fieldseparator_kaeph9Ee ' || t2 ; +END; +$$ LANGUAGE plpgsql +IMMUTABLE +RETURNS NULL ON NULL INPUT; + +CREATE AGGREGATE ff_string_agg ( + basetype = text, + sfunc = ff_string_add, + stype = text +); only in patch2: unchanged: --- fusionforge-5.1.1.orig/common/include/Group.class.php +++ fusionforge-5.1.1/common/include/Group.class.php @@ -316,6 +316,14 @@ return false; } else { + // Check if sys_use_project_vhost for homepage + if (forge_get_config('use_project_vhost')) { + $homepage = $unix_name.".".forge_get_config('web_host'); + } else { + $homepage = forge_get_config('web_host')."/www/".$unix_name."/"; + } + + db_begin(); $res = db_query_params (' @@ -339,7 +347,7 @@ $unix_name, htmlspecialchars($description), $unix_name.".".forge_get_config('web_host'), - $unix_name.".".forge_get_config('web_host'), + $homepage, 'P', $unix_box, $scm_box, only in patch2: unchanged: --- fusionforge-5.1.1.orig/common/include/database-pgsql.php +++ fusionforge-5.1.1/common/include/database-pgsql.php @@ -99,6 +99,15 @@ define('SYS_DB_TROVE', $gfconn2); define('SYS_DB_SEARCH', $gfconn2); + $res = db_query_params ('SELECT set_config($1, $2, false)', + array('default_text_search_config', + 'simple')); + if (!$res) { + // Cope with PostgreSQL < 8.3 + db_query_params ('SELECT set_curcfg($1)', + array('simple')); + } + // Register top-level "finally" handler to abort current // transaction in case of error register_shutdown_function("system_cleanup"); @@ -248,6 +257,7 @@ if ($sysdebug_dbquery) { ffDebug('trace', "tracing call of db_query_params():\n", debug_string_backtrace()); + error_log('SQL: '.db_query_to_string($qstring,$params).'; '); } $res = @pg_query_params($dbserver,$qstring,$params); @@ -589,6 +599,17 @@ return db_construct_qpa ($old_qpa, $new_qpa[0], $new_qpa[1]) ; } +function db_query_to_string ($sql, $params = array()) { + foreach ($params as $index => $value) { + $sql = preg_replace('/\\$'.($index+1).'(?!\d)/', "'".$value."'", $sql); + } + return $sql; +} + +function db_qpa_to_string ($qpa) { + return db_query_to_string($qpa[0], $qpa[1]); +} + // Local Variables: // mode: php // c-file-style: "bsd" only in patch2: unchanged: --- fusionforge-5.1.1.orig/common/search/SkillSearchQuery.class.php +++ fusionforge-5.1.1/common/search/SkillSearchQuery.class.php @@ -48,21 +48,13 @@ $qpa = db_construct_qpa () ; if (forge_get_config('use_fti')) { - if(count($this->words)) { - $words = $this->getFormattedWords(); - $qpa = db_construct_qpa ($qpa, - 'SELECT skills_data.skills_data_id, skills_data.type, skills_data.start, skills_data.finish, ts_headline(skills_data.title, q) as title, ts_headline(skills_data.keywords, q) as keywords FROM skills_data, users, skills_data_types, to_tsquery($1) AS q, skills_data_idx WHERE (vectors @@ q ', - array ($words)) ; - } else { - $qpa = db_construct_qpa ($qpa, - 'SELECT skills_data.skills_data_id, skills_data.type, skills_data.start, skills_data.finish, FROM skills_data, users, skills_data_types WHERE (vectors @@ q ') ; - } - + $words = $this->getFTIwords(); + $qpa = db_construct_qpa ($qpa, + 'SELECT skills_data.skills_data_id, skills_data.type, skills_data.start, skills_data.finish, ts_headline(skills_data.title, q) as title, ts_headline(skills_data.keywords, q) as keywords FROM skills_data, users, skills_data_types, to_tsquery($1) AS q, skills_data_idx WHERE (vectors @@ q ', + array ($words)) ; if (count ($this->phrases)) { - if (count ($this->words)) { - $qpa = db_construct_qpa ($qpa, - $this->getOperator()) ; - } + $qpa = db_construct_qpa ($qpa, + $this->getOperator()) ; $qpa = db_construct_qpa ($qpa, ' ((') ; $qpa = $this->addMatchCondition ($qpa, 'skills_data.title') ; @@ -74,19 +66,12 @@ } $qpa = db_construct_qpa ($qpa, ')') ; - if (count ($this->words)) { - $qpa = db_construct_qpa ($qpa, - 'AND skills_data.skills_data_id = skills_data_idx.skills_data_id ') ; - } + $qpa = db_construct_qpa ($qpa, + 'AND skills_data.skills_data_id = skills_data_idx.skills_data_id ') ; $qpa = db_construct_qpa ($qpa, 'AND (skills_data.user_id=users.user_id) AND (skills_data.type=skills_data_types.type_id) ') ; - if (count ($this->words)) { - $qpa = db_construct_qpa ($qpa, - 'ORDER BY ts_rank(vectors, q) DESC, finish DESC') ; - } else { - $qpa = db_construct_qpa ($qpa, - 'ORDER BY finish DESC') ; - } + $qpa = db_construct_qpa ($qpa, + 'ORDER BY ts_rank(vectors, q) DESC, finish DESC') ; } else { $qpa = db_construct_qpa ($qpa, 'SELECT * FROM skills_data, users, skills_data_types WHERE ((') ; only in patch2: unchanged: --- fusionforge-5.1.1.orig/common/search/NewsSearchQuery.class.php +++ fusionforge-5.1.1/common/search/NewsSearchQuery.class.php @@ -59,48 +59,28 @@ if (forge_get_config('use_fti')) { $group_id=$this->groupId; - if (count ($this->words)) { - $words = $this->getFormattedWords(); - $qpa = db_construct_qpa ($qpa, - 'SELECT ts_headline(news_bytes.summary, q) as summary, news_bytes.post_date, news_bytes.forum_id, users.realname FROM news_bytes, users, to_tsquery($1) AS q, news_bytes_idx WHERE (news_bytes.group_id=$2 AND news_bytes.is_approved <> 4 AND news_bytes_idx.id = news_bytes.id AND news_bytes.submitted_by=users.user_id) AND (vectors @@ q ', - array ($words, - $group_id)) ; - } else { - $qpa = db_construct_qpa ($qpa, - 'SELECT summary, news_bytes.post_date, news_bytes.forum_id, users.realname FROM news_bytes, users WHERE (news_bytes.group_id=$1 AND news_bytes.is_approved <> 4 AND news_bytes.submitted_by=users.user_id) ', - array ($group_id)) ; - } + $words = $this->getFTIwords(); + $qpa = db_construct_qpa ($qpa, + 'SELECT x.* FROM (SELECT ts_headline(news_bytes.summary, q) as summary, news_bytes.post_date, news_bytes.forum_id, users.realname, summary||$1||details AS full_string_agg, news_bytes_idx.vectors FROM news_bytes, users, to_tsquery($2) AS q, news_bytes_idx WHERE (news_bytes.group_id=$3 AND news_bytes.is_approved <> 4 AND news_bytes_idx.id = news_bytes.id AND news_bytes.submitted_by=users.user_id) AND vectors @@ q) AS x ', + array ($this->field_separator, + $words, + $group_id)) ; if (count ($this->phrases)) { - if (count ($this->words)) { - $qpa = db_construct_qpa ($qpa, - $this->getOperator()) ; - } - $qpa = db_construct_qpa ($qpa, - ' ((') ; - $qpa = $this->addMatchCondition ($qpa, 'summary') ; - $qpa = db_construct_qpa ($qpa, - ') OR (') ; - $qpa = $this->addMatchCondition ($qpa, 'details') ; $qpa = db_construct_qpa ($qpa, - '))') ; + 'WHERE '); + $qpa = $this->addMatchCondition ($qpa, 'full_string_agg') ; } - if (count ($this->words)) { - $qpa = db_construct_qpa ($qpa, - ') ORDER BY ts_rank(vectors, q) DESC, post_date DESC') ; - } else { - $qpa = db_construct_qpa ($qpa, - ') ORDER BY post_date DESC') ; - } - } else { $qpa = db_construct_qpa ($qpa, - 'SELECT news_bytes.summary, news_bytes.post_date, news_bytes.forum_id, users.realname FROM news_bytes, users WHERE group_id=$1 AND is_approved <> 4 AND news_bytes.submitted_by = users.user_id AND ((', - array ($this->groupId)) ; - $qpa = $this->addIlikeCondition ($qpa, 'summary') ; + ' ORDER BY ts_rank(vectors, $1) DESC, post_date DESC', + array($words)) ; + } else { $qpa = db_construct_qpa ($qpa, - ') OR (') ; - $qpa = $this->addIlikeCondition ($qpa, 'details') ; + 'SELECT x.* FROM (SELECT news_bytes.summary, news_bytes.post_date, news_bytes.forum_id, users.realname, summary||$1||details AS full_string_agg FROM news_bytes, users WHERE group_id=$2 AND is_approved <> 4 AND news_bytes.submitted_by = users.user_id) AS x WHERE ', + array ($this->field_separator, + $this->groupId)) ; + $qpa = $this->addIlikeCondition ($qpa, 'full_string_agg') ; $qpa = db_construct_qpa ($qpa, - ')) ORDER BY post_date DESC') ; + ' ORDER BY post_date DESC') ; } return $qpa ; } only in patch2: unchanged: --- fusionforge-5.1.1.orig/common/search/ExportProjectSearchQuery.class.php +++ fusionforge-5.1.1/common/search/ExportProjectSearchQuery.class.php @@ -45,59 +45,35 @@ $qpa = db_construct_qpa () ; if (forge_get_config('use_fti')) { - $words = $this->getFormattedWords(); - if(count($this->words)) { - $qpa = db_construct_qpa ($qpa, - 'SELECT ts_headline(unix_group_name, q) as unix_group_name, ts_headline(short_description, q) as short_description, type_id, groups.group_id, license, register_time FROM groups, groups_idx, to_tsquery($1) q ', - array (implode (' ', $words))) ; - $qpa = db_construct_qpa ($qpa, - 'WHERE status IN ($1, $2) AND short_description <> $3 AND groups.group_id = groups_idx.group_id', - array ('A', - 'H', - '')) ; + $words = $this->getFTIwords(); + + $qpa = db_construct_qpa ($qpa, + 'SELECT ts_headline(unix_group_name, q) as unix_group_name, ts_headline(short_description, q) as short_description, type_id, groups.group_id, license, register_time FROM groups, groups_idx, to_tsquery($1) q ', + array (implode (' ', $words))) ; + $qpa = db_construct_qpa ($qpa, + 'WHERE status IN ($1, $2) AND short_description <> $3 AND groups.group_id = groups_idx.group_id', + array ('A', + 'H', + '')) ; + $qpa = db_construct_qpa ($qpa, + ' AND (vectors @@ q' ) ; + if (count($this->phrases)) { $qpa = db_construct_qpa ($qpa, - ' AND (vectors @@ q' ) ; - if (count($this->phrases)) { - $qpa = db_construct_qpa ($qpa, - $this->getOperator()) ; - $qpa = db_construct_qpa ($qpa, - '(') ; - $qpa = $this->addMatchCondition($qpa, 'group_name'); - $qpa = db_construct_qpa ($qpa, - ') OR (') ; - $qpa = $this->addMatchCondition($qpa, 'unix_group_name'); - $qpa = db_construct_qpa ($qpa, - ') OR (') ; - $qpa = $this->addMatchCondition($qpa, 'short_description'); - $qpa = db_construct_qpa ($qpa, - ')') ; - } + $this->getOperator()) ; $qpa = db_construct_qpa ($qpa, - ') ORDER BY ts_rank(vectors, q) DESC, group_name ASC') ; - } else { + '(') ; + $qpa = $this->addMatchCondition($qpa, 'group_name'); $qpa = db_construct_qpa ($qpa, - 'SELECT unix_group_name, short_description, type_id, groups.group_id, license, register_time FROM groups ') ; + ') OR (') ; + $qpa = $this->addMatchCondition($qpa, 'unix_group_name'); $qpa = db_construct_qpa ($qpa, - 'WHERE status IN ($1, $2) AND short_description <> $3', - array ('A', - 'H', - '')) ; - if (count($this->phrases)) { - $qpa = db_construct_qpa ($qpa, - ' AND ((' ) ; - $qpa = $this->addMatchCondition($qpa, 'group_name'); - $qpa = db_construct_qpa ($qpa, - ') OR (') ; - $qpa = $this->addMatchCondition($qpa, 'unix_group_name'); - $qpa = db_construct_qpa ($qpa, - ') OR (') ; - $qpa = $this->addMatchCondition($qpa, 'short_description'); - $qpa = db_construct_qpa ($qpa, - '))') ; - } + ') OR (') ; + $qpa = $this->addMatchCondition($qpa, 'short_description'); $qpa = db_construct_qpa ($qpa, - ') ORDER BY group_name' ) ; + ')') ; } + $qpa = db_construct_qpa ($qpa, + ') ORDER BY ts_rank(vectors, q) DESC, group_name ASC') ; } else { $qpa = db_construct_qpa ($qpa, 'SELECT group_name,unix_group_name,type_id,groups.group_id, short_description,license,register_time FROM groups WHERE status IN ($1, $2) AND short_description <> $3 AND groups.group_id = groups_idx.group_id', only in patch2: unchanged: --- fusionforge-5.1.1.orig/common/search/ProjectSearchQuery.class.php +++ fusionforge-5.1.1/common/search/ProjectSearchQuery.class.php @@ -44,26 +44,17 @@ * @return array query+params array */ function getQuery() { - global $LUSER; - $qpa = db_construct_qpa () ; if (forge_get_config('use_fti')) { - if (count ($this->words)) { - $words = $this->getFormattedWords(); - $qpa = db_construct_qpa ($qpa, - 'SELECT DISTINCT ON (ts_rank(vectors, q), group_name) type_id, g.group_id, ts_headline(group_name, q) as group_name, unix_group_name, ts_headline(short_description, q) as short_description FROM groups AS g, to_tsquery($1) AS q, groups_idx as i WHERE g.status in ($2, $3) ', - array ($words, - 'A', - 'H')) ; - $qpa = db_construct_qpa ($qpa, - 'AND vectors @@ q ') ; - } else { - $qpa = db_construct_qpa ($qpa, - 'SELECT DISTINCT ON (group_name) type_id, g.group_id, group_name, unix_group_name, short_description FROM groups AS g WHERE g.status in ($1, $2) ', - array ('A', - 'H')) ; - } + $words = $this->getFTIwords(); + $qpa = db_construct_qpa ($qpa, + 'SELECT DISTINCT ON (ts_rank(vectors, q), group_name) type_id, g.group_id, ts_headline(group_name, q) as group_name, unix_group_name, ts_headline(short_description, q) as short_description FROM groups AS g, to_tsquery($1) AS q, groups_idx as i WHERE g.status in ($2, $3) ', + array ($words, + 'A', + 'H')) ; + $qpa = db_construct_qpa ($qpa, + 'AND vectors @@ q ') ; if (count($this->phrases)) { $qpa = db_construct_qpa ($qpa, ' AND ((') ; @@ -77,13 +68,8 @@ $qpa = db_construct_qpa ($qpa, ')) ') ; } - if (count ($this->words)) { - $qpa = db_construct_qpa ($qpa, - 'AND g.group_id = i.group_id ORDER BY ts_rank(vectors, q) DESC, group_name') ; - } else { - $qpa = db_construct_qpa ($qpa, - 'ORDER BY group_name') ; - } + $qpa = db_construct_qpa ($qpa, + 'AND g.group_id = i.group_id ORDER BY ts_rank(vectors, q) DESC, group_name') ; } else { $qpa = db_construct_qpa ($qpa, 'SELECT g.group_name AS group_name, g.unix_group_name AS unix_group_name, g.type_id AS type_id, g.group_id AS group_id, g.short_description AS short_description FROM groups g WHERE g.status IN ($1, $2) AND ((', only in patch2: unchanged: --- fusionforge-5.1.1.orig/common/search/SearchQuery.class.php +++ fusionforge-5.1.1/common/search/SearchQuery.class.php @@ -83,6 +83,9 @@ var $phrases = array(); + // Something that's hopefully not going to end up in real data + var $field_separator = ' ioM0Thu6_fieldseparator_kaeph9Ee '; + /** * Constructor * @@ -92,6 +95,8 @@ * @param int $rowsPerPage number of rows per page */ function SearchQuery($words, $offset, $isExact, $rowsPerPage = SEARCH__DEFAULT_ROWS_PER_PAGE) { + $this->field_separator = ' ioM0Thu6_fieldseparator_kaeph9Ee '; + $this->cleanSearchWords($words); //We manual escap because every Query in Search escap parameters $words = addslashes($words); @@ -102,7 +107,7 @@ } if (is_array ($this->phrases)){ $this->phrases = array_map ('addslashes',$this->phrases); - } else{ + } else { $this->phrases = array(); } $this->rowsPerPage = $rowsPerPage; @@ -136,8 +141,8 @@ $inQuote = false; foreach(explode(' ', quotemeta($words)) as $word) { if($inQuote) { - if(substr($word, -3) == "\\\\'") { - $word = substr($word, 0, -3); + if(substr($word, -1) == "'") { + $word = substr($word, 0, -1); $inQuote = false; $phrase .= ' '.$word; $this->phrases[] = $phrase; @@ -145,14 +150,14 @@ $phrase .= ' '.$word; } } else { - if(substr($word, 0, 3) == "\\\\'") { - $word = substr($word, 3); + if(substr($word, 0, 1) == "'") { + $word = substr($word, 1); $inQuote = true; - if(substr($word, -3) == "\\\\'") { + if(substr($word, -1) == "'") { // This is a special case where the phrase is just one word - $word = substr($word, 0, -3); + $word = substr($word, 0, -1); $inQuote = false; - $this->phrases[] = $word; + $this->words[] = $word; } else { $phrase = $word; } @@ -176,11 +181,6 @@ $qpa = $this->getQuery(); } - if (forge_get_config('use_fti')) { - db_query_params ('SELECT set_config($1, $2, false)', - array('default_text_search_config', - 'simple')); - } $this->result = db_query_qpa ( $qpa, $this->rowsPerPage + 1, @@ -203,26 +203,30 @@ } function addMatchCondition($qpa, $fieldName) { - if(!count($arr)) { + if(!count($this->phrases)) { $qpa = db_construct_qpa ($qpa, 'TRUE') ; - } else { - $regexs = str_replace(' ', "\\\s+", $arr); - for ($i = 0; $i < count ($regexs); $i++) { - if ($i > 0) { - $qpa = db_construct_qpa ($qpa, - $this->operator) ; - } + return $qpa; + } + + $regexs = array_map ('strtolower', + array_merge ($this->phrases, + str_replace(' ', "\s+", $this->phrases))); + + for ($i = 0; $i < count ($regexs); $i++) { + if ($i > 0) { $qpa = db_construct_qpa ($qpa, - $fieldName.' ~* $1', - array ($regexs[$i])) ; + $this->operator) ; } + $qpa = db_construct_qpa ($qpa, + $fieldName.' ~* $1', + array ($regexs[$i])) ; } return $qpa; } function addIlikeCondition($qpa, $fieldName) { $wordArgs = array_map ('strtolower', - array_merge($this->words, str_replace(' ', "\\\s+", $this->phrases))); + array_merge($this->words, $this->phrases)); for ($i = 0; $i < count ($wordArgs); $i++) { if ($i > 0) { @@ -313,30 +317,43 @@ } /** + * getPhrases - returns the array containing phrases we are searching for + * + * @return array phrases we are searching for + */ + function getPhrases() { + return $this->phrases; + } + + /** * setSections - set the sections list * * @param $sections mixed array of sections or SEARCH__ALL_SECTIONS */ function setSections($sections) { if(is_array($sections)) { - $this->sections = array_keys ($sections) ; + $this->sections = array_values ($sections) ; } else { $this->sections = $sections; } } /** - * getFormattedWords - get words formatted in order to be used in the FTI stored procedures + * getFTIwords - get words formatted in order to be used in the FTI stored procedures * - * @return string words we are searching for, separated by a pipe + * @return string words we are searching for, separated by */ - function getFormattedWords() { + function getFTIwords() { + $bits = $this->words; + foreach ($this->phrases as $p) { + $bits[] = '('.implode ('&', explode (' ', $p)).')'; + } if ($this->isExact) { - $words = implode('&', $this->words); + $query = implode('&', $bits); } else { - $words = implode('|', $this->words); + $query = implode('|', $bits); } - return $words; + return $query; } } only in patch2: unchanged: --- fusionforge-5.1.1.orig/common/search/ArtifactSearchQuery.class.php +++ fusionforge-5.1.1/common/search/ArtifactSearchQuery.class.php @@ -62,71 +62,111 @@ * @return array query+params array */ function getQuery() { + $qpa = db_construct_qpa () ; + + $words = $this->getFTIwords(); + + $qpa = db_construct_qpa ($qpa, + 'SELECT x.* FROM (SELECT artifact.artifact_id, artifact.group_artifact_id, artifact.summary, artifact.open_date, users.realname, artifact.summary||$1||artifact.details||$1||coalesce(ff_string_agg(artifact_message.body), $1) as full_string_agg', + array ('')); + if (forge_get_config('use_fti')) { + $qpa = db_construct_qpa ($qpa, + ', (artifact_idx.vectors || coalesce(ff_tsvector_agg(artifact_message_idx.vectors), $1::tsvector)) AS full_vector_agg', + array('')); + } + $qpa = db_construct_qpa ($qpa, + ' FROM artifact LEFT OUTER JOIN artifact_message USING (artifact_id), users', + array ()) ; + if (forge_get_config('use_fti')) { + $qpa = db_construct_qpa ($qpa, + ', artifact_idx, artifact_message_idx', + array ()) ; + } + $qpa = db_construct_qpa ($qpa, + ' WHERE users.user_id = artifact.submitted_by AND artifact.group_artifact_id = $1 ', + array ($this->artifactId)) ; + if (forge_get_config('use_fti')) { + $qpa = db_construct_qpa ($qpa, + 'AND artifact.artifact_id = artifact_idx.artifact_id AND artifact_message.id = artifact_message_idx.id ', + array ()) ; + } + $qpa = db_construct_qpa ($qpa, + 'GROUP BY artifact.artifact_id, artifact.group_artifact_id, artifact.summary, artifact.open_date, users.realname, artifact.details') ; + + if (forge_get_config('use_fti')) { + $qpa = db_construct_qpa ($qpa, + ', artifact_idx.vectors', + array ()) ; + } + $qpa = db_construct_qpa ($qpa, + ') AS x WHERE ') ; + + if (forge_get_config('use_fti')) { + $qpa = db_construct_qpa ($qpa, + 'full_vector_agg @@ $1 ', + array($words)); + if (count($this->phrases)) { + $qpa = db_construct_qpa ($qpa, + 'AND (') ; + $qpa = $this->addMatchCondition ($qpa, 'x.full_string_agg') ; + $qpa = db_construct_qpa ($qpa, + ') ') ; + } + $qpa = db_construct_qpa ($qpa, + 'ORDER BY ts_rank(full_vector_agg, $1) DESC', + array($words)) ; + + } else { + $qpa = $this->addIlikeCondition ($qpa, 'x.full_string_agg') ; + $qpa = db_construct_qpa ($qpa, + 'ORDER BY x.artifact_id') ; + } + return $qpa ; + + + + $qpa = db_construct_qpa () ; if (forge_get_config('use_fti')) { - $words=$this->getFormattedWords(); + $words=$this->getFTIwords(); $artifactId = $this->artifactId; - if (count($words)) { + $qpa = db_construct_qpa ($qpa, + 'SELECT a.group_artifact_id, a.artifact_id, ts_headline(summary, $1) AS summary, ', + array ($words)) ; + $qpa = db_construct_qpa ($qpa, + 'a.open_date, users.realname, rank FROM (SELECT a.artifact_id, SUM (ts_rank(ai.vectors, q) + ts_rank(ami.vectors, q)) AS rank, artifact.summary||$1||artifact.details||$1||coalesce(ff_string_agg(artifact_message.body), $1) as full_string_agg FROM artifact a LEFT OUTER JOIN artifact_message am USING (artifact_id)', + array('')) ; + + $qpa = db_construct_qpa ($qpa, + ', artifact_idx ai, artifact_message_idx ami, to_tsquery($1) q', + array ($words)) ; + $qpa = db_construct_qpa ($qpa, + 'WHERE a.group_artifact_id=$1', + array ($artifactId)) ; + $qpa = db_construct_qpa ($qpa, + ' AND ai.artifact_id = a.artifact_id AND ami.id = am.id AND ((ai.vectors @@ q OR ami.vectors @@ q) ') ; + + if (count($this->phrases)) { $qpa = db_construct_qpa ($qpa, - 'SELECT a.group_artifact_id, a.artifact_id, ts_headline(summary, $1) AS summary, ', - array ($this->getFormattedWords())) ; + $this->getOperator()) ; $qpa = db_construct_qpa ($qpa, - 'a.open_date, users.realname, rank FROM (SELECT a.artifact_id, SUM (ts_rank(ai.vectors, q) + ts_rank(ami.vectors, q)) AS rank FROM artifact a LEFT OUTER JOIN artifact_message am USING (artifact_id)') ; - + '((') ; + $qpa = $this->addMatchCondition($qpa, 'a.details'); + $qpa = db_construct_qpa ($qpa, + ') OR (') ; + $qpa = $this->addMatchCondition($qpa, 'a.summary'); $qpa = db_construct_qpa ($qpa, - ', artifact_idx ai, artifact_message_idx ami, to_tsquery($1) q', - array ($words)) ; - $qpa = db_construct_qpa ($qpa, - 'WHERE a.group_artifact_id=$1', - array ($artifactId)) ; - $qpa = db_construct_qpa ($qpa, - ' AND ai.artifact_id = a.artifact_id AND ami.id = am.id AND ((ai.vectors @@ q OR ami.vectors @@ q) ') ; - - if (count($this->phrases)) { - $qpa = db_construct_qpa ($qpa, - $this->getOperator()) ; - $qpa = db_construct_qpa ($qpa, - '((') ; - $qpa = $this->addMatchCondition($qpa, 'a.details'); - $qpa = db_construct_qpa ($qpa, - ') OR (') ; - $qpa = $this->addMatchCondition($qpa, 'a.summary'); - $qpa = db_construct_qpa ($qpa, - ') OR (') ; - $qpa = $this->addMatchCondition($qpa, 'am.body'); - $qpa = db_construct_qpa ($qpa, - '))') ; - } - $qpa = db_construct_qpa ($qpa, - ') GROUP BY a.artifact_id) x, artifact a, users WHERE a.artifact_id=x.artifact_id AND users.user_id=a.submitted_by ORDER BY group_artifact_id ASC, rank DESC, a.artifact_id ASC') ; - } else { - $qpa = db_construct_qpa ($qpa, - 'SELECT a.group_artifact_id, a.artifact_id, summary, a.open_date, users.realname, rank FROM (SELECT a.artifact_id, 0 AS rank FROM artifact a LEFT OUTER JOIN artifact_message am USING (artifact_id)') ; - - $qpa = db_construct_qpa ($qpa, - 'WHERE a.group_artifact_id=$1', - array ($artifactId)) ; - - if (count($this->phrases)) { - $qpa = db_construct_qpa ($qpa, - ' AND ((') ; - $qpa = $this->addMatchCondition($qpa, 'a.details'); - $qpa = db_construct_qpa ($qpa, - ') OR (') ; - $qpa = $this->addMatchCondition($qpa, 'a.summary'); - $qpa = db_construct_qpa ($qpa, - ') OR (') ; - $qpa = $this->addMatchCondition($qpa, 'am.body'); - $qpa = db_construct_qpa ($qpa, - '))') ; - } + ') OR (') ; + $qpa = $this->addMatchCondition($qpa, 'am.body'); $qpa = db_construct_qpa ($qpa, - ' GROUP BY a.artifact_id) x, artifact a, users WHERE a.artifact_id=x.artifact_id AND users.user_id=a.submitted_by ORDER BY group_artifact_id ASC, rank DESC, a.artifact_id ASC') ; + '))') ; } + $qpa = db_construct_qpa ($qpa, + ') GROUP BY a.artifact_id) x, artifact a, users WHERE a.artifact_id=x.artifact_id AND users.user_id=a.submitted_by ORDER BY group_artifact_id ASC, rank DESC, a.artifact_id ASC') ; } else { $qpa = db_construct_qpa ($qpa, 'SELECT DISTINCT ON (a.group_artifact_id,a.artifact_id) a.group_artifact_id,a.artifact_id,a.summary,a.open_date,users.realname ') ; only in patch2: unchanged: --- fusionforge-5.1.1.orig/common/search/TasksSearchQuery.class.php +++ fusionforge-5.1.1/common/search/TasksSearchQuery.class.php @@ -65,78 +65,72 @@ * @return array query+params array */ function getQuery() { + $qpa = db_construct_qpa () ; + $qpa = db_construct_qpa ($qpa, + 'SELECT x.* FROM (SELECT project_task.project_task_id, project_task.summary, project_task.percent_complete, project_task.start_date, project_task.end_date, users.realname, project_group_list.project_name, project_task.summary||$1||project_task.details||$1||coalesce(ff_string_agg(project_messages.body), $1) as full_string_agg', + array ('')); + if (forge_get_config('use_fti')) { + $words = $this->getFTIwords(); + $qpa = db_construct_qpa ($qpa, + ', (project_task_idx.vectors || coalesce(ff_tsvector_agg(project_messages_idx.vectors), $1::tsvector)) AS full_vector_agg', + array ('')); + } + $qpa = db_construct_qpa ($qpa, + ' FROM project_task LEFT OUTER JOIN project_messages USING (project_task_id), users, project_group_list', + array ()) ; + if (forge_get_config('use_fti')) { + $qpa = db_construct_qpa ($qpa, + ', project_task_idx, project_messages_idx', + array ()) ; + } + $qpa = db_construct_qpa ($qpa, + ' WHERE project_task.created_by = users.user_id AND project_task.group_project_id = project_group_list.group_project_id AND project_group_list.group_id = $1 AND project_messages.project_task_id = project_task.project_task_id ', + array ($this->groupId)) ; + if ($this->sections != SEARCH__ALL_SECTIONS) { + $qpa = db_construct_qpa ($qpa, + 'AND project_group_list.group_project_id = ANY ($1) ', + array (db_int_array_to_any_clause ($this->sections))) ; + } + if (!$this->showNonPublic) { + $qpa = db_construct_qpa ($qpa, + 'AND project_group_list.is_public = 1 ') ; + } - $qpa = db_construct_qpa () ; - if (forge_get_config('use_fti')) { - if (count ($this->words)) { - $words = $this->getFormattedWords(); + $qpa = db_construct_qpa ($qpa, + 'AND project_task.project_task_id = project_task_idx.project_task_id AND project_messages.project_message_id = project_messages_idx.id ', + array ()) ; + } + $qpa = db_construct_qpa ($qpa, + 'GROUP BY project_task.project_task_id, project_task.summary, project_task.percent_complete, project_task.start_date, project_task.end_date, users.realname, project_group_list.project_name, project_task.details') ; + if (forge_get_config('use_fti')) { + $qpa = db_construct_qpa ($qpa, + ', project_task_idx.vectors', + array ()) ; + } + $qpa = db_construct_qpa ($qpa, + ') AS x WHERE ') ; - $qpa = db_construct_qpa ($qpa, - 'SELECT project_task.project_task_id, project_task.percent_complete, ts_headline(project_task.summary, q) AS summary, project_task.start_date,project_task.end_date,users.firstname||$1||users.lastname AS realname, project_group_list.project_name, project_group_list.group_project_id FROM project_task, users, project_group_list, to_tsquery($2) AS q, project_task_idx WHERE project_task.created_by = users.user_id AND project_task.project_task_id = project_task_idx.project_task_id AND project_task.group_project_id = project_group_list.group_project_id AND project_group_list.group_id=$3 ', - array (' ', - $words, - $this->groupId)) ; - } else { - $qpa = db_construct_qpa ($qpa, - 'SELECT project_task.project_task_id, project_task.percent_complete, summary, project_task.start_date,project_task.end_date,users.firstname||$1||users.lastname AS realname, project_group_list.project_name, project_group_list.group_project_id FROM project_task, users, project_group_list WHERE project_task.created_by = users.user_id AND project_task.group_project_id = project_group_list.group_project_id AND project_group_list.group_id = $2 ', - array (' ', - $this->groupId)) ; - } - if ($this->sections != SEARCH__ALL_SECTIONS) { - $qpa = db_construct_qpa ($qpa, - 'AND project_group_list.group_project_id = ANY ($1) ', - db_int_array_to_any_clause ($this->sections)) ; - } - if (!$this->showNonPublic) { - $qpa = db_construct_qpa ($qpa, - 'AND project_group_list.is_public = 1 ') ; - } - if (count($this->phrases)) { - if (count ($this->words)) { - $qpa = db_construct_qpa ($qpa, - 'AND (vectors @@ q AND (') ; - } else { - $qpa = db_construct_qpa ($qpa, - 'AND ((') ; - } - $qpa = $this->addMatchCondition($qpa, 'summary'); - $qpa = db_construct_qpa ($qpa, - ') OR (') ; - $qpa = $this->addMatchCondition($qpa, 'details'); - $qpa = db_construct_qpa ($qpa, - ')) ') ; - } - if (count ($this->words)) { - $qpa = db_construct_qpa ($qpa, - 'ORDER BY project_group_list.project_name, ts_rank(vectors, q) DESC, project_task.project_task_id') ; - } else { - $qpa = db_construct_qpa ($qpa, - 'ORDER BY project_group_list.project_name, project_task.project_task_id') ; - } - } else { + if (forge_get_config('use_fti')) { $qpa = db_construct_qpa ($qpa, - 'SELECT project_task.project_task_id, project_task.summary, project_task.percent_complete, project_task.start_date, project_task.end_date, users.firstname||$1||users.lastname AS realname, project_group_list.project_name, project_group_list.group_project_id FROM project_task, users, project_group_list WHERE project_task.created_by = users.user_id AND project_task.group_project_id = project_group_list.group_project_id AND project_group_list.group_id = $2 ', - array (' ', - $this->groupId)) ; - if ($this->sections != SEARCH__ALL_SECTIONS) { + 'full_vector_agg @@ $1 ', + array($words)); + if (count($this->phrases)) { $qpa = db_construct_qpa ($qpa, - 'AND project_group_list.group_project_id = ANY ($1) ', - db_int_array_to_any_clause ($this->sections)) ; - } - if (!$this->showNonPublic) { + 'AND (') ; + $qpa = $this->addMatchCondition ($qpa, 'x.full_string_agg') ; $qpa = db_construct_qpa ($qpa, - 'AND project_group_list.is_public = 1 ') ; + ') ') ; } $qpa = db_construct_qpa ($qpa, - ' AND ((') ; - $qpa = $this->addIlikeCondition ($qpa, 'summary') ; - $qpa = db_construct_qpa ($qpa, - ') OR (') ; - $qpa = $this->addIlikeCondition ($qpa, 'details') ; + 'ORDER BY ts_rank(full_vector_agg, $1) DESC', + array($words)) ; + + } else { + $qpa = $this->addIlikeCondition ($qpa, 'x.full_string_agg') ; $qpa = db_construct_qpa ($qpa, - ')) ORDER BY project_group_list.project_name, project_task.project_task_id') ; + ' ORDER BY x.project_name, x.project_task_id') ; } return $qpa ; } only in patch2: unchanged: --- fusionforge-5.1.1.orig/common/search/DocsSearchQuery.class.php +++ fusionforge-5.1.1/common/search/DocsSearchQuery.class.php @@ -71,12 +71,13 @@ } else { $qpa = db_construct_qpa () ; $qpa = db_construct_qpa ($qpa, - 'SELECT doc_data.docid, doc_data.title, doc_data.filename, doc_data.description, doc_groups.groupname FROM doc_data, doc_groups WHERE doc_data.doc_group = doc_groups.doc_group AND doc_data.group_id = $1', - array ($this->groupId)) ; + 'SELECT x.* FROM (SELECT doc_data.docid, doc_data.title, doc_data.filename, doc_data.description, doc_groups.groupname, title||$1||description AS full_string_agg FROM doc_data, doc_groups WHERE doc_data.doc_group = doc_groups.doc_group AND doc_data.group_id = $2', + array ($this->field_separator, + $this->groupId)) ; if ($this->sections != SEARCH__ALL_SECTIONS) { $qpa = db_construct_qpa ($qpa, 'AND doc_groups.doc_group = ANY ($1) ', - db_int_array_to_any_clause ($this->sections)) ; + array( db_int_array_to_any_clause ($this->sections))) ; } if ($this->showNonPublic) { $qpa = db_construct_qpa ($qpa, @@ -86,92 +87,51 @@ ' AND doc_data.stateid = 1') ; } $qpa = db_construct_qpa ($qpa, - ' AND ((') ; - $qpa = $this->addIlikeCondition ($qpa, 'title') ; + ') AS x WHERE ') ; + $qpa = $this->addIlikeCondition ($qpa, 'full_string_agg') ; $qpa = db_construct_qpa ($qpa, - ') OR (') ; - $qpa = $this->addIlikeCondition ($qpa, 'description') ; - $qpa = db_construct_qpa ($qpa, - ')) ORDER BY doc_groups.groupname, doc_data.docid') ; + ' ORDER BY x.groupname, x.docid') ; } return $qpa; } function getFTIQuery() { - $words = $this->getFormattedWords(); + $words = $this->getFTIwords(); $group_id=$this->groupId; $qpa = db_construct_qpa () ; - if(count($this->words)) { - $qpa = db_construct_qpa ($qpa, - 'SELECT doc_data.docid, doc_data.filename, ts_headline(doc_data.title, q) AS title, ts_headline(doc_data.description, q) AS description doc_groups.groupname FROM doc_data, doc_groups, doc_data_idx, to_tsquery($1) q', - array (implode (' ', $words))) ; - $qpa = db_construct_qpa ($qpa, - ' WHERE doc_data.doc_group = doc_groups.doc_group AND doc_data.docid = doc_data_idx.docid AND (vectors @@ q') ; - if (count($this->phrases)) { - $qpa = db_construct_qpa ($qpa, - $this->getOperator()) ; - $qpa = db_construct_qpa ($qpa, - '(') ; - $qpa = $this->addMatchCondition($qpa, 'title'); - $qpa = db_construct_qpa ($qpa, - ') OR (') ; - $qpa = $this->addMatchCondition($qpa, 'description'); - $qpa = db_construct_qpa ($qpa, - ')') ; - } + + $qpa = db_construct_qpa ($qpa, + 'SELECT x.* FROM (SELECT doc_data.docid, doc_data.filename, ts_headline(doc_data.title, q) AS title, ts_headline(doc_data.description, q) AS description, doc_groups.groupname, title||$1||description AS full_string_agg, doc_data_idx.vectors FROM doc_data, doc_groups, doc_data_idx, to_tsquery($2) AS q', + array ($this->field_separator, + $words)) ; + $qpa = db_construct_qpa ($qpa, + ' WHERE doc_data.doc_group = doc_groups.doc_group AND doc_data.docid = doc_data_idx.docid AND (vectors @@ $1', + array ($words)) ; + $qpa = db_construct_qpa ($qpa, + ') AND doc_data.group_id = $1', + array ($group_id)) ; + if ($this->sections != SEARCH__ALL_SECTIONS) { $qpa = db_construct_qpa ($qpa, - ') AND doc_data.group_id = $1', - array ($group_id)) ; - if ($this->sections != SEARCH__ALL_SECTIONS) { - $qpa = db_construct_qpa ($qpa, - ' AND doc_groups.doc_group = ANY ($1)', - db_int_array_to_any_clause ($this->sections)) ; - } - if ($this->showNonPublic) { - $qpa = db_construct_qpa ($qpa, - ' AND doc_data.stateid IN (1, 4, 5)') ; - } else { - $qpa = db_construct_qpa ($qpa, - ' AND doc_data.stateid = 1') ; - } + ' AND doc_groups.doc_group = ANY ($1)', + array( db_int_array_to_any_clause ($this->sections))) ; + } + if ($this->showNonPublic) { $qpa = db_construct_qpa ($qpa, - ' ORDER BY ts_rank(vectors, q) DESC, groupname ASC') ; + ' AND doc_data.stateid IN (1, 4, 5)') ; } else { $qpa = db_construct_qpa ($qpa, - 'SELECT doc_data.docid, title, filename, description doc_groups.groupname FROM doc_data, doc_groups') ; - $qpa = db_construct_qpa ($qpa, - 'WHERE doc_data.doc_group = doc_groups.doc_group') ; - if (count($this->phrases)) { - $qpa = db_construct_qpa ($qpa, - $this->getOperator()) ; - $qpa = db_construct_qpa ($qpa, - '((') ; - $qpa = $this->addMatchCondition($qpa, 'title'); - $qpa = db_construct_qpa ($qpa, - ') OR (') ; - $qpa = $this->addMatchCondition($qpa, 'description'); - $qpa = db_construct_qpa ($qpa, - '))') ; - } - $qpa = db_construct_qpa ($qpa, - ') AND doc_data.group_id = $1', - array ($group_id)) ; - if ($this->sections != SEARCH__ALL_SECTIONS) { - $qpa = db_construct_qpa ($qpa, - 'AND doc_groups.doc_group = ANY ($1) ', - db_int_array_to_any_clause ($this->sections)) ; - } - if ($this->showNonPublic) { - $qpa = db_construct_qpa ($qpa, - ' AND doc_data.stateid IN (1, 4, 5)') ; - } else { - $qpa = db_construct_qpa ($qpa, - ' AND doc_data.stateid = 1') ; - } - $qpa = db_construct_qpa ($qpa, - ' ORDER BY groupname') ; + ' AND doc_data.stateid = 1') ; + } + $qpa = db_construct_qpa ($qpa, + ') AS x ') ; + if (count($this->phrases)) { + $qpa = db_construct_qpa ('WHERE ') ; + $qpa = $this->addMatchCondition($qpa, 'full_string_agg'); } + $qpa = db_construct_qpa ($qpa, + ' ORDER BY ts_rank(vectors, $1) DESC, groupname ASC', + array($words)) ; return $qpa ; } only in patch2: unchanged: --- fusionforge-5.1.1.orig/common/search/ForumSearchQuery.class.php +++ fusionforge-5.1.1/common/search/ForumSearchQuery.class.php @@ -66,48 +66,32 @@ $qpa = db_construct_qpa () ; if (forge_get_config('use_fti')) { - $words = $this->getFormattedWords(); - - - if(count($this->words)) { - $qpa = db_construct_qpa ($qpa, - 'SELECT forum.msg_id, ts_headline(forum.subject, q) AS subject, forum.post_date, users.realname FROM forum, users, to_tsquery($1) AS q, forum_idx as fi WHERE forum.group_forum_id = $2 AND forum.posted_by = users.user_id AND fi.msg_id = forum.msg_id AND vectors @@ q ', - array ($words, - $this->forumId)) ; - $phraseOp = $this->getOperator(); - } else { - $qpa = db_construct_qpa ($qpa, - 'SELECT forum.msg_id, subject, forum.post_date, users.realname FROM forum, users WHERE forum.group_forum_id = $1 AND forum.posted_by = users.user_id ', - array ($this->forumId)) ; - } + $words = $this->getFTIwords(); + $qpa = db_construct_qpa ($qpa, + 'SELECT x.* FROM (SELECT forum.msg_id, ts_headline(forum.subject, $1::tsquery) AS subject, forum.post_date, users.realname, forum.subject||$2||forum.body as full_string_agg, forum_idx.vectors FROM forum, users, to_tsquery($1) AS q, forum_idx WHERE forum.group_forum_id = $3 AND forum.posted_by = users.user_id AND forum_idx.msg_id = forum.msg_id GROUP BY forum.msg_id, subject, body, post_date, realname, forum_idx.vectors) AS x WHERE vectors @@ $1::tsquery ', + array ($words, + $this->field_separator, + $this->forumId)) ; + $phraseOp = $this->getOperator(); if(count($this->phrases)) { $qpa = db_construct_qpa ($qpa, - 'AND ((') ; - $qpa = $this->addMatchCondition($qpa, 'forum.body'); - $qpa = db_construct_qpa ($qpa, - ') OR (') ; - $qpa = $this->addMatchCondition($qpa, 'forum.subject'); + 'AND (') ; + $qpa = $this->addMatchCondition($qpa, 'full_string_agg'); $qpa = db_construct_qpa ($qpa, - ')) ') ; + ') ') ; } - if(count($this->words)) { - $qpa = db_construct_qpa ($qpa, - 'ORDER BY ts_rank(vectors, q) DESC') ; - } else { - $qpa = db_construct_qpa ($qpa, - 'ORDER BY post_date DESC') ; - } - } else { $qpa = db_construct_qpa ($qpa, - 'SELECT forum.msg_id, forum.subject, forum.post_date, users.realname FROM forum,users WHERE users.user_id=forum.posted_by AND ((') ; - $qpa = $this->addIlikeCondition ($qpa, 'forum.body') ; + 'ORDER BY ts_rank(vectors, $1) DESC', + array($words)) ; + } else { $qpa = db_construct_qpa ($qpa, - ') OR (') ; - $qpa = $this->addIlikeCondition ($qpa, 'forum.subject') ; + 'SELECT x.* FROM (SELECT forum.msg_id, forum.subject, forum.post_date, users.realname, forum.subject||$1||forum.body as full_string_agg FROM forum,users WHERE users.user_id=forum.posted_by AND forum.group_forum_id=$2 GROUP BY msg_id, subject, post_date, realname, body) AS x WHERE ', + array ($this->field_separator, + $this->forumId)) ; + $qpa = $this->addIlikeCondition ($qpa, 'full_string_agg') ; $qpa = db_construct_qpa ($qpa, - ')) AND forum.group_forum_id=$1 GROUP BY msg_id, subject, post_date, realname', - array ($this->forumId)) ; + ' '); } return $qpa ; } only in patch2: unchanged: --- fusionforge-5.1.1.orig/common/search/PeopleSearchQuery.class.php +++ fusionforge-5.1.1/common/search/PeopleSearchQuery.class.php @@ -43,27 +43,17 @@ * @return array query+params array */ function getQuery() { - - $qpa = db_construct_qpa () ; if (forge_get_config('use_fti')) { - if (count ($this->words)) { - $words = $this->getFormattedWords(); - $qpa = db_construct_qpa ($qpa, - 'SELECT users.user_id, user_name, ts_headline(realname, q) as realname FROM users, to_tsquery($1) AS q, users_idx WHERE status=$2 AND users_idx.user_id = users.user_id AND (vectors @@ q ', - array ($words, - 'A')); - } else { - $qpa = db_construct_qpa ($qpa, - 'SELECT users.user_id, user_name, realname FROM users WHERE status=$1 AND users_idx.user_id = users.user_id AND (', - array ('A')); - } + $words = $this->getFTIwords(); + $qpa = db_construct_qpa ($qpa, + 'SELECT users.user_id, user_name, ts_headline(realname, q) as realname FROM users, to_tsquery($1) AS q, users_idx WHERE status=$2 AND users_idx.user_id = users.user_id AND (vectors @@ q ', + array ($words, + 'A')); if (count ($this->phrases)) { - if (count ($this->words)) { - $qpa = db_construct_qpa ($qpa, - $this->getOperator()) ; - } + $qpa = db_construct_qpa ($qpa, + $this->getOperator()) ; $qpa = db_construct_qpa ($qpa, '(') ; $qpa = $this->addMatchCondition($qpa, 'user_name'); @@ -73,13 +63,8 @@ $qpa = db_construct_qpa ($qpa, ')') ; } - if (count ($this->words)) { - $qpa = db_construct_qpa ($qpa, - ') ORDER BY ts_rank(vectors, q) DESC, user_name') ; - } else { - $qpa = db_construct_qpa ($qpa, - ') ORDER BY user_name') ; - } + $qpa = db_construct_qpa ($qpa, + ') ORDER BY ts_rank(vectors, q) DESC, user_name') ; } else { $qpa = db_construct_qpa ($qpa, 'SELECT user_name,user_id,realname FROM users WHERE ((') ; only in patch2: unchanged: --- fusionforge-5.1.1.orig/common/search/ForumsSearchQuery.class.php +++ fusionforge-5.1.1/common/search/ForumsSearchQuery.class.php @@ -80,8 +80,9 @@ } $qpa = db_construct_qpa ($qpa, - 'SELECT forum.msg_id, ts_headline(forum.subject, q) AS subject, forum.post_date, users.realname, forum_group_list.forum_name FROM forum, users, forum_group_list, forum_idx, to_tsquery($1) as q ', - array ($this->getFormattedWords())) ; + 'SELECT forum.msg_id, ts_headline(forum.subject, q) AS subject, forum.post_date, users.realname, forum_group_list.forum_name, forum.subject||$2||forum.body as full_string_agg FROM forum, users, forum_group_list, forum_idx, to_tsquery($1) as q ', + array ($this->getFTIwords(), + $this->field_separator)) ; $qpa = db_construct_qpa ($qpa, 'WHERE users.user_id = forum.posted_by AND vectors @@ q AND forum.msg_id = forum_idx.msg_id AND forum_group_list.group_forum_id = forum.group_forum_id AND forum_group_list.is_public <> 9 AND forum.group_forum_id IN (SELECT group_forum_id FROM forum_group_list WHERE group_id = $1) ', array ($this->groupId)); @@ -94,12 +95,22 @@ $qpa = db_construct_qpa ($qpa, 'AND forum_group_list.is_public = 1 ') ; } + + if(count($this->phrases)) { + $qpa = db_construct_qpa ($qpa, + 'AND (') ; + $qpa = $this->addMatchCondition($qpa, 'full_string_agg'); + $qpa = db_construct_qpa ($qpa, + ') ') ; + } + $qpa = db_construct_qpa ($qpa, 'ORDER BY forum_group_list.forum_name ASC, forum.msg_id ASC, ts_rank(vectors, q) DESC') ; } else { $qpa = db_construct_qpa ($qpa, - 'SELECT forum.msg_id, forum.subject, forum.post_date, users.realname, forum_group_list.forum_name FROM forum, users, forum_group_list WHERE users.user_id = forum.posted_by AND forum_group_list.group_forum_id = forum.group_forum_id AND forum_group_list.is_public <> 9 AND forum.group_forum_id IN (SELECT group_forum_id FROM forum_group_list WHERE group_id = $1) ', - array ($this->groupId)) ; + 'SELECT x.* FROM (SELECT forum.msg_id, forum.subject, forum.post_date, users.realname, forum_group_list.forum_name, forum.subject||$1||forum.body as full_string_agg FROM forum, users, forum_group_list WHERE users.user_id = forum.posted_by AND forum_group_list.group_forum_id = forum.group_forum_id AND forum_group_list.is_public <> 9 AND forum.group_forum_id IN (SELECT group_forum_id FROM forum_group_list WHERE group_id = $2) ', + array ($this->field_separator, + $this->groupId)) ; if ($this->sections != SEARCH__ALL_SECTIONS) { $qpa = db_construct_qpa ($qpa, 'AND forum_group_list.group_forum_id = ANY ($1) ', @@ -110,13 +121,10 @@ 'AND forum_group_list.is_public = 1 ') ; } $qpa = db_construct_qpa ($qpa, - 'AND ((') ; - $qpa = $this->addIlikeCondition ($qpa, 'forum.body') ; - $qpa = db_construct_qpa ($qpa, - ') OR (') ; - $qpa = $this->addIlikeCondition ($qpa,'forum.subject') ; + ') AS x WHERE ') ; + $qpa = $this->addIlikeCondition ($qpa, 'full_string_agg') ; $qpa = db_construct_qpa ($qpa, - ')) ORDER BY forum_group_list.forum_name, forum.msg_id') ; + ' ORDER BY x.forum_name, x.msg_id') ; } return $qpa ; } only in patch2: unchanged: --- fusionforge-5.1.1.orig/common/search/TrackersSearchQuery.class.php +++ fusionforge-5.1.1/common/search/TrackersSearchQuery.class.php @@ -65,83 +65,72 @@ * @return array query+params array */ function getQuery() { - - $qpa = db_construct_qpa () ; + $qpa = db_construct_qpa ($qpa, + 'SELECT x.* FROM (SELECT artifact.artifact_id, artifact.group_artifact_id, artifact.summary, artifact.open_date, users.realname, artifact_group_list.name, artifact.summary||$1||artifact.details||$1||coalesce(ff_string_agg(artifact_message.body), $1) as full_string_agg', + array ('')); if (forge_get_config('use_fti')) { - if (count ($this->words)) { - $qpa = db_construct_qpa ($qpa, - 'SELECT DISTINCT x.* FROM (SELECT artifact.artifact_id, artifact.group_artifact_id, artifact.summary, artifact.open_date, users.realname, artifact_group_list.name, (ts_rank(artifact_idx.vectors, q)+ts_rank(artifact_message_idx.vectors, q)) AS rank FROM artifact LEFT OUTER JOIN artifact_message USING (artifact_id), users, artifact_group_list, to_tsquery($1) q, artifact_idx, artifact_message_idx WHERE users.user_id = artifact.submitted_by AND artifact_idx.artifact_id = artifact.artifact_id AND artifact_message_idx.id = artifact_message.id AND artifact_message_idx.artifact_id = artifact_message_idx.artifact_id AND artifact_group_list.group_artifact_id = artifact.group_artifact_id AND artifact_group_list.group_id = $2 ', - - array ($this->getFormattedWords(), - $this->groupId)) ; - $tsmatch = "(artifact_idx.vectors @@ q OR artifact_message_idx.vectors @@ q)"; - $phraseOp = $this->getOperator(); - } else { - $qpa = db_construct_qpa ($qpa, - 'SELECT DISTINCT x.* FROM (SELECT artifact.artifact_id, artifact.group_artifact_id, artifact.summary, artifact.open_date, users.realname, artifact_group_list.name FROM artifact LEFT OUTER JOIN artifact_message USING (artifact_id), users, artifact_group_list WHERE users.user_id = artifact.submitted_by AND artifact_group_list.group_artifact_id = artifact.group_artifact_id AND artifact_group_list.group_id = $1 ', - array ($this->groupId)) ; - - - $tsmatch = ""; - $orderBy = ""; - $phraseOp = ""; - } + $words = $this->getFTIwords(); + $qpa = db_construct_qpa ($qpa, + ', (artifact_idx.vectors || coalesce(ff_tsvector_agg(artifact_message_idx.vectors), $1::tsvector)) AS full_vector_agg', + array ('')); + } + $qpa = db_construct_qpa ($qpa, + ' FROM artifact LEFT OUTER JOIN artifact_message USING (artifact_id), users, artifact_group_list', + array ()) ; + if (forge_get_config('use_fti')) { + $qpa = db_construct_qpa ($qpa, + ', artifact_idx, artifact_message_idx', + array ()) ; + } + $qpa = db_construct_qpa ($qpa, + ' WHERE users.user_id = artifact.submitted_by AND artifact_group_list.group_artifact_id = artifact.group_artifact_id AND artifact_group_list.group_id = $1 AND artifact_message.artifact_id = artifact.artifact_id ', + array ($this->groupId)) ; + if ($this->sections != SEARCH__ALL_SECTIONS) { + $qpa = db_construct_qpa ($qpa, + 'AND artifact_group_list.group_artifact_id = ANY ($1) ', + array (db_int_array_to_any_clause ($this->sections))) ; + } + if (!$this->showNonPublic) { + $qpa = db_construct_qpa ($qpa, + 'AND artifact_group_list.is_public = 1 ') ; + } + if (forge_get_config('use_fti')) { + $qpa = db_construct_qpa ($qpa, + 'AND artifact.artifact_id = artifact_idx.artifact_id AND artifact_message.id = artifact_message_idx.id ', + array ()) ; + } + $qpa = db_construct_qpa ($qpa, + 'GROUP BY artifact.artifact_id, artifact.group_artifact_id, artifact.summary, artifact.open_date, users.realname, artifact_group_list.name, artifact.details') ; + if (forge_get_config('use_fti')) { + $qpa = db_construct_qpa ($qpa, + ', artifact_idx.vectors', + array ()) ; + } + $qpa = db_construct_qpa ($qpa, + ') AS x WHERE ') ; + + if (forge_get_config('use_fti')) { + $qpa = db_construct_qpa ($qpa, + 'full_vector_agg @@ $1 ', + array($words)); if (count($this->phrases)) { $qpa = db_construct_qpa ($qpa, - 'AND ((') ; - $qpa = $this->addMatchCondition($qpa, 'artifact.details'); - $qpa = db_construct_qpa ($qpa, - ') OR (') ; - $qpa = $this->addMatchCondition($qpa, 'artifact.summary'); - $qpa = db_construct_qpa ($qpa, - ') OR (') ; - $qpa = $this->addMatchCondition($qpa, 'artifact_message.body'); + 'AND (') ; + $qpa = $this->addMatchCondition ($qpa, 'x.full_string_agg') ; $qpa = db_construct_qpa ($qpa, - ')) ') ; - } - if ($this->sections != SEARCH__ALL_SECTIONS) { - $qpa = db_construct_qpa ($qpa, - 'AND artifact_group_list.group_artifact_id = ANY ($1) ', - db_int_array_to_any_clause ($this->sections)) ; - } - if (!$this->showNonPublic) { - $qpa = db_construct_qpa ($qpa, - 'AND artifact_group_list.is_public = 1 ') ; + ') ') ; } $qpa = db_construct_qpa ($qpa, - ') x') ; - if (count ($this->words)) { - $qpa = db_construct_qpa ($qpa, - 'ORDER BY rank DESC') ; - } + 'ORDER BY ts_rank(full_vector_agg, $1) DESC', + array($words)) ; + } else { + $qpa = $this->addIlikeCondition ($qpa, 'x.full_string_agg') ; $qpa = db_construct_qpa ($qpa, - 'SELECT DISTINCT artifact.artifact_id, artifact.group_artifact_id, artifact.summary, artifact.open_date, users.realname, artifact_group_list.name FROM artifact LEFT OUTER JOIN artifact_message USING (artifact_id), users, artifact_group_list WHERE users.user_id = artifact.submitted_by AND artifact_group_list.group_artifact_id = artifact.group_artifact_id AND artifact_group_list.group_id = $1 ', - array ($this->groupId)) ; - if ($this->sections != SEARCH__ALL_SECTIONS) { - $qpa = db_construct_qpa ($qpa, - 'AND artifact_group_list.group_artifact_id = ANY ($1) ', - db_int_array_to_any_clause ($this->sections)) ; - } - if (!$this->showNonPublic) { - $qpa = db_construct_qpa ($qpa, - 'AND artifact_group_list.is_public = 1 ') ; - } - - $qpa = db_construct_qpa ($qpa, - ' AND ((') ; - $qpa = $this->addIlikeCondition ($qpa, 'artifact.details') ; - $qpa = db_construct_qpa ($qpa, - ') OR (') ; - $qpa = $this->addIlikeCondition ($qpa, 'artifact.summary') ; - $qpa = db_construct_qpa ($qpa, - ') OR (') ; - $qpa = $this->addIlikeCondition ($qpa, 'artifact_message.body') ; - $qpa = db_construct_qpa ($qpa, - ')) ORDER BY artifact_group_list.name, artifact.artifact_id') ; + ' ORDER BY x.name, x.artifact_id') ; } return $qpa ; } @@ -176,7 +165,7 @@ if ($this->sections != SEARCH__ALL_SECTIONS) { $qpa = db_construct_qpa ($qpa, 'AND artifact_group_list.group_artifact_id = ANY ($1) ', - db_int_array_to_any_clause ($this->sections)) ; + array( db_int_array_to_any_clause ($this->sections))) ; } if (!$this->showNonPublic) { $qpa = db_construct_qpa ($qpa, only in patch2: unchanged: --- fusionforge-5.1.1.orig/common/search/FrsSearchQuery.class.php +++ fusionforge-5.1.1/common/search/FrsSearchQuery.class.php @@ -69,17 +69,11 @@ $qpa = db_construct_qpa () ; if (forge_get_config('use_fti')) { - if(count($this->words)) { - $qpa = db_construct_qpa () ; - $qpa = db_construct_qpa ($qpa, - 'SELECT ts_headline(frs_package.name, q) AS package_name, ts_headline(frs_release.name, q) as release_name, frs_release.release_date, frs_release.release_id, users.realname FROM frs_file, frs_release, users, frs_package, to_tsquery($1) AS q, frs_release_idx r, frs_file_idx f WHERE frs_release.released_by = users.user_id AND r.release_id = frs_release.release_id AND f.file_id = frs_file.file_id AND frs_package.package_id = frs_release.package_id AND frs_file.release_id=frs_release.release_id AND frs_package.group_id=$2 ', - array ($this->getFormattedWords(), - $this->groupId)) ; - } else { - $qpa = db_construct_qpa ($qpa, - 'SELECT frs_package.name as package_name, frs_release.name as release_name, frs_release.release_date, frs_release.release_id, users.realname FROM frs_file, frs_release, users, frs_package WHERE frs_release.released_by = users.user_id AND frs_package.package_id = frs_release.package_id AND frs_file.release_id=frs_release.release_id AND frs_package.group_id=$1 ', - array ($this->groupId)) ; - } + $qpa = db_construct_qpa () ; + $qpa = db_construct_qpa ($qpa, + 'SELECT ts_headline(frs_package.name, q) AS package_name, ts_headline(frs_release.name, q) as release_name, frs_release.release_date, frs_release.release_id, users.realname FROM frs_file, frs_release, users, frs_package, to_tsquery($1) AS q, frs_release_idx r, frs_file_idx f WHERE frs_release.released_by = users.user_id AND r.release_id = frs_release.release_id AND f.file_id = frs_file.file_id AND frs_package.package_id = frs_release.package_id AND frs_file.release_id=frs_release.release_id AND frs_package.group_id=$2 ', + array ($this->getFTIwords(), + $this->groupId)) ; if ($this->sections != SEARCH__ALL_SECTIONS) { $qpa = db_construct_qpa ($qpa, 'AND frs_package.package_id = ANY ($1) ', @@ -89,10 +83,8 @@ $qpa = db_construct_qpa ($qpa, 'AND is_public = 1 ') ; } - if (count ($this->words)) { - $qpa = db_construct_qpa ($qpa, - 'AND (f.vectors @@ q OR r.vectors @@ q) ') ; - } + $qpa = db_construct_qpa ($qpa, + 'AND (f.vectors @@ q OR r.vectors @@ q) ') ; if(count($this->phrases)) { $qpa = db_construct_qpa ($qpa, 'AND ((') ; only in patch2: unchanged: --- fusionforge-5.1.1.orig/common/docman/actions/addsubdocgroup.php +++ fusionforge-5.1.1/common/docman/actions/addsubdocgroup.php @@ -38,7 +38,7 @@ session_redirect('/docman/?group_id='.$group_id.'&warning_msg='.urlencode($return_msg)); } } else { - $groupname = $_POST['groupname']; + $groupname = trim(getStringFromRequest('groupname')); $dg = new DocumentGroup($g); only in patch2: unchanged: --- fusionforge-5.1.1.orig/common/docman/views/addfile.php +++ fusionforge-5.1.1/common/docman/views/addfile.php @@ -110,7 +110,7 @@ '. _('Type of Document') .''.utils_requiredField() .' - '. _('File') .''. _('URL'); + '. _('File') .''. _('URL'); if (forge_get_config('use_manual_uploads')) { echo ''. _('Already-uploaded file'); } @@ -119,7 +119,7 @@ } echo ' - + '. _('Upload File') .''. utils_requiredField() .'' only in patch2: unchanged: --- fusionforge-5.1.1.orig/common/forum/Forum.class.php +++ fusionforge-5.1.1/common/forum/Forum.class.php @@ -457,7 +457,7 @@ */ $result = db_query_params ('INSERT INTO forum_monitored_forums (forum_id,user_id) VALUES ($1,$2)', array ($this->getID(), - $user_id)) ; + $u)) ; if (!$result) { $this->setError(_('Unable To Add Monitor').' : '.db_error()); only in patch2: unchanged: --- fusionforge-5.1.1.orig/common/tracker/Artifact.class.php +++ fusionforge-5.1.1/common/tracker/Artifact.class.php @@ -744,7 +744,7 @@ $user_id=user_getid(); $user =& user_get_object($user_id); if (!$user || !is_object($user)) { - $this->setError('ERROR - Logged In User Bug Could Not Get User Object'); + $this->setError('ERROR - Logged In User But Could Not Get User Object'); return false; } // we'll store this email even though it will likely never be used - @@ -803,7 +803,7 @@ return db_query_params ('INSERT INTO artifact_history(artifact_id,field_name,old_value,mod_by,entrydate) VALUES ($1,$2,$3,$4,$5)', array ($this->getID(), $field_name, - addslashes($old_value), + $old_value, $user, $time)) ; } @@ -1334,7 +1334,7 @@ } else { continue; } - } elseif (addslashes(db_result($resd,0,'field_data')) == htmlspecialchars($extra_fields[$efid])) { + } elseif (db_result($resd,0,'field_data') == htmlspecialchars($extra_fields[$efid])) { //element did not change continue; } else { only in patch2: unchanged: --- fusionforge-5.1.1.orig/common/widget/Widget_ProjectPublicAreas.class.php +++ fusionforge-5.1.1/common/widget/Widget_ProjectPublicAreas.class.php @@ -185,7 +185,11 @@ $link_content = $HTML->getFtpPic('') . ' ' . _('Anonymous FTP Space'); // print ''; - print util_make_link('ftp://' . $project->getUnixName() . '.' . forge_get_config('web_host') . '/pub/'. $project->getUnixName(), $link_content, false, true); + if (forge_get_config('use_project_vhost')) { + print util_make_link('ftp://' . $project->getUnixName() . '.' . forge_get_config('web_host') . '/pub/'. $project->getUnixName(), $link_content, false, true); + } else { + print util_make_link('ftp://' . forge_get_config('web_host') . '/pub/'. $project->getUnixName(), $link_content, false, true); + } echo "\n\n"; } } only in patch2: unchanged: --- fusionforge-5.1.1.orig/common/reporting/ReportSetup.class.php +++ fusionforge-5.1.1/common/reporting/ReportSetup.class.php @@ -292,6 +292,7 @@ $sql[]="DROP VIEW rep_site_act_oa_vw"; $sql[]="CREATE VIEW rep_site_act_oa_vw AS + SELECT sum(tracker_opened) AS tracker_opened, sum(tracker_closed) AS tracker_closed, sum(forum) AS forum, only in patch2: unchanged: --- fusionforge-5.1.1.orig/debian/dsf-in/web-apache2-vhosts.logrotate +++ fusionforge-5.1.1/debian/dsf-in/web-apache2-vhosts.logrotate @@ -0,0 +1,10 @@ +/var/log/@OLDPACKAGE@/vhosts/*/access.log { + weekly + missingok + rotate 52 + compress + delaycompress + notifempty + create 640 root adm + sharedscripts +} only in patch2: unchanged: --- fusionforge-5.1.1.orig/debian/dsf-in/web-apache2.logrotate +++ fusionforge-5.1.1/debian/dsf-in/web-apache2.logrotate @@ -0,0 +1,11 @@ +/var/log/@OLDPACKAGE@/access.log /var/log/@OLDPACKAGE@/awstats.log { + weekly + missingok + rotate 52 + compress + delaycompress + notifempty + create 640 root adm + sharedscripts +} +