From ed9e9b65cf300bf249f4851cd1397fe6ecc6794b Mon Sep 17 00:00:00 2001 From: Matthieu Marcillaud <marcimat@rezo.net> Date: Sat, 2 Mar 2013 11:16:23 +0000 Subject: [PATCH] =?UTF-8?q?Correction=20d'une=20bard=C3=A9e=20de=20notices?= =?UTF-8?q?=20PHP=20=C3=A0=20l'installation=20de=20SPIP.=20Il=20en=20reste?= =?UTF-8?q?=20!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ecrire/base/objets.php | 8 ++++++-- ecrire/base/trouver_table.php | 4 +++- ecrire/inc/charsets.php | 20 +++++++++++++------- ecrire/inc/config.php | 2 +- ecrire/inc/filtres.php | 2 +- ecrire/inc/filtres_mini.php | 2 +- ecrire/inc/meta.php | 6 ++++-- ecrire/inc/traduire.php | 2 +- ecrire/inc/utils.php | 6 ++++-- ecrire/install/etape_1.php | 2 +- 10 files changed, 35 insertions(+), 19 deletions(-) diff --git a/ecrire/base/objets.php b/ecrire/base/objets.php index 72eda3c114..8926090134 100644 --- a/ecrire/base/objets.php +++ b/ecrire/base/objets.php @@ -54,9 +54,13 @@ function lister_tables_objets_sql($table_sql=null, $desc=array()){ static $infos_tables = null; static $md5 = null; static $plugin_hash = null; + + // plugins hash connu ? non si _CACHE_PLUGINS_OPT est pas encore chargé. + $_PLUGINS_HASH = defined('_PLUGINS_HASH') ? _PLUGINS_HASH : '!_CACHE_PLUGINS_OPT'; + // prealablement recuperer les tables_principales if (is_null($infos_tables) - OR $plugin_hash!==_PLUGINS_HASH){ + OR $plugin_hash!==$_PLUGINS_HASH){ // pas de reentrance (cas base/serial) if ($deja_la) { spip_log ("Re-entrance anormale sur lister_tables_objets_sql :" @@ -64,7 +68,7 @@ function lister_tables_objets_sql($table_sql=null, $desc=array()){ return ($table_sql==="::md5"?$md5:array()); } $deja_la = true; - $plugin_hash = _PLUGINS_HASH; // avant de lancer les pipelines + $plugin_hash = $_PLUGINS_HASH; // avant de lancer les pipelines // recuperer les declarations explicites ancienne mode // qui servent a completer declarer_tables_objets_sql diff --git a/ecrire/base/trouver_table.php b/ecrire/base/trouver_table.php index b3824ee6a1..9e02081e84 100644 --- a/ecrire/base/trouver_table.php +++ b/ecrire/base/trouver_table.php @@ -151,9 +151,11 @@ function base_trouver_table_dist($nom, $serveur='', $table_spip = true){ // on ne sait pas lire la structure de la table : // on retombe sur la description donnee dans les fichiers spip $desc = $fdesc; + $desc['exist'] = false; } - else + else { $desc['exist'] = true; + } $desc['table'] = $desc['table_sql'] = $nom_sql; $desc['connexion']= $serveur; diff --git a/ecrire/inc/charsets.php b/ecrire/inc/charsets.php index eebd21d770..73a6d75503 100644 --- a/ecrire/inc/charsets.php +++ b/ecrire/inc/charsets.php @@ -23,6 +23,8 @@ // securité if (!defined('_ECRIRE_INC_VERSION')) return; +// se faciliter la lecture du charset +include_spip('inc/config'); /** * Charge en mémoire la liste des caractères d'un charset @@ -84,7 +86,7 @@ function init_mb_string() { AND function_exists('mb_encode_mimeheader') AND function_exists('mb_encode_numericentity') AND function_exists('mb_decode_numericentity') - AND mb_detect_order($GLOBALS['meta']['charset']) + AND mb_detect_order(lire_config('charset', _DEFAULT_CHARSET)) ) { mb_internal_encoding('utf-8'); $mb = 1; @@ -214,7 +216,9 @@ function corriger_caracteres_windows($texte, $charset='AUTO', $charset_cible='un return array_map('corriger_caracteres_windows', $texte); } - if ($charset=='AUTO') $charset = $GLOBALS['meta']['charset']; + if ($charset=='AUTO') { + $charset = lire_config('charset', _DEFAULT_CHARSET); + } if ($charset == 'utf-8') { $p = chr(194); if (strpos($texte,$p)==false) @@ -347,8 +351,9 @@ function mathml2unicode($texte) { function charset2unicode($texte, $charset='AUTO' /* $forcer: obsolete*/) { static $trans; - if ($charset == 'AUTO') - $charset = $GLOBALS['meta']['charset']; + if ($charset == 'AUTO') { + $charset = lire_config('charset', _DEFAULT_CHARSET); + } if ($charset == '') $charset = 'iso-8859-1'; $charset = strtolower($charset); @@ -418,8 +423,9 @@ function unicode2charset($texte, $charset='AUTO') { static $CHARSET_REVERSE; static $trans = array(); - if ($charset == 'AUTO') - $charset = $GLOBALS['meta']['charset']; + if ($charset == 'AUTO') { + $charset = lire_config('charset', _DEFAULT_CHARSET); + } switch($charset) { case 'utf-8': @@ -1056,7 +1062,7 @@ if (!isset($GLOBALS['meta']['pcre_u']) OR (isset($_GET['var_mode']) AND !isset($_GET['var_profile']))) { include_spip('inc/meta'); ecrire_meta('pcre_u', - $u = ($GLOBALS['meta']['charset'] == 'utf-8' + $u = (lire_config('charset', _DEFAULT_CHARSET) AND test_pcre_unicode()) ? 'u' :'' ); diff --git a/ecrire/inc/config.php b/ecrire/inc/config.php index a4f80f4006..88ee848802 100644 --- a/ecrire/inc/config.php +++ b/ecrire/inc/config.php @@ -459,7 +459,7 @@ function actualise_metas($liste_meta) sql_updateq('spip_meta',array('impt'=>'non'),sql_in('nom',$meta_serveur)); while (list($nom, $valeur) = each($liste_meta)) { - if (!$GLOBALS['meta'][$nom]) { + if (!isset($GLOBALS['meta'][$nom]) OR !$GLOBALS['meta'][$nom]) { ecrire_meta($nom, $valeur); } } diff --git a/ecrire/inc/filtres.php b/ecrire/inc/filtres.php index db63c06e7c..38a3744988 100644 --- a/ecrire/inc/filtres.php +++ b/ecrire/inc/filtres.php @@ -568,7 +568,7 @@ function texte_backend($texte) { $texte = charset2unicode($texte); // Caracteres problematiques en iso-latin 1 - if ($GLOBALS['meta']['charset'] == 'iso-8859-1') { + if (isset($GLOBALS['meta']['charset']) and $GLOBALS['meta']['charset'] == 'iso-8859-1') { $texte = str_replace(chr(156), 'œ', $texte); $texte = str_replace(chr(140), 'Œ', $texte); $texte = str_replace(chr(159), 'Ÿ', $texte); diff --git a/ecrire/inc/filtres_mini.php b/ecrire/inc/filtres_mini.php index 9490423279..2af1cba47e 100644 --- a/ecrire/inc/filtres_mini.php +++ b/ecrire/inc/filtres_mini.php @@ -65,7 +65,7 @@ function suivre_lien($url, $lien) { if (preg_match(',^(mailto|javascript):,iS', $lien)) return $lien; if (preg_match(';^((?:[a-z]{3,7}:)?//.*?)(/.*)?$;iS', $lien, $r)) { - $r = array_pad($r, 2, null); + $r = array_pad($r, 3, null); return $r[1].resolve_path($r[2]); } diff --git a/ecrire/inc/meta.php b/ecrire/inc/meta.php index 11d27d2b0c..0450182650 100644 --- a/ecrire/inc/meta.php +++ b/ecrire/inc/meta.php @@ -72,10 +72,12 @@ function lire_metas($table='meta') { $GLOBALS[$table][$row['nom']] = $row['valeur']; sql_free($result); - if (!$GLOBALS[$table]['charset'] + if (!isset($GLOBALS[$table]['charset']) + OR !$GLOBALS[$table]['charset'] OR $GLOBALS[$table]['charset']=='_DEFAULT_CHARSET' // hum, correction d'un bug ayant abime quelques install - ) + ) { ecrire_meta('charset', _DEFAULT_CHARSET, NULL, $table); + } // noter cette table de configuration dans les meta de SPIP if ($table!=='meta') { diff --git a/ecrire/inc/traduire.php b/ecrire/inc/traduire.php index 9544272b6b..4d7e32df9d 100644 --- a/ecrire/inc/traduire.php +++ b/ecrire/inc/traduire.php @@ -170,7 +170,7 @@ function inc_traduire_dist($ori, $lang) { // Si on n'est pas en utf-8, la chaine peut l'etre... // le cas echeant on la convertit en entites html &#xxx; - if ($GLOBALS['meta']['charset'] !== 'utf-8' + if ((!isset($GLOBALS['meta']['charset']) OR $GLOBALS['meta']['charset'] !== 'utf-8') AND preg_match(',[\x7f-\xff],S', $text)) { include_spip('inc/charsets'); $text = charset2unicode($text,'utf-8'); diff --git a/ecrire/inc/utils.php b/ecrire/inc/utils.php index d420720fe3..86a415c5fc 100644 --- a/ecrire/inc/utils.php +++ b/ecrire/inc/utils.php @@ -1808,8 +1808,10 @@ function spip_initialisation_core($pi=NULL, $pa=NULL, $ti=NULL, $ta=NULL) { // Se mefier des fichiers mal remplis! if (!defined('_SPIP_CHMOD')) define('_SPIP_CHMOD', 0777); - // Le charset par defaut lors de l'installation - if (!defined('_DEFAULT_CHARSET')) define('_DEFAULT_CHARSET', 'utf-8'); + if (!defined('_DEFAULT_CHARSET')) { + /** Le charset par défaut lors de l'installation */ + define('_DEFAULT_CHARSET', 'utf-8'); + } if (!defined('_ROOT_PLUGINS')) define('_ROOT_PLUGINS', _ROOT_RACINE . "plugins/"); if (!defined('_ROOT_PLUGINS_DIST')) define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . "plugins-dist/"); if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE,'',_DIR_PLUGINS_SUPPL)); diff --git a/ecrire/install/etape_1.php b/ecrire/install/etape_1.php index 17ffc22417..22f37cad3e 100644 --- a/ecrire/install/etape_1.php +++ b/ecrire/install/etape_1.php @@ -39,7 +39,7 @@ function install_etape_1_dist() $db = array($adresse_db, _T('entree_base_donnee_2')); $login = array($login_db, _T('entree_login_connexion_2')); - $pass = array($pass_db, _T('entree_mot_passe_2')); + $pass = array('', _T('entree_mot_passe_2')); $predef = array(defined('_INSTALL_SERVER_DB') ? _INSTALL_SERVER_DB:'', defined('_INSTALL_HOST_DB'), -- GitLab