drupal core updated to 7.28

This commit is contained in:
Bachir Soussi Chiadmi
2014-07-07 18:53:44 +02:00
parent 10de06dd70
commit c3011cef61
263 changed files with 3331 additions and 8894 deletions

View File

@@ -25,7 +25,7 @@
* the template.
*
* Default keys within $info_split:
* - $info_split['type']: Node type (or item type string supplied by module).
* - $info_split['module']: The module that implemented the search query.
* - $info_split['user']: Author of the node linked to users profile. Depends
* on permission.
* - $info_split['date']: Last update of the node. Short formatted.

View File

@@ -105,6 +105,8 @@ class SearchQuery extends SelectQueryExtender {
* Stores score expressions.
*
* @var array
*
* @see addScore()
*/
protected $scores = array();
@@ -116,7 +118,7 @@ class SearchQuery extends SelectQueryExtender {
protected $scoresArguments = array();
/**
* Total value of all the multipliers.
* Stores multipliers for score expressions.
*
* @var array
*/
@@ -391,21 +393,39 @@ class SearchQuery extends SelectQueryExtender {
/**
* Adds a custom score expression to the search query.
*
* Each score expression can optionally use a multiplier, and multiple
* expressions are combined.
* Score expressions are used to order search results. If no calls to
* addScore() have taken place, a default keyword relevance score will be
* used. However, if at least one call to addScore() has taken place, the
* keyword relevance score is not automatically added.
*
* Also note that if you call orderBy() directly on the query, search scores
* will not automatically be used to order search results. Your orderBy()
* expression can reference 'calculated_score', which will be the total
* calculated score value.
*
* @param $score
* The score expression.
* The score expression, which should evaluate to a number between 0 and 1.
* The string 'i.relevance' in a score expression will be replaced by a
* measure of keyword relevance between 0 and 1.
* @param $arguments
* Custom query arguments for that expression.
* Query arguments needed to provide values to the score expression.
* @param $multiply
* If set, the score is multiplied with that value. Search query ensures
* that the search scores are still normalized.
* If set, the score is multiplied with this value. However, all scores
* with multipliers are then divided by the total of all multipliers, so
* that overall, the normalization is maintained.
*
* @return object
* The updated query object.
*/
public function addScore($score, $arguments = array(), $multiply = FALSE) {
if ($multiply) {
$i = count($this->multiply);
// Modify the score expression so it is multiplied by the multiplier,
// with a divisor to renormalize.
$score = "CAST(:multiply_$i AS DECIMAL) * COALESCE(( " . $score . "), 0) / CAST(:total_$i AS DECIMAL)";
// Add an argument for the multiplier. The :total_$i argument is taken
// care of in the execute() method, which is when the total divisor is
// calculated.
$arguments[':multiply_' . $i] = $multiply;
$this->multiply[] = $multiply;
}
@@ -446,8 +466,9 @@ class SearchQuery extends SelectQueryExtender {
}
if (count($this->multiply)) {
// Add the total multiplicator as many times as requested to maintain
// normalization as far as possible.
// Re-normalize scores with multipliers by dividing by the total of all
// multipliers. The expressions were altered in addScore(), so here just
// add the arguments for the total.
$i = 0;
$sum = array_sum($this->multiply);
foreach ($this->multiply as $total) {
@@ -456,13 +477,20 @@ class SearchQuery extends SelectQueryExtender {
}
}
// Replace i.relevance pseudo-field with the actual, normalized value.
$this->scores = str_replace('i.relevance', '(' . (1.0 / $this->normalize) . ' * i.score * t.count)', $this->scores);
// Convert scores to an expression.
// Replace the pseudo-expression 'i.relevance' with a measure of keyword
// relevance in all score expressions, using string replacement. Careful
// though! If you just print out a float, some locales use ',' as the
// decimal separator in PHP, while SQL always uses '.'. So, make sure to
// set the number format correctly.
$relevance = number_format((1.0 / $this->normalize), 10, '.', '');
$this->scores = str_replace('i.relevance', '(' . $relevance . ' * i.score * t.count)', $this->scores);
// Add all scores together to form a query field.
$this->addExpression('SUM(' . implode(' + ', $this->scores) . ')', 'calculated_score', $this->scoresArguments);
// If an order has not yet been set for this query, add a default order
// that sorts by the calculated sum of scores.
if (count($this->getOrderBy()) == 0) {
// Add default order after adding the expression.
$this->orderBy('calculated_score', 'DESC');
}

View File

@@ -8,8 +8,8 @@ files[] = search.test
configure = admin/config/search/settings
stylesheets[all][] = search.css
; Information added by drupal.org packaging script on 2013-08-08
version = "7.23"
; Information added by Drupal.org packaging script on 2014-05-08
version = "7.28"
project = "drupal"
datestamp = "1375928238"
datestamp = "1399522731"

View File

@@ -11,6 +11,9 @@ define('SEARCH_TYPE', '_test_');
define('SEARCH_TYPE_2', '_test2_');
define('SEARCH_TYPE_JPN', '_test3_');
/**
* Indexes content and queries it.
*/
class SearchMatchTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
@@ -307,6 +310,9 @@ class SearchPageText extends DrupalWebTestCase {
}
}
/**
* Indexes content and tests the advanced search form.
*/
class SearchAdvancedSearchForm extends DrupalWebTestCase {
protected $node;
@@ -370,6 +376,9 @@ class SearchAdvancedSearchForm extends DrupalWebTestCase {
}
}
/**
* Indexes content and tests ranking factors.
*/
class SearchRankingTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
@@ -580,6 +589,9 @@ class SearchRankingTestCase extends DrupalWebTestCase {
}
}
/**
* Tests the rendering of the search block.
*/
class SearchBlockTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
@@ -727,7 +739,7 @@ class SearchCommentTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => 'Comment Search tests',
'description' => 'Verify text formats and filters used elsewhere.',
'description' => 'Test integration searching comments.',
'group' => 'Search',
);
}
@@ -1567,7 +1579,7 @@ class SearchConfigSettingsForm extends DrupalWebTestCase {
/**
* Tests the search_excerpt() function.
*/
class SearchExcerptTestCase extends DrupalUnitTestCase {
class SearchExcerptTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => 'Search excerpt extraction',
@@ -1577,8 +1589,7 @@ class SearchExcerptTestCase extends DrupalUnitTestCase {
}
function setUp() {
drupal_load('module', 'search');
parent::setUp();
parent::setUp('search');
}
/**
@@ -1603,7 +1614,7 @@ class SearchExcerptTestCase extends DrupalUnitTestCase {
$this->assertEqual($result, 'The quick brown <strong>fox</strong> &amp; jumps over the lazy dog ...', 'Found keyword is highlighted');
$longtext = str_repeat($text . ' ', 10);
$result = preg_replace('| +|', ' ', search_excerpt('nothing', $text));
$result = preg_replace('| +|', ' ', search_excerpt('nothing', $longtext));
$this->assertTrue(strpos($result, $expected) === 0, 'When keyword is not found in long string, return value starts as expected');
$entities = str_repeat('k&eacute;sz&iacute;t&eacute;se ', 20);
@@ -2036,3 +2047,45 @@ class SearchNodeAccessTest extends DrupalWebTestCase {
$this->assertText($node->title);
}
}
/**
* Tests searching with locale values set.
*/
class SearchSetLocaleTest extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => 'Search with numeric locale set',
'description' => 'Check that search works with numeric locale settings',
'group' => 'Search',
);
}
function setUp() {
parent::setUp('search');
// Create a simple node so something will be put in the index.
$info = array(
'body' => array(LANGUAGE_NONE => array(array('value' => 'Tapir'))),
);
$this->drupalCreateNode($info);
// Run cron to index.
$this->cronRun();
}
/**
* Verify that search works with a numeric locale set.
*/
public function testSearchWithNumericLocale() {
// French decimal point is comma.
setlocale(LC_NUMERIC, 'fr_FR');
// An exception will be thrown if a float in the wrong format occurs in the
// query to the database, so an assertion is not necessary here.
db_select('search_index', 'i')
->extend('searchquery')
->searchexpression('tapir', 'node')
->execute();
}
}

View File

@@ -5,8 +5,8 @@ version = VERSION
core = 7.x
hidden = TRUE
; Information added by drupal.org packaging script on 2013-08-08
version = "7.23"
; Information added by Drupal.org packaging script on 2014-05-08
version = "7.28"
project = "drupal"
datestamp = "1375928238"
datestamp = "1399522731"

View File

@@ -5,8 +5,8 @@ version = VERSION
core = 7.x
hidden = TRUE
; Information added by drupal.org packaging script on 2013-08-08
version = "7.23"
; Information added by Drupal.org packaging script on 2014-05-08
version = "7.28"
project = "drupal"
datestamp = "1375928238"
datestamp = "1399522731"