dépôts
/
lhc
/
web
/
www.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[SPIP] ~spip v3.2.0-->v3.2.1
[lhc/web/www.git]
/
www
/
ecrire
/
inc
/
rechercher.php
diff --git
a/www/ecrire/inc/rechercher.php
b/www/ecrire/inc/rechercher.php
index
0cf0452
..
4d08038
100644
(file)
--- a/
www/ecrire/inc/rechercher.php
+++ b/
www/ecrire/inc/rechercher.php
@@
-20,6
+20,7
@@
if (!defined('_ECRIRE_INC_VERSION')) {
return;
}
return;
}
+defined('_RECHERCHE_LOCK_KEY') || define('_RECHERCHE_LOCK_KEY', 'fulltext');
/**
* Donne la liste des champs/tables où l'on sait chercher / remplacer
/**
* Donne la liste des champs/tables où l'on sait chercher / remplacer
@@
-91,6
+92,10
@@
function expression_recherche($recherche, $options) {
include_spip('inc/charsets');
$recherche = trim($recherche);
include_spip('inc/charsets');
$recherche = trim($recherche);
+ // retirer les + de +truc et les * de truc*
+ $recherche = preg_replace(',(^|\s)\+(\w),Uims', '$1$2', $recherche);
+ $recherche = preg_replace(',(\w)\*($|\s),Uims', '$1$2', $recherche);
+
$is_preg = false;
if (substr($recherche, 0, 1) == '/' and substr($recherche, -1, 1) == '/' and strlen($recherche) > 2) {
// c'est une preg
$is_preg = false;
if (substr($recherche, 0, 1) == '/' and substr($recherche, -1, 1) == '/' and strlen($recherche) > 2) {
// c'est une preg
@@
-179,6
+184,7
@@
function expression_recherche($recherche, $options) {
);
$preg = '/' . preg_replace(",\s+," . $u, ".+", trim($recherche_mod)) . '/' . $options['preg_flags'];
);
$preg = '/' . preg_replace(",\s+," . $u, ".+", trim($recherche_mod)) . '/' . $options['preg_flags'];
+
} else {
$methode = 'REGEXP';
$q = sql_quote(trim($recherche, '/'));
} else {
$methode = 'REGEXP';
$q = sql_quote(trim($recherche, '/'));
@@
-289,16
+295,17
@@
function recherche_en_base($recherche = '', $tables = null, $options = array(),
// id2 = { 'score' => x, attrs => { } },
// }
// id2 = { 'score' => x, attrs => { } },
// }
+ include_spip('inc/recherche_to_array');
+
foreach ($tables as $table => $champs) {
# lock via memoization, si dispo
if (function_exists('cache_lock')) {
foreach ($tables as $table => $champs) {
# lock via memoization, si dispo
if (function_exists('cache_lock')) {
- cache_lock($lock =
'recherche
' . $table . ' ' . $recherche);
+ cache_lock($lock =
_RECHERCHE_LOCK_KEY . '
' . $table . ' ' . $recherche);
}
spip_timer('rech');
}
spip_timer('rech');
- // TODO: ici plutot charger un iterateur via l'API iterateurs
- include_spip('inc/recherche_to_array');
+ # TODO : ici plutot charger un iterateur via l'API iterateurs
$to_array = charger_fonction('recherche_to_array', 'inc');
$results[$table] = $to_array($recherche,
array_merge($options, array('table' => $table, 'champs' => $champs))
$to_array = charger_fonction('recherche_to_array', 'inc');
$results[$table] = $to_array($recherche,
array_merge($options, array('table' => $table, 'champs' => $champs))
@@
-350,7
+357,7
@@
function remplace_en_base($recherche = '', $remplace = null, $tables = null, $op
$modifs = array();
foreach ($x['champs'] as $key => $val) {
if ($key == $_id_table) {
$modifs = array();
foreach ($x['champs'] as $key => $val) {
if ($key == $_id_table) {
-
next
;
+
continue
;
}
$repl = preg_replace($preg, $remplace, $val);
if ($repl <> $val) {
}
$repl = preg_replace($preg, $remplace, $val);
if ($repl <> $val) {