@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | * @package SPIP\Core\SQL\Upgrade |
| 19 | 19 | **/ |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | include_spip('base/medias'); |
@@ -27,27 +27,27 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | // http://archives.rezo.net/archives/spip-zone.mbox/C6RZKNBUNJYN42IOEOC4QKVCA233AMLI/ |
| 29 | 29 | $GLOBALS['maj'][13833] = [ |
| 30 | - ['sql_alter', 'TABLE spip_documents_liens ADD INDEX objet(id_objet,objet)'] |
|
| 30 | + ['sql_alter', 'TABLE spip_documents_liens ADD INDEX objet(id_objet,objet)'] |
|
| 31 | 31 | ]; |
| 32 | 32 | |
| 33 | 33 | // 2.1 |
| 34 | 34 | |
| 35 | 35 | $GLOBALS['maj'][13904] = [ |
| 36 | - ['sql_alter', "TABLE spip_auteurs ADD webmestre varchar(3) DEFAULT 'non' NOT NULL"], |
|
| 37 | - [ |
|
| 38 | - 'sql_update', |
|
| 39 | - 'spip_auteurs', |
|
| 40 | - ['webmestre' => "'oui'"], |
|
| 41 | - sql_in('id_auteur', defined('_ID_WEBMESTRES') ? explode( |
|
| 42 | - ':', |
|
| 43 | - _ID_WEBMESTRES |
|
| 44 | - ) : (autoriser('configurer') ? [$GLOBALS['visiteur_session']['id_auteur']] : [0])) |
|
| 45 | - ] // le webmestre est celui qui fait l'upgrade si rien de defini |
|
| 36 | + ['sql_alter', "TABLE spip_auteurs ADD webmestre varchar(3) DEFAULT 'non' NOT NULL"], |
|
| 37 | + [ |
|
| 38 | + 'sql_update', |
|
| 39 | + 'spip_auteurs', |
|
| 40 | + ['webmestre' => "'oui'"], |
|
| 41 | + sql_in('id_auteur', defined('_ID_WEBMESTRES') ? explode( |
|
| 42 | + ':', |
|
| 43 | + _ID_WEBMESTRES |
|
| 44 | + ) : (autoriser('configurer') ? [$GLOBALS['visiteur_session']['id_auteur']] : [0])) |
|
| 45 | + ] // le webmestre est celui qui fait l'upgrade si rien de defini |
|
| 46 | 46 | ]; |
| 47 | 47 | |
| 48 | 48 | // sites plantes en mode "'su" au lieu de "sus" |
| 49 | 49 | $GLOBALS['maj'][13929] = [ |
| 50 | - ['sql_update', 'spip_syndic', ['syndication' => "'sus'"], "syndication LIKE '\\'%'"] |
|
| 50 | + ['sql_update', 'spip_syndic', ['syndication' => "'sus'"], "syndication LIKE '\\'%'"] |
|
| 51 | 51 | ]; |
| 52 | 52 | |
| 53 | 53 | // Types de fichiers m4a/m4b/m4p/m4u/m4v/dv |
@@ -61,24 +61,24 @@ discard block |
||
| 61 | 61 | // La version 14588 etait une mauvaise piste: |
| 62 | 62 | // Retour en arriere pour ceux qui l'ont subi, ne rien faire sinon |
| 63 | 63 | if (@$GLOBALS['meta']['version_installee'] >= 14588) { |
| 64 | - // "mode" est un mot-cle d'Oracle |
|
| 65 | - $GLOBALS['maj'][14588] = [ |
|
| 66 | - ['sql_alter', 'TABLE spip_documents DROP INDEX mode'], |
|
| 67 | - [ |
|
| 68 | - 'sql_alter', |
|
| 69 | - "TABLE spip_documents CHANGE mode genre ENUM('vignette', 'image', 'document') DEFAULT 'document' NOT NULL" |
|
| 70 | - ], |
|
| 71 | - ['sql_alter', 'TABLE spip_documents ADD INDEX genre(genre)'] |
|
| 72 | - ]; |
|
| 73 | - // solution moins intrusive au pb de mot-cle d'Oracle, retour avant 14588 |
|
| 74 | - $GLOBALS['maj'][14598] = [ |
|
| 75 | - ['sql_alter', 'TABLE spip_documents DROP INDEX genre'], |
|
| 76 | - [ |
|
| 77 | - 'sql_alter', |
|
| 78 | - "TABLE spip_documents CHANGE genre mode ENUM('vignette', 'image', 'document') DEFAULT 'document' NOT NULL" |
|
| 79 | - ], |
|
| 80 | - ['sql_alter', 'TABLE spip_documents ADD INDEX mode(mode)'] |
|
| 81 | - ]; |
|
| 64 | + // "mode" est un mot-cle d'Oracle |
|
| 65 | + $GLOBALS['maj'][14588] = [ |
|
| 66 | + ['sql_alter', 'TABLE spip_documents DROP INDEX mode'], |
|
| 67 | + [ |
|
| 68 | + 'sql_alter', |
|
| 69 | + "TABLE spip_documents CHANGE mode genre ENUM('vignette', 'image', 'document') DEFAULT 'document' NOT NULL" |
|
| 70 | + ], |
|
| 71 | + ['sql_alter', 'TABLE spip_documents ADD INDEX genre(genre)'] |
|
| 72 | + ]; |
|
| 73 | + // solution moins intrusive au pb de mot-cle d'Oracle, retour avant 14588 |
|
| 74 | + $GLOBALS['maj'][14598] = [ |
|
| 75 | + ['sql_alter', 'TABLE spip_documents DROP INDEX genre'], |
|
| 76 | + [ |
|
| 77 | + 'sql_alter', |
|
| 78 | + "TABLE spip_documents CHANGE genre mode ENUM('vignette', 'image', 'document') DEFAULT 'document' NOT NULL" |
|
| 79 | + ], |
|
| 80 | + ['sql_alter', 'TABLE spip_documents ADD INDEX mode(mode)'] |
|
| 81 | + ]; |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | // Restauration correcte des types mime des fichiers Ogg |
@@ -18,10 +18,10 @@ |
||
| 18 | 18 | * @package SPIP\Core\SQL\Upgrade |
| 19 | 19 | **/ |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | |
| 25 | 25 | $GLOBALS['maj'][23375] = [ |
| 26 | - ['sql_alter', 'TABLE spip_auteurs CHANGE prefs prefs text'], |
|
| 26 | + ['sql_alter', 'TABLE spip_auteurs CHANGE prefs prefs text'], |
|
| 27 | 27 | ]; |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * @package SPIP\Core\SQL\Upgrade |
| 21 | 21 | **/ |
| 22 | 22 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 23 | - return; |
|
| 23 | + return; |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | |
@@ -35,49 +35,49 @@ discard block |
||
| 35 | 35 | **/ |
| 36 | 36 | function maj_timestamp_mysql($tables = null) { |
| 37 | 37 | |
| 38 | - include_spip('base/dump'); |
|
| 39 | - if (is_null($tables)) { |
|
| 40 | - $tables = base_lister_toutes_tables(); |
|
| 41 | - } elseif (is_string($tables)) { |
|
| 42 | - $tables = [$tables]; |
|
| 43 | - } elseif (!is_array($tables)) { |
|
| 44 | - return; |
|
| 45 | - } |
|
| 38 | + include_spip('base/dump'); |
|
| 39 | + if (is_null($tables)) { |
|
| 40 | + $tables = base_lister_toutes_tables(); |
|
| 41 | + } elseif (is_string($tables)) { |
|
| 42 | + $tables = [$tables]; |
|
| 43 | + } elseif (!is_array($tables)) { |
|
| 44 | + return; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - // rien a faire si base non mysql |
|
| 48 | - if (strncmp($GLOBALS['connexions'][0]['type'], 'mysql', 5) !== 0) { |
|
| 49 | - return; |
|
| 50 | - } |
|
| 47 | + // rien a faire si base non mysql |
|
| 48 | + if (strncmp($GLOBALS['connexions'][0]['type'], 'mysql', 5) !== 0) { |
|
| 49 | + return; |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 53 | - // forcer le vidage de cache |
|
| 54 | - $trouver_table(''); |
|
| 52 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 53 | + // forcer le vidage de cache |
|
| 54 | + $trouver_table(''); |
|
| 55 | 55 | |
| 56 | - foreach ($tables as $table) { |
|
| 57 | - if (time() >= _TIME_OUT) { |
|
| 58 | - return; |
|
| 59 | - } |
|
| 60 | - if ($desc = $trouver_table($table)) { |
|
| 61 | - $fields_corrected = _mysql_remplacements_definitions_table($desc['field']); |
|
| 62 | - $d = array_diff($desc['field'], $fields_corrected); |
|
| 63 | - if ($d) { |
|
| 64 | - spip_log("Table $table TIMESTAMP incorrect", 'maj'); |
|
| 65 | - foreach ($desc['field'] as $field => $type) { |
|
| 66 | - if ($desc['field'][$field] !== $fields_corrected[$field]) { |
|
| 67 | - spip_log("Adaptation TIMESTAMP table $table", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 68 | - sql_alter("table $table change $field $field " . $fields_corrected[$field]); |
|
| 69 | - $trouver_table(''); |
|
| 70 | - $new_desc = $trouver_table($table); |
|
| 71 | - spip_log( |
|
| 72 | - "Apres conversion $table : " . var_export($new_desc['field'], true), |
|
| 73 | - 'maj.' . _LOG_INFO_IMPORTANTE |
|
| 74 | - ); |
|
| 75 | - } |
|
| 76 | - } |
|
| 77 | - } |
|
| 78 | - } |
|
| 79 | - } |
|
| 56 | + foreach ($tables as $table) { |
|
| 57 | + if (time() >= _TIME_OUT) { |
|
| 58 | + return; |
|
| 59 | + } |
|
| 60 | + if ($desc = $trouver_table($table)) { |
|
| 61 | + $fields_corrected = _mysql_remplacements_definitions_table($desc['field']); |
|
| 62 | + $d = array_diff($desc['field'], $fields_corrected); |
|
| 63 | + if ($d) { |
|
| 64 | + spip_log("Table $table TIMESTAMP incorrect", 'maj'); |
|
| 65 | + foreach ($desc['field'] as $field => $type) { |
|
| 66 | + if ($desc['field'][$field] !== $fields_corrected[$field]) { |
|
| 67 | + spip_log("Adaptation TIMESTAMP table $table", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 68 | + sql_alter("table $table change $field $field " . $fields_corrected[$field]); |
|
| 69 | + $trouver_table(''); |
|
| 70 | + $new_desc = $trouver_table($table); |
|
| 71 | + spip_log( |
|
| 72 | + "Apres conversion $table : " . var_export($new_desc['field'], true), |
|
| 73 | + 'maj.' . _LOG_INFO_IMPORTANTE |
|
| 74 | + ); |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - // forcer le vidage de cache |
|
| 82 | - $trouver_table(''); |
|
| 81 | + // forcer le vidage de cache |
|
| 82 | + $trouver_table(''); |
|
| 83 | 83 | } |
@@ -64,13 +64,13 @@ |
||
| 64 | 64 | spip_log("Table $table TIMESTAMP incorrect", 'maj'); |
| 65 | 65 | foreach ($desc['field'] as $field => $type) { |
| 66 | 66 | if ($desc['field'][$field] !== $fields_corrected[$field]) { |
| 67 | - spip_log("Adaptation TIMESTAMP table $table", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 68 | - sql_alter("table $table change $field $field " . $fields_corrected[$field]); |
|
| 67 | + spip_log("Adaptation TIMESTAMP table $table", 'maj.'._LOG_INFO_IMPORTANTE); |
|
| 68 | + sql_alter("table $table change $field $field ".$fields_corrected[$field]); |
|
| 69 | 69 | $trouver_table(''); |
| 70 | 70 | $new_desc = $trouver_table($table); |
| 71 | 71 | spip_log( |
| 72 | - "Apres conversion $table : " . var_export($new_desc['field'], true), |
|
| 73 | - 'maj.' . _LOG_INFO_IMPORTANTE |
|
| 72 | + "Apres conversion $table : ".var_export($new_desc['field'], true), |
|
| 73 | + 'maj.'._LOG_INFO_IMPORTANTE |
|
| 74 | 74 | ); |
| 75 | 75 | } |
| 76 | 76 | } |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | include_spip('maj/legacy/v30'); |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | 19 | return; |
| 20 | 20 | } |
| 21 | -require_once _ROOT_RESTREINT . 'base/objets.php'; |
|
| 21 | +require_once _ROOT_RESTREINT.'base/objets.php'; |
|
| 22 | 22 | |
| 23 | 23 | |
| 24 | 24 | /** |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | $f = (!preg_match('/^[\w\.]*$/', $serveur)) |
| 60 | 60 | ? '' // nom de serveur mal ecrit |
| 61 | 61 | : ($serveur ? |
| 62 | - (_DIR_CONNECT . $serveur . '.php') // serveur externe |
|
| 62 | + (_DIR_CONNECT.$serveur.'.php') // serveur externe |
|
| 63 | 63 | : (_FILE_CONNECT ? _FILE_CONNECT // serveur principal ok |
| 64 | 64 | : ($install ? _FILE_CONNECT_TMP // init du serveur principal |
| 65 | 65 | : ''))); // installation pas faite |
@@ -102,9 +102,9 @@ discard block |
||
| 102 | 102 | // chargement de la version du jeu de fonctions |
| 103 | 103 | // si pas dans le fichier par defaut |
| 104 | 104 | $type = $GLOBALS['db_ok']['type']; |
| 105 | - $jeu = 'spip_' . $type . '_functions_' . $version; |
|
| 105 | + $jeu = 'spip_'.$type.'_functions_'.$version; |
|
| 106 | 106 | if (!isset($GLOBALS[$jeu])) { |
| 107 | - if (!find_in_path($type . '_' . $version . '.php', 'req/', true)) { |
|
| 107 | + if (!find_in_path($type.'_'.$version.'.php', 'req/', true)) { |
|
| 108 | 108 | spip_log("spip_connect: serveur $index version '$version' non defini pour '$type'", _LOG_HS); |
| 109 | 109 | |
| 110 | 110 | // ne plus reessayer |
@@ -166,9 +166,9 @@ discard block |
||
| 166 | 166 | $connexion = spip_connect($serveur); |
| 167 | 167 | $e = sql_errno($serveur); |
| 168 | 168 | $t = (isset($connexion['type']) ? $connexion['type'] : 'sql'); |
| 169 | - $m = "Erreur $e de $t: " . sql_error($serveur) . "\nin " . sql_error_backtrace() . "\n" . trim($connexion['last']); |
|
| 170 | - $f = $t . $serveur; |
|
| 171 | - spip_log($m, $f . '.' . _LOG_ERREUR); |
|
| 169 | + $m = "Erreur $e de $t: ".sql_error($serveur)."\nin ".sql_error_backtrace()."\n".trim($connexion['last']); |
|
| 170 | + $f = $t.$serveur; |
|
| 171 | + spip_log($m, $f.'.'._LOG_ERREUR); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | /** |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | // si en cours d'installation ou si db=@test@ on ne pose rien |
| 251 | 251 | // car c'est un test de connexion |
| 252 | 252 | if (!defined('_ECRIRE_INSTALL') and $db !== '@test@') { |
| 253 | - $f = _DIR_TMP . $type . '.' . substr(md5($host . $port . $db), 0, 8) . '.out'; |
|
| 253 | + $f = _DIR_TMP.$type.'.'.substr(md5($host.$port.$db), 0, 8).'.out'; |
|
| 254 | 254 | } elseif ($db == '@test@') { |
| 255 | 255 | $db = ''; |
| 256 | 256 | } |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | // En cas d'indisponibilite du serveur, eviter de le bombarder |
| 291 | 291 | if ($f) { |
| 292 | 292 | @touch($f); |
| 293 | - spip_log("Echec connexion serveur $type : host[$host] port[$port] login[$login] base[$db]", $type . '.' . _LOG_HS); |
|
| 293 | + spip_log("Echec connexion serveur $type : host[$host] port[$port] login[$login] base[$db]", $type.'.'._LOG_HS); |
|
| 294 | 294 | } |
| 295 | 295 | } |
| 296 | 296 | |
@@ -382,8 +382,7 @@ discard block |
||
| 382 | 382 | * @return string Valeur échappée. |
| 383 | 383 | **/ |
| 384 | 384 | function _q($a) { |
| 385 | - return (is_numeric($a)) ? strval($a) : |
|
| 386 | - (!is_array($a) ? ("'" . addslashes($a) . "'") |
|
| 385 | + return (is_numeric($a)) ? strval($a) : (!is_array($a) ? ("'".addslashes($a)."'") |
|
| 387 | 386 | : join(',', array_map('_q', $a))); |
| 388 | 387 | } |
| 389 | 388 | |
@@ -425,7 +424,7 @@ discard block |
||
| 425 | 424 | break; |
| 426 | 425 | default: |
| 427 | 426 | $replace = range(1, count($textes)); |
| 428 | - $replace = '%' . implode('$s,%', $replace) . '$s'; |
|
| 427 | + $replace = '%'.implode('$s,%', $replace).'$s'; |
|
| 429 | 428 | $replace = explode(',', $replace); |
| 430 | 429 | break; |
| 431 | 430 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\SQL |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | require_once _ROOT_RESTREINT . 'base/objets.php'; |
| 22 | 22 | |
@@ -42,119 +42,119 @@ discard block |
||
| 42 | 42 | **/ |
| 43 | 43 | function spip_connect($serveur = '', $version = '') { |
| 44 | 44 | |
| 45 | - $serveur = !is_string($serveur) ? '' : strtolower($serveur); |
|
| 46 | - $index = $serveur ? $serveur : 0; |
|
| 47 | - if (!$version) { |
|
| 48 | - $version = $GLOBALS['spip_sql_version']; |
|
| 49 | - } |
|
| 50 | - if (isset($GLOBALS['connexions'][$index][$version])) { |
|
| 51 | - return $GLOBALS['connexions'][$index]; |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - include_spip('base/abstract_sql'); |
|
| 55 | - $install = (_request('exec') == 'install'); |
|
| 56 | - |
|
| 57 | - // Premiere connexion ? |
|
| 58 | - if (!($old = isset($GLOBALS['connexions'][$index]))) { |
|
| 59 | - $f = (!preg_match('/^[\w\.]*$/', $serveur)) |
|
| 60 | - ? '' // nom de serveur mal ecrit |
|
| 61 | - : ($serveur ? |
|
| 62 | - (_DIR_CONNECT . $serveur . '.php') // serveur externe |
|
| 63 | - : (_FILE_CONNECT ? _FILE_CONNECT // serveur principal ok |
|
| 64 | - : ($install ? _FILE_CONNECT_TMP // init du serveur principal |
|
| 65 | - : ''))); // installation pas faite |
|
| 66 | - |
|
| 67 | - unset($GLOBALS['db_ok']); |
|
| 68 | - unset($GLOBALS['spip_connect_version']); |
|
| 69 | - if ($f) { |
|
| 70 | - if (is_readable($f)) { |
|
| 71 | - include($f); |
|
| 72 | - } elseif ($serveur and !$install) { |
|
| 73 | - // chercher une declaration de serveur dans le path |
|
| 74 | - // qui pourra un jour servir a declarer des bases sqlite |
|
| 75 | - // par des plugins. Et sert aussi aux boucles POUR. |
|
| 76 | - find_in_path("$serveur.php", 'connect/', true); |
|
| 77 | - } |
|
| 78 | - } |
|
| 79 | - if (!isset($GLOBALS['db_ok'])) { |
|
| 80 | - // fera mieux la prochaine fois |
|
| 81 | - if ($install) { |
|
| 82 | - return false; |
|
| 83 | - } |
|
| 84 | - if ($f and is_readable($f)) { |
|
| 85 | - spip_log("spip_connect: fichier de connexion '$f' OK.", _LOG_INFO_IMPORTANTE); |
|
| 86 | - } else { |
|
| 87 | - spip_log("spip_connect: fichier de connexion '$f' non trouve", _LOG_INFO_IMPORTANTE); |
|
| 88 | - } |
|
| 89 | - spip_log("spip_connect: echec connexion ou serveur $index mal defini dans '$f'.", _LOG_HS); |
|
| 90 | - |
|
| 91 | - // ne plus reessayer si ce n'est pas l'install |
|
| 92 | - return $GLOBALS['connexions'][$index] = false; |
|
| 93 | - } |
|
| 94 | - $GLOBALS['connexions'][$index] = $GLOBALS['db_ok']; |
|
| 95 | - } |
|
| 96 | - // si la connexion a deja ete tentee mais a echoue, le dire! |
|
| 97 | - if (!$GLOBALS['connexions'][$index]) { |
|
| 98 | - return false; |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - // la connexion a reussi ou etait deja faite. |
|
| 102 | - // chargement de la version du jeu de fonctions |
|
| 103 | - // si pas dans le fichier par defaut |
|
| 104 | - $type = $GLOBALS['db_ok']['type']; |
|
| 105 | - $jeu = 'spip_' . $type . '_functions_' . $version; |
|
| 106 | - if (!isset($GLOBALS[$jeu])) { |
|
| 107 | - if (!find_in_path($type . '_' . $version . '.php', 'req/', true)) { |
|
| 108 | - spip_log("spip_connect: serveur $index version '$version' non defini pour '$type'", _LOG_HS); |
|
| 109 | - |
|
| 110 | - // ne plus reessayer |
|
| 111 | - return $GLOBALS['connexions'][$index][$version] = []; |
|
| 112 | - } |
|
| 113 | - } |
|
| 114 | - $GLOBALS['connexions'][$index][$version] = $GLOBALS[$jeu]; |
|
| 115 | - if ($old) { |
|
| 116 | - return $GLOBALS['connexions'][$index]; |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - $GLOBALS['connexions'][$index]['spip_connect_version'] = isset($GLOBALS['spip_connect_version']) ? $GLOBALS['spip_connect_version'] : 0; |
|
| 120 | - |
|
| 121 | - // initialisation de l'alphabet utilise dans les connexions SQL |
|
| 122 | - // si l'installation l'a determine. |
|
| 123 | - // Celui du serveur principal l'impose aux serveurs secondaires |
|
| 124 | - // s'ils le connaissent |
|
| 125 | - |
|
| 126 | - if (!$serveur) { |
|
| 127 | - $charset = spip_connect_main($GLOBALS[$jeu], $GLOBALS['db_ok']['charset']); |
|
| 128 | - if (!$charset) { |
|
| 129 | - unset($GLOBALS['connexions'][$index]); |
|
| 130 | - spip_log('spip_connect: absence de charset', _LOG_AVERTISSEMENT); |
|
| 131 | - |
|
| 132 | - return false; |
|
| 133 | - } |
|
| 134 | - } else { |
|
| 135 | - if ($GLOBALS['db_ok']['charset']) { |
|
| 136 | - $charset = $GLOBALS['db_ok']['charset']; |
|
| 137 | - } |
|
| 138 | - // spip_meta n'existe pas toujours dans la base |
|
| 139 | - // C'est le cas d'un dump sqlite par exemple |
|
| 140 | - elseif ( |
|
| 141 | - $GLOBALS['connexions'][$index]['spip_connect_version'] |
|
| 142 | - and sql_showtable('spip_meta', true, $serveur) |
|
| 143 | - and $r = sql_getfetsel('valeur', 'spip_meta', "nom='charset_sql_connexion'", '', '', '', '', $serveur) |
|
| 144 | - ) { |
|
| 145 | - $charset = $r; |
|
| 146 | - } else { |
|
| 147 | - $charset = -1; |
|
| 148 | - } |
|
| 149 | - } |
|
| 150 | - if ($charset != -1) { |
|
| 151 | - $f = $GLOBALS[$jeu]['set_charset']; |
|
| 152 | - if (function_exists($f)) { |
|
| 153 | - $f($charset, $serveur); |
|
| 154 | - } |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - return $GLOBALS['connexions'][$index]; |
|
| 45 | + $serveur = !is_string($serveur) ? '' : strtolower($serveur); |
|
| 46 | + $index = $serveur ? $serveur : 0; |
|
| 47 | + if (!$version) { |
|
| 48 | + $version = $GLOBALS['spip_sql_version']; |
|
| 49 | + } |
|
| 50 | + if (isset($GLOBALS['connexions'][$index][$version])) { |
|
| 51 | + return $GLOBALS['connexions'][$index]; |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + include_spip('base/abstract_sql'); |
|
| 55 | + $install = (_request('exec') == 'install'); |
|
| 56 | + |
|
| 57 | + // Premiere connexion ? |
|
| 58 | + if (!($old = isset($GLOBALS['connexions'][$index]))) { |
|
| 59 | + $f = (!preg_match('/^[\w\.]*$/', $serveur)) |
|
| 60 | + ? '' // nom de serveur mal ecrit |
|
| 61 | + : ($serveur ? |
|
| 62 | + (_DIR_CONNECT . $serveur . '.php') // serveur externe |
|
| 63 | + : (_FILE_CONNECT ? _FILE_CONNECT // serveur principal ok |
|
| 64 | + : ($install ? _FILE_CONNECT_TMP // init du serveur principal |
|
| 65 | + : ''))); // installation pas faite |
|
| 66 | + |
|
| 67 | + unset($GLOBALS['db_ok']); |
|
| 68 | + unset($GLOBALS['spip_connect_version']); |
|
| 69 | + if ($f) { |
|
| 70 | + if (is_readable($f)) { |
|
| 71 | + include($f); |
|
| 72 | + } elseif ($serveur and !$install) { |
|
| 73 | + // chercher une declaration de serveur dans le path |
|
| 74 | + // qui pourra un jour servir a declarer des bases sqlite |
|
| 75 | + // par des plugins. Et sert aussi aux boucles POUR. |
|
| 76 | + find_in_path("$serveur.php", 'connect/', true); |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | + if (!isset($GLOBALS['db_ok'])) { |
|
| 80 | + // fera mieux la prochaine fois |
|
| 81 | + if ($install) { |
|
| 82 | + return false; |
|
| 83 | + } |
|
| 84 | + if ($f and is_readable($f)) { |
|
| 85 | + spip_log("spip_connect: fichier de connexion '$f' OK.", _LOG_INFO_IMPORTANTE); |
|
| 86 | + } else { |
|
| 87 | + spip_log("spip_connect: fichier de connexion '$f' non trouve", _LOG_INFO_IMPORTANTE); |
|
| 88 | + } |
|
| 89 | + spip_log("spip_connect: echec connexion ou serveur $index mal defini dans '$f'.", _LOG_HS); |
|
| 90 | + |
|
| 91 | + // ne plus reessayer si ce n'est pas l'install |
|
| 92 | + return $GLOBALS['connexions'][$index] = false; |
|
| 93 | + } |
|
| 94 | + $GLOBALS['connexions'][$index] = $GLOBALS['db_ok']; |
|
| 95 | + } |
|
| 96 | + // si la connexion a deja ete tentee mais a echoue, le dire! |
|
| 97 | + if (!$GLOBALS['connexions'][$index]) { |
|
| 98 | + return false; |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + // la connexion a reussi ou etait deja faite. |
|
| 102 | + // chargement de la version du jeu de fonctions |
|
| 103 | + // si pas dans le fichier par defaut |
|
| 104 | + $type = $GLOBALS['db_ok']['type']; |
|
| 105 | + $jeu = 'spip_' . $type . '_functions_' . $version; |
|
| 106 | + if (!isset($GLOBALS[$jeu])) { |
|
| 107 | + if (!find_in_path($type . '_' . $version . '.php', 'req/', true)) { |
|
| 108 | + spip_log("spip_connect: serveur $index version '$version' non defini pour '$type'", _LOG_HS); |
|
| 109 | + |
|
| 110 | + // ne plus reessayer |
|
| 111 | + return $GLOBALS['connexions'][$index][$version] = []; |
|
| 112 | + } |
|
| 113 | + } |
|
| 114 | + $GLOBALS['connexions'][$index][$version] = $GLOBALS[$jeu]; |
|
| 115 | + if ($old) { |
|
| 116 | + return $GLOBALS['connexions'][$index]; |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + $GLOBALS['connexions'][$index]['spip_connect_version'] = isset($GLOBALS['spip_connect_version']) ? $GLOBALS['spip_connect_version'] : 0; |
|
| 120 | + |
|
| 121 | + // initialisation de l'alphabet utilise dans les connexions SQL |
|
| 122 | + // si l'installation l'a determine. |
|
| 123 | + // Celui du serveur principal l'impose aux serveurs secondaires |
|
| 124 | + // s'ils le connaissent |
|
| 125 | + |
|
| 126 | + if (!$serveur) { |
|
| 127 | + $charset = spip_connect_main($GLOBALS[$jeu], $GLOBALS['db_ok']['charset']); |
|
| 128 | + if (!$charset) { |
|
| 129 | + unset($GLOBALS['connexions'][$index]); |
|
| 130 | + spip_log('spip_connect: absence de charset', _LOG_AVERTISSEMENT); |
|
| 131 | + |
|
| 132 | + return false; |
|
| 133 | + } |
|
| 134 | + } else { |
|
| 135 | + if ($GLOBALS['db_ok']['charset']) { |
|
| 136 | + $charset = $GLOBALS['db_ok']['charset']; |
|
| 137 | + } |
|
| 138 | + // spip_meta n'existe pas toujours dans la base |
|
| 139 | + // C'est le cas d'un dump sqlite par exemple |
|
| 140 | + elseif ( |
|
| 141 | + $GLOBALS['connexions'][$index]['spip_connect_version'] |
|
| 142 | + and sql_showtable('spip_meta', true, $serveur) |
|
| 143 | + and $r = sql_getfetsel('valeur', 'spip_meta', "nom='charset_sql_connexion'", '', '', '', '', $serveur) |
|
| 144 | + ) { |
|
| 145 | + $charset = $r; |
|
| 146 | + } else { |
|
| 147 | + $charset = -1; |
|
| 148 | + } |
|
| 149 | + } |
|
| 150 | + if ($charset != -1) { |
|
| 151 | + $f = $GLOBALS[$jeu]['set_charset']; |
|
| 152 | + if (function_exists($f)) { |
|
| 153 | + $f($charset, $serveur); |
|
| 154 | + } |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + return $GLOBALS['connexions'][$index]; |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | /** |
@@ -163,12 +163,12 @@ discard block |
||
| 163 | 163 | * @param string $serveur Nom du connecteur de bdd utilisé |
| 164 | 164 | **/ |
| 165 | 165 | function spip_sql_erreur($serveur = '') { |
| 166 | - $connexion = spip_connect($serveur); |
|
| 167 | - $e = sql_errno($serveur); |
|
| 168 | - $t = (isset($connexion['type']) ? $connexion['type'] : 'sql'); |
|
| 169 | - $m = "Erreur $e de $t: " . sql_error($serveur) . "\nin " . sql_error_backtrace() . "\n" . trim($connexion['last']); |
|
| 170 | - $f = $t . $serveur; |
|
| 171 | - spip_log($m, $f . '.' . _LOG_ERREUR); |
|
| 166 | + $connexion = spip_connect($serveur); |
|
| 167 | + $e = sql_errno($serveur); |
|
| 168 | + $t = (isset($connexion['type']) ? $connexion['type'] : 'sql'); |
|
| 169 | + $m = "Erreur $e de $t: " . sql_error($serveur) . "\nin " . sql_error_backtrace() . "\n" . trim($connexion['last']); |
|
| 170 | + $f = $t . $serveur; |
|
| 171 | + spip_log($m, $f . '.' . _LOG_ERREUR); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | /** |
@@ -190,19 +190,19 @@ discard block |
||
| 190 | 190 | * - array : description de la connexion, si l'instruction sql est indisponible pour cette connexion |
| 191 | 191 | **/ |
| 192 | 192 | function spip_connect_sql($version, $ins = '', $serveur = '', $continue = false) { |
| 193 | - $desc = spip_connect($serveur, $version); |
|
| 194 | - if (function_exists($f = @$desc[$version][$ins])) { |
|
| 195 | - return $f; |
|
| 196 | - } |
|
| 197 | - if ($continue) { |
|
| 198 | - return $desc; |
|
| 199 | - } |
|
| 200 | - if ($ins) { |
|
| 201 | - spip_log("Le serveur '$serveur' version $version n'a pas '$ins'", _LOG_ERREUR); |
|
| 202 | - } |
|
| 203 | - include_spip('inc/minipres'); |
|
| 204 | - echo minipres(_T('info_travaux_titre'), _T('titre_probleme_technique'), ['status' => 503]); |
|
| 205 | - exit; |
|
| 193 | + $desc = spip_connect($serveur, $version); |
|
| 194 | + if (function_exists($f = @$desc[$version][$ins])) { |
|
| 195 | + return $f; |
|
| 196 | + } |
|
| 197 | + if ($continue) { |
|
| 198 | + return $desc; |
|
| 199 | + } |
|
| 200 | + if ($ins) { |
|
| 201 | + spip_log("Le serveur '$serveur' version $version n'a pas '$ins'", _LOG_ERREUR); |
|
| 202 | + } |
|
| 203 | + include_spip('inc/minipres'); |
|
| 204 | + echo minipres(_T('info_travaux_titre'), _T('titre_probleme_technique'), ['status' => 503]); |
|
| 205 | + exit; |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | /** |
@@ -228,70 +228,70 @@ discard block |
||
| 228 | 228 | * @return array Description de la connexion |
| 229 | 229 | */ |
| 230 | 230 | function spip_connect_db( |
| 231 | - $host, |
|
| 232 | - $port, |
|
| 233 | - $login, |
|
| 234 | - $pass, |
|
| 235 | - $db = '', |
|
| 236 | - $type = 'mysql', |
|
| 237 | - $prefixe = '', |
|
| 238 | - $auth = '', |
|
| 239 | - $charset = '' |
|
| 231 | + $host, |
|
| 232 | + $port, |
|
| 233 | + $login, |
|
| 234 | + $pass, |
|
| 235 | + $db = '', |
|
| 236 | + $type = 'mysql', |
|
| 237 | + $prefixe = '', |
|
| 238 | + $auth = '', |
|
| 239 | + $charset = '' |
|
| 240 | 240 | ) { |
| 241 | - // temps avant nouvelle tentative de connexion |
|
| 242 | - // suite a une connection echouee |
|
| 243 | - if (!defined('_CONNECT_RETRY_DELAY')) { |
|
| 244 | - define('_CONNECT_RETRY_DELAY', 30); |
|
| 245 | - } |
|
| 246 | - |
|
| 247 | - $f = ''; |
|
| 248 | - // un fichier de identifiant par combinaison (type,host,port,db) |
|
| 249 | - // pour ne pas declarer tout indisponible d'un coup |
|
| 250 | - // si en cours d'installation ou si db=@test@ on ne pose rien |
|
| 251 | - // car c'est un test de connexion |
|
| 252 | - if (!defined('_ECRIRE_INSTALL') and $db !== '@test@') { |
|
| 253 | - $f = _DIR_TMP . $type . '.' . substr(md5($host . $port . $db), 0, 8) . '.out'; |
|
| 254 | - } elseif ($db == '@test@') { |
|
| 255 | - $db = ''; |
|
| 256 | - } |
|
| 257 | - |
|
| 258 | - if ( |
|
| 259 | - $f |
|
| 260 | - and @file_exists($f) |
|
| 261 | - and (time() - @filemtime($f) < _CONNECT_RETRY_DELAY) |
|
| 262 | - ) { |
|
| 263 | - spip_log("Echec : $f recent. Pas de tentative de connexion", _LOG_HS); |
|
| 264 | - |
|
| 265 | - return; |
|
| 266 | - } |
|
| 267 | - |
|
| 268 | - if (!$prefixe) { |
|
| 269 | - $prefixe = isset($GLOBALS['table_prefix']) |
|
| 270 | - ? $GLOBALS['table_prefix'] : $db; |
|
| 271 | - } |
|
| 272 | - $h = charger_fonction($type, 'req', true); |
|
| 273 | - if (!$h) { |
|
| 274 | - spip_log("les requetes $type ne sont pas fournies", _LOG_HS); |
|
| 275 | - |
|
| 276 | - return; |
|
| 277 | - } |
|
| 278 | - if ($g = $h($host, $port, $login, $pass, $db, $prefixe)) { |
|
| 279 | - if (!is_array($auth)) { |
|
| 280 | - // compatibilite version 0.7 initiale |
|
| 281 | - $g['ldap'] = $auth; |
|
| 282 | - $auth = ['ldap' => $auth]; |
|
| 283 | - } |
|
| 284 | - $g['authentification'] = $auth; |
|
| 285 | - $g['type'] = $type; |
|
| 286 | - $g['charset'] = $charset; |
|
| 287 | - |
|
| 288 | - return $GLOBALS['db_ok'] = $g; |
|
| 289 | - } |
|
| 290 | - // En cas d'indisponibilite du serveur, eviter de le bombarder |
|
| 291 | - if ($f) { |
|
| 292 | - @touch($f); |
|
| 293 | - spip_log("Echec connexion serveur $type : host[$host] port[$port] login[$login] base[$db]", $type . '.' . _LOG_HS); |
|
| 294 | - } |
|
| 241 | + // temps avant nouvelle tentative de connexion |
|
| 242 | + // suite a une connection echouee |
|
| 243 | + if (!defined('_CONNECT_RETRY_DELAY')) { |
|
| 244 | + define('_CONNECT_RETRY_DELAY', 30); |
|
| 245 | + } |
|
| 246 | + |
|
| 247 | + $f = ''; |
|
| 248 | + // un fichier de identifiant par combinaison (type,host,port,db) |
|
| 249 | + // pour ne pas declarer tout indisponible d'un coup |
|
| 250 | + // si en cours d'installation ou si db=@test@ on ne pose rien |
|
| 251 | + // car c'est un test de connexion |
|
| 252 | + if (!defined('_ECRIRE_INSTALL') and $db !== '@test@') { |
|
| 253 | + $f = _DIR_TMP . $type . '.' . substr(md5($host . $port . $db), 0, 8) . '.out'; |
|
| 254 | + } elseif ($db == '@test@') { |
|
| 255 | + $db = ''; |
|
| 256 | + } |
|
| 257 | + |
|
| 258 | + if ( |
|
| 259 | + $f |
|
| 260 | + and @file_exists($f) |
|
| 261 | + and (time() - @filemtime($f) < _CONNECT_RETRY_DELAY) |
|
| 262 | + ) { |
|
| 263 | + spip_log("Echec : $f recent. Pas de tentative de connexion", _LOG_HS); |
|
| 264 | + |
|
| 265 | + return; |
|
| 266 | + } |
|
| 267 | + |
|
| 268 | + if (!$prefixe) { |
|
| 269 | + $prefixe = isset($GLOBALS['table_prefix']) |
|
| 270 | + ? $GLOBALS['table_prefix'] : $db; |
|
| 271 | + } |
|
| 272 | + $h = charger_fonction($type, 'req', true); |
|
| 273 | + if (!$h) { |
|
| 274 | + spip_log("les requetes $type ne sont pas fournies", _LOG_HS); |
|
| 275 | + |
|
| 276 | + return; |
|
| 277 | + } |
|
| 278 | + if ($g = $h($host, $port, $login, $pass, $db, $prefixe)) { |
|
| 279 | + if (!is_array($auth)) { |
|
| 280 | + // compatibilite version 0.7 initiale |
|
| 281 | + $g['ldap'] = $auth; |
|
| 282 | + $auth = ['ldap' => $auth]; |
|
| 283 | + } |
|
| 284 | + $g['authentification'] = $auth; |
|
| 285 | + $g['type'] = $type; |
|
| 286 | + $g['charset'] = $charset; |
|
| 287 | + |
|
| 288 | + return $GLOBALS['db_ok'] = $g; |
|
| 289 | + } |
|
| 290 | + // En cas d'indisponibilite du serveur, eviter de le bombarder |
|
| 291 | + if ($f) { |
|
| 292 | + @touch($f); |
|
| 293 | + spip_log("Echec connexion serveur $type : host[$host] port[$port] login[$login] base[$db]", $type . '.' . _LOG_HS); |
|
| 294 | + } |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | |
@@ -323,32 +323,32 @@ discard block |
||
| 323 | 323 | * - nom du charset sinon |
| 324 | 324 | **/ |
| 325 | 325 | function spip_connect_main($connexion, $charset_sql_connexion = '') { |
| 326 | - if ($GLOBALS['spip_connect_version'] < 0.1 and _DIR_RESTREINT) { |
|
| 327 | - include_spip('inc/headers'); |
|
| 328 | - redirige_url_ecrire('upgrade', 'reinstall=oui'); |
|
| 329 | - } |
|
| 330 | - |
|
| 331 | - if (!($f = $connexion['select'])) { |
|
| 332 | - return false; |
|
| 333 | - } |
|
| 334 | - // si le charset est fourni, l'utiliser |
|
| 335 | - if ($charset_sql_connexion) { |
|
| 336 | - return $charset_sql_connexion; |
|
| 337 | - } |
|
| 338 | - // sinon on regarde la table spip_meta |
|
| 339 | - // en cas d'erreur select retourne la requette (is_string=true donc) |
|
| 340 | - if ( |
|
| 341 | - !$r = $f('valeur', 'spip_meta', "nom='charset_sql_connexion'") |
|
| 342 | - or is_string($r) |
|
| 343 | - ) { |
|
| 344 | - return false; |
|
| 345 | - } |
|
| 346 | - if (!($f = $connexion['fetch'])) { |
|
| 347 | - return false; |
|
| 348 | - } |
|
| 349 | - $r = $f($r); |
|
| 350 | - |
|
| 351 | - return (isset($r['valeur']) && $r['valeur']) ? $r['valeur'] : -1; |
|
| 326 | + if ($GLOBALS['spip_connect_version'] < 0.1 and _DIR_RESTREINT) { |
|
| 327 | + include_spip('inc/headers'); |
|
| 328 | + redirige_url_ecrire('upgrade', 'reinstall=oui'); |
|
| 329 | + } |
|
| 330 | + |
|
| 331 | + if (!($f = $connexion['select'])) { |
|
| 332 | + return false; |
|
| 333 | + } |
|
| 334 | + // si le charset est fourni, l'utiliser |
|
| 335 | + if ($charset_sql_connexion) { |
|
| 336 | + return $charset_sql_connexion; |
|
| 337 | + } |
|
| 338 | + // sinon on regarde la table spip_meta |
|
| 339 | + // en cas d'erreur select retourne la requette (is_string=true donc) |
|
| 340 | + if ( |
|
| 341 | + !$r = $f('valeur', 'spip_meta', "nom='charset_sql_connexion'") |
|
| 342 | + or is_string($r) |
|
| 343 | + ) { |
|
| 344 | + return false; |
|
| 345 | + } |
|
| 346 | + if (!($f = $connexion['fetch'])) { |
|
| 347 | + return false; |
|
| 348 | + } |
|
| 349 | + $r = $f($r); |
|
| 350 | + |
|
| 351 | + return (isset($r['valeur']) && $r['valeur']) ? $r['valeur'] : -1; |
|
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | /** |
@@ -364,9 +364,9 @@ discard block |
||
| 364 | 364 | * @return array |
| 365 | 365 | */ |
| 366 | 366 | function spip_connect_ldap($serveur = '') { |
| 367 | - include_spip('auth/ldap'); |
|
| 367 | + include_spip('auth/ldap'); |
|
| 368 | 368 | |
| 369 | - return auth_ldap_connect($serveur); |
|
| 369 | + return auth_ldap_connect($serveur); |
|
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | /** |
@@ -382,9 +382,9 @@ discard block |
||
| 382 | 382 | * @return string Valeur échappée. |
| 383 | 383 | **/ |
| 384 | 384 | function _q($a) { |
| 385 | - return (is_numeric($a)) ? strval($a) : |
|
| 386 | - (!is_array($a) ? ("'" . addslashes($a) . "'") |
|
| 387 | - : join(',', array_map('_q', $a))); |
|
| 385 | + return (is_numeric($a)) ? strval($a) : |
|
| 386 | + (!is_array($a) ? ("'" . addslashes($a) . "'") |
|
| 387 | + : join(',', array_map('_q', $a))); |
|
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | /** |
@@ -400,66 +400,66 @@ discard block |
||
| 400 | 400 | * @return array |
| 401 | 401 | */ |
| 402 | 402 | function query_echappe_textes($query, $uniqid = null) { |
| 403 | - static $codeEchappements = null; |
|
| 404 | - if (is_null($codeEchappements) or $uniqid) { |
|
| 405 | - if (is_null($uniqid)) { |
|
| 406 | - $uniqid = uniqid(); |
|
| 407 | - } |
|
| 408 | - $uniqid = substr(md5($uniqid), 0, 4); |
|
| 409 | - $codeEchappements = ['\\\\' => "\x1@#{$uniqid}#@\x1", "\\'" => "\x2@#{$uniqid}#@\x2", '\\"' => "\x3@#{$uniqid}#@\x3"]; |
|
| 410 | - } |
|
| 411 | - if ($query === null) { |
|
| 412 | - return $codeEchappements; |
|
| 413 | - } |
|
| 414 | - |
|
| 415 | - // si la query contient deja des codes d'echappement on va s'emmeler les pinceaux et donc on ne touche a rien |
|
| 416 | - // ce n'est pas un cas legitime |
|
| 417 | - foreach ($codeEchappements as $codeEchappement) { |
|
| 418 | - if (strpos($query, $codeEchappement) !== false) { |
|
| 419 | - return [$query, []]; |
|
| 420 | - } |
|
| 421 | - } |
|
| 422 | - |
|
| 423 | - $query_echappees = str_replace(array_keys($codeEchappements), array_values($codeEchappements), $query); |
|
| 424 | - if (preg_match_all("/('[^']*')|(\"[^\"]*\")/S", $query_echappees, $textes)) { |
|
| 425 | - $textes = reset($textes); // indice 0 du match |
|
| 426 | - switch (count($textes)) { |
|
| 427 | - case 0: |
|
| 428 | - $replace = []; |
|
| 429 | - break; |
|
| 430 | - case 1: |
|
| 431 | - $replace = ['%1$s']; |
|
| 432 | - break; |
|
| 433 | - case 2: |
|
| 434 | - $replace = ['%1$s', '%2$s']; |
|
| 435 | - break; |
|
| 436 | - case 3: |
|
| 437 | - $replace = ['%1$s', '%2$s', '%3$s']; |
|
| 438 | - break; |
|
| 439 | - case 4: |
|
| 440 | - $replace = ['%1$s', '%2$s', '%3$s', '%4$s']; |
|
| 441 | - break; |
|
| 442 | - case 5: |
|
| 443 | - $replace = ['%1$s', '%2$s', '%3$s', '%4$s', '%5$s']; |
|
| 444 | - break; |
|
| 445 | - default: |
|
| 446 | - $replace = range(1, count($textes)); |
|
| 447 | - $replace = '%' . implode('$s,%', $replace) . '$s'; |
|
| 448 | - $replace = explode(',', $replace); |
|
| 449 | - break; |
|
| 450 | - } |
|
| 451 | - $query_echappees = str_replace($textes, $replace, $query_echappees); |
|
| 452 | - } else { |
|
| 453 | - $textes = []; |
|
| 454 | - } |
|
| 455 | - |
|
| 456 | - // si il reste des quotes simples ou doubles, c'est qu'on s'est emmelles les pinceaux |
|
| 457 | - // dans le doute on ne touche a rien |
|
| 458 | - if (strpbrk($query_echappees, "'\"") !== false) { |
|
| 459 | - return [$query, []]; |
|
| 460 | - } |
|
| 461 | - |
|
| 462 | - return [$query_echappees, $textes]; |
|
| 403 | + static $codeEchappements = null; |
|
| 404 | + if (is_null($codeEchappements) or $uniqid) { |
|
| 405 | + if (is_null($uniqid)) { |
|
| 406 | + $uniqid = uniqid(); |
|
| 407 | + } |
|
| 408 | + $uniqid = substr(md5($uniqid), 0, 4); |
|
| 409 | + $codeEchappements = ['\\\\' => "\x1@#{$uniqid}#@\x1", "\\'" => "\x2@#{$uniqid}#@\x2", '\\"' => "\x3@#{$uniqid}#@\x3"]; |
|
| 410 | + } |
|
| 411 | + if ($query === null) { |
|
| 412 | + return $codeEchappements; |
|
| 413 | + } |
|
| 414 | + |
|
| 415 | + // si la query contient deja des codes d'echappement on va s'emmeler les pinceaux et donc on ne touche a rien |
|
| 416 | + // ce n'est pas un cas legitime |
|
| 417 | + foreach ($codeEchappements as $codeEchappement) { |
|
| 418 | + if (strpos($query, $codeEchappement) !== false) { |
|
| 419 | + return [$query, []]; |
|
| 420 | + } |
|
| 421 | + } |
|
| 422 | + |
|
| 423 | + $query_echappees = str_replace(array_keys($codeEchappements), array_values($codeEchappements), $query); |
|
| 424 | + if (preg_match_all("/('[^']*')|(\"[^\"]*\")/S", $query_echappees, $textes)) { |
|
| 425 | + $textes = reset($textes); // indice 0 du match |
|
| 426 | + switch (count($textes)) { |
|
| 427 | + case 0: |
|
| 428 | + $replace = []; |
|
| 429 | + break; |
|
| 430 | + case 1: |
|
| 431 | + $replace = ['%1$s']; |
|
| 432 | + break; |
|
| 433 | + case 2: |
|
| 434 | + $replace = ['%1$s', '%2$s']; |
|
| 435 | + break; |
|
| 436 | + case 3: |
|
| 437 | + $replace = ['%1$s', '%2$s', '%3$s']; |
|
| 438 | + break; |
|
| 439 | + case 4: |
|
| 440 | + $replace = ['%1$s', '%2$s', '%3$s', '%4$s']; |
|
| 441 | + break; |
|
| 442 | + case 5: |
|
| 443 | + $replace = ['%1$s', '%2$s', '%3$s', '%4$s', '%5$s']; |
|
| 444 | + break; |
|
| 445 | + default: |
|
| 446 | + $replace = range(1, count($textes)); |
|
| 447 | + $replace = '%' . implode('$s,%', $replace) . '$s'; |
|
| 448 | + $replace = explode(',', $replace); |
|
| 449 | + break; |
|
| 450 | + } |
|
| 451 | + $query_echappees = str_replace($textes, $replace, $query_echappees); |
|
| 452 | + } else { |
|
| 453 | + $textes = []; |
|
| 454 | + } |
|
| 455 | + |
|
| 456 | + // si il reste des quotes simples ou doubles, c'est qu'on s'est emmelles les pinceaux |
|
| 457 | + // dans le doute on ne touche a rien |
|
| 458 | + if (strpbrk($query_echappees, "'\"") !== false) { |
|
| 459 | + return [$query, []]; |
|
| 460 | + } |
|
| 461 | + |
|
| 462 | + return [$query_echappees, $textes]; |
|
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | /** |
@@ -473,14 +473,14 @@ discard block |
||
| 473 | 473 | * @return string |
| 474 | 474 | */ |
| 475 | 475 | function query_reinjecte_textes($query, $textes) { |
| 476 | - // recuperer les codes echappements |
|
| 477 | - $codeEchappements = query_echappe_textes(null); |
|
| 476 | + // recuperer les codes echappements |
|
| 477 | + $codeEchappements = query_echappe_textes(null); |
|
| 478 | 478 | |
| 479 | - $query = sprintf($query, ...$textes); |
|
| 479 | + $query = sprintf($query, ...$textes); |
|
| 480 | 480 | |
| 481 | - $query = str_replace(array_values($codeEchappements), array_keys($codeEchappements), $query); |
|
| 481 | + $query = str_replace(array_values($codeEchappements), array_keys($codeEchappements), $query); |
|
| 482 | 482 | |
| 483 | - return $query; |
|
| 483 | + return $query; |
|
| 484 | 484 | } |
| 485 | 485 | |
| 486 | 486 | |
@@ -499,7 +499,7 @@ discard block |
||
| 499 | 499 | **/ |
| 500 | 500 | function spip_query($query, $serveur = '') { |
| 501 | 501 | |
| 502 | - $f = spip_connect_sql($GLOBALS['spip_sql_version'], 'query', $serveur, true); |
|
| 502 | + $f = spip_connect_sql($GLOBALS['spip_sql_version'], 'query', $serveur, true); |
|
| 503 | 503 | |
| 504 | - return function_exists($f) ? $f($query, $serveur) : false; |
|
| 504 | + return function_exists($f) ? $f($query, $serveur) : false; |
|
| 505 | 505 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Installation |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | include_spip('inc/acces'); |
@@ -33,18 +33,18 @@ discard block |
||
| 33 | 33 | * @return bool |
| 34 | 34 | */ |
| 35 | 35 | function base_determine_autoinc($table, $desc = []) { |
| 36 | - if ($t = lister_tables_principales() and isset($t[$table])) { |
|
| 37 | - $autoinc = true; |
|
| 38 | - } elseif ($t = lister_tables_auxiliaires() and isset($t[$table])) { |
|
| 39 | - $autoinc = false; |
|
| 40 | - } else { |
|
| 41 | - // essayer de faire au mieux ! |
|
| 42 | - $autoinc = (isset($desc['key']['PRIMARY KEY']) |
|
| 43 | - and strpos($desc['key']['PRIMARY KEY'], ',') === false |
|
| 44 | - and strpos($desc['field'][$desc['key']['PRIMARY KEY']], 'default') === false); |
|
| 45 | - } |
|
| 36 | + if ($t = lister_tables_principales() and isset($t[$table])) { |
|
| 37 | + $autoinc = true; |
|
| 38 | + } elseif ($t = lister_tables_auxiliaires() and isset($t[$table])) { |
|
| 39 | + $autoinc = false; |
|
| 40 | + } else { |
|
| 41 | + // essayer de faire au mieux ! |
|
| 42 | + $autoinc = (isset($desc['key']['PRIMARY KEY']) |
|
| 43 | + and strpos($desc['key']['PRIMARY KEY'], ',') === false |
|
| 44 | + and strpos($desc['field'][$desc['key']['PRIMARY KEY']], 'default') === false); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - return $autoinc; |
|
| 47 | + return $autoinc; |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
@@ -61,58 +61,58 @@ discard block |
||
| 61 | 61 | * @return void |
| 62 | 62 | */ |
| 63 | 63 | function creer_ou_upgrader_table($table, $desc, $autoinc, $upgrade = false, $serveur = '') { |
| 64 | - #spip_log("creer_ou_upgrader_table table=$table autoinc=$autoinc upgrade=$upgrade","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 65 | - $sql_desc = $upgrade ? sql_showtable($table, true, $serveur) : false; |
|
| 66 | - #if (!$sql_desc) $sql_desc = false; |
|
| 67 | - #spip_log("table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 68 | - if (!$sql_desc) { |
|
| 69 | - if ($autoinc === 'auto') { |
|
| 70 | - $autoinc = base_determine_autoinc($table, $desc); |
|
| 71 | - } |
|
| 72 | - #spip_log("sql_create $table autoinc=$autoinc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 73 | - if (isset($desc['field']) and isset($desc['key'])) { |
|
| 74 | - sql_create($table, $desc['field'], $desc['key'], $autoinc, false, $serveur); |
|
| 75 | - } |
|
| 76 | - // verifier la bonne installation de la table (php-fpm es-tu la ?) |
|
| 77 | - $sql_desc = sql_showtable($table, true, $serveur); |
|
| 78 | - #if (!$sql_desc) $sql_desc = false; |
|
| 79 | - #spip_log("Resultat table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 80 | - if (!$sql_desc) { |
|
| 81 | - // on retente avec un sleep ? |
|
| 82 | - sleep(1); |
|
| 83 | - sql_create($table, $desc['field'], $desc['key'], $autoinc, false, $serveur); |
|
| 84 | - $sql_desc = sql_showtable($table, true, $serveur); |
|
| 85 | - #if (!$sql_desc) $sql_desc = false; |
|
| 86 | - #spip_log("Resultat table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 87 | - if (!$sql_desc) { |
|
| 88 | - spip_log("Echec creation table $table", 'maj' . _LOG_CRITIQUE); |
|
| 89 | - } |
|
| 90 | - } |
|
| 91 | - } else { |
|
| 92 | - #spip_log("sql_alter $table ... (on s'en fiche)","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 93 | - // ajouter les champs manquants |
|
| 94 | - // on ne supprime jamais les champs, car c'est dangereux |
|
| 95 | - // c'est toujours a faire manuellement |
|
| 96 | - $last = ''; |
|
| 97 | - if (isset($desc['field'])) { |
|
| 98 | - foreach ($desc['field'] as $field => $type) { |
|
| 99 | - if (!isset($sql_desc['field'][$field])) { |
|
| 100 | - sql_alter("TABLE $table ADD $field $type" . ($last ? " AFTER $last" : ''), $serveur); |
|
| 101 | - } |
|
| 102 | - $last = $field; |
|
| 103 | - } |
|
| 104 | - } |
|
| 105 | - if (isset($desc['key'])) { |
|
| 106 | - foreach ($desc['key'] as $key => $type) { |
|
| 107 | - // Ne pas oublier les cas des cles non nommees dans la declaration et qui sont retournees |
|
| 108 | - // par le showtable sous la forme d'un index de tableau "KEY $type" et non "KEY" |
|
| 109 | - if (!isset($sql_desc['key'][$key]) and !isset($sql_desc['key']["$key $type"])) { |
|
| 110 | - sql_alter("TABLE $table ADD $key ($type)", $serveur); |
|
| 111 | - } |
|
| 112 | - $last = $field; |
|
| 113 | - } |
|
| 114 | - } |
|
| 115 | - } |
|
| 64 | + #spip_log("creer_ou_upgrader_table table=$table autoinc=$autoinc upgrade=$upgrade","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 65 | + $sql_desc = $upgrade ? sql_showtable($table, true, $serveur) : false; |
|
| 66 | + #if (!$sql_desc) $sql_desc = false; |
|
| 67 | + #spip_log("table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 68 | + if (!$sql_desc) { |
|
| 69 | + if ($autoinc === 'auto') { |
|
| 70 | + $autoinc = base_determine_autoinc($table, $desc); |
|
| 71 | + } |
|
| 72 | + #spip_log("sql_create $table autoinc=$autoinc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 73 | + if (isset($desc['field']) and isset($desc['key'])) { |
|
| 74 | + sql_create($table, $desc['field'], $desc['key'], $autoinc, false, $serveur); |
|
| 75 | + } |
|
| 76 | + // verifier la bonne installation de la table (php-fpm es-tu la ?) |
|
| 77 | + $sql_desc = sql_showtable($table, true, $serveur); |
|
| 78 | + #if (!$sql_desc) $sql_desc = false; |
|
| 79 | + #spip_log("Resultat table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 80 | + if (!$sql_desc) { |
|
| 81 | + // on retente avec un sleep ? |
|
| 82 | + sleep(1); |
|
| 83 | + sql_create($table, $desc['field'], $desc['key'], $autoinc, false, $serveur); |
|
| 84 | + $sql_desc = sql_showtable($table, true, $serveur); |
|
| 85 | + #if (!$sql_desc) $sql_desc = false; |
|
| 86 | + #spip_log("Resultat table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 87 | + if (!$sql_desc) { |
|
| 88 | + spip_log("Echec creation table $table", 'maj' . _LOG_CRITIQUE); |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | + } else { |
|
| 92 | + #spip_log("sql_alter $table ... (on s'en fiche)","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 93 | + // ajouter les champs manquants |
|
| 94 | + // on ne supprime jamais les champs, car c'est dangereux |
|
| 95 | + // c'est toujours a faire manuellement |
|
| 96 | + $last = ''; |
|
| 97 | + if (isset($desc['field'])) { |
|
| 98 | + foreach ($desc['field'] as $field => $type) { |
|
| 99 | + if (!isset($sql_desc['field'][$field])) { |
|
| 100 | + sql_alter("TABLE $table ADD $field $type" . ($last ? " AFTER $last" : ''), $serveur); |
|
| 101 | + } |
|
| 102 | + $last = $field; |
|
| 103 | + } |
|
| 104 | + } |
|
| 105 | + if (isset($desc['key'])) { |
|
| 106 | + foreach ($desc['key'] as $key => $type) { |
|
| 107 | + // Ne pas oublier les cas des cles non nommees dans la declaration et qui sont retournees |
|
| 108 | + // par le showtable sous la forme d'un index de tableau "KEY $type" et non "KEY" |
|
| 109 | + if (!isset($sql_desc['key'][$key]) and !isset($sql_desc['key']["$key $type"])) { |
|
| 110 | + sql_alter("TABLE $table ADD $key ($type)", $serveur); |
|
| 111 | + } |
|
| 112 | + $last = $field; |
|
| 113 | + } |
|
| 114 | + } |
|
| 115 | + } |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -134,26 +134,26 @@ discard block |
||
| 134 | 134 | * @return void |
| 135 | 135 | */ |
| 136 | 136 | function alterer_base($tables_inc, $tables_noinc, $up = false, $serveur = '') { |
| 137 | - if ($up === false) { |
|
| 138 | - $old = false; |
|
| 139 | - $up = []; |
|
| 140 | - } else { |
|
| 141 | - $old = true; |
|
| 142 | - if (!is_array($up)) { |
|
| 143 | - $up = [$up]; |
|
| 144 | - } |
|
| 145 | - } |
|
| 146 | - foreach ($tables_inc as $k => $v) { |
|
| 147 | - if (!$old or in_array($k, $up)) { |
|
| 148 | - creer_ou_upgrader_table($k, $v, true, $old, $serveur); |
|
| 149 | - } |
|
| 150 | - } |
|
| 137 | + if ($up === false) { |
|
| 138 | + $old = false; |
|
| 139 | + $up = []; |
|
| 140 | + } else { |
|
| 141 | + $old = true; |
|
| 142 | + if (!is_array($up)) { |
|
| 143 | + $up = [$up]; |
|
| 144 | + } |
|
| 145 | + } |
|
| 146 | + foreach ($tables_inc as $k => $v) { |
|
| 147 | + if (!$old or in_array($k, $up)) { |
|
| 148 | + creer_ou_upgrader_table($k, $v, true, $old, $serveur); |
|
| 149 | + } |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | - foreach ($tables_noinc as $k => $v) { |
|
| 153 | - if (!$old or in_array($k, $up)) { |
|
| 154 | - creer_ou_upgrader_table($k, $v, false, $old, $serveur); |
|
| 155 | - } |
|
| 156 | - } |
|
| 152 | + foreach ($tables_noinc as $k => $v) { |
|
| 153 | + if (!$old or in_array($k, $up)) { |
|
| 154 | + creer_ou_upgrader_table($k, $v, false, $old, $serveur); |
|
| 155 | + } |
|
| 156 | + } |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
@@ -173,16 +173,16 @@ discard block |
||
| 173 | 173 | */ |
| 174 | 174 | function creer_base($serveur = '') { |
| 175 | 175 | |
| 176 | - // Note: les mises a jour reexecutent ce code pour s'assurer |
|
| 177 | - // de la conformite de la base |
|
| 178 | - // pas de panique sur "already exists" et "duplicate entry" donc. |
|
| 176 | + // Note: les mises a jour reexecutent ce code pour s'assurer |
|
| 177 | + // de la conformite de la base |
|
| 178 | + // pas de panique sur "already exists" et "duplicate entry" donc. |
|
| 179 | 179 | |
| 180 | - alterer_base( |
|
| 181 | - lister_tables_principales(), |
|
| 182 | - lister_tables_auxiliaires(), |
|
| 183 | - false, |
|
| 184 | - $serveur |
|
| 185 | - ); |
|
| 180 | + alterer_base( |
|
| 181 | + lister_tables_principales(), |
|
| 182 | + lister_tables_auxiliaires(), |
|
| 183 | + false, |
|
| 184 | + $serveur |
|
| 185 | + ); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | /** |
@@ -202,10 +202,10 @@ discard block |
||
| 202 | 202 | * @return void |
| 203 | 203 | */ |
| 204 | 204 | function maj_tables($upgrade_tables = [], $serveur = '') { |
| 205 | - alterer_base( |
|
| 206 | - lister_tables_principales(), |
|
| 207 | - lister_tables_auxiliaires(), |
|
| 208 | - $upgrade_tables, |
|
| 209 | - $serveur |
|
| 210 | - ); |
|
| 205 | + alterer_base( |
|
| 206 | + lister_tables_principales(), |
|
| 207 | + lister_tables_auxiliaires(), |
|
| 208 | + $upgrade_tables, |
|
| 209 | + $serveur |
|
| 210 | + ); |
|
| 211 | 211 | } |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | #if (!$sql_desc) $sql_desc = false; |
| 86 | 86 | #spip_log("Resultat table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
| 87 | 87 | if (!$sql_desc) { |
| 88 | - spip_log("Echec creation table $table", 'maj' . _LOG_CRITIQUE); |
|
| 88 | + spip_log("Echec creation table $table", 'maj'._LOG_CRITIQUE); |
|
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | } else { |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | if (isset($desc['field'])) { |
| 98 | 98 | foreach ($desc['field'] as $field => $type) { |
| 99 | 99 | if (!isset($sql_desc['field'][$field])) { |
| 100 | - sql_alter("TABLE $table ADD $field $type" . ($last ? " AFTER $last" : ''), $serveur); |
|
| 100 | + sql_alter("TABLE $table ADD $field $type".($last ? " AFTER $last" : ''), $serveur); |
|
| 101 | 101 | } |
| 102 | 102 | $last = $field; |
| 103 | 103 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -36,20 +36,20 @@ discard block |
||
| 36 | 36 | **/ |
| 37 | 37 | function base_repair_dist($titre = '', $reprise = '') { |
| 38 | 38 | |
| 39 | - $res = admin_repair_tables(); |
|
| 40 | - if (!$res) { |
|
| 41 | - $res = "<div class='error'>" . _T('avis_erreur_mysql') . ' ' . sql_errno() . ': ' . sql_error() . "</div>\n"; |
|
| 42 | - } else { |
|
| 43 | - include_spip('inc/rubriques'); |
|
| 44 | - calculer_rubriques(); |
|
| 45 | - propager_les_secteurs(); |
|
| 46 | - } |
|
| 47 | - include_spip('inc/minipres'); |
|
| 48 | - $res .= pipeline('base_admin_repair', $res); |
|
| 49 | - echo minipres( |
|
| 50 | - _T('texte_tentative_recuperation'), |
|
| 51 | - $res . generer_form_ecrire('accueil', '', '', _T('public:accueil_site')) |
|
| 52 | - ); |
|
| 39 | + $res = admin_repair_tables(); |
|
| 40 | + if (!$res) { |
|
| 41 | + $res = "<div class='error'>" . _T('avis_erreur_mysql') . ' ' . sql_errno() . ': ' . sql_error() . "</div>\n"; |
|
| 42 | + } else { |
|
| 43 | + include_spip('inc/rubriques'); |
|
| 44 | + calculer_rubriques(); |
|
| 45 | + propager_les_secteurs(); |
|
| 46 | + } |
|
| 47 | + include_spip('inc/minipres'); |
|
| 48 | + $res .= pipeline('base_admin_repair', $res); |
|
| 49 | + echo minipres( |
|
| 50 | + _T('texte_tentative_recuperation'), |
|
| 51 | + $res . generer_form_ecrire('accueil', '', '', _T('public:accueil_site')) |
|
| 52 | + ); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /** |
@@ -63,59 +63,59 @@ discard block |
||
| 63 | 63 | **/ |
| 64 | 64 | function admin_repair_tables() { |
| 65 | 65 | |
| 66 | - $repair = sql_repair('repair', null, 'continue'); |
|
| 66 | + $repair = sql_repair('repair', null, 'continue'); |
|
| 67 | 67 | |
| 68 | - // recreer les tables manquantes eventuelles |
|
| 69 | - include_spip('base/create'); |
|
| 70 | - creer_base(); |
|
| 71 | - $tables = sql_alltable(); |
|
| 68 | + // recreer les tables manquantes eventuelles |
|
| 69 | + include_spip('base/create'); |
|
| 70 | + creer_base(); |
|
| 71 | + $tables = sql_alltable(); |
|
| 72 | 72 | |
| 73 | - $res = ''; |
|
| 74 | - foreach ($tables as $tab) { |
|
| 75 | - $class = ''; |
|
| 76 | - $m = "<strong>$tab</strong> "; |
|
| 77 | - spip_log("Repare $tab", _LOG_INFO_IMPORTANTE); |
|
| 78 | - // supprimer la meta avant de lancer la reparation |
|
| 79 | - // car le repair peut etre long ; on ne veut pas boucler |
|
| 80 | - effacer_meta('admin_repair'); |
|
| 81 | - if ($repair) { |
|
| 82 | - $result_repair = sql_repair($tab); |
|
| 83 | - if (!$result_repair) { |
|
| 84 | - return false; |
|
| 85 | - } |
|
| 86 | - } |
|
| 73 | + $res = ''; |
|
| 74 | + foreach ($tables as $tab) { |
|
| 75 | + $class = ''; |
|
| 76 | + $m = "<strong>$tab</strong> "; |
|
| 77 | + spip_log("Repare $tab", _LOG_INFO_IMPORTANTE); |
|
| 78 | + // supprimer la meta avant de lancer la reparation |
|
| 79 | + // car le repair peut etre long ; on ne veut pas boucler |
|
| 80 | + effacer_meta('admin_repair'); |
|
| 81 | + if ($repair) { |
|
| 82 | + $result_repair = sql_repair($tab); |
|
| 83 | + if (!$result_repair) { |
|
| 84 | + return false; |
|
| 85 | + } |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - // essayer de maj la table (creation de champs manquants) |
|
| 89 | - maj_tables($tab); |
|
| 88 | + // essayer de maj la table (creation de champs manquants) |
|
| 89 | + maj_tables($tab); |
|
| 90 | 90 | |
| 91 | - $count = sql_countsel($tab); |
|
| 91 | + $count = sql_countsel($tab); |
|
| 92 | 92 | |
| 93 | - if ($count > 1) { |
|
| 94 | - $m .= '(' . _T('texte_compte_elements', ['count' => $count]) . ")\n"; |
|
| 95 | - } else { |
|
| 96 | - if ($count == 1) { |
|
| 97 | - $m .= '(' . _T('texte_compte_element', ['count' => $count]) . ")\n"; |
|
| 98 | - } else { |
|
| 99 | - $m .= '(' . _T('texte_vide') . ")\n"; |
|
| 100 | - } |
|
| 101 | - } |
|
| 93 | + if ($count > 1) { |
|
| 94 | + $m .= '(' . _T('texte_compte_elements', ['count' => $count]) . ")\n"; |
|
| 95 | + } else { |
|
| 96 | + if ($count == 1) { |
|
| 97 | + $m .= '(' . _T('texte_compte_element', ['count' => $count]) . ")\n"; |
|
| 98 | + } else { |
|
| 99 | + $m .= '(' . _T('texte_vide') . ")\n"; |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - if ( |
|
| 104 | - $result_repair |
|
| 105 | - and $msg = join( |
|
| 106 | - ' ', |
|
| 107 | - (is_resource($result_repair) or is_object($result_repair)) ? sql_fetch($result_repair) : $result_repair |
|
| 108 | - ) . ' ' |
|
| 109 | - and strpos($msg, ' OK ') === false |
|
| 110 | - ) { |
|
| 111 | - $class = " class='notice'"; |
|
| 112 | - $m .= '<br /><tt>' . spip_htmlentities($msg) . "</tt>\n"; |
|
| 113 | - } else { |
|
| 114 | - $m .= ' ' . _T('texte_table_ok'); |
|
| 115 | - } |
|
| 103 | + if ( |
|
| 104 | + $result_repair |
|
| 105 | + and $msg = join( |
|
| 106 | + ' ', |
|
| 107 | + (is_resource($result_repair) or is_object($result_repair)) ? sql_fetch($result_repair) : $result_repair |
|
| 108 | + ) . ' ' |
|
| 109 | + and strpos($msg, ' OK ') === false |
|
| 110 | + ) { |
|
| 111 | + $class = " class='notice'"; |
|
| 112 | + $m .= '<br /><tt>' . spip_htmlentities($msg) . "</tt>\n"; |
|
| 113 | + } else { |
|
| 114 | + $m .= ' ' . _T('texte_table_ok'); |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - $res .= "<div$class>$m</div>"; |
|
| 118 | - } |
|
| 117 | + $res .= "<div$class>$m</div>"; |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | - return $res; |
|
| 120 | + return $res; |
|
| 121 | 121 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | $res = admin_repair_tables(); |
| 40 | 40 | if (!$res) { |
| 41 | - $res = "<div class='error'>" . _T('avis_erreur_mysql') . ' ' . sql_errno() . ': ' . sql_error() . "</div>\n"; |
|
| 41 | + $res = "<div class='error'>"._T('avis_erreur_mysql').' '.sql_errno().': '.sql_error()."</div>\n"; |
|
| 42 | 42 | } else { |
| 43 | 43 | include_spip('inc/rubriques'); |
| 44 | 44 | calculer_rubriques(); |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | $res .= pipeline('base_admin_repair', $res); |
| 49 | 49 | echo minipres( |
| 50 | 50 | _T('texte_tentative_recuperation'), |
| 51 | - $res . generer_form_ecrire('accueil', '', '', _T('public:accueil_site')) |
|
| 51 | + $res.generer_form_ecrire('accueil', '', '', _T('public:accueil_site')) |
|
| 52 | 52 | ); |
| 53 | 53 | } |
| 54 | 54 | |
@@ -91,12 +91,12 @@ discard block |
||
| 91 | 91 | $count = sql_countsel($tab); |
| 92 | 92 | |
| 93 | 93 | if ($count > 1) { |
| 94 | - $m .= '(' . _T('texte_compte_elements', ['count' => $count]) . ")\n"; |
|
| 94 | + $m .= '('._T('texte_compte_elements', ['count' => $count]).")\n"; |
|
| 95 | 95 | } else { |
| 96 | 96 | if ($count == 1) { |
| 97 | - $m .= '(' . _T('texte_compte_element', ['count' => $count]) . ")\n"; |
|
| 97 | + $m .= '('._T('texte_compte_element', ['count' => $count]).")\n"; |
|
| 98 | 98 | } else { |
| 99 | - $m .= '(' . _T('texte_vide') . ")\n"; |
|
| 99 | + $m .= '('._T('texte_vide').")\n"; |
|
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | |
@@ -105,13 +105,13 @@ discard block |
||
| 105 | 105 | and $msg = join( |
| 106 | 106 | ' ', |
| 107 | 107 | (is_resource($result_repair) or is_object($result_repair)) ? sql_fetch($result_repair) : $result_repair |
| 108 | - ) . ' ' |
|
| 108 | + ).' ' |
|
| 109 | 109 | and strpos($msg, ' OK ') === false |
| 110 | 110 | ) { |
| 111 | 111 | $class = " class='notice'"; |
| 112 | - $m .= '<br /><tt>' . spip_htmlentities($msg) . "</tt>\n"; |
|
| 112 | + $m .= '<br /><tt>'.spip_htmlentities($msg)."</tt>\n"; |
|
| 113 | 113 | } else { |
| 114 | - $m .= ' ' . _T('texte_table_ok'); |
|
| 114 | + $m .= ' '._T('texte_table_ok'); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | $res .= "<div$class>$m</div>"; |
@@ -17,17 +17,17 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | if (!defined('_UPGRADE_TIME_OUT')) { |
| 24 | - /** |
|
| 25 | - * Durée en secondes pour relancer les scripts de mises à jour, x secondes |
|
| 26 | - * avant que la durée d'exécution du script provoque un timeout |
|
| 27 | - * |
|
| 28 | - * @var int |
|
| 29 | - **/ |
|
| 30 | - define('_UPGRADE_TIME_OUT', 20); |
|
| 24 | + /** |
|
| 25 | + * Durée en secondes pour relancer les scripts de mises à jour, x secondes |
|
| 26 | + * avant que la durée d'exécution du script provoque un timeout |
|
| 27 | + * |
|
| 28 | + * @var int |
|
| 29 | + **/ |
|
| 30 | + define('_UPGRADE_TIME_OUT', 20); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
@@ -50,40 +50,40 @@ discard block |
||
| 50 | 50 | * @return void |
| 51 | 51 | */ |
| 52 | 52 | function base_upgrade_dist($titre = '', $reprise = '') { |
| 53 | - if (!$titre) { |
|
| 54 | - return; |
|
| 55 | - } // anti-testeur automatique |
|
| 56 | - if ($GLOBALS['spip_version_base'] != $GLOBALS['meta']['version_installee']) { |
|
| 57 | - if (!is_numeric(_request('reinstall'))) { |
|
| 58 | - include_spip('base/create'); |
|
| 59 | - spip_log('recree les tables eventuellement disparues', 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 60 | - creer_base(); |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - // quand on rentre par ici, c'est toujours une mise a jour de SPIP |
|
| 64 | - // lancement de l'upgrade SPIP |
|
| 65 | - $res = maj_base(); |
|
| 66 | - |
|
| 67 | - if ($res) { |
|
| 68 | - // on arrete tout ici ! |
|
| 69 | - exit; |
|
| 70 | - } |
|
| 71 | - } |
|
| 72 | - spip_log('Fin de mise a jour SQL. Debut m-a-j acces et config', 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 73 | - |
|
| 74 | - // supprimer quelques fichiers temporaires qui peuvent se retrouver invalides |
|
| 75 | - @spip_unlink(_CACHE_RUBRIQUES); |
|
| 76 | - @spip_unlink(_CACHE_PIPELINES); |
|
| 77 | - @spip_unlink(_CACHE_PLUGINS_PATH); |
|
| 78 | - @spip_unlink(_CACHE_PLUGINS_OPT); |
|
| 79 | - @spip_unlink(_CACHE_PLUGINS_FCT); |
|
| 80 | - @spip_unlink(_CACHE_CHEMIN); |
|
| 81 | - @spip_unlink(_DIR_TMP . 'plugin_xml_cache.gz'); |
|
| 82 | - |
|
| 83 | - include_spip('inc/auth'); |
|
| 84 | - auth_synchroniser_distant(); |
|
| 85 | - $config = charger_fonction('config', 'inc'); |
|
| 86 | - $config(); |
|
| 53 | + if (!$titre) { |
|
| 54 | + return; |
|
| 55 | + } // anti-testeur automatique |
|
| 56 | + if ($GLOBALS['spip_version_base'] != $GLOBALS['meta']['version_installee']) { |
|
| 57 | + if (!is_numeric(_request('reinstall'))) { |
|
| 58 | + include_spip('base/create'); |
|
| 59 | + spip_log('recree les tables eventuellement disparues', 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 60 | + creer_base(); |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + // quand on rentre par ici, c'est toujours une mise a jour de SPIP |
|
| 64 | + // lancement de l'upgrade SPIP |
|
| 65 | + $res = maj_base(); |
|
| 66 | + |
|
| 67 | + if ($res) { |
|
| 68 | + // on arrete tout ici ! |
|
| 69 | + exit; |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | + spip_log('Fin de mise a jour SQL. Debut m-a-j acces et config', 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 73 | + |
|
| 74 | + // supprimer quelques fichiers temporaires qui peuvent se retrouver invalides |
|
| 75 | + @spip_unlink(_CACHE_RUBRIQUES); |
|
| 76 | + @spip_unlink(_CACHE_PIPELINES); |
|
| 77 | + @spip_unlink(_CACHE_PLUGINS_PATH); |
|
| 78 | + @spip_unlink(_CACHE_PLUGINS_OPT); |
|
| 79 | + @spip_unlink(_CACHE_PLUGINS_FCT); |
|
| 80 | + @spip_unlink(_CACHE_CHEMIN); |
|
| 81 | + @spip_unlink(_DIR_TMP . 'plugin_xml_cache.gz'); |
|
| 82 | + |
|
| 83 | + include_spip('inc/auth'); |
|
| 84 | + auth_synchroniser_distant(); |
|
| 85 | + $config = charger_fonction('config', 'inc'); |
|
| 86 | + $config(); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
@@ -114,51 +114,51 @@ discard block |
||
| 114 | 114 | */ |
| 115 | 115 | function maj_base($version_cible = 0, $redirect = '', $debut_page = true) { |
| 116 | 116 | |
| 117 | - $version_installee = $GLOBALS['meta']['version_installee'] ?? null; |
|
| 118 | - |
|
| 119 | - spip_log( |
|
| 120 | - "Version anterieure: $version_installee. Courante: " . $GLOBALS['spip_version_base'], |
|
| 121 | - 'maj.' . _LOG_INFO_IMPORTANTE |
|
| 122 | - ); |
|
| 123 | - if (!$version_installee or ($GLOBALS['spip_version_base'] < $version_installee)) { |
|
| 124 | - sql_replace( |
|
| 125 | - 'spip_meta', |
|
| 126 | - [ |
|
| 127 | - 'nom' => 'version_installee', |
|
| 128 | - 'valeur' => $GLOBALS['spip_version_base'], |
|
| 129 | - 'impt' => 'non' |
|
| 130 | - ] |
|
| 131 | - ); |
|
| 132 | - return false; |
|
| 133 | - } |
|
| 134 | - if (!upgrade_test()) { |
|
| 135 | - return true; |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - $cible = ($version_cible ? $version_cible : $GLOBALS['spip_version_base']); |
|
| 139 | - |
|
| 140 | - if ($version_installee < 2021010100) { |
|
| 141 | - include_spip('maj/legacy/v21'); |
|
| 142 | - include_spip('maj/legacy/v30'); |
|
| 143 | - include_spip('maj/legacy/v31'); |
|
| 144 | - include_spip('maj/legacy/v32'); |
|
| 145 | - include_spip('maj/legacy/v40'); |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - include_spip('maj/2021'); |
|
| 149 | - |
|
| 150 | - ksort($GLOBALS['maj']); |
|
| 151 | - $res = maj_while($version_installee, $cible, $GLOBALS['maj'], 'version_installee', 'meta', $redirect, $debut_page); |
|
| 152 | - if ($res) { |
|
| 153 | - if (!is_array($res)) { |
|
| 154 | - spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_INFO_ERREUR); |
|
| 155 | - } else { |
|
| 156 | - echo _T('avis_operation_echec') . ' ' . join(' ', $res); |
|
| 157 | - echo install_fin_html(); |
|
| 158 | - } |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - return $res; |
|
| 117 | + $version_installee = $GLOBALS['meta']['version_installee'] ?? null; |
|
| 118 | + |
|
| 119 | + spip_log( |
|
| 120 | + "Version anterieure: $version_installee. Courante: " . $GLOBALS['spip_version_base'], |
|
| 121 | + 'maj.' . _LOG_INFO_IMPORTANTE |
|
| 122 | + ); |
|
| 123 | + if (!$version_installee or ($GLOBALS['spip_version_base'] < $version_installee)) { |
|
| 124 | + sql_replace( |
|
| 125 | + 'spip_meta', |
|
| 126 | + [ |
|
| 127 | + 'nom' => 'version_installee', |
|
| 128 | + 'valeur' => $GLOBALS['spip_version_base'], |
|
| 129 | + 'impt' => 'non' |
|
| 130 | + ] |
|
| 131 | + ); |
|
| 132 | + return false; |
|
| 133 | + } |
|
| 134 | + if (!upgrade_test()) { |
|
| 135 | + return true; |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + $cible = ($version_cible ? $version_cible : $GLOBALS['spip_version_base']); |
|
| 139 | + |
|
| 140 | + if ($version_installee < 2021010100) { |
|
| 141 | + include_spip('maj/legacy/v21'); |
|
| 142 | + include_spip('maj/legacy/v30'); |
|
| 143 | + include_spip('maj/legacy/v31'); |
|
| 144 | + include_spip('maj/legacy/v32'); |
|
| 145 | + include_spip('maj/legacy/v40'); |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + include_spip('maj/2021'); |
|
| 149 | + |
|
| 150 | + ksort($GLOBALS['maj']); |
|
| 151 | + $res = maj_while($version_installee, $cible, $GLOBALS['maj'], 'version_installee', 'meta', $redirect, $debut_page); |
|
| 152 | + if ($res) { |
|
| 153 | + if (!is_array($res)) { |
|
| 154 | + spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_INFO_ERREUR); |
|
| 155 | + } else { |
|
| 156 | + echo _T('avis_operation_echec') . ' ' . join(' ', $res); |
|
| 157 | + echo install_fin_html(); |
|
| 158 | + } |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + return $res; |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
@@ -200,53 +200,53 @@ discard block |
||
| 200 | 200 | */ |
| 201 | 201 | function maj_plugin($nom_meta_base_version, $version_cible, $maj, $table_meta = 'meta') { |
| 202 | 202 | |
| 203 | - if ($table_meta !== 'meta') { |
|
| 204 | - installer_table_meta($table_meta); |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - $current_version = null; |
|
| 208 | - |
|
| 209 | - if ( |
|
| 210 | - (!isset($GLOBALS[$table_meta][$nom_meta_base_version])) |
|
| 211 | - || (!spip_version_compare($current_version = $GLOBALS[$table_meta][$nom_meta_base_version], $version_cible, '=')) |
|
| 212 | - ) { |
|
| 213 | - // $maj['create'] contient les directives propres a la premiere creation de base |
|
| 214 | - // c'est une operation derogatoire qui fait aboutir directement dans la version_cible |
|
| 215 | - if (isset($maj['create'])) { |
|
| 216 | - if (!isset($GLOBALS[$table_meta][$nom_meta_base_version])) { |
|
| 217 | - // installation : on ne fait que l'operation create |
|
| 218 | - $maj = ['init' => $maj['create']]; |
|
| 219 | - // et on lui ajoute un appel a inc/config |
|
| 220 | - // pour creer les metas par defaut |
|
| 221 | - $config = charger_fonction('config', 'inc'); |
|
| 222 | - $maj[$version_cible] = [[$config]]; |
|
| 223 | - } |
|
| 224 | - // dans tous les cas enlever cet index du tableau |
|
| 225 | - unset($maj['create']); |
|
| 226 | - } |
|
| 227 | - // si init, deja dans le bon ordre |
|
| 228 | - if (!isset($maj['init'])) { |
|
| 229 | - include_spip('inc/plugin'); // pour spip_version_compare |
|
| 230 | - uksort($maj, 'spip_version_compare'); |
|
| 231 | - } |
|
| 232 | - |
|
| 233 | - // la redirection se fait par defaut sur la page d'administration des plugins |
|
| 234 | - // sauf lorsque nous sommes sur l'installation de SPIP |
|
| 235 | - // ou define _REDIRECT_MAJ_PLUGIN |
|
| 236 | - $redirect = (defined('_REDIRECT_MAJ_PLUGIN') ? _REDIRECT_MAJ_PLUGIN : generer_url_ecrire('admin_plugin')); |
|
| 237 | - if (defined('_ECRIRE_INSTALL')) { |
|
| 238 | - $redirect = parametre_url(generer_url_ecrire('install'), 'etape', _request('etape')); |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - $res = maj_while($current_version, $version_cible, $maj, $nom_meta_base_version, $table_meta, $redirect); |
|
| 242 | - if ($res) { |
|
| 243 | - if (!is_array($res)) { |
|
| 244 | - spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_INFO_ERREUR); |
|
| 245 | - } else { |
|
| 246 | - echo '<p>' . _T('avis_operation_echec') . ' ' . join(' ', $res) . '</p>'; |
|
| 247 | - } |
|
| 248 | - } |
|
| 249 | - } |
|
| 203 | + if ($table_meta !== 'meta') { |
|
| 204 | + installer_table_meta($table_meta); |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + $current_version = null; |
|
| 208 | + |
|
| 209 | + if ( |
|
| 210 | + (!isset($GLOBALS[$table_meta][$nom_meta_base_version])) |
|
| 211 | + || (!spip_version_compare($current_version = $GLOBALS[$table_meta][$nom_meta_base_version], $version_cible, '=')) |
|
| 212 | + ) { |
|
| 213 | + // $maj['create'] contient les directives propres a la premiere creation de base |
|
| 214 | + // c'est une operation derogatoire qui fait aboutir directement dans la version_cible |
|
| 215 | + if (isset($maj['create'])) { |
|
| 216 | + if (!isset($GLOBALS[$table_meta][$nom_meta_base_version])) { |
|
| 217 | + // installation : on ne fait que l'operation create |
|
| 218 | + $maj = ['init' => $maj['create']]; |
|
| 219 | + // et on lui ajoute un appel a inc/config |
|
| 220 | + // pour creer les metas par defaut |
|
| 221 | + $config = charger_fonction('config', 'inc'); |
|
| 222 | + $maj[$version_cible] = [[$config]]; |
|
| 223 | + } |
|
| 224 | + // dans tous les cas enlever cet index du tableau |
|
| 225 | + unset($maj['create']); |
|
| 226 | + } |
|
| 227 | + // si init, deja dans le bon ordre |
|
| 228 | + if (!isset($maj['init'])) { |
|
| 229 | + include_spip('inc/plugin'); // pour spip_version_compare |
|
| 230 | + uksort($maj, 'spip_version_compare'); |
|
| 231 | + } |
|
| 232 | + |
|
| 233 | + // la redirection se fait par defaut sur la page d'administration des plugins |
|
| 234 | + // sauf lorsque nous sommes sur l'installation de SPIP |
|
| 235 | + // ou define _REDIRECT_MAJ_PLUGIN |
|
| 236 | + $redirect = (defined('_REDIRECT_MAJ_PLUGIN') ? _REDIRECT_MAJ_PLUGIN : generer_url_ecrire('admin_plugin')); |
|
| 237 | + if (defined('_ECRIRE_INSTALL')) { |
|
| 238 | + $redirect = parametre_url(generer_url_ecrire('install'), 'etape', _request('etape')); |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + $res = maj_while($current_version, $version_cible, $maj, $nom_meta_base_version, $table_meta, $redirect); |
|
| 242 | + if ($res) { |
|
| 243 | + if (!is_array($res)) { |
|
| 244 | + spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_INFO_ERREUR); |
|
| 245 | + } else { |
|
| 246 | + echo '<p>' . _T('avis_operation_echec') . ' ' . join(' ', $res) . '</p>'; |
|
| 247 | + } |
|
| 248 | + } |
|
| 249 | + } |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | /** |
@@ -263,17 +263,17 @@ discard block |
||
| 263 | 263 | * @return void |
| 264 | 264 | */ |
| 265 | 265 | function relance_maj($meta, $table, $redirect = '') { |
| 266 | - include_spip('inc/headers'); |
|
| 267 | - if (!$redirect) { |
|
| 268 | - // recuperer la valeur installee en cours |
|
| 269 | - // on la tronque numeriquement, elle ne sert pas reellement |
|
| 270 | - // sauf pour verifier que ce n'est pas oui ou non |
|
| 271 | - // sinon is_numeric va echouer sur un numero de version 1.2.3 |
|
| 272 | - $installee = intval($GLOBALS[$table][$meta]); |
|
| 273 | - $redirect = generer_url_ecrire('upgrade', "reinstall=$installee&meta=$meta&table=$table", true); |
|
| 274 | - } |
|
| 275 | - echo redirige_formulaire($redirect); |
|
| 276 | - exit(); |
|
| 266 | + include_spip('inc/headers'); |
|
| 267 | + if (!$redirect) { |
|
| 268 | + // recuperer la valeur installee en cours |
|
| 269 | + // on la tronque numeriquement, elle ne sert pas reellement |
|
| 270 | + // sauf pour verifier que ce n'est pas oui ou non |
|
| 271 | + // sinon is_numeric va echouer sur un numero de version 1.2.3 |
|
| 272 | + $installee = intval($GLOBALS[$table][$meta]); |
|
| 273 | + $redirect = generer_url_ecrire('upgrade', "reinstall=$installee&meta=$meta&table=$table", true); |
|
| 274 | + } |
|
| 275 | + echo redirige_formulaire($redirect); |
|
| 276 | + exit(); |
|
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | /** |
@@ -286,26 +286,26 @@ discard block |
||
| 286 | 286 | * @return void |
| 287 | 287 | */ |
| 288 | 288 | function maj_debut_page($installee, $meta, $table) { |
| 289 | - static $done = false; |
|
| 290 | - if ($done) { |
|
| 291 | - return; |
|
| 292 | - } |
|
| 293 | - include_spip('inc/minipres'); |
|
| 294 | - @ini_set('zlib.output_compression', '0'); // pour permettre l'affichage au fur et a mesure |
|
| 295 | - $timeout = _UPGRADE_TIME_OUT * 2; |
|
| 296 | - $titre = _T('titre_page_upgrade'); |
|
| 297 | - $balise_img = charger_filtre('balise_img'); |
|
| 298 | - $titre .= $balise_img(chemin_image('loader.svg'), '', 'loader'); |
|
| 299 | - echo(install_debut_html($titre)); |
|
| 300 | - // script de rechargement auto sur timeout |
|
| 301 | - $redirect = generer_url_ecrire('upgrade', "reinstall=$installee&meta=$meta&table=$table", true); |
|
| 302 | - echo http_script("window.setTimeout('location.href=\"" . $redirect . "\";'," . ($timeout * 1000) . ')'); |
|
| 303 | - echo "<div style='text-align: left'>\n"; |
|
| 304 | - if (ob_get_level()) { |
|
| 305 | - ob_flush(); |
|
| 306 | - } |
|
| 307 | - flush(); |
|
| 308 | - $done = true; |
|
| 289 | + static $done = false; |
|
| 290 | + if ($done) { |
|
| 291 | + return; |
|
| 292 | + } |
|
| 293 | + include_spip('inc/minipres'); |
|
| 294 | + @ini_set('zlib.output_compression', '0'); // pour permettre l'affichage au fur et a mesure |
|
| 295 | + $timeout = _UPGRADE_TIME_OUT * 2; |
|
| 296 | + $titre = _T('titre_page_upgrade'); |
|
| 297 | + $balise_img = charger_filtre('balise_img'); |
|
| 298 | + $titre .= $balise_img(chemin_image('loader.svg'), '', 'loader'); |
|
| 299 | + echo(install_debut_html($titre)); |
|
| 300 | + // script de rechargement auto sur timeout |
|
| 301 | + $redirect = generer_url_ecrire('upgrade', "reinstall=$installee&meta=$meta&table=$table", true); |
|
| 302 | + echo http_script("window.setTimeout('location.href=\"" . $redirect . "\";'," . ($timeout * 1000) . ')'); |
|
| 303 | + echo "<div style='text-align: left'>\n"; |
|
| 304 | + if (ob_get_level()) { |
|
| 305 | + ob_flush(); |
|
| 306 | + } |
|
| 307 | + flush(); |
|
| 308 | + $done = true; |
|
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | |
@@ -349,64 +349,64 @@ discard block |
||
| 349 | 349 | * - tableau vide sinon. |
| 350 | 350 | */ |
| 351 | 351 | function maj_while($installee, $cible, $maj, $meta = '', $table = 'meta', $redirect = '', $debut_page = false) { |
| 352 | - # inclusions pour que les procedures d'upgrade disposent des fonctions de base |
|
| 353 | - include_spip('base/create'); |
|
| 354 | - include_spip('base/abstract_sql'); |
|
| 355 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 356 | - include_spip('inc/plugin'); // pour spip_version_compare |
|
| 357 | - $n = 0; |
|
| 358 | - $time = time(); |
|
| 359 | - |
|
| 360 | - if (!defined('_TIME_OUT')) { |
|
| 361 | - /** |
|
| 362 | - * Définir le timeout qui peut-être utilisé dans les fonctions |
|
| 363 | - * de mises à jour qui durent trop longtemps |
|
| 364 | - * |
|
| 365 | - * À utiliser tel que : `if (time() >= _TIME_OUT)` |
|
| 366 | - * |
|
| 367 | - * @var int |
|
| 368 | - */ |
|
| 369 | - define('_TIME_OUT', $time + _UPGRADE_TIME_OUT); |
|
| 370 | - } |
|
| 371 | - |
|
| 372 | - foreach ($maj as $v => $operations) { |
|
| 373 | - // si une maj pour cette version |
|
| 374 | - if ( |
|
| 375 | - $v == 'init' or |
|
| 376 | - (spip_version_compare($v, $installee, '>') |
|
| 377 | - and spip_version_compare($v, $cible, '<=')) |
|
| 378 | - ) { |
|
| 379 | - if ($debut_page) { |
|
| 380 | - maj_debut_page($v, $meta, $table); |
|
| 381 | - } |
|
| 382 | - echo "MAJ $v"; |
|
| 383 | - $etape = serie_alter($v, $operations, $meta, $table, $redirect); |
|
| 384 | - $trouver_table(''); // vider le cache des descriptions de table |
|
| 385 | - # echec sur une etape en cours ? |
|
| 386 | - # on sort |
|
| 387 | - if ($etape) { |
|
| 388 | - return [$v, $etape]; |
|
| 389 | - } |
|
| 390 | - $n = time() - $time; |
|
| 391 | - spip_log("$table $meta: $v en $n secondes", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 392 | - if ($meta) { |
|
| 393 | - ecrire_meta($meta, $installee = $v, 'oui', $table); |
|
| 394 | - } |
|
| 395 | - echo (_IS_CLI ? "\n" : '<br />'); |
|
| 396 | - } |
|
| 397 | - if (time() >= _TIME_OUT) { |
|
| 398 | - relance_maj($meta, $table, $redirect); |
|
| 399 | - } |
|
| 400 | - } |
|
| 401 | - $trouver_table(''); // vider le cache des descriptions de table |
|
| 402 | - // indispensable pour les chgt de versions qui n'ecrivent pas en base |
|
| 403 | - // tant pis pour la redondance eventuelle avec ci-dessus |
|
| 404 | - if ($meta) { |
|
| 405 | - ecrire_meta($meta, $cible, 'oui', $table); |
|
| 406 | - } |
|
| 407 | - spip_log("MAJ terminee. $meta: $installee", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 408 | - |
|
| 409 | - return []; |
|
| 352 | + # inclusions pour que les procedures d'upgrade disposent des fonctions de base |
|
| 353 | + include_spip('base/create'); |
|
| 354 | + include_spip('base/abstract_sql'); |
|
| 355 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 356 | + include_spip('inc/plugin'); // pour spip_version_compare |
|
| 357 | + $n = 0; |
|
| 358 | + $time = time(); |
|
| 359 | + |
|
| 360 | + if (!defined('_TIME_OUT')) { |
|
| 361 | + /** |
|
| 362 | + * Définir le timeout qui peut-être utilisé dans les fonctions |
|
| 363 | + * de mises à jour qui durent trop longtemps |
|
| 364 | + * |
|
| 365 | + * À utiliser tel que : `if (time() >= _TIME_OUT)` |
|
| 366 | + * |
|
| 367 | + * @var int |
|
| 368 | + */ |
|
| 369 | + define('_TIME_OUT', $time + _UPGRADE_TIME_OUT); |
|
| 370 | + } |
|
| 371 | + |
|
| 372 | + foreach ($maj as $v => $operations) { |
|
| 373 | + // si une maj pour cette version |
|
| 374 | + if ( |
|
| 375 | + $v == 'init' or |
|
| 376 | + (spip_version_compare($v, $installee, '>') |
|
| 377 | + and spip_version_compare($v, $cible, '<=')) |
|
| 378 | + ) { |
|
| 379 | + if ($debut_page) { |
|
| 380 | + maj_debut_page($v, $meta, $table); |
|
| 381 | + } |
|
| 382 | + echo "MAJ $v"; |
|
| 383 | + $etape = serie_alter($v, $operations, $meta, $table, $redirect); |
|
| 384 | + $trouver_table(''); // vider le cache des descriptions de table |
|
| 385 | + # echec sur une etape en cours ? |
|
| 386 | + # on sort |
|
| 387 | + if ($etape) { |
|
| 388 | + return [$v, $etape]; |
|
| 389 | + } |
|
| 390 | + $n = time() - $time; |
|
| 391 | + spip_log("$table $meta: $v en $n secondes", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 392 | + if ($meta) { |
|
| 393 | + ecrire_meta($meta, $installee = $v, 'oui', $table); |
|
| 394 | + } |
|
| 395 | + echo (_IS_CLI ? "\n" : '<br />'); |
|
| 396 | + } |
|
| 397 | + if (time() >= _TIME_OUT) { |
|
| 398 | + relance_maj($meta, $table, $redirect); |
|
| 399 | + } |
|
| 400 | + } |
|
| 401 | + $trouver_table(''); // vider le cache des descriptions de table |
|
| 402 | + // indispensable pour les chgt de versions qui n'ecrivent pas en base |
|
| 403 | + // tant pis pour la redondance eventuelle avec ci-dessus |
|
| 404 | + if ($meta) { |
|
| 405 | + ecrire_meta($meta, $cible, 'oui', $table); |
|
| 406 | + } |
|
| 407 | + spip_log("MAJ terminee. $meta: $installee", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 408 | + |
|
| 409 | + return []; |
|
| 410 | 410 | } |
| 411 | 411 | |
| 412 | 412 | /** |
@@ -429,53 +429,53 @@ discard block |
||
| 429 | 429 | * @return int |
| 430 | 430 | */ |
| 431 | 431 | function serie_alter($serie, $q = [], $meta = '', $table = 'meta', $redirect = '') { |
| 432 | - $meta2 = $meta . '_maj_' . $serie; |
|
| 433 | - $etape = 0; |
|
| 434 | - if (isset($GLOBALS[$table][$meta2])) { |
|
| 435 | - $etape = intval($GLOBALS[$table][$meta2]); |
|
| 436 | - } |
|
| 437 | - foreach ($q as $i => $r) { |
|
| 438 | - if ($i >= $etape) { |
|
| 439 | - $msg = "maj $table $meta2 etape $i"; |
|
| 440 | - if ( |
|
| 441 | - is_array($r) |
|
| 442 | - and function_exists($f = array_shift($r)) |
|
| 443 | - ) { |
|
| 444 | - // note: $r (arguments de la fonction $f) peut avoir des données tabulaires |
|
| 445 | - spip_log("$msg: $f " . @join(',', $r), 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 446 | - // pour les fonctions atomiques sql_xx |
|
| 447 | - // on enregistre le meta avant de lancer la fonction, |
|
| 448 | - // de maniere a eviter de boucler sur timeout |
|
| 449 | - // mais pour les fonctions complexes, |
|
| 450 | - // il faut les rejouer jusqu'a achevement. |
|
| 451 | - // C'est a elle d'assurer qu'elles progressent a chaque rappel |
|
| 452 | - if (strncmp($f, 'sql_', 4) == 0) { |
|
| 453 | - ecrire_meta($meta2, $i + 1, 'non', $table); |
|
| 454 | - } |
|
| 455 | - echo (_IS_CLI ? '.' : " <span title='$i'>.</span>"); |
|
| 456 | - call_user_func_array($f, $r); |
|
| 457 | - // si temps imparti depasse, on relance sans ecrire en meta |
|
| 458 | - // car on est peut etre sorti sur timeout si c'est une fonction longue |
|
| 459 | - if (time() >= _TIME_OUT) { |
|
| 460 | - relance_maj($meta, $table, $redirect); |
|
| 461 | - } |
|
| 462 | - ecrire_meta($meta2, $i + 1, 'non', $table); |
|
| 463 | - spip_log("$meta2: ok", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 464 | - } else { |
|
| 465 | - if (!is_array($r)) { |
|
| 466 | - spip_log("maj $i format incorrect", 'maj.' . _LOG_ERREUR); |
|
| 467 | - } else { |
|
| 468 | - spip_log("maj $i fonction $f non definie", 'maj.' . _LOG_ERREUR); |
|
| 469 | - } |
|
| 470 | - // en cas d'erreur serieuse, on s'arrete |
|
| 471 | - // mais on permet de passer par dessus en rechargeant la page. |
|
| 472 | - return $i + 1; |
|
| 473 | - } |
|
| 474 | - } |
|
| 475 | - } |
|
| 476 | - effacer_meta($meta2, $table); |
|
| 477 | - |
|
| 478 | - return 0; |
|
| 432 | + $meta2 = $meta . '_maj_' . $serie; |
|
| 433 | + $etape = 0; |
|
| 434 | + if (isset($GLOBALS[$table][$meta2])) { |
|
| 435 | + $etape = intval($GLOBALS[$table][$meta2]); |
|
| 436 | + } |
|
| 437 | + foreach ($q as $i => $r) { |
|
| 438 | + if ($i >= $etape) { |
|
| 439 | + $msg = "maj $table $meta2 etape $i"; |
|
| 440 | + if ( |
|
| 441 | + is_array($r) |
|
| 442 | + and function_exists($f = array_shift($r)) |
|
| 443 | + ) { |
|
| 444 | + // note: $r (arguments de la fonction $f) peut avoir des données tabulaires |
|
| 445 | + spip_log("$msg: $f " . @join(',', $r), 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 446 | + // pour les fonctions atomiques sql_xx |
|
| 447 | + // on enregistre le meta avant de lancer la fonction, |
|
| 448 | + // de maniere a eviter de boucler sur timeout |
|
| 449 | + // mais pour les fonctions complexes, |
|
| 450 | + // il faut les rejouer jusqu'a achevement. |
|
| 451 | + // C'est a elle d'assurer qu'elles progressent a chaque rappel |
|
| 452 | + if (strncmp($f, 'sql_', 4) == 0) { |
|
| 453 | + ecrire_meta($meta2, $i + 1, 'non', $table); |
|
| 454 | + } |
|
| 455 | + echo (_IS_CLI ? '.' : " <span title='$i'>.</span>"); |
|
| 456 | + call_user_func_array($f, $r); |
|
| 457 | + // si temps imparti depasse, on relance sans ecrire en meta |
|
| 458 | + // car on est peut etre sorti sur timeout si c'est une fonction longue |
|
| 459 | + if (time() >= _TIME_OUT) { |
|
| 460 | + relance_maj($meta, $table, $redirect); |
|
| 461 | + } |
|
| 462 | + ecrire_meta($meta2, $i + 1, 'non', $table); |
|
| 463 | + spip_log("$meta2: ok", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 464 | + } else { |
|
| 465 | + if (!is_array($r)) { |
|
| 466 | + spip_log("maj $i format incorrect", 'maj.' . _LOG_ERREUR); |
|
| 467 | + } else { |
|
| 468 | + spip_log("maj $i fonction $f non definie", 'maj.' . _LOG_ERREUR); |
|
| 469 | + } |
|
| 470 | + // en cas d'erreur serieuse, on s'arrete |
|
| 471 | + // mais on permet de passer par dessus en rechargeant la page. |
|
| 472 | + return $i + 1; |
|
| 473 | + } |
|
| 474 | + } |
|
| 475 | + } |
|
| 476 | + effacer_meta($meta2, $table); |
|
| 477 | + |
|
| 478 | + return 0; |
|
| 479 | 479 | } |
| 480 | 480 | |
| 481 | 481 | /** |
@@ -484,16 +484,16 @@ discard block |
||
| 484 | 484 | * @return bool True si possible. |
| 485 | 485 | **/ |
| 486 | 486 | function upgrade_test() { |
| 487 | - sql_drop_table('spip_test', true); |
|
| 488 | - sql_create('spip_test', ['a' => 'int']); |
|
| 489 | - sql_alter('TABLE spip_test ADD b INT'); |
|
| 490 | - sql_insertq('spip_test', ['b' => 1], ['field' => ['b' => 'int']]); |
|
| 491 | - $result = sql_select('b', 'spip_test'); |
|
| 492 | - // ne pas garder le resultat de la requete sinon sqlite3 |
|
| 493 | - // ne peut pas supprimer la table spip_test lors du sql_alter qui suit |
|
| 494 | - // car cette table serait alors 'verouillee' |
|
| 495 | - $result = $result ? true : false; |
|
| 496 | - sql_alter('TABLE spip_test DROP b'); |
|
| 497 | - |
|
| 498 | - return $result; |
|
| 487 | + sql_drop_table('spip_test', true); |
|
| 488 | + sql_create('spip_test', ['a' => 'int']); |
|
| 489 | + sql_alter('TABLE spip_test ADD b INT'); |
|
| 490 | + sql_insertq('spip_test', ['b' => 1], ['field' => ['b' => 'int']]); |
|
| 491 | + $result = sql_select('b', 'spip_test'); |
|
| 492 | + // ne pas garder le resultat de la requete sinon sqlite3 |
|
| 493 | + // ne peut pas supprimer la table spip_test lors du sql_alter qui suit |
|
| 494 | + // car cette table serait alors 'verouillee' |
|
| 495 | + $result = $result ? true : false; |
|
| 496 | + sql_alter('TABLE spip_test DROP b'); |
|
| 497 | + |
|
| 498 | + return $result; |
|
| 499 | 499 | } |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | if ($GLOBALS['spip_version_base'] != $GLOBALS['meta']['version_installee']) { |
| 57 | 57 | if (!is_numeric(_request('reinstall'))) { |
| 58 | 58 | include_spip('base/create'); |
| 59 | - spip_log('recree les tables eventuellement disparues', 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 59 | + spip_log('recree les tables eventuellement disparues', 'maj.'._LOG_INFO_IMPORTANTE); |
|
| 60 | 60 | creer_base(); |
| 61 | 61 | } |
| 62 | 62 | |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | exit; |
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | - spip_log('Fin de mise a jour SQL. Debut m-a-j acces et config', 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 72 | + spip_log('Fin de mise a jour SQL. Debut m-a-j acces et config', 'maj.'._LOG_INFO_IMPORTANTE); |
|
| 73 | 73 | |
| 74 | 74 | // supprimer quelques fichiers temporaires qui peuvent se retrouver invalides |
| 75 | 75 | @spip_unlink(_CACHE_RUBRIQUES); |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | @spip_unlink(_CACHE_PLUGINS_OPT); |
| 79 | 79 | @spip_unlink(_CACHE_PLUGINS_FCT); |
| 80 | 80 | @spip_unlink(_CACHE_CHEMIN); |
| 81 | - @spip_unlink(_DIR_TMP . 'plugin_xml_cache.gz'); |
|
| 81 | + @spip_unlink(_DIR_TMP.'plugin_xml_cache.gz'); |
|
| 82 | 82 | |
| 83 | 83 | include_spip('inc/auth'); |
| 84 | 84 | auth_synchroniser_distant(); |
@@ -117,8 +117,8 @@ discard block |
||
| 117 | 117 | $version_installee = $GLOBALS['meta']['version_installee'] ?? null; |
| 118 | 118 | |
| 119 | 119 | spip_log( |
| 120 | - "Version anterieure: $version_installee. Courante: " . $GLOBALS['spip_version_base'], |
|
| 121 | - 'maj.' . _LOG_INFO_IMPORTANTE |
|
| 120 | + "Version anterieure: $version_installee. Courante: ".$GLOBALS['spip_version_base'], |
|
| 121 | + 'maj.'._LOG_INFO_IMPORTANTE |
|
| 122 | 122 | ); |
| 123 | 123 | if (!$version_installee or ($GLOBALS['spip_version_base'] < $version_installee)) { |
| 124 | 124 | sql_replace( |
@@ -151,9 +151,9 @@ discard block |
||
| 151 | 151 | $res = maj_while($version_installee, $cible, $GLOBALS['maj'], 'version_installee', 'meta', $redirect, $debut_page); |
| 152 | 152 | if ($res) { |
| 153 | 153 | if (!is_array($res)) { |
| 154 | - spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_INFO_ERREUR); |
|
| 154 | + spip_log("Pb d'acces SQL a la mise a jour", 'maj.'._LOG_INFO_ERREUR); |
|
| 155 | 155 | } else { |
| 156 | - echo _T('avis_operation_echec') . ' ' . join(' ', $res); |
|
| 156 | + echo _T('avis_operation_echec').' '.join(' ', $res); |
|
| 157 | 157 | echo install_fin_html(); |
| 158 | 158 | } |
| 159 | 159 | } |
@@ -241,9 +241,9 @@ discard block |
||
| 241 | 241 | $res = maj_while($current_version, $version_cible, $maj, $nom_meta_base_version, $table_meta, $redirect); |
| 242 | 242 | if ($res) { |
| 243 | 243 | if (!is_array($res)) { |
| 244 | - spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_INFO_ERREUR); |
|
| 244 | + spip_log("Pb d'acces SQL a la mise a jour", 'maj.'._LOG_INFO_ERREUR); |
|
| 245 | 245 | } else { |
| 246 | - echo '<p>' . _T('avis_operation_echec') . ' ' . join(' ', $res) . '</p>'; |
|
| 246 | + echo '<p>'._T('avis_operation_echec').' '.join(' ', $res).'</p>'; |
|
| 247 | 247 | } |
| 248 | 248 | } |
| 249 | 249 | } |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | echo(install_debut_html($titre)); |
| 300 | 300 | // script de rechargement auto sur timeout |
| 301 | 301 | $redirect = generer_url_ecrire('upgrade', "reinstall=$installee&meta=$meta&table=$table", true); |
| 302 | - echo http_script("window.setTimeout('location.href=\"" . $redirect . "\";'," . ($timeout * 1000) . ')'); |
|
| 302 | + echo http_script("window.setTimeout('location.href=\"".$redirect."\";',".($timeout * 1000).')'); |
|
| 303 | 303 | echo "<div style='text-align: left'>\n"; |
| 304 | 304 | if (ob_get_level()) { |
| 305 | 305 | ob_flush(); |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | return [$v, $etape]; |
| 389 | 389 | } |
| 390 | 390 | $n = time() - $time; |
| 391 | - spip_log("$table $meta: $v en $n secondes", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 391 | + spip_log("$table $meta: $v en $n secondes", 'maj.'._LOG_INFO_IMPORTANTE); |
|
| 392 | 392 | if ($meta) { |
| 393 | 393 | ecrire_meta($meta, $installee = $v, 'oui', $table); |
| 394 | 394 | } |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | if ($meta) { |
| 405 | 405 | ecrire_meta($meta, $cible, 'oui', $table); |
| 406 | 406 | } |
| 407 | - spip_log("MAJ terminee. $meta: $installee", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 407 | + spip_log("MAJ terminee. $meta: $installee", 'maj.'._LOG_INFO_IMPORTANTE); |
|
| 408 | 408 | |
| 409 | 409 | return []; |
| 410 | 410 | } |
@@ -429,7 +429,7 @@ discard block |
||
| 429 | 429 | * @return int |
| 430 | 430 | */ |
| 431 | 431 | function serie_alter($serie, $q = [], $meta = '', $table = 'meta', $redirect = '') { |
| 432 | - $meta2 = $meta . '_maj_' . $serie; |
|
| 432 | + $meta2 = $meta.'_maj_'.$serie; |
|
| 433 | 433 | $etape = 0; |
| 434 | 434 | if (isset($GLOBALS[$table][$meta2])) { |
| 435 | 435 | $etape = intval($GLOBALS[$table][$meta2]); |
@@ -442,7 +442,7 @@ discard block |
||
| 442 | 442 | and function_exists($f = array_shift($r)) |
| 443 | 443 | ) { |
| 444 | 444 | // note: $r (arguments de la fonction $f) peut avoir des données tabulaires |
| 445 | - spip_log("$msg: $f " . @join(',', $r), 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 445 | + spip_log("$msg: $f ".@join(',', $r), 'maj.'._LOG_INFO_IMPORTANTE); |
|
| 446 | 446 | // pour les fonctions atomiques sql_xx |
| 447 | 447 | // on enregistre le meta avant de lancer la fonction, |
| 448 | 448 | // de maniere a eviter de boucler sur timeout |
@@ -460,12 +460,12 @@ discard block |
||
| 460 | 460 | relance_maj($meta, $table, $redirect); |
| 461 | 461 | } |
| 462 | 462 | ecrire_meta($meta2, $i + 1, 'non', $table); |
| 463 | - spip_log("$meta2: ok", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 463 | + spip_log("$meta2: ok", 'maj.'._LOG_INFO_IMPORTANTE); |
|
| 464 | 464 | } else { |
| 465 | 465 | if (!is_array($r)) { |
| 466 | - spip_log("maj $i format incorrect", 'maj.' . _LOG_ERREUR); |
|
| 466 | + spip_log("maj $i format incorrect", 'maj.'._LOG_ERREUR); |
|
| 467 | 467 | } else { |
| 468 | - spip_log("maj $i fonction $f non definie", 'maj.' . _LOG_ERREUR); |
|
| 468 | + spip_log("maj $i fonction $f non definie", 'maj.'._LOG_ERREUR); |
|
| 469 | 469 | } |
| 470 | 470 | // en cas d'erreur serieuse, on s'arrete |
| 471 | 471 | // mais on permet de passer par dessus en rechargeant la page. |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\SQL\Tables |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | include_spip('base/objets'); |
| 22 | 22 | |
@@ -64,143 +64,143 @@ discard block |
||
| 64 | 64 | * |
| 65 | 65 | **/ |
| 66 | 66 | function base_trouver_table_dist($nom, $serveur = '', $table_spip = true) { |
| 67 | - static $nom_cache_desc_sql = []; |
|
| 68 | - |
|
| 69 | - if ( |
|
| 70 | - !spip_connect($serveur) |
|
| 71 | - or !preg_match('/^[a-zA-Z0-9._-]*/', $nom) |
|
| 72 | - ) { |
|
| 73 | - return null; |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - $connexion = &$GLOBALS['connexions'][$serveur ? strtolower($serveur) : 0]; |
|
| 77 | - $objets_sql = lister_tables_objets_sql('::md5'); |
|
| 78 | - |
|
| 79 | - // le nom du cache depend du serveur mais aussi du nom de la db et du prefixe |
|
| 80 | - // ce qui permet une auto invalidation en cas de modif manuelle du fichier |
|
| 81 | - // de connexion, et tout risque d'ambiguite |
|
| 82 | - if (!isset($nom_cache_desc_sql[$serveur][$objets_sql])) { |
|
| 83 | - $nom_cache_desc_sql[$serveur][$objets_sql] = |
|
| 84 | - _DIR_CACHE . 'sql_desc_' |
|
| 85 | - . ($serveur ? "{$serveur}_" : '') |
|
| 86 | - . substr(md5($connexion['db'] . ':' . $connexion['prefixe'] . ":$objets_sql"), 0, 8) |
|
| 87 | - . '.txt'; |
|
| 88 | - // nouveau nom de cache = nouvelle version en memoire |
|
| 89 | - unset($connexion['tables']); |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - // un appel avec $nom vide est une demande explicite de vidange du cache des descriptions |
|
| 93 | - if (!$nom) { |
|
| 94 | - spip_unlink($nom_cache_desc_sql[$serveur][$objets_sql]); |
|
| 95 | - $connexion['tables'] = []; |
|
| 96 | - |
|
| 97 | - return null; |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - $nom_sql = $nom; |
|
| 101 | - if (preg_match('/\.(.*)$/', $nom, $s)) { |
|
| 102 | - $nom_sql = $s[1]; |
|
| 103 | - } else { |
|
| 104 | - $nom_sql = $nom; |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - $fdesc = $desc = ''; |
|
| 108 | - $connexion = &$GLOBALS['connexions'][$serveur ? $serveur : 0]; |
|
| 109 | - |
|
| 110 | - // base sous SPIP: gerer les abreviations explicites des noms de table |
|
| 111 | - if ($connexion['spip_connect_version']) { |
|
| 112 | - if ($table_spip and isset($GLOBALS['table_des_tables'][$nom])) { |
|
| 113 | - $nom = $GLOBALS['table_des_tables'][$nom]; |
|
| 114 | - $nom_sql = 'spip_' . $nom; |
|
| 115 | - } |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - // si c'est la premiere table qu'on cherche |
|
| 119 | - // et si on est pas explicitement en recalcul |
|
| 120 | - // on essaye de recharger le cache des decriptions de ce serveur |
|
| 121 | - // dans le fichier cache |
|
| 122 | - if ( |
|
| 123 | - !isset($connexion['tables'][$nom_sql]) |
|
| 124 | - and defined('_VAR_MODE') and _VAR_MODE !== 'recalcul' |
|
| 125 | - and (!isset($connexion['tables']) or !$connexion['tables']) |
|
| 126 | - ) { |
|
| 127 | - if ( |
|
| 128 | - lire_fichier($nom_cache_desc_sql[$serveur][$objets_sql], $desc_cache) |
|
| 129 | - and $desc_cache = unserialize($desc_cache) |
|
| 130 | - ) { |
|
| 131 | - $connexion['tables'] = $desc_cache; |
|
| 132 | - } |
|
| 133 | - } |
|
| 134 | - if ($table_spip and !isset($connexion['tables'][$nom_sql])) { |
|
| 135 | - if (isset($GLOBALS['tables_principales'][$nom_sql])) { |
|
| 136 | - $fdesc = $GLOBALS['tables_principales'][$nom_sql]; |
|
| 137 | - } |
|
| 138 | - // meme si pas d'abreviation declaree, trouver la table spip_$nom |
|
| 139 | - // si c'est une table principale, |
|
| 140 | - // puisqu'on le fait aussi pour les tables auxiliaires |
|
| 141 | - elseif ($nom_sql == $nom and isset($GLOBALS['tables_principales']['spip_' . $nom])) { |
|
| 142 | - $nom_sql = 'spip_' . $nom; |
|
| 143 | - $fdesc = &$GLOBALS['tables_principales'][$nom_sql]; |
|
| 144 | - } elseif ( |
|
| 145 | - isset($GLOBALS['tables_auxiliaires'][$n = $nom]) |
|
| 146 | - or isset($GLOBALS['tables_auxiliaires'][$n = 'spip_' . $nom]) |
|
| 147 | - ) { |
|
| 148 | - $nom_sql = $n; |
|
| 149 | - $fdesc = &$GLOBALS['tables_auxiliaires'][$n]; |
|
| 150 | - } # table locale a cote de SPIP, comme non SPIP: |
|
| 151 | - } |
|
| 152 | - if (!isset($connexion['tables'][$nom_sql])) { |
|
| 153 | - // La *vraie* base a la priorite |
|
| 154 | - $desc = sql_showtable($nom_sql, $table_spip, $serveur); |
|
| 155 | - if (!$desc or !$desc['field']) { |
|
| 156 | - if (!$fdesc) { |
|
| 157 | - spip_log("trouver_table: table inconnue '$serveur' '$nom'", 'base' . _LOG_INFO_IMPORTANTE); |
|
| 158 | - |
|
| 159 | - return null; |
|
| 160 | - } |
|
| 161 | - // on ne sait pas lire la structure de la table : |
|
| 162 | - // on retombe sur la description donnee dans les fichiers spip |
|
| 163 | - $desc = $fdesc; |
|
| 164 | - $desc['exist'] = false; |
|
| 165 | - } else { |
|
| 166 | - $desc['exist'] = true; |
|
| 167 | - // gerer le cas des cles vides (echec de l'analyse sur une vue par exemple) |
|
| 168 | - // pour recuperer la declaration de lister_tables_objets_sql() si il y en a une |
|
| 169 | - if (! $desc['key']) { |
|
| 170 | - spip_log("trouver_table: table sans cle '$serveur' '$nom'", 'base'); |
|
| 171 | - unset($desc['key']); |
|
| 172 | - } |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - $desc['table'] = $desc['table_sql'] = $nom_sql; |
|
| 176 | - $desc['connexion'] = $serveur; |
|
| 177 | - |
|
| 178 | - // charger les infos declarees pour cette table |
|
| 179 | - // en lui passant les infos connues |
|
| 180 | - // $desc est prioritaire pour la description de la table |
|
| 181 | - $desc = array_merge(lister_tables_objets_sql($nom_sql, $desc), $desc); |
|
| 182 | - // s'assurer qu'on a toujours un 'key' |
|
| 183 | - if (!isset($desc['key']) && !empty($fdesc['key'])) { |
|
| 184 | - $desc['key'] = $fdesc['key']; |
|
| 185 | - } |
|
| 186 | - if (! isset($desc['key'])) { |
|
| 187 | - $desc['key'] = []; |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - // si tables_objets_sql est bien fini d'init, on peut cacher |
|
| 191 | - $connexion['tables'][$nom_sql] = $desc; |
|
| 192 | - $res = &$connexion['tables'][$nom_sql]; |
|
| 193 | - // une nouvelle table a ete decrite |
|
| 194 | - // mettons donc a jour le cache des descriptions de ce serveur |
|
| 195 | - if (is_writeable(_DIR_CACHE)) { |
|
| 196 | - ecrire_fichier($nom_cache_desc_sql[$serveur][$objets_sql], serialize($connexion['tables']), true); |
|
| 197 | - } |
|
| 198 | - } else { |
|
| 199 | - $res = &$connexion['tables'][$nom_sql]; |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - // toujours retourner $nom dans id_table |
|
| 203 | - $res['id_table'] = $nom; |
|
| 204 | - |
|
| 205 | - return $res; |
|
| 67 | + static $nom_cache_desc_sql = []; |
|
| 68 | + |
|
| 69 | + if ( |
|
| 70 | + !spip_connect($serveur) |
|
| 71 | + or !preg_match('/^[a-zA-Z0-9._-]*/', $nom) |
|
| 72 | + ) { |
|
| 73 | + return null; |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + $connexion = &$GLOBALS['connexions'][$serveur ? strtolower($serveur) : 0]; |
|
| 77 | + $objets_sql = lister_tables_objets_sql('::md5'); |
|
| 78 | + |
|
| 79 | + // le nom du cache depend du serveur mais aussi du nom de la db et du prefixe |
|
| 80 | + // ce qui permet une auto invalidation en cas de modif manuelle du fichier |
|
| 81 | + // de connexion, et tout risque d'ambiguite |
|
| 82 | + if (!isset($nom_cache_desc_sql[$serveur][$objets_sql])) { |
|
| 83 | + $nom_cache_desc_sql[$serveur][$objets_sql] = |
|
| 84 | + _DIR_CACHE . 'sql_desc_' |
|
| 85 | + . ($serveur ? "{$serveur}_" : '') |
|
| 86 | + . substr(md5($connexion['db'] . ':' . $connexion['prefixe'] . ":$objets_sql"), 0, 8) |
|
| 87 | + . '.txt'; |
|
| 88 | + // nouveau nom de cache = nouvelle version en memoire |
|
| 89 | + unset($connexion['tables']); |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + // un appel avec $nom vide est une demande explicite de vidange du cache des descriptions |
|
| 93 | + if (!$nom) { |
|
| 94 | + spip_unlink($nom_cache_desc_sql[$serveur][$objets_sql]); |
|
| 95 | + $connexion['tables'] = []; |
|
| 96 | + |
|
| 97 | + return null; |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + $nom_sql = $nom; |
|
| 101 | + if (preg_match('/\.(.*)$/', $nom, $s)) { |
|
| 102 | + $nom_sql = $s[1]; |
|
| 103 | + } else { |
|
| 104 | + $nom_sql = $nom; |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + $fdesc = $desc = ''; |
|
| 108 | + $connexion = &$GLOBALS['connexions'][$serveur ? $serveur : 0]; |
|
| 109 | + |
|
| 110 | + // base sous SPIP: gerer les abreviations explicites des noms de table |
|
| 111 | + if ($connexion['spip_connect_version']) { |
|
| 112 | + if ($table_spip and isset($GLOBALS['table_des_tables'][$nom])) { |
|
| 113 | + $nom = $GLOBALS['table_des_tables'][$nom]; |
|
| 114 | + $nom_sql = 'spip_' . $nom; |
|
| 115 | + } |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + // si c'est la premiere table qu'on cherche |
|
| 119 | + // et si on est pas explicitement en recalcul |
|
| 120 | + // on essaye de recharger le cache des decriptions de ce serveur |
|
| 121 | + // dans le fichier cache |
|
| 122 | + if ( |
|
| 123 | + !isset($connexion['tables'][$nom_sql]) |
|
| 124 | + and defined('_VAR_MODE') and _VAR_MODE !== 'recalcul' |
|
| 125 | + and (!isset($connexion['tables']) or !$connexion['tables']) |
|
| 126 | + ) { |
|
| 127 | + if ( |
|
| 128 | + lire_fichier($nom_cache_desc_sql[$serveur][$objets_sql], $desc_cache) |
|
| 129 | + and $desc_cache = unserialize($desc_cache) |
|
| 130 | + ) { |
|
| 131 | + $connexion['tables'] = $desc_cache; |
|
| 132 | + } |
|
| 133 | + } |
|
| 134 | + if ($table_spip and !isset($connexion['tables'][$nom_sql])) { |
|
| 135 | + if (isset($GLOBALS['tables_principales'][$nom_sql])) { |
|
| 136 | + $fdesc = $GLOBALS['tables_principales'][$nom_sql]; |
|
| 137 | + } |
|
| 138 | + // meme si pas d'abreviation declaree, trouver la table spip_$nom |
|
| 139 | + // si c'est une table principale, |
|
| 140 | + // puisqu'on le fait aussi pour les tables auxiliaires |
|
| 141 | + elseif ($nom_sql == $nom and isset($GLOBALS['tables_principales']['spip_' . $nom])) { |
|
| 142 | + $nom_sql = 'spip_' . $nom; |
|
| 143 | + $fdesc = &$GLOBALS['tables_principales'][$nom_sql]; |
|
| 144 | + } elseif ( |
|
| 145 | + isset($GLOBALS['tables_auxiliaires'][$n = $nom]) |
|
| 146 | + or isset($GLOBALS['tables_auxiliaires'][$n = 'spip_' . $nom]) |
|
| 147 | + ) { |
|
| 148 | + $nom_sql = $n; |
|
| 149 | + $fdesc = &$GLOBALS['tables_auxiliaires'][$n]; |
|
| 150 | + } # table locale a cote de SPIP, comme non SPIP: |
|
| 151 | + } |
|
| 152 | + if (!isset($connexion['tables'][$nom_sql])) { |
|
| 153 | + // La *vraie* base a la priorite |
|
| 154 | + $desc = sql_showtable($nom_sql, $table_spip, $serveur); |
|
| 155 | + if (!$desc or !$desc['field']) { |
|
| 156 | + if (!$fdesc) { |
|
| 157 | + spip_log("trouver_table: table inconnue '$serveur' '$nom'", 'base' . _LOG_INFO_IMPORTANTE); |
|
| 158 | + |
|
| 159 | + return null; |
|
| 160 | + } |
|
| 161 | + // on ne sait pas lire la structure de la table : |
|
| 162 | + // on retombe sur la description donnee dans les fichiers spip |
|
| 163 | + $desc = $fdesc; |
|
| 164 | + $desc['exist'] = false; |
|
| 165 | + } else { |
|
| 166 | + $desc['exist'] = true; |
|
| 167 | + // gerer le cas des cles vides (echec de l'analyse sur une vue par exemple) |
|
| 168 | + // pour recuperer la declaration de lister_tables_objets_sql() si il y en a une |
|
| 169 | + if (! $desc['key']) { |
|
| 170 | + spip_log("trouver_table: table sans cle '$serveur' '$nom'", 'base'); |
|
| 171 | + unset($desc['key']); |
|
| 172 | + } |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + $desc['table'] = $desc['table_sql'] = $nom_sql; |
|
| 176 | + $desc['connexion'] = $serveur; |
|
| 177 | + |
|
| 178 | + // charger les infos declarees pour cette table |
|
| 179 | + // en lui passant les infos connues |
|
| 180 | + // $desc est prioritaire pour la description de la table |
|
| 181 | + $desc = array_merge(lister_tables_objets_sql($nom_sql, $desc), $desc); |
|
| 182 | + // s'assurer qu'on a toujours un 'key' |
|
| 183 | + if (!isset($desc['key']) && !empty($fdesc['key'])) { |
|
| 184 | + $desc['key'] = $fdesc['key']; |
|
| 185 | + } |
|
| 186 | + if (! isset($desc['key'])) { |
|
| 187 | + $desc['key'] = []; |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + // si tables_objets_sql est bien fini d'init, on peut cacher |
|
| 191 | + $connexion['tables'][$nom_sql] = $desc; |
|
| 192 | + $res = &$connexion['tables'][$nom_sql]; |
|
| 193 | + // une nouvelle table a ete decrite |
|
| 194 | + // mettons donc a jour le cache des descriptions de ce serveur |
|
| 195 | + if (is_writeable(_DIR_CACHE)) { |
|
| 196 | + ecrire_fichier($nom_cache_desc_sql[$serveur][$objets_sql], serialize($connexion['tables']), true); |
|
| 197 | + } |
|
| 198 | + } else { |
|
| 199 | + $res = &$connexion['tables'][$nom_sql]; |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + // toujours retourner $nom dans id_table |
|
| 203 | + $res['id_table'] = $nom; |
|
| 204 | + |
|
| 205 | + return $res; |
|
| 206 | 206 | } |
@@ -81,9 +81,9 @@ discard block |
||
| 81 | 81 | // de connexion, et tout risque d'ambiguite |
| 82 | 82 | if (!isset($nom_cache_desc_sql[$serveur][$objets_sql])) { |
| 83 | 83 | $nom_cache_desc_sql[$serveur][$objets_sql] = |
| 84 | - _DIR_CACHE . 'sql_desc_' |
|
| 84 | + _DIR_CACHE.'sql_desc_' |
|
| 85 | 85 | . ($serveur ? "{$serveur}_" : '') |
| 86 | - . substr(md5($connexion['db'] . ':' . $connexion['prefixe'] . ":$objets_sql"), 0, 8) |
|
| 86 | + . substr(md5($connexion['db'].':'.$connexion['prefixe'].":$objets_sql"), 0, 8) |
|
| 87 | 87 | . '.txt'; |
| 88 | 88 | // nouveau nom de cache = nouvelle version en memoire |
| 89 | 89 | unset($connexion['tables']); |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | if ($connexion['spip_connect_version']) { |
| 112 | 112 | if ($table_spip and isset($GLOBALS['table_des_tables'][$nom])) { |
| 113 | 113 | $nom = $GLOBALS['table_des_tables'][$nom]; |
| 114 | - $nom_sql = 'spip_' . $nom; |
|
| 114 | + $nom_sql = 'spip_'.$nom; |
|
| 115 | 115 | } |
| 116 | 116 | } |
| 117 | 117 | |
@@ -138,12 +138,12 @@ discard block |
||
| 138 | 138 | // meme si pas d'abreviation declaree, trouver la table spip_$nom |
| 139 | 139 | // si c'est une table principale, |
| 140 | 140 | // puisqu'on le fait aussi pour les tables auxiliaires |
| 141 | - elseif ($nom_sql == $nom and isset($GLOBALS['tables_principales']['spip_' . $nom])) { |
|
| 142 | - $nom_sql = 'spip_' . $nom; |
|
| 141 | + elseif ($nom_sql == $nom and isset($GLOBALS['tables_principales']['spip_'.$nom])) { |
|
| 142 | + $nom_sql = 'spip_'.$nom; |
|
| 143 | 143 | $fdesc = &$GLOBALS['tables_principales'][$nom_sql]; |
| 144 | 144 | } elseif ( |
| 145 | 145 | isset($GLOBALS['tables_auxiliaires'][$n = $nom]) |
| 146 | - or isset($GLOBALS['tables_auxiliaires'][$n = 'spip_' . $nom]) |
|
| 146 | + or isset($GLOBALS['tables_auxiliaires'][$n = 'spip_'.$nom]) |
|
| 147 | 147 | ) { |
| 148 | 148 | $nom_sql = $n; |
| 149 | 149 | $fdesc = &$GLOBALS['tables_auxiliaires'][$n]; |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | $desc = sql_showtable($nom_sql, $table_spip, $serveur); |
| 155 | 155 | if (!$desc or !$desc['field']) { |
| 156 | 156 | if (!$fdesc) { |
| 157 | - spip_log("trouver_table: table inconnue '$serveur' '$nom'", 'base' . _LOG_INFO_IMPORTANTE); |
|
| 157 | + spip_log("trouver_table: table inconnue '$serveur' '$nom'", 'base'._LOG_INFO_IMPORTANTE); |
|
| 158 | 158 | |
| 159 | 159 | return null; |
| 160 | 160 | } |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | $desc['exist'] = true; |
| 167 | 167 | // gerer le cas des cles vides (echec de l'analyse sur une vue par exemple) |
| 168 | 168 | // pour recuperer la declaration de lister_tables_objets_sql() si il y en a une |
| 169 | - if (! $desc['key']) { |
|
| 169 | + if (!$desc['key']) { |
|
| 170 | 170 | spip_log("trouver_table: table sans cle '$serveur' '$nom'", 'base'); |
| 171 | 171 | unset($desc['key']); |
| 172 | 172 | } |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | if (!isset($desc['key']) && !empty($fdesc['key'])) { |
| 184 | 184 | $desc['key'] = $fdesc['key']; |
| 185 | 185 | } |
| 186 | - if (! isset($desc['key'])) { |
|
| 186 | + if (!isset($desc['key'])) { |
|
| 187 | 187 | $desc['key'] = []; |
| 188 | 188 | } |
| 189 | 189 | |