@@ -52,17 +52,17 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | if ($compil_info) { |
| 54 | 54 | return [ |
| 55 | - $trace[0]['file'],// sourcefile |
|
| 55 | + $trace[0]['file'], // sourcefile |
|
| 56 | 56 | '', //nom |
| 57 | - (isset($trace[1]) ? $trace[1]['function'] . "(){\n" : '') |
|
| 58 | - . $trace[0]['function'] . '();' |
|
| 57 | + (isset($trace[1]) ? $trace[1]['function']."(){\n" : '') |
|
| 58 | + . $trace[0]['function'].'();' |
|
| 59 | 59 | . (isset($trace[1]) ? "\n}" : ''), //id_boucle |
| 60 | 60 | $trace[0]['line'], // ligne |
| 61 | 61 | $GLOBALS['spip_lang'], // lang |
| 62 | 62 | ]; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - $message = count($trace) ? $trace[0]['file'] . ' L' . $trace[0]['line'] : ''; |
|
| 65 | + $message = count($trace) ? $trace[0]['file'].' L'.$trace[0]['line'] : ''; |
|
| 66 | 66 | $f = []; |
| 67 | 67 | while (count($trace) && ($t = array_shift($trace))) { |
| 68 | 68 | if (in_array($t['function'], ['include_once', 'include_spip', 'find_in_path'])) { |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | $f[] = $t['function']; |
| 72 | 72 | } |
| 73 | 73 | if ($f !== []) { |
| 74 | - $message .= ' [' . implode('(),', $f) . '()]'; |
|
| 74 | + $message .= ' ['.implode('(),', $f).'()]'; |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | return $message; |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | // le debug, c'est pour ce qui a ete produit par le compilateur |
| 265 | 265 | if (isset($GLOBALS['debug']['aucasou'])) { |
| 266 | 266 | [$table, $id, ] = $GLOBALS['debug']['aucasou']; |
| 267 | - $nom = $GLOBALS['debug_objets']['courant'] . $id; |
|
| 267 | + $nom = $GLOBALS['debug_objets']['courant'].$id; |
|
| 268 | 268 | $GLOBALS['debug_objets']['requete'][$nom] = $query; |
| 269 | 269 | } |
| 270 | 270 | $res = $f($select, $from, $where, $groupby, $orderby, $limit, $having, $serveur, true); |
@@ -1141,7 +1141,7 @@ discard block |
||
| 1141 | 1141 | // la globale n'est remplie qu'apres l'appel de sql_serveur. |
| 1142 | 1142 | if ($spip == null) { |
| 1143 | 1143 | $connexion = $GLOBALS['connexions'][$serveur ? strtolower($serveur) : 0]; |
| 1144 | - $spip = $connexion['prefixe'] . '\_%'; |
|
| 1144 | + $spip = $connexion['prefixe'].'\_%'; |
|
| 1145 | 1145 | } |
| 1146 | 1146 | |
| 1147 | 1147 | return $f($spip, $serveur, $option !== false); |
@@ -2298,9 +2298,9 @@ discard block |
||
| 2298 | 2298 | $jour = 0; |
| 2299 | 2299 | } |
| 2300 | 2300 | |
| 2301 | - return sprintf('%04u', $annee) . '-' . sprintf('%02u', $mois) . '-' |
|
| 2302 | - . sprintf('%02u', $jour) . ' ' . sprintf('%02u', $h) . ':' |
|
| 2303 | - . sprintf('%02u', $m) . ':' . sprintf('%02u', $s); |
|
| 2301 | + return sprintf('%04u', $annee).'-'.sprintf('%02u', $mois).'-' |
|
| 2302 | + . sprintf('%02u', $jour).' '.sprintf('%02u', $h).':' |
|
| 2303 | + . sprintf('%02u', $m).':'.sprintf('%02u', $s); |
|
| 2304 | 2304 | } |
| 2305 | 2305 | |
| 2306 | 2306 | |
@@ -2362,7 +2362,7 @@ discard block |
||
| 2362 | 2362 | */ |
| 2363 | 2363 | function prefixer_table_spip($table, $prefixe) { |
| 2364 | 2364 | if ($prefixe) { |
| 2365 | - $table = preg_replace('/^spip_/', $prefixe . '_', $table); |
|
| 2365 | + $table = preg_replace('/^spip_/', $prefixe.'_', $table); |
|
| 2366 | 2366 | } |
| 2367 | 2367 | return $table; |
| 2368 | 2368 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 18 | 18 | return; |
| 19 | 19 | } |
| 20 | -require_once _ROOT_RESTREINT . 'base/objets.php'; |
|
| 20 | +require_once _ROOT_RESTREINT.'base/objets.php'; |
|
| 21 | 21 | |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | defined('_DIR_CONNECT') |
| 63 | 63 | && preg_match('/^[\w\.]*$/', $serveur) |
| 64 | 64 | ) { |
| 65 | - $f = _DIR_CONNECT . $serveur . '.php'; |
|
| 65 | + $f = _DIR_CONNECT.$serveur.'.php'; |
|
| 66 | 66 | if (!is_readable($f) && !$install) { |
| 67 | 67 | // chercher une declaration de serveur dans le path |
| 68 | 68 | // qui peut servir à des plugins à declarer des connexions à une base sqlite |
@@ -110,8 +110,8 @@ discard block |
||
| 110 | 110 | // chargement de la version du jeu de fonctions |
| 111 | 111 | // si pas dans le fichier par defaut |
| 112 | 112 | $type = $GLOBALS['db_ok']['type']; |
| 113 | - $jeu = 'spip_' . $type . '_functions_' . $version; |
|
| 114 | - if (!isset($GLOBALS[$jeu]) && !find_in_path($type . '_' . $version . '.php', 'req/', true)) { |
|
| 113 | + $jeu = 'spip_'.$type.'_functions_'.$version; |
|
| 114 | + if (!isset($GLOBALS[$jeu]) && !find_in_path($type.'_'.$version.'.php', 'req/', true)) { |
|
| 115 | 115 | spip_log("spip_connect: serveur $index version '$version' non defini pour '$type'", _LOG_HS); |
| 116 | 116 | // ne plus reessayer |
| 117 | 117 | return $GLOBALS['connexions'][$index][$version] = []; |
@@ -171,9 +171,9 @@ discard block |
||
| 171 | 171 | $connexion = spip_connect($serveur); |
| 172 | 172 | $e = sql_errno($serveur); |
| 173 | 173 | $t = ($connexion['type'] ?? 'sql'); |
| 174 | - $m = "Erreur $e de $t: " . sql_error($serveur) . "\nin " . sql_error_backtrace() . "\n" . trim((string) $connexion['last']); |
|
| 175 | - $f = $t . $serveur; |
|
| 176 | - spip_log($m, $f . '.' . _LOG_ERREUR); |
|
| 174 | + $m = "Erreur $e de $t: ".sql_error($serveur)."\nin ".sql_error_backtrace()."\n".trim((string) $connexion['last']); |
|
| 175 | + $f = $t.$serveur; |
|
| 176 | + spip_log($m, $f.'.'._LOG_ERREUR); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | /** |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | // si en cours d'installation ou si db=@test@ on ne pose rien |
| 260 | 260 | // car c'est un test de connexion |
| 261 | 261 | if (!defined('_ECRIRE_INSTALL') && $db !== '@test@') { |
| 262 | - $f = _DIR_TMP . $type . '.' . substr(md5($host . $port . $db), 0, 8) . '.out'; |
|
| 262 | + $f = _DIR_TMP.$type.'.'.substr(md5($host.$port.$db), 0, 8).'.out'; |
|
| 263 | 263 | } elseif ($db == '@test@') { |
| 264 | 264 | $db = ''; |
| 265 | 265 | } |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | // En cas d'indisponibilite du serveur, eviter de le bombarder |
| 299 | 299 | if ($f) { |
| 300 | 300 | @touch($f); |
| 301 | - spip_log("Echec connexion serveur $type : host[$host] port[$port] login[$login] base[$db]", $type . '.' . _LOG_HS); |
|
| 301 | + spip_log("Echec connexion serveur $type : host[$host] port[$port] login[$login] base[$db]", $type.'.'._LOG_HS); |
|
| 302 | 302 | } |
| 303 | 303 | return null; |
| 304 | 304 | } |
@@ -395,11 +395,11 @@ discard block |
||
| 395 | 395 | } elseif (is_array($a)) { |
| 396 | 396 | return implode(',', array_map('_q', $a)); |
| 397 | 397 | } elseif (is_scalar($a)) { |
| 398 | - return ("'" . addslashes($a) . "'"); |
|
| 398 | + return ("'".addslashes($a)."'"); |
|
| 399 | 399 | } elseif ($a === null) { |
| 400 | 400 | return "''"; |
| 401 | 401 | } |
| 402 | - throw new \RuntimeException('Can’t use _q with ' . gettype($a)); |
|
| 402 | + throw new \RuntimeException('Can’t use _q with '.gettype($a)); |
|
| 403 | 403 | } |
| 404 | 404 | |
| 405 | 405 | /** |
@@ -450,7 +450,7 @@ discard block |
||
| 450 | 450 | $next = reset($textes); |
| 451 | 451 | if ( |
| 452 | 452 | str_starts_with((string) $next, "'") |
| 453 | - && strpos($query_echappees, $part . $next, $currentpos) === $nextpos |
|
| 453 | + && strpos($query_echappees, $part.$next, $currentpos) === $nextpos |
|
| 454 | 454 | ) { |
| 455 | 455 | $part .= array_shift($textes); |
| 456 | 456 | } |
@@ -462,7 +462,7 @@ discard block |
||
| 462 | 462 | $parts[$k] = [ |
| 463 | 463 | 'texte' => $part, |
| 464 | 464 | 'position' => $nextpos, |
| 465 | - 'placeholder' => '%' . $k . '$s', |
|
| 465 | + 'placeholder' => '%'.$k.'$s', |
|
| 466 | 466 | ]; |
| 467 | 467 | $currentpos = $nextpos + strlen((string) $part); |
| 468 | 468 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * @return string |
| 38 | 38 | **/ |
| 39 | 39 | function base_dump_meta_name($rub) { |
| 40 | - return $meta = "status_dump_{$rub}_" . abs($GLOBALS['visiteur_session']['id_auteur']); |
|
| 40 | + return $meta = "status_dump_{$rub}_".abs($GLOBALS['visiteur_session']['id_auteur']); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | $connexion = $GLOBALS['connexions'][$serveur ?: 0]; |
| 83 | 83 | $prefixe = $connexion['prefixe']; |
| 84 | 84 | |
| 85 | - $p = '/^' . $prefixe . '/'; |
|
| 85 | + $p = '/^'.$prefixe.'/'; |
|
| 86 | 86 | $res = $tables; |
| 87 | 87 | foreach (sql_alltable(null, $serveur) as $t) { |
| 88 | 88 | if (preg_match($p, (string) $t)) { |
@@ -341,8 +341,8 @@ discard block |
||
| 341 | 341 | $trouver_table = charger_fonction('trouver_table', 'base'); |
| 342 | 342 | |
| 343 | 343 | spip_log( |
| 344 | - 'Vider ' . count($tables) . " tables sur serveur '$serveur' : " . implode(', ', $tables), |
|
| 345 | - 'base.' . _LOG_INFO_IMPORTANTE |
|
| 344 | + 'Vider '.count($tables)." tables sur serveur '$serveur' : ".implode(', ', $tables), |
|
| 345 | + 'base.'._LOG_INFO_IMPORTANTE |
|
| 346 | 346 | ); |
| 347 | 347 | foreach ($tables as $table) { |
| 348 | 348 | // sur le serveur principal, il ne faut pas supprimer l'auteur loge ! |
@@ -380,15 +380,15 @@ discard block |
||
| 380 | 380 | // s'asurer qu'on a pas deja fait la manip ! |
| 381 | 381 | if ($GLOBALS['visiteur_session']['id_auteur'] > 0 && sql_countsel('spip_auteurs', 'id_auteur>0')) { |
| 382 | 382 | spip_log( |
| 383 | - 'Conserver copieur dans id_auteur=' . $GLOBALS['visiteur_session']['id_auteur'] . " pour le serveur '$serveur'", |
|
| 384 | - 'dump.' . _LOG_INFO_IMPORTANTE |
|
| 383 | + 'Conserver copieur dans id_auteur='.$GLOBALS['visiteur_session']['id_auteur']." pour le serveur '$serveur'", |
|
| 384 | + 'dump.'._LOG_INFO_IMPORTANTE |
|
| 385 | 385 | ); |
| 386 | 386 | sql_delete('spip_auteurs', 'id_auteur<0', $serveur); |
| 387 | 387 | if ($move) { |
| 388 | 388 | sql_updateq( |
| 389 | 389 | 'spip_auteurs', |
| 390 | 390 | ['id_auteur' => -$GLOBALS['visiteur_session']['id_auteur']], |
| 391 | - 'id_auteur=' . (int) $GLOBALS['visiteur_session']['id_auteur'], |
|
| 391 | + 'id_auteur='.(int) $GLOBALS['visiteur_session']['id_auteur'], |
|
| 392 | 392 | [], |
| 393 | 393 | $serveur |
| 394 | 394 | ); |
@@ -396,7 +396,7 @@ discard block |
||
| 396 | 396 | $row = sql_fetsel( |
| 397 | 397 | '*', |
| 398 | 398 | 'spip_auteurs', |
| 399 | - 'id_auteur=' . $GLOBALS['visiteur_session']['id_auteur'], |
|
| 399 | + 'id_auteur='.$GLOBALS['visiteur_session']['id_auteur'], |
|
| 400 | 400 | '', |
| 401 | 401 | '', |
| 402 | 402 | '', |
@@ -424,17 +424,17 @@ discard block |
||
| 424 | 424 | // rien a faire si ce n'est pas le serveur principal ! |
| 425 | 425 | if ($serveur == '') { |
| 426 | 426 | if (sql_countsel('spip_auteurs', 'id_auteur>0')) { |
| 427 | - spip_log("Detruire copieur id_auteur<0 pour le serveur '$serveur'", 'dump.' . _LOG_INFO_IMPORTANTE); |
|
| 427 | + spip_log("Detruire copieur id_auteur<0 pour le serveur '$serveur'", 'dump.'._LOG_INFO_IMPORTANTE); |
|
| 428 | 428 | sql_delete('spip_auteurs', 'id_auteur<0', $serveur); |
| 429 | 429 | } else { |
| 430 | 430 | spip_log( |
| 431 | 431 | "Restaurer copieur id_auteur<0 pour le serveur '$serveur' (aucun autre auteur en base)", |
| 432 | - 'dump.' . _LOG_INFO_IMPORTANTE |
|
| 432 | + 'dump.'._LOG_INFO_IMPORTANTE |
|
| 433 | 433 | ); |
| 434 | 434 | sql_update('spip_auteurs', ['id_auteur' => '-id_auteur'], 'id_auteur<0'); |
| 435 | 435 | } |
| 436 | 436 | } else { |
| 437 | - spip_log("Pas de destruction copieur sur serveur '$serveur'", 'dump.' . _LOG_INFO_IMPORTANTE); |
|
| 437 | + spip_log("Pas de destruction copieur sur serveur '$serveur'", 'dump.'._LOG_INFO_IMPORTANTE); |
|
| 438 | 438 | } |
| 439 | 439 | } |
| 440 | 440 | |
@@ -468,19 +468,19 @@ discard block |
||
| 468 | 468 | } |
| 469 | 469 | } else { |
| 470 | 470 | sql_drop_table($table, '', $serveur_dest); |
| 471 | - spip_log("drop table '$table' sur serveur '$serveur_dest'", 'dump.' . _LOG_INFO_IMPORTANTE); |
|
| 471 | + spip_log("drop table '$table' sur serveur '$serveur_dest'", 'dump.'._LOG_INFO_IMPORTANTE); |
|
| 472 | 472 | } |
| 473 | 473 | $desc_dest = false; |
| 474 | 474 | } |
| 475 | 475 | // si la table n'existe pas dans la destination, la creer a l'identique ! |
| 476 | 476 | if (!$desc_dest) { |
| 477 | - spip_log("creation '$table' sur serveur '$serveur_dest'", 'dump.' . _LOG_INFO_IMPORTANTE); |
|
| 477 | + spip_log("creation '$table' sur serveur '$serveur_dest'", 'dump.'._LOG_INFO_IMPORTANTE); |
|
| 478 | 478 | include_spip('base/create'); |
| 479 | 479 | creer_ou_upgrader_table($table, $desc, 'auto', $upgrade, $serveur_dest); |
| 480 | 480 | $desc_dest = sql_showtable($table, true, $serveur_dest); |
| 481 | 481 | } |
| 482 | 482 | if (!$desc_dest) { |
| 483 | - spip_log("Erreur creation '$table' sur serveur '$serveur_dest'" . var_export($desc, 1), 'dump.' . _LOG_ERREUR); |
|
| 483 | + spip_log("Erreur creation '$table' sur serveur '$serveur_dest'".var_export($desc, 1), 'dump.'._LOG_ERREUR); |
|
| 484 | 484 | } |
| 485 | 485 | |
| 486 | 486 | return $desc_dest; |
@@ -541,17 +541,17 @@ discard block |
||
| 541 | 541 | $data_pool = $options['data_pool'] ?? 50 * 1024; |
| 542 | 542 | |
| 543 | 543 | spip_log( |
| 544 | - 'Copier ' . count($tables) . " tables de '$serveur_source' vers '$serveur_dest'", |
|
| 545 | - 'dump.' . _LOG_INFO_IMPORTANTE |
|
| 544 | + 'Copier '.count($tables)." tables de '$serveur_source' vers '$serveur_dest'", |
|
| 545 | + 'dump.'._LOG_INFO_IMPORTANTE |
|
| 546 | 546 | ); |
| 547 | 547 | |
| 548 | 548 | if (!$inserer_copie = charger_fonction($fonction_base_inserer, $racine_fonctions, true)) { |
| 549 | - spip_log("Fonction '{$racine_fonctions}_$fonction_base_inserer' inconnue. Abandon", 'dump.' . _LOG_INFO_IMPORTANTE); |
|
| 549 | + spip_log("Fonction '{$racine_fonctions}_$fonction_base_inserer' inconnue. Abandon", 'dump.'._LOG_INFO_IMPORTANTE); |
|
| 550 | 550 | |
| 551 | 551 | return true; // echec mais on a fini, donc true |
| 552 | 552 | } |
| 553 | 553 | if (!$preparer_table_dest = charger_fonction('preparer_table_dest', $racine_fonctions, true)) { |
| 554 | - spip_log("Fonction '{$racine_fonctions}_$preparer_table_dest' inconnue. Abandon", 'dump.' . _LOG_INFO_IMPORTANTE); |
|
| 554 | + spip_log("Fonction '{$racine_fonctions}_$preparer_table_dest' inconnue. Abandon", 'dump.'._LOG_INFO_IMPORTANTE); |
|
| 555 | 555 | |
| 556 | 556 | return true; // echec mais on a fini, donc true |
| 557 | 557 | } |
@@ -579,7 +579,7 @@ discard block |
||
| 579 | 579 | ) { |
| 580 | 580 | spip_log( |
| 581 | 581 | "Fonction '{$racine_fonctions}_vider_tables_destination_copie' inconnue. Abandon", |
| 582 | - 'dump.' . _LOG_INFO_IMPORTANTE |
|
| 582 | + 'dump.'._LOG_INFO_IMPORTANTE |
|
| 583 | 583 | ); |
| 584 | 584 | |
| 585 | 585 | return true; // echec mais on a fini, donc true |
@@ -598,7 +598,7 @@ discard block |
||
| 598 | 598 | $tables = array_diff($tables, ['spip_meta']); |
| 599 | 599 | $tables[] = 'spip_meta'; |
| 600 | 600 | } |
| 601 | - spip_log('Tables a copier :' . implode(', ', $tables), 'dump.' . _LOG_INFO); |
|
| 601 | + spip_log('Tables a copier :'.implode(', ', $tables), 'dump.'._LOG_INFO); |
|
| 602 | 602 | |
| 603 | 603 | $trouver_table = charger_fonction('trouver_table', 'base'); |
| 604 | 604 | |
@@ -662,7 +662,7 @@ discard block |
||
| 662 | 662 | // mais si ca renvoie false c'est une erreur fatale => abandon |
| 663 | 663 | if ($inserer_copie($table, $rows, $desc_dest, $serveur_dest) === false) { |
| 664 | 664 | // forcer la sortie, charge a l'appelant de gerer l'echec |
| 665 | - spip_log("Erreur fatale dans $inserer_copie table $table", 'dump' . _LOG_ERREUR); |
|
| 665 | + spip_log("Erreur fatale dans $inserer_copie table $table", 'dump'._LOG_ERREUR); |
|
| 666 | 666 | $status['errors'][] = "Erreur fatale lors de la copie de la table $table"; |
| 667 | 667 | ecrire_fichier($status_file, serialize($status)); |
| 668 | 668 | |
@@ -677,7 +677,7 @@ discard block |
||
| 677 | 677 | if ($n == $status['tables_copiees'][$table]) { |
| 678 | 678 | break; |
| 679 | 679 | } |
| 680 | - spip_log("recopie $table " . $status['tables_copiees'][$table], 'dump.' . _LOG_INFO_IMPORTANTE); |
|
| 680 | + spip_log("recopie $table ".$status['tables_copiees'][$table], 'dump.'._LOG_INFO_IMPORTANTE); |
|
| 681 | 681 | if ($callback_progression) { |
| 682 | 682 | $callback_progression($status['tables_copiees'][$table], 0, $table); |
| 683 | 683 | } |
@@ -688,30 +688,30 @@ discard block |
||
| 688 | 688 | } |
| 689 | 689 | if ($drop_source) { |
| 690 | 690 | sql_drop_table($table, '', $serveur_source); |
| 691 | - spip_log("drop $table sur serveur source '$serveur_source'", 'dump.' . _LOG_INFO_IMPORTANTE); |
|
| 691 | + spip_log("drop $table sur serveur source '$serveur_source'", 'dump.'._LOG_INFO_IMPORTANTE); |
|
| 692 | 692 | } |
| 693 | 693 | $status['tables_copiees'][$table] = ($status['tables_copiees'][$table] ? -$status['tables_copiees'][$table] : 'zero'); |
| 694 | 694 | ecrire_fichier($status_file, serialize($status)); |
| 695 | - spip_log('tables_recopiees ' . implode(',', array_keys($status['tables_copiees'])), 'dump.' . _LOG_INFO); |
|
| 695 | + spip_log('tables_recopiees '.implode(',', array_keys($status['tables_copiees'])), 'dump.'._LOG_INFO); |
|
| 696 | 696 | if ($callback_progression) { |
| 697 | 697 | $callback_progression($status['tables_copiees'][$table], $status['tables_copiees'][$table], $table); |
| 698 | 698 | } |
| 699 | 699 | } else { |
| 700 | 700 | if ($status['tables_copiees'][$table] < 0) { |
| 701 | - spip_log("Table $table deja copiee : " . $status['tables_copiees'][$table], 'dump.' . _LOG_INFO); |
|
| 701 | + spip_log("Table $table deja copiee : ".$status['tables_copiees'][$table], 'dump.'._LOG_INFO); |
|
| 702 | 702 | } |
| 703 | 703 | if ($callback_progression) { |
| 704 | 704 | $callback_progression( |
| 705 | 705 | 0, |
| 706 | 706 | $status['tables_copiees'][$table], |
| 707 | - "$table" . ((is_numeric($status['tables_copiees'][$table]) && $status['tables_copiees'][$table] >= 0) ? '[Echec]' : '') |
|
| 707 | + "$table".((is_numeric($status['tables_copiees'][$table]) && $status['tables_copiees'][$table] >= 0) ? '[Echec]' : '') |
|
| 708 | 708 | ); |
| 709 | 709 | } |
| 710 | 710 | } |
| 711 | 711 | } else { |
| 712 | 712 | $status['errors'][] = "Impossible de lire la description de la table $table"; |
| 713 | 713 | ecrire_fichier($status_file, serialize($status)); |
| 714 | - spip_log("Impossible de lire la description de la table $table", 'dump.' . _LOG_ERREUR); |
|
| 714 | + spip_log("Impossible de lire la description de la table $table", 'dump.'._LOG_ERREUR); |
|
| 715 | 715 | } |
| 716 | 716 | } |
| 717 | 717 | |
@@ -719,17 +719,17 @@ discard block |
||
| 719 | 719 | // abandonner |
| 720 | 720 | if ((is_countable($status['tables_copiees']) ? count($status['tables_copiees']) : 0) < count($tables)) { |
| 721 | 721 | spip_log( |
| 722 | - 'Nombre de tables copiees incorrect : ' . (is_countable($status['tables_copiees']) ? count($status['tables_copiees']) : 0) . '/' . count($tables), |
|
| 723 | - 'dump.' . _LOG_ERREUR |
|
| 722 | + 'Nombre de tables copiees incorrect : '.(is_countable($status['tables_copiees']) ? count($status['tables_copiees']) : 0).'/'.count($tables), |
|
| 723 | + 'dump.'._LOG_ERREUR |
|
| 724 | 724 | ); |
| 725 | - $status['errors'][] = 'Nombre de tables copiees incorrect : ' . (is_countable($status['tables_copiees']) ? count($status['tables_copiees']) : 0) . '/' . count($tables); |
|
| 725 | + $status['errors'][] = 'Nombre de tables copiees incorrect : '.(is_countable($status['tables_copiees']) ? count($status['tables_copiees']) : 0).'/'.count($tables); |
|
| 726 | 726 | ecrire_fichier($status_file, serialize($status)); |
| 727 | 727 | } |
| 728 | 728 | |
| 729 | 729 | if ($detruire_copieur_si_besoin = charger_fonction('detruire_copieur_si_besoin', $racine_fonctions, true)) { |
| 730 | 730 | $detruire_copieur_si_besoin($serveur_dest); |
| 731 | 731 | } else { |
| 732 | - spip_log("Fonction '{$racine_fonctions}_detruire_copieur_si_besoin' inconnue.", 'dump.' . _LOG_INFO_IMPORTANTE); |
|
| 732 | + spip_log("Fonction '{$racine_fonctions}_detruire_copieur_si_besoin' inconnue.", 'dump.'._LOG_INFO_IMPORTANTE); |
|
| 733 | 733 | } |
| 734 | 734 | |
| 735 | 735 | // OK, copie complete |
@@ -754,8 +754,8 @@ discard block |
||
| 754 | 754 | $nb = sql_countsel($table, '', '', '', $serveur_dest); |
| 755 | 755 | if ($nb - $nb1 < count($rows)) { |
| 756 | 756 | spip_log( |
| 757 | - 'base_inserer_copie : ' . ($nb - $nb1) . ' insertions au lieu de ' . count($rows) . '. On retente 1 par 1', |
|
| 758 | - 'dump' . _LOG_INFO_IMPORTANTE |
|
| 757 | + 'base_inserer_copie : '.($nb - $nb1).' insertions au lieu de '.count($rows).'. On retente 1 par 1', |
|
| 758 | + 'dump'._LOG_INFO_IMPORTANTE |
|
| 759 | 759 | ); |
| 760 | 760 | foreach ($rows as $row) { |
| 761 | 761 | // si l'enregistrement est deja en base, ca fera un echec ou un doublon |
@@ -766,8 +766,8 @@ discard block |
||
| 766 | 766 | $nb = sql_countsel($table, '', '', '', $serveur_dest); |
| 767 | 767 | if ($nb - $nb1 < count($rows)) { |
| 768 | 768 | spip_log( |
| 769 | - 'base_inserer_copie : ' . ($nb - $nb1) . ' insertions au lieu de ' . count($rows) . ' apres insertion 1 par 1', |
|
| 770 | - 'dump' . _LOG_ERREUR |
|
| 769 | + 'base_inserer_copie : '.($nb - $nb1).' insertions au lieu de '.count($rows).' apres insertion 1 par 1', |
|
| 770 | + 'dump'._LOG_ERREUR |
|
| 771 | 771 | ); |
| 772 | 772 | $r = false; |
| 773 | 773 | } |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | if ($GLOBALS['spip_version_base'] != $GLOBALS['meta']['version_installee']) { |
| 56 | 56 | if (!is_numeric(_request('reinstall'))) { |
| 57 | 57 | include_spip('base/create'); |
| 58 | - spip_log('recree les tables eventuellement disparues', 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 58 | + spip_log('recree les tables eventuellement disparues', 'maj.'._LOG_INFO_IMPORTANTE); |
|
| 59 | 59 | creer_base(); |
| 60 | 60 | } |
| 61 | 61 | |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | exit; |
| 69 | 69 | } |
| 70 | 70 | } |
| 71 | - spip_log('Fin de mise a jour SQL. Debut m-a-j acces et config', 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 71 | + spip_log('Fin de mise a jour SQL. Debut m-a-j acces et config', 'maj.'._LOG_INFO_IMPORTANTE); |
|
| 72 | 72 | |
| 73 | 73 | // supprimer quelques fichiers temporaires qui peuvent se retrouver invalides |
| 74 | 74 | @spip_unlink(_CACHE_RUBRIQUES); |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | @spip_unlink(_CACHE_PLUGINS_OPT); |
| 78 | 78 | @spip_unlink(_CACHE_PLUGINS_FCT); |
| 79 | 79 | @spip_unlink(_CACHE_CHEMIN); |
| 80 | - @spip_unlink(_DIR_TMP . 'plugin_xml_cache.gz'); |
|
| 80 | + @spip_unlink(_DIR_TMP.'plugin_xml_cache.gz'); |
|
| 81 | 81 | |
| 82 | 82 | include_spip('inc/auth'); |
| 83 | 83 | auth_synchroniser_distant(); |
@@ -116,8 +116,8 @@ discard block |
||
| 116 | 116 | $version_installee = $GLOBALS['meta']['version_installee'] ?? null; |
| 117 | 117 | |
| 118 | 118 | spip_log( |
| 119 | - "Version anterieure: $version_installee. Courante: " . $GLOBALS['spip_version_base'], |
|
| 120 | - 'maj.' . _LOG_INFO_IMPORTANTE |
|
| 119 | + "Version anterieure: $version_installee. Courante: ".$GLOBALS['spip_version_base'], |
|
| 120 | + 'maj.'._LOG_INFO_IMPORTANTE |
|
| 121 | 121 | ); |
| 122 | 122 | if (!$version_installee || $GLOBALS['spip_version_base'] < $version_installee) { |
| 123 | 123 | sql_replace( |
@@ -150,9 +150,9 @@ discard block |
||
| 150 | 150 | $res = maj_while($version_installee, $cible, $GLOBALS['maj'], 'version_installee', 'meta', $redirect, $debut_page); |
| 151 | 151 | if ($res) { |
| 152 | 152 | if (!is_array($res)) { |
| 153 | - spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_ERREUR); |
|
| 153 | + spip_log("Pb d'acces SQL a la mise a jour", 'maj.'._LOG_ERREUR); |
|
| 154 | 154 | } else { |
| 155 | - echo _T('avis_operation_echec') . ' ' . implode(' ', $res); |
|
| 155 | + echo _T('avis_operation_echec').' '.implode(' ', $res); |
|
| 156 | 156 | echo install_fin_html(); |
| 157 | 157 | } |
| 158 | 158 | } |
@@ -240,9 +240,9 @@ discard block |
||
| 240 | 240 | $res = maj_while($current_version, $version_cible, $maj, $nom_meta_base_version, $table_meta, $redirect); |
| 241 | 241 | if ($res) { |
| 242 | 242 | if (!is_array($res)) { |
| 243 | - spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_ERREUR); |
|
| 243 | + spip_log("Pb d'acces SQL a la mise a jour", 'maj.'._LOG_ERREUR); |
|
| 244 | 244 | } else { |
| 245 | - echo '<p>' . _T('avis_operation_echec') . ' ' . implode(' ', $res) . '</p>'; |
|
| 245 | + echo '<p>'._T('avis_operation_echec').' '.implode(' ', $res).'</p>'; |
|
| 246 | 246 | } |
| 247 | 247 | } |
| 248 | 248 | } |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | echo(install_debut_html($titre)); |
| 302 | 302 | // script de rechargement auto sur timeout |
| 303 | 303 | $redirect = generer_url_ecrire('upgrade', "reinstall=$installee&meta=$meta&table=$table", true); |
| 304 | - echo http_script("window.setTimeout('location.href=\"" . $redirect . "\";'," . ($timeout * 1000) . ')'); |
|
| 304 | + echo http_script("window.setTimeout('location.href=\"".$redirect."\";',".($timeout * 1000).')'); |
|
| 305 | 305 | echo "<div style='text-align: left'>\n"; |
| 306 | 306 | if (ob_get_level()) { |
| 307 | 307 | ob_flush(); |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | return [$v, $etape]; |
| 390 | 390 | } |
| 391 | 391 | $n = time() - $time; |
| 392 | - spip_log("$table $meta: $v en $n secondes", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 392 | + spip_log("$table $meta: $v en $n secondes", 'maj.'._LOG_INFO_IMPORTANTE); |
|
| 393 | 393 | if ($meta) { |
| 394 | 394 | ecrire_meta($meta, $installee = $v, 'oui', $table); |
| 395 | 395 | } |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | if ($meta) { |
| 406 | 406 | ecrire_meta($meta, $cible, 'oui', $table); |
| 407 | 407 | } |
| 408 | - spip_log("MAJ terminee. $meta: $installee", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 408 | + spip_log("MAJ terminee. $meta: $installee", 'maj.'._LOG_INFO_IMPORTANTE); |
|
| 409 | 409 | |
| 410 | 410 | return []; |
| 411 | 411 | } |
@@ -430,7 +430,7 @@ discard block |
||
| 430 | 430 | * @return int |
| 431 | 431 | */ |
| 432 | 432 | function serie_alter($serie, $q = [], $meta = '', $table = 'meta', $redirect = '') { |
| 433 | - $meta2 = $meta . '_maj_' . $serie; |
|
| 433 | + $meta2 = $meta.'_maj_'.$serie; |
|
| 434 | 434 | $etape = 0; |
| 435 | 435 | if (isset($GLOBALS[$table][$meta2])) { |
| 436 | 436 | $etape = (int) $GLOBALS[$table][$meta2]; |
@@ -443,7 +443,7 @@ discard block |
||
| 443 | 443 | && function_exists($f = array_shift($r)) |
| 444 | 444 | ) { |
| 445 | 445 | // note: $r (arguments de la fonction $f) peut avoir des données tabulaires |
| 446 | - spip_log("$msg: $f " . @implode(',', $r), 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 446 | + spip_log("$msg: $f ".@implode(',', $r), 'maj.'._LOG_INFO_IMPORTANTE); |
|
| 447 | 447 | // pour les fonctions atomiques sql_xx |
| 448 | 448 | // on enregistre le meta avant de lancer la fonction, |
| 449 | 449 | // de maniere a eviter de boucler sur timeout |
@@ -461,12 +461,12 @@ discard block |
||
| 461 | 461 | relance_maj($meta, $table, $redirect); |
| 462 | 462 | } |
| 463 | 463 | ecrire_meta($meta2, $i + 1, 'non', $table); |
| 464 | - spip_log("$meta2: ok", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 464 | + spip_log("$meta2: ok", 'maj.'._LOG_INFO_IMPORTANTE); |
|
| 465 | 465 | } else { |
| 466 | 466 | if (!is_array($r)) { |
| 467 | - spip_log("maj $i format incorrect", 'maj.' . _LOG_ERREUR); |
|
| 467 | + spip_log("maj $i format incorrect", 'maj.'._LOG_ERREUR); |
|
| 468 | 468 | } else { |
| 469 | - spip_log("maj $i fonction $f non definie", 'maj.' . _LOG_ERREUR); |
|
| 469 | + spip_log("maj $i fonction $f non definie", 'maj.'._LOG_ERREUR); |
|
| 470 | 470 | } |
| 471 | 471 | // en cas d'erreur serieuse, on s'arrete |
| 472 | 472 | // mais on permet de passer par dessus en rechargeant la page. |
@@ -90,9 +90,9 @@ discard block |
||
| 90 | 90 | // de connexion, et tout risque d'ambiguite |
| 91 | 91 | if (!isset($nom_cache_desc_sql[$serveur][$objets_sql])) { |
| 92 | 92 | $nom_cache_desc_sql[$serveur][$objets_sql] = |
| 93 | - _DIR_CACHE . 'sql_desc_' |
|
| 93 | + _DIR_CACHE.'sql_desc_' |
|
| 94 | 94 | . ($serveur ? "{$serveur}_" : '') |
| 95 | - . substr(md5($connexion['db'] . ':' . $connexion['prefixe'] . ":$objets_sql"), 0, 8) |
|
| 95 | + . substr(md5($connexion['db'].':'.$connexion['prefixe'].":$objets_sql"), 0, 8) |
|
| 96 | 96 | . '.txt'; |
| 97 | 97 | // nouveau nom de cache = nouvelle version en memoire |
| 98 | 98 | unset($connexion['tables']); |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | && isset($GLOBALS['table_des_tables'][$nom]) |
| 120 | 120 | ) { |
| 121 | 121 | $nom = $GLOBALS['table_des_tables'][$nom]; |
| 122 | - $nom_sql = 'spip_' . $nom; |
|
| 122 | + $nom_sql = 'spip_'.$nom; |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | // si c'est la premiere table qu'on cherche |
@@ -143,12 +143,12 @@ discard block |
||
| 143 | 143 | // meme si pas d'abreviation declaree, trouver la table spip_$nom |
| 144 | 144 | // si c'est une table principale, |
| 145 | 145 | // puisqu'on le fait aussi pour les tables auxiliaires |
| 146 | - elseif ($nom_sql == $nom && isset($GLOBALS['tables_principales']['spip_' . $nom])) { |
|
| 147 | - $nom_sql = 'spip_' . $nom; |
|
| 146 | + elseif ($nom_sql == $nom && isset($GLOBALS['tables_principales']['spip_'.$nom])) { |
|
| 147 | + $nom_sql = 'spip_'.$nom; |
|
| 148 | 148 | $fdesc = &$GLOBALS['tables_principales'][$nom_sql]; |
| 149 | 149 | } elseif ( |
| 150 | 150 | isset($GLOBALS['tables_auxiliaires'][$n = $nom]) |
| 151 | - || isset($GLOBALS['tables_auxiliaires'][$n = 'spip_' . $nom]) |
|
| 151 | + || isset($GLOBALS['tables_auxiliaires'][$n = 'spip_'.$nom]) |
|
| 152 | 152 | ) { |
| 153 | 153 | $nom_sql = $n; |
| 154 | 154 | $fdesc = &$GLOBALS['tables_auxiliaires'][$n]; |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | ) { |
| 165 | 165 | if (!$fdesc) { |
| 166 | 166 | $log_level = $options['log_missing'] ? _LOG_INFO_IMPORTANTE : _LOG_DEBUG; |
| 167 | - spip_log("trouver_table: table inconnue '$serveur' '$nom'", 'base' . $log_level); |
|
| 167 | + spip_log("trouver_table: table inconnue '$serveur' '$nom'", 'base'.$log_level); |
|
| 168 | 168 | |
| 169 | 169 | return null; |
| 170 | 170 | } |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | $desc['exist'] = true; |
| 177 | 177 | // gerer le cas des cles vides (echec de l'analyse sur une vue par exemple) |
| 178 | 178 | // pour recuperer la declaration de lister_tables_objets_sql() si il y en a une |
| 179 | - if (! $desc['key']) { |
|
| 179 | + if (!$desc['key']) { |
|
| 180 | 180 | spip_log("trouver_table: table sans cle '$serveur' '$nom'", 'base'); |
| 181 | 181 | unset($desc['key']); |
| 182 | 182 | } |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | if (!isset($desc['key']) && !empty($fdesc['key'])) { |
| 194 | 194 | $desc['key'] = $fdesc['key']; |
| 195 | 195 | } |
| 196 | - if (! isset($desc['key'])) { |
|
| 196 | + if (!isset($desc['key'])) { |
|
| 197 | 197 | $desc['key'] = []; |
| 198 | 198 | } |
| 199 | 199 | |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | . ' <b>' |
| 57 | 57 | . $pere |
| 58 | 58 | . '</b>' |
| 59 | - . ($bons_peres ? '<p style="font-size: 80%"> ' . _T('zxml_mais_de') . ' <b>' . $bons_peres . '</b></p>' : '')); |
|
| 59 | + . ($bons_peres ? '<p style="font-size: 80%"> '._T('zxml_mais_de').' <b>'.$bons_peres.'</b></p>' : '')); |
|
| 60 | 60 | } elseif ($this->dtc->regles[$pere][0] == '/') { |
| 61 | 61 | $frat = substr((string) $depth, 2); |
| 62 | 62 | if (!isset($this->fratrie[$frat])) { |
@@ -92,15 +92,15 @@ discard block |
||
| 92 | 92 | if (!isset($a[$name])) { |
| 93 | 93 | $bons = implode(', ', array_keys($a)); |
| 94 | 94 | if ($bons) { |
| 95 | - $bons = " title=' " . |
|
| 96 | - _T('zxml_connus_attributs') . |
|
| 97 | - ' : ' . |
|
| 98 | - $bons . |
|
| 95 | + $bons = " title=' ". |
|
| 96 | + _T('zxml_connus_attributs'). |
|
| 97 | + ' : '. |
|
| 98 | + $bons. |
|
| 99 | 99 | "'"; |
| 100 | 100 | } |
| 101 | 101 | $bons .= " style='font-weight: bold'"; |
| 102 | 102 | coordonnees_erreur($this, " <b>$name</b> " |
| 103 | - . _T('zxml_inconnu_attribut') . ' ' . _T('zxml_de') |
|
| 103 | + . _T('zxml_inconnu_attribut').' '._T('zxml_de') |
|
| 104 | 104 | . " <a$bons>$bal</a> (" |
| 105 | 105 | . _T('zxml_survoler') |
| 106 | 106 | . ')'); |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | if (!preg_match('/^\w+$/', (string) $type)) { |
| 110 | 110 | $this->valider_motif($phraseur, $name, $val, $bal, $type); |
| 111 | 111 | } else { |
| 112 | - if (method_exists($this, $f = 'validerAttribut_' . $type)) { |
|
| 112 | + if (method_exists($this, $f = 'validerAttribut_'.$type)) { |
|
| 113 | 113 | $this->$f($phraseur, $name, $val, $bal); |
| 114 | 114 | } |
| 115 | 115 | } |
@@ -158,13 +158,13 @@ discard block |
||
| 158 | 158 | . " <b>$bal</b> " |
| 159 | 159 | . _T('zxml_non_conforme') |
| 160 | 160 | . '</p><p>' |
| 161 | - . '<b>' . $motif . '</b>'); |
|
| 161 | + . '<b>'.$motif.'</b>'); |
|
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | public function valider_idref($nom, $ligne, $col) { |
| 166 | 166 | if (!isset($this->ids[$nom])) { |
| 167 | - $this->err[] = [" <p><b>$nom</b> " . _T('zxml_inconnu_id'), $ligne, $col]; |
|
| 167 | + $this->err[] = [" <p><b>$nom</b> "._T('zxml_inconnu_id'), $ligne, $col]; |
|
| 168 | 168 | } |
| 169 | 169 | } |
| 170 | 170 | |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | // controler que les balises devant etre vides le sont |
| 212 | 212 | if ($vide) { |
| 213 | 213 | if ($n != $k + $c) { |
| 214 | - coordonnees_erreur($this, " <p><b>$name</b> " . _T('zxml_nonvide_balise')); |
|
| 214 | + coordonnees_erreur($this, " <p><b>$name</b> "._T('zxml_nonvide_balise')); |
|
| 215 | 215 | } |
| 216 | 216 | // pour les regles PCDATA ou iteration de disjonction, tout est fait |
| 217 | 217 | } elseif ($regle && $regle != '*') { |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | $d = $this->ouvrant[$d]; |
| 247 | 247 | preg_match('/^\s*(\S+)/', (string) $d, $m); |
| 248 | 248 | if (isset($this->dtc->pcdata[$m[1]]) && $this->dtc->pcdata[$m[1]]) { |
| 249 | - coordonnees_erreur($this, ' <p><b>' . $m[1] . '</b> ' |
|
| 249 | + coordonnees_erreur($this, ' <p><b>'.$m[1].'</b> ' |
|
| 250 | 250 | . _T('zxml_nonvide_balise')); // message a affiner |
| 251 | 251 | } |
| 252 | 252 | } |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | public function phraserTout($phraseur, $data) { |
| 291 | 291 | xml_parsestring($this, $data); |
| 292 | 292 | |
| 293 | - if (!$this->dtc || preg_match(',^' . _MESSAGE_DOCTYPE . ',', (string) $data)) { |
|
| 293 | + if (!$this->dtc || preg_match(',^'._MESSAGE_DOCTYPE.',', (string) $data)) { |
|
| 294 | 294 | $this->err[] = ['DOCTYPE ?', 0, 0]; |
| 295 | 295 | } else { |
| 296 | 296 | $this->valider_passe2(); |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | $grammaire = find_in_path($grammaire); |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - $file = _DIR_CACHE_XML . preg_replace('/[^\w.]/', '_', (string) $rotlvl) . '.gz'; |
|
| 30 | + $file = _DIR_CACHE_XML.preg_replace('/[^\w.]/', '_', (string) $rotlvl).'.gz'; |
|
| 31 | 31 | |
| 32 | 32 | if (lire_fichier($file, $r)) { |
| 33 | 33 | if (!$grammaire) { |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | $dtc->peres[$k] = $v; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - spip_log("Analyser DTD $avail $grammaire (" . spip_timer('dtd') . ') ' . (is_countable($dtc->macros) ? count($dtc->macros) : 0) . ' macros, ' . (is_countable($dtc->elements) ? count($dtc->elements) : 0) . ' elements, ' . (is_countable($dtc->attributs) ? count($dtc->attributs) : 0) . " listes d'attributs, " . (is_countable($dtc->entites) ? count($dtc->entites) : 0) . ' entites'); |
|
| 57 | + spip_log("Analyser DTD $avail $grammaire (".spip_timer('dtd').') '.(is_countable($dtc->macros) ? count($dtc->macros) : 0).' macros, '.(is_countable($dtc->elements) ? count($dtc->elements) : 0).' elements, '.(is_countable($dtc->attributs) ? count($dtc->attributs) : 0)." listes d'attributs, ".(is_countable($dtc->entites) ? count($dtc->entites) : 0).' entites'); |
|
| 58 | 58 | # $r = $dtc->regles; ksort($r);foreach($r as $l => $v) {$t=array_keys($dtc->attributs[$l]);echo "<b>$l</b> '$v' ", count($t), " attributs: ", join (', ',$t);$t=$dtc->peres[$l];echo "<br />",count($t), " peres: ", @join (', ',$t), "<br />\n";}exit; |
| 59 | 59 | ecrire_fichier($file, serialize($dtc), true); |
| 60 | 60 | } |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | }; |
| 155 | 155 | } |
| 156 | 156 | if (!is_string($r)) { |
| 157 | - spip_log("erreur $r dans la DTD " . substr($dtd, 0, 80) . '.....'); |
|
| 157 | + spip_log("erreur $r dans la DTD ".substr($dtd, 0, 80).'.....'); |
|
| 158 | 158 | |
| 159 | 159 | return false; |
| 160 | 160 | } |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | if ( |
| 199 | 199 | $n[0] == 'PUBLIC' && !tester_url_absolue($n[1]) |
| 200 | 200 | ) { |
| 201 | - $n[1] = substr((string) $grammaire, 0, strrpos((string) $grammaire, '/') + 1) . $n[1]; |
|
| 201 | + $n[1] = substr((string) $grammaire, 0, strrpos((string) $grammaire, '/') + 1).$n[1]; |
|
| 202 | 202 | } |
| 203 | 203 | analyser_dtd($n[1], $n[0], $dtc); |
| 204 | 204 | } |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | return $dtc->macros[$m[1]] == 'INCLUDE' |
| 228 | - ? $r[1] . substr($m[2], strlen($r[0])) |
|
| 228 | + ? $r[1].substr($m[2], strlen($r[0])) |
|
| 229 | 229 | : substr($m[2], strlen($r[0])); |
| 230 | 230 | } |
| 231 | 231 | |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | spip_log("redefinition de l'entite $nom"); |
| 253 | 253 | } |
| 254 | 254 | if ($k6) { |
| 255 | - return $k6 . $dtd; |
|
| 255 | + return $k6.$dtd; |
|
| 256 | 256 | } // cas du synonyme complet |
| 257 | 257 | $val = expanserEntite(($k2 ? $k3 : ($k4 ? $k5 : $k6)), $dtc->macros); |
| 258 | 258 | |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | if (preg_match_all("/\s*(\S+)\s+(([(][^)]*[)])|(\S+))\s+([^\s']*)(\s*'[^']*')?/", $val, $r2, PREG_SET_ORDER)) { |
| 353 | 353 | foreach ($r2 as $m2) { |
| 354 | 354 | $v = preg_match('/^\w+$/', $m2[2]) ? $m2[2] |
| 355 | - : ('/^' . preg_replace('/\s+/', '', $m2[2]) . '$/'); |
|
| 355 | + : ('/^'.preg_replace('/\s+/', '', $m2[2]).'$/'); |
|
| 356 | 356 | $m21 = expanserEntite($m2[1], $dtc->macros); |
| 357 | 357 | $m25 = expanserEntite($m2[5], $dtc->macros); |
| 358 | 358 | $dtc->attributs[$nom][$m21] = [$v, $m25]; |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | if (!$link) { |
| 60 | 60 | $erreurs[] = pg_last_error(); |
| 61 | 61 | foreach ($erreurs as $e) { |
| 62 | - spip_log('Echec pg_connect. Erreur : ' . $e, 'pg.' . _LOG_HS); |
|
| 62 | + spip_log('Echec pg_connect. Erreur : '.$e, 'pg.'._LOG_HS); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | return false; |
@@ -77,8 +77,8 @@ discard block |
||
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | spip_log( |
| 80 | - "Connexion vers $host, base $db, prefixe $prefixe " . ($link ? 'operationnelle' : 'impossible'), |
|
| 81 | - 'pg.' . _LOG_DEBUG |
|
| 80 | + "Connexion vers $host, base $db, prefixe $prefixe ".($link ? 'operationnelle' : 'impossible'), |
|
| 81 | + 'pg.'._LOG_DEBUG |
|
| 82 | 82 | ); |
| 83 | 83 | |
| 84 | 84 | return $link ? [ |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | } else { |
| 167 | 167 | $suite = ''; |
| 168 | 168 | } |
| 169 | - $query = preg_replace('/([,\s])spip_/', '\1' . $prefixe . '_', (string) $query) . $suite; |
|
| 169 | + $query = preg_replace('/([,\s])spip_/', '\1'.$prefixe.'_', (string) $query).$suite; |
|
| 170 | 170 | |
| 171 | 171 | // renvoyer la requete inerte si demandee |
| 172 | 172 | if (!$requeter) { |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | // ou revoir l'api de sql_alter en creant un |
| 235 | 235 | // sql_alter_table($table,array($actions)); |
| 236 | 236 | if (!preg_match('/\s*((\s*IGNORE)?\s*TABLE\s*([^\s]*))\s*(.*)?/is', (string) $query, $regs)) { |
| 237 | - spip_log("$query mal comprise", 'pg.' . _LOG_ERREUR); |
|
| 237 | + spip_log("$query mal comprise", 'pg.'._LOG_ERREUR); |
|
| 238 | 238 | |
| 239 | 239 | return false; |
| 240 | 240 | } |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | $i = 0; |
| 248 | 248 | $ouverte = false; |
| 249 | 249 | while ($do = array_shift($todo)) { |
| 250 | - $todo2[$i] = isset($todo2[$i]) ? $todo2[$i] . ',' . $do : $do; |
|
| 250 | + $todo2[$i] = isset($todo2[$i]) ? $todo2[$i].','.$do : $do; |
|
| 251 | 251 | $o = (str_contains($do, '(')); |
| 252 | 252 | $f = (str_contains($do, ')')); |
| 253 | 253 | if ($o && !$f) { |
@@ -260,33 +260,33 @@ discard block |
||
| 260 | 260 | } |
| 261 | 261 | } |
| 262 | 262 | $todo = $todo2; |
| 263 | - $query = $debut . ' ' . array_shift($todo); |
|
| 263 | + $query = $debut.' '.array_shift($todo); |
|
| 264 | 264 | |
| 265 | 265 | if (!preg_match('/^\s*(IGNORE\s*)?TABLE\s+(\w+)\s+(ADD|DROP|CHANGE|MODIFY|RENAME)\s*(.*)$/is', $query, $r)) { |
| 266 | - spip_log("$query incompris", 'pg.' . _LOG_ERREUR); |
|
| 266 | + spip_log("$query incompris", 'pg.'._LOG_ERREUR); |
|
| 267 | 267 | } else { |
| 268 | 268 | if ($r[1]) { |
| 269 | - spip_log("j'ignore IGNORE dans $query", 'pg.' . _LOG_AVERTISSEMENT); |
|
| 269 | + spip_log("j'ignore IGNORE dans $query", 'pg.'._LOG_AVERTISSEMENT); |
|
| 270 | 270 | } |
| 271 | - $f = 'spip_pg_alter_' . strtolower($r[3]); |
|
| 271 | + $f = 'spip_pg_alter_'.strtolower($r[3]); |
|
| 272 | 272 | if (function_exists($f)) { |
| 273 | 273 | $f($r[2], $r[4], $serveur, $requeter); |
| 274 | 274 | } else { |
| 275 | - spip_log("$query non prevu", 'pg.' . _LOG_ERREUR); |
|
| 275 | + spip_log("$query non prevu", 'pg.'._LOG_ERREUR); |
|
| 276 | 276 | } |
| 277 | 277 | } |
| 278 | 278 | // Alter a plusieurs args. Faudrait optimiser. |
| 279 | 279 | if ($todo) { |
| 280 | - spip_pg_alter("TABLE $table " . implode(',', $todo)); |
|
| 280 | + spip_pg_alter("TABLE $table ".implode(',', $todo)); |
|
| 281 | 281 | } |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | function spip_pg_alter_change($table, $arg, $serveur = '', $requeter = true) { |
| 285 | 285 | if (!preg_match('/^`?(\w+)`?\s+`?(\w+)`?\s+(.*?)\s*(DEFAULT .*?)?(NOT\s+NULL)?\s*(DEFAULT .*?)?$/i', (string) $arg, $r)) { |
| 286 | - spip_log("alter change: $arg incompris", 'pg.' . _LOG_ERREUR); |
|
| 286 | + spip_log("alter change: $arg incompris", 'pg.'._LOG_ERREUR); |
|
| 287 | 287 | } else { |
| 288 | 288 | [, $old, $new, $type, $default, $null, $def2] = $r; |
| 289 | - $actions = ["ALTER $old TYPE " . mysql2pg_type($type)]; |
|
| 289 | + $actions = ["ALTER $old TYPE ".mysql2pg_type($type)]; |
|
| 290 | 290 | $actions[] = $null ? "ALTER $old SET NOT NULL" : "ALTER $old DROP NOT NULL"; |
| 291 | 291 | |
| 292 | 292 | if ($d = ($default ?: $def2)) { |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | $actions[] = "ALTER $old DROP DEFAULT"; |
| 296 | 296 | } |
| 297 | 297 | |
| 298 | - spip_pg_query("ALTER TABLE $table " . implode(', ', $actions)); |
|
| 298 | + spip_pg_query("ALTER TABLE $table ".implode(', ', $actions)); |
|
| 299 | 299 | |
| 300 | 300 | if ($old !== $new) { |
| 301 | 301 | spip_pg_query("ALTER TABLE $table RENAME $old TO $new", $serveur); |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | function spip_pg_alter_add($table, $arg, $serveur = '', $requeter = true) { |
| 307 | 307 | $nom_index = null; |
| 308 | 308 | if (!preg_match('/^(COLUMN|INDEX|KEY|PRIMARY\s+KEY|)\s*(.*)$/', (string) $arg, $r)) { |
| 309 | - spip_log("alter add $arg incompris", 'pg.' . _LOG_ERREUR); |
|
| 309 | + spip_log("alter add $arg incompris", 'pg.'._LOG_ERREUR); |
|
| 310 | 310 | |
| 311 | 311 | return null; |
| 312 | 312 | } |
@@ -316,14 +316,14 @@ discard block |
||
| 316 | 316 | $m[2] = $n[1]; |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | - return spip_pg_query("ALTER TABLE $table ADD " . $m[1] . ' ' . mysql2pg_type($m[2]), $serveur, $requeter); |
|
| 319 | + return spip_pg_query("ALTER TABLE $table ADD ".$m[1].' '.mysql2pg_type($m[2]), $serveur, $requeter); |
|
| 320 | 320 | } elseif ($r[1][0] == 'P') { |
| 321 | 321 | // la primary peut etre sur plusieurs champs |
| 322 | 322 | $r[2] = trim(str_replace('`', '', $r[2])); |
| 323 | 323 | $m = ($r[2][0] == '(') ? substr($r[2], 1, -1) : $r[2]; |
| 324 | 324 | |
| 325 | 325 | return spip_pg_query( |
| 326 | - "ALTER TABLE $table ADD CONSTRAINT $table" . '_pkey PRIMARY KEY (' . $m . ')', |
|
| 326 | + "ALTER TABLE $table ADD CONSTRAINT $table".'_pkey PRIMARY KEY ('.$m.')', |
|
| 327 | 327 | $serveur, |
| 328 | 328 | $requeter |
| 329 | 329 | ); |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | $colonnes = substr($m[1], 1, -1); |
| 343 | 343 | if (str_contains(',', $colonnes)) { |
| 344 | 344 | spip_log('PG : Erreur, impossible de creer un index sur plusieurs colonnes' |
| 345 | - . " sans qu'il ait de nom ($table, ($colonnes))", 'pg.' . _LOG_ERREUR); |
|
| 345 | + . " sans qu'il ait de nom ($table, ($colonnes))", 'pg.'._LOG_ERREUR); |
|
| 346 | 346 | } else { |
| 347 | 347 | $nom_index = $colonnes; |
| 348 | 348 | } |
@@ -358,23 +358,23 @@ discard block |
||
| 358 | 358 | |
| 359 | 359 | function spip_pg_alter_drop($table, $arg, $serveur = '', $requeter = true) { |
| 360 | 360 | if (!preg_match('/^(COLUMN|INDEX|KEY|PRIMARY\s+KEY|)\s*`?(\w*)`?/', (string) $arg, $r)) { |
| 361 | - spip_log("alter drop: $arg incompris", 'pg.' . _LOG_ERREUR); |
|
| 361 | + spip_log("alter drop: $arg incompris", 'pg.'._LOG_ERREUR); |
|
| 362 | 362 | } else { |
| 363 | 363 | if (!$r[1] || $r[1] == 'COLUMN') { |
| 364 | - return spip_pg_query("ALTER TABLE $table DROP " . $r[2], $serveur); |
|
| 364 | + return spip_pg_query("ALTER TABLE $table DROP ".$r[2], $serveur); |
|
| 365 | 365 | } elseif ($r[1][0] == 'P') { |
| 366 | - return spip_pg_query("ALTER TABLE $table DROP CONSTRAINT $table" . '_pkey', $serveur); |
|
| 366 | + return spip_pg_query("ALTER TABLE $table DROP CONSTRAINT $table".'_pkey', $serveur); |
|
| 367 | 367 | } else { |
| 368 | - return spip_pg_query('DROP INDEX ' . $table . '_' . $r[2], $serveur); |
|
| 368 | + return spip_pg_query('DROP INDEX '.$table.'_'.$r[2], $serveur); |
|
| 369 | 369 | } |
| 370 | 370 | } |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | function spip_pg_alter_modify($table, $arg, $serveur = '', $requeter = true) { |
| 374 | 374 | if (!preg_match('/^`?(\w+)`?\s+(.*)$/', (string) $arg, $r)) { |
| 375 | - spip_log("alter modify: $arg incompris", 'pg.' . _LOG_ERREUR); |
|
| 375 | + spip_log("alter modify: $arg incompris", 'pg.'._LOG_ERREUR); |
|
| 376 | 376 | } else { |
| 377 | - return spip_pg_alter_change($table, $r[1] . ' ' . $arg, $serveur = '', $requeter = true); |
|
| 377 | + return spip_pg_alter_change($table, $r[1].' '.$arg, $serveur = '', $requeter = true); |
|
| 378 | 378 | } |
| 379 | 379 | } |
| 380 | 380 | |
@@ -390,7 +390,7 @@ discard block |
||
| 390 | 390 | } elseif (preg_match('/^(TO)\s*`?(\w*)`?/', (string) $arg, $r)) { |
| 391 | 391 | $rename = $r[2]; |
| 392 | 392 | } else { |
| 393 | - spip_log("alter rename: $arg incompris", 'pg.' . _LOG_ERREUR); |
|
| 393 | + spip_log("alter rename: $arg incompris", 'pg.'._LOG_ERREUR); |
|
| 394 | 394 | } |
| 395 | 395 | |
| 396 | 396 | return $rename ? spip_pg_query("ALTER TABLE $table RENAME TO $rename") : false; |
@@ -411,8 +411,8 @@ discard block |
||
| 411 | 411 | function spip_pg_create_index($nom, $table, $champs, $serveur = '', $requeter = true) { |
| 412 | 412 | if (!($nom || $table || $champs)) { |
| 413 | 413 | spip_log( |
| 414 | - "Champ manquant pour creer un index pg ($nom, $table, (" . @implode(',', $champs) . '))', |
|
| 415 | - 'pg.' . _LOG_ERREUR |
|
| 414 | + "Champ manquant pour creer un index pg ($nom, $table, (".@implode(',', $champs).'))', |
|
| 415 | + 'pg.'._LOG_ERREUR |
|
| 416 | 416 | ); |
| 417 | 417 | |
| 418 | 418 | return false; |
@@ -423,7 +423,7 @@ discard block |
||
| 423 | 423 | |
| 424 | 424 | // PG ne differentie pas noms des index en fonction des tables |
| 425 | 425 | // il faut donc creer des noms uniques d'index pour une base pg |
| 426 | - $nom = $table . '_' . $nom; |
|
| 426 | + $nom = $table.'_'.$nom; |
|
| 427 | 427 | // enlever d'eventuelles parentheses deja presentes sur champs |
| 428 | 428 | if (!is_array($champs)) { |
| 429 | 429 | if ($champs[0] == '(') { |
@@ -431,7 +431,7 @@ discard block |
||
| 431 | 431 | } |
| 432 | 432 | $champs = [$champs]; |
| 433 | 433 | } |
| 434 | - $query = "CREATE INDEX $nom ON $table (" . implode(',', $champs) . ')'; |
|
| 434 | + $query = "CREATE INDEX $nom ON $table (".implode(',', $champs).')'; |
|
| 435 | 435 | if (!$requeter) { |
| 436 | 436 | return $query; |
| 437 | 437 | } |
@@ -453,7 +453,7 @@ discard block |
||
| 453 | 453 | } else { |
| 454 | 454 | $suite = ''; |
| 455 | 455 | } |
| 456 | - $query = 'EXPLAIN ' . preg_replace('/([,\s])spip_/', '\1' . $prefixe . '_', (string) $query) . $suite; |
|
| 456 | + $query = 'EXPLAIN '.preg_replace('/([,\s])spip_/', '\1'.$prefixe.'_', (string) $query).$suite; |
|
| 457 | 457 | |
| 458 | 458 | if (!$requeter) { |
| 459 | 459 | return $query; |
@@ -542,16 +542,16 @@ discard block |
||
| 542 | 542 | $having = implode("\n\tAND ", array_map('calculer_pg_where', $having)); |
| 543 | 543 | } |
| 544 | 544 | $from = spip_pg_from($from, $prefixe); |
| 545 | - $query = 'SELECT ' . $select |
|
| 545 | + $query = 'SELECT '.$select |
|
| 546 | 546 | . ($from ? "\nFROM $from" : '') |
| 547 | - . ($where ? "\nWHERE " . (is_array($where) ? implode( |
|
| 547 | + . ($where ? "\nWHERE ".(is_array($where) ? implode( |
|
| 548 | 548 | "\n\tAND ", |
| 549 | 549 | array_map('calculer_pg_where', $where) |
| 550 | 550 | ) : (calculer_pg_where($where))) : ('')) |
| 551 | 551 | . spip_pg_groupby($groupby, $from, $select) |
| 552 | 552 | . ($having ? "\nHAVING $having" : '') |
| 553 | 553 | . ($orderby ? ("\nORDER BY $orderby") : '') |
| 554 | - . ($limit ? " LIMIT $count" . ($offset ? " OFFSET $offset" : '') : ('')); |
|
| 554 | + . ($limit ? " LIMIT $count".($offset ? " OFFSET $offset" : '') : ('')); |
|
| 555 | 555 | |
| 556 | 556 | // renvoyer la requete inerte si demandee |
| 557 | 557 | if ($requeter === false) { |
@@ -572,7 +572,7 @@ discard block |
||
| 572 | 572 | $from = spip_pg_select_as($from); |
| 573 | 573 | } |
| 574 | 574 | |
| 575 | - return $prefixe ? preg_replace('/(\b)spip_/', '\1' . $prefixe . '_', (string) $from) : $from; |
|
| 575 | + return $prefixe ? preg_replace('/(\b)spip_/', '\1'.$prefixe.'_', (string) $from) : $from; |
|
| 576 | 576 | } |
| 577 | 577 | |
| 578 | 578 | function spip_pg_orderby($order, $select) { |
@@ -580,7 +580,7 @@ discard block |
||
| 580 | 580 | $arg = (is_array($order) ? $order : preg_split('/\s*,\s*/', (string) $order)); |
| 581 | 581 | |
| 582 | 582 | foreach ($arg as $v) { |
| 583 | - $res[] = preg_match('/(case\s+.*?else\s+0\s+end)\s*AS\s+' . $v . '/', (string) $select, $m) ? $m[1] : $v; |
|
| 583 | + $res[] = preg_match('/(case\s+.*?else\s+0\s+end)\s*AS\s+'.$v.'/', (string) $select, $m) ? $m[1] : $v; |
|
| 584 | 584 | } |
| 585 | 585 | |
| 586 | 586 | return spip_pg_frommysql(implode(',', $res)); |
@@ -754,7 +754,7 @@ discard block |
||
| 754 | 754 | $n++; |
| 755 | 755 | $res .= "\nwhen $index=$v then $n"; |
| 756 | 756 | } |
| 757 | - $arg = $m[1] . "case $res else 0 end " |
|
| 757 | + $arg = $m[1]."case $res else 0 end " |
|
| 758 | 758 | . substr((string) $arg, strlen($m[0])); |
| 759 | 759 | } |
| 760 | 760 | |
@@ -797,9 +797,9 @@ discard block |
||
| 797 | 797 | } |
| 798 | 798 | |
| 799 | 799 | if (strtoupper((string) $join) === 'AND') { |
| 800 | - return $exp . implode("\n\t$join ", array_map('calculer_pg_where', $v)); |
|
| 800 | + return $exp.implode("\n\t$join ", array_map('calculer_pg_where', $v)); |
|
| 801 | 801 | } else { |
| 802 | - return $exp . implode($join, $v); |
|
| 802 | + return $exp.implode($join, $v); |
|
| 803 | 803 | } |
| 804 | 804 | } |
| 805 | 805 | |
@@ -809,7 +809,7 @@ discard block |
||
| 809 | 809 | if (str_ends_with((string) $k, '@')) { |
| 810 | 810 | // c'est une jointure qui se refere au from precedent |
| 811 | 811 | // pas de virgule |
| 812 | - $argsas .= ' ' . $v; |
|
| 812 | + $argsas .= ' '.$v; |
|
| 813 | 813 | } else { |
| 814 | 814 | $as = ''; |
| 815 | 815 | // spip_log("$k : $v", _LOG_DEBUG); |
@@ -819,7 +819,7 @@ discard block |
||
| 819 | 819 | } elseif ($v != $k) { |
| 820 | 820 | $p = strpos((string) $v, ' '); |
| 821 | 821 | if ($p) { |
| 822 | - $v = substr((string) $v, 0, $p) . " AS $k" . substr((string) $v, $p); |
|
| 822 | + $v = substr((string) $v, 0, $p)." AS $k".substr((string) $v, $p); |
|
| 823 | 823 | } else { |
| 824 | 824 | $as = " AS $k"; |
| 825 | 825 | } |
@@ -827,7 +827,7 @@ discard block |
||
| 827 | 827 | } |
| 828 | 828 | // spip_log("subs $k : $v avec $as", _LOG_DEBUG); |
| 829 | 829 | // if (strpos($v, 'JOIN') === false) $argsas .= ', '; |
| 830 | - $argsas .= ', ' . $v . $as; |
|
| 830 | + $argsas .= ', '.$v.$as; |
|
| 831 | 831 | } |
| 832 | 832 | } |
| 833 | 833 | |
@@ -858,7 +858,7 @@ discard block |
||
| 858 | 858 | $serveur = '', |
| 859 | 859 | $requeter = true |
| 860 | 860 | ) { |
| 861 | - $c = $groupby ? 'DISTINCT ' . (is_string($groupby) ? $groupby : implode(',', $groupby)) : ('*'); |
|
| 861 | + $c = $groupby ? 'DISTINCT '.(is_string($groupby) ? $groupby : implode(',', $groupby)) : ('*'); |
|
| 862 | 862 | $r = spip_pg_select("COUNT($c)", $from, $where, '', '', '', $having, $serveur, $requeter); |
| 863 | 863 | if (!$requeter) { |
| 864 | 864 | return $r; |
@@ -959,8 +959,8 @@ discard block |
||
| 959 | 959 | |
| 960 | 960 | return spip_pg_insert( |
| 961 | 961 | $table, |
| 962 | - '(' . implode(',', array_keys($couples)) . ')', |
|
| 963 | - '(' . implode(',', $couples) . ')', |
|
| 962 | + '('.implode(',', array_keys($couples)).')', |
|
| 963 | + '('.implode(',', $couples).')', |
|
| 964 | 964 | $desc, |
| 965 | 965 | $serveur, |
| 966 | 966 | $requeter |
@@ -983,7 +983,7 @@ discard block |
||
| 983 | 983 | $c = $tab_couples[0] ?? []; |
| 984 | 984 | $les_cles = spip_pg_ajouter_champs_timestamp($table, $c, $desc, $serveur); |
| 985 | 985 | |
| 986 | - $cles = '(' . implode(',', array_keys($les_cles)) . ')'; |
|
| 986 | + $cles = '('.implode(',', array_keys($les_cles)).')'; |
|
| 987 | 987 | $valeurs = []; |
| 988 | 988 | foreach ($tab_couples as $couples) { |
| 989 | 989 | foreach ($couples as $champ => $val) { |
@@ -992,7 +992,7 @@ discard block |
||
| 992 | 992 | // recherche de champs 'timestamp' pour mise a jour auto de ceux-ci |
| 993 | 993 | $couples = spip_pg_ajouter_champs_timestamp($table, $couples, $desc, $serveur); |
| 994 | 994 | |
| 995 | - $valeurs[] = '(' . implode(',', $couples) . ')'; |
|
| 995 | + $valeurs[] = '('.implode(',', $couples).')'; |
|
| 996 | 996 | } |
| 997 | 997 | $valeurs = implode(', ', $valeurs); |
| 998 | 998 | |
@@ -1013,7 +1013,7 @@ discard block |
||
| 1013 | 1013 | |
| 1014 | 1014 | $set = []; |
| 1015 | 1015 | foreach ($couples as $champ => $val) { |
| 1016 | - $set[] = $champ . '=' . $val; |
|
| 1016 | + $set[] = $champ.'='.$val; |
|
| 1017 | 1017 | } |
| 1018 | 1018 | |
| 1019 | 1019 | $query = calculer_pg_expression('UPDATE', $table, ',') |
@@ -1048,7 +1048,7 @@ discard block |
||
| 1048 | 1048 | |
| 1049 | 1049 | function spip_pg_replace($table, $values, $desc, $serveur = '', $requeter = true) { |
| 1050 | 1050 | if (!$values) { |
| 1051 | - spip_log("replace vide $table", 'pg.' . _LOG_AVERTISSEMENT); |
|
| 1051 | + spip_log("replace vide $table", 'pg.'._LOG_AVERTISSEMENT); |
|
| 1052 | 1052 | |
| 1053 | 1053 | return 0; |
| 1054 | 1054 | } |
@@ -1082,8 +1082,8 @@ discard block |
||
| 1082 | 1082 | if (!$where) { |
| 1083 | 1083 | return spip_pg_insert( |
| 1084 | 1084 | $table, |
| 1085 | - '(' . implode(',', array_keys($values)) . ')', |
|
| 1086 | - '(' . implode(',', $values) . ')', |
|
| 1085 | + '('.implode(',', array_keys($values)).')', |
|
| 1086 | + '('.implode(',', $values).')', |
|
| 1087 | 1087 | $desc, |
| 1088 | 1088 | $serveur |
| 1089 | 1089 | ); |
@@ -1104,12 +1104,11 @@ discard block |
||
| 1104 | 1104 | $couples = pg_affected_rows($couples); |
| 1105 | 1105 | } |
| 1106 | 1106 | if (!$couples) { |
| 1107 | - $ret = $seq ? " RETURNING nextval('$seq') < $prim" : |
|
| 1108 | - (''); |
|
| 1109 | - $connexion['last'] = $q = "INSERT INTO $table (" . implode(',', array_keys($values)) . ') VALUES (' . implode( |
|
| 1107 | + $ret = $seq ? " RETURNING nextval('$seq') < $prim" : (''); |
|
| 1108 | + $connexion['last'] = $q = "INSERT INTO $table (".implode(',', array_keys($values)).') VALUES ('.implode( |
|
| 1110 | 1109 | ',', |
| 1111 | 1110 | $values |
| 1112 | - ) . ")$ret"; |
|
| 1111 | + ).")$ret"; |
|
| 1113 | 1112 | $couples = spip_pg_query_simple($link, $q); |
| 1114 | 1113 | if (!$couples) { |
| 1115 | 1114 | return false; |
@@ -1156,7 +1155,7 @@ discard block |
||
| 1156 | 1155 | ) { |
| 1157 | 1156 | return ''; |
| 1158 | 1157 | } else { |
| 1159 | - return $raw ? $prim : $table . '_' . $prim . '_seq'; |
|
| 1158 | + return $raw ? $prim : $table.'_'.$prim.'_seq'; |
|
| 1160 | 1159 | } |
| 1161 | 1160 | } |
| 1162 | 1161 | |
@@ -1173,29 +1172,29 @@ discard block |
||
| 1173 | 1172 | return spip_pg_frommysql($v); |
| 1174 | 1173 | } else { |
| 1175 | 1174 | if (str_starts_with((string) $v, '0000')) { |
| 1176 | - $v = '0001' . substr((string) $v, 4); |
|
| 1175 | + $v = '0001'.substr((string) $v, 4); |
|
| 1177 | 1176 | } |
| 1178 | 1177 | if (strpos((string) $v, '-00-00') === 4) { |
| 1179 | - $v = substr((string) $v, 0, 4) . '-01-01' . substr((string) $v, 10); |
|
| 1178 | + $v = substr((string) $v, 0, 4).'-01-01'.substr((string) $v, 10); |
|
| 1180 | 1179 | } |
| 1181 | 1180 | |
| 1182 | 1181 | return "timestamp '$v'"; |
| 1183 | 1182 | } |
| 1184 | 1183 | } elseif (!sql_test_int($t)) { |
| 1185 | - return ("'" . pg_escape_string($v) . "'"); |
|
| 1184 | + return ("'".pg_escape_string($v)."'"); |
|
| 1186 | 1185 | } elseif (is_numeric($v) || str_starts_with((string) $v, 'CAST(')) { |
| 1187 | 1186 | return $v; |
| 1188 | 1187 | } elseif ($v[0] == '0' && $v[1] !== 'x' && ctype_xdigit(substr((string) $v, 1))) { |
| 1189 | 1188 | return substr((string) $v, 1); |
| 1190 | 1189 | } else { |
| 1191 | - spip_log("Warning: '$v' n'est pas de type $t", 'pg.' . _LOG_AVERTISSEMENT); |
|
| 1190 | + spip_log("Warning: '$v' n'est pas de type $t", 'pg.'._LOG_AVERTISSEMENT); |
|
| 1192 | 1191 | |
| 1193 | 1192 | return (int) $v; |
| 1194 | 1193 | } |
| 1195 | 1194 | } |
| 1196 | 1195 | |
| 1197 | 1196 | function spip_pg_hex($v) { |
| 1198 | - return "CAST(x'" . $v . "' as bigint)"; |
|
| 1197 | + return "CAST(x'".$v."' as bigint)"; |
|
| 1199 | 1198 | } |
| 1200 | 1199 | |
| 1201 | 1200 | function spip_pg_quote($v, $type = '') { |
@@ -1233,15 +1232,15 @@ discard block |
||
| 1233 | 1232 | return $not ? '0=0' : '0=1'; |
| 1234 | 1233 | } |
| 1235 | 1234 | if (str_contains((string) $valeurs, "CAST(x'")) { |
| 1236 | - return "($val=" . implode("OR $val=", explode(',', (string) $valeurs)) . ')'; |
|
| 1235 | + return "($val=".implode("OR $val=", explode(',', (string) $valeurs)).')'; |
|
| 1237 | 1236 | } |
| 1238 | 1237 | $n = $i = 0; |
| 1239 | 1238 | $in_sql = ''; |
| 1240 | 1239 | while ($n = strpos((string) $valeurs, ',', $n + 1)) { |
| 1241 | 1240 | if ((++$i) >= 255) { |
| 1242 | - $in_sql .= "($val $not IN (" . |
|
| 1243 | - substr((string) $valeurs, 0, $n) . |
|
| 1244 | - "))\n" . |
|
| 1241 | + $in_sql .= "($val $not IN (". |
|
| 1242 | + substr((string) $valeurs, 0, $n). |
|
| 1243 | + "))\n". |
|
| 1245 | 1244 | ($not ? "AND\t" : "OR\t"); |
| 1246 | 1245 | $valeurs = substr((string) $valeurs, $n + 1); |
| 1247 | 1246 | $i = $n = 0; |
@@ -1257,7 +1256,7 @@ discard block |
||
| 1257 | 1256 | $s = $link ? pg_last_error($link) : pg_last_error(); |
| 1258 | 1257 | if ($s) { |
| 1259 | 1258 | $s = str_replace('ERROR', 'errcode: 1000 ', $s); |
| 1260 | - spip_log("$s - $query", 'pg.' . _LOG_ERREUR); |
|
| 1259 | + spip_log("$s - $query", 'pg.'._LOG_ERREUR); |
|
| 1261 | 1260 | } |
| 1262 | 1261 | |
| 1263 | 1262 | return $s; |
@@ -1305,7 +1304,7 @@ discard block |
||
| 1305 | 1304 | function spip_pg_showbase($match, $serveur = '', $requeter = true) { |
| 1306 | 1305 | $connexion = &$GLOBALS['connexions'][$serveur ? strtolower($serveur) : 0]; |
| 1307 | 1306 | $link = $connexion['link']; |
| 1308 | - $connexion['last'] = $q = 'SELECT tablename FROM pg_tables WHERE tablename ILIKE ' . _q($match); |
|
| 1307 | + $connexion['last'] = $q = 'SELECT tablename FROM pg_tables WHERE tablename ILIKE '._q($match); |
|
| 1309 | 1308 | |
| 1310 | 1309 | return spip_pg_query_simple($link, $q); |
| 1311 | 1310 | } |
@@ -1313,7 +1312,7 @@ discard block |
||
| 1313 | 1312 | function spip_pg_showtable($nom_table, $serveur = '', $requeter = true) { |
| 1314 | 1313 | $connexion = &$GLOBALS['connexions'][$serveur ? strtolower((string) $serveur) : 0]; |
| 1315 | 1314 | $link = $connexion['link']; |
| 1316 | - $connexion['last'] = $q = 'SELECT column_name, column_default, data_type FROM information_schema.columns WHERE table_name ILIKE ' . _q($nom_table); |
|
| 1315 | + $connexion['last'] = $q = 'SELECT column_name, column_default, data_type FROM information_schema.columns WHERE table_name ILIKE '._q($nom_table); |
|
| 1317 | 1316 | |
| 1318 | 1317 | $res = spip_pg_query_simple($link, $q); |
| 1319 | 1318 | if (!$res) { |
@@ -1324,15 +1323,15 @@ discard block |
||
| 1324 | 1323 | // il faut en tenir compte dans le return |
| 1325 | 1324 | $fields = []; |
| 1326 | 1325 | while ($field = pg_fetch_array($res, null, PGSQL_NUM)) { |
| 1327 | - $fields[$field[0]] = $field[2] . ($field[1] ? ' DEFAULT ' . $field[1] : ('')); |
|
| 1326 | + $fields[$field[0]] = $field[2].($field[1] ? ' DEFAULT '.$field[1] : ('')); |
|
| 1328 | 1327 | } |
| 1329 | - $connexion['last'] = $q = 'SELECT indexdef FROM pg_indexes WHERE tablename ILIKE ' . _q($nom_table); |
|
| 1328 | + $connexion['last'] = $q = 'SELECT indexdef FROM pg_indexes WHERE tablename ILIKE '._q($nom_table); |
|
| 1330 | 1329 | $res = spip_pg_query_simple($link, $q); |
| 1331 | 1330 | $keys = []; |
| 1332 | 1331 | while ($index = pg_fetch_array($res, null, PGSQL_NUM)) { |
| 1333 | 1332 | if (preg_match('/CREATE\s+(UNIQUE\s+)?INDEX\s([^\s]+).*\((.*)\)$/', $index[0], $r)) { |
| 1334 | - $nom = str_replace($nom_table . '_', '', $r[2]); |
|
| 1335 | - $keys[($r[1] ? 'PRIMARY KEY' : ('KEY ' . $nom))] = $r[3]; |
|
| 1333 | + $nom = str_replace($nom_table.'_', '', $r[2]); |
|
| 1334 | + $keys[($r[1] ? 'PRIMARY KEY' : ('KEY '.$nom))] = $r[3]; |
|
| 1336 | 1335 | } |
| 1337 | 1336 | } |
| 1338 | 1337 | |
@@ -1364,16 +1363,16 @@ discard block |
||
| 1364 | 1363 | if (str_starts_with($k, 'KEY ')) { |
| 1365 | 1364 | $n = str_replace('`', '', $k); |
| 1366 | 1365 | $v = str_replace('`', '"', (string) $v); |
| 1367 | - $i = $nom . preg_replace('/KEY +/', '_', $n); |
|
| 1366 | + $i = $nom.preg_replace('/KEY +/', '_', $n); |
|
| 1368 | 1367 | if ($k != $n) { |
| 1369 | 1368 | $i = "\"$i\""; |
| 1370 | 1369 | } |
| 1371 | 1370 | $keys[] = "CREATE INDEX $i ON $nom ($v);"; |
| 1372 | 1371 | } elseif (str_starts_with($k, 'UNIQUE ')) { |
| 1373 | 1372 | $k = preg_replace('/^UNIQUE +/', '', $k); |
| 1374 | - $prim .= "$s\n\t\tCONSTRAINT " . str_replace('`', '"', $k) . " UNIQUE ($v)"; |
|
| 1373 | + $prim .= "$s\n\t\tCONSTRAINT ".str_replace('`', '"', $k)." UNIQUE ($v)"; |
|
| 1375 | 1374 | } else { |
| 1376 | - $prim .= "$s\n\t\t" . str_replace('`', '"', $k) . " ($v)"; |
|
| 1375 | + $prim .= "$s\n\t\t".str_replace('`', '"', $k)." ($v)"; |
|
| 1377 | 1376 | } |
| 1378 | 1377 | if ($k == 'PRIMARY KEY') { |
| 1379 | 1378 | $prim_name = $v; |
@@ -1384,16 +1383,16 @@ discard block |
||
| 1384 | 1383 | |
| 1385 | 1384 | $character_set = ''; |
| 1386 | 1385 | if (@$GLOBALS['meta']['charset_sql_base']) { |
| 1387 | - $character_set .= ' CHARACTER SET ' . $GLOBALS['meta']['charset_sql_base']; |
|
| 1386 | + $character_set .= ' CHARACTER SET '.$GLOBALS['meta']['charset_sql_base']; |
|
| 1388 | 1387 | } |
| 1389 | 1388 | if (@$GLOBALS['meta']['charset_collation_sql_base']) { |
| 1390 | - $character_set .= ' COLLATE ' . $GLOBALS['meta']['charset_collation_sql_base']; |
|
| 1389 | + $character_set .= ' COLLATE '.$GLOBALS['meta']['charset_collation_sql_base']; |
|
| 1391 | 1390 | } |
| 1392 | 1391 | |
| 1393 | 1392 | foreach ($champs as $k => $v) { |
| 1394 | 1393 | $k = str_replace('`', '"', $k); |
| 1395 | 1394 | if (preg_match(',([a-z]*\s*(\(\s*\d*\s*\))?(\s*binary)?),i', (string) $v, $defs) && (preg_match(',(char|text),i', $defs[1]) && !preg_match(',binary,i', $defs[1]))) { |
| 1396 | - $v = $defs[1] . $character_set . ' ' . substr((string) $v, strlen($defs[1])); |
|
| 1395 | + $v = $defs[1].$character_set.' '.substr((string) $v, strlen($defs[1])); |
|
| 1397 | 1396 | } |
| 1398 | 1397 | |
| 1399 | 1398 | $query .= "$s\n\t\t$k " |
@@ -1407,7 +1406,7 @@ discard block |
||
| 1407 | 1406 | |
| 1408 | 1407 | // En l'absence de "if not exists" en PG, on neutralise les erreurs |
| 1409 | 1408 | |
| 1410 | - $q = "CREATE $temporary TABLE $nom ($query" . ($prim ? ",$prim" : '') . ')' . |
|
| 1409 | + $q = "CREATE $temporary TABLE $nom ($query".($prim ? ",$prim" : '').')'. |
|
| 1411 | 1410 | ($character_set ? " DEFAULT $character_set" : '') |
| 1412 | 1411 | . "\n"; |
| 1413 | 1412 | |
@@ -1418,7 +1417,7 @@ discard block |
||
| 1418 | 1417 | $r = @pg_query($link, $q); |
| 1419 | 1418 | |
| 1420 | 1419 | if (!$r) { |
| 1421 | - spip_log("Impossible de creer cette table: $q", 'pg.' . _LOG_ERREUR); |
|
| 1420 | + spip_log("Impossible de creer cette table: $q", 'pg.'._LOG_ERREUR); |
|
| 1422 | 1421 | } else { |
| 1423 | 1422 | foreach ($keys as $index) { |
| 1424 | 1423 | pg_query($link, $index); |
@@ -1441,20 +1440,20 @@ discard block |
||
| 1441 | 1440 | // vue deja presente |
| 1442 | 1441 | if (sql_showtable($nom, false, $serveur)) { |
| 1443 | 1442 | if ($requeter) { |
| 1444 | - spip_log("Echec creation d'une vue sql ($nom) car celle-ci existe deja (serveur:$serveur)", 'pg.' . _LOG_ERREUR); |
|
| 1443 | + spip_log("Echec creation d'une vue sql ($nom) car celle-ci existe deja (serveur:$serveur)", 'pg.'._LOG_ERREUR); |
|
| 1445 | 1444 | } |
| 1446 | 1445 | |
| 1447 | 1446 | return false; |
| 1448 | 1447 | } |
| 1449 | 1448 | |
| 1450 | - $query = "CREATE VIEW $nom AS " . $query_select; |
|
| 1449 | + $query = "CREATE VIEW $nom AS ".$query_select; |
|
| 1451 | 1450 | |
| 1452 | 1451 | return spip_pg_query($query, $serveur, $requeter); |
| 1453 | 1452 | } |
| 1454 | 1453 | |
| 1455 | 1454 | |
| 1456 | 1455 | function spip_pg_set_connect_charset($charset, $serveur = '', $requeter = true) { |
| 1457 | - spip_log('changement de charset sql a ecrire en PG', 'pg.' . _LOG_ERREUR); |
|
| 1456 | + spip_log('changement de charset sql a ecrire en PG', 'pg.'._LOG_ERREUR); |
|
| 1458 | 1457 | } |
| 1459 | 1458 | |
| 1460 | 1459 | |
@@ -1467,7 +1466,7 @@ discard block |
||
| 1467 | 1466 | * @return bool|string true / false / requete |
| 1468 | 1467 | **/ |
| 1469 | 1468 | function spip_pg_optimize($table, $serveur = '', $requeter = true) { |
| 1470 | - return spip_pg_query('VACUUM ' . $table, $serveur, $requeter); |
|
| 1469 | + return spip_pg_query('VACUUM '.$table, $serveur, $requeter); |
|
| 1471 | 1470 | } |
| 1472 | 1471 | |
| 1473 | 1472 | // Selectionner la sous-chaine dans $objet |
@@ -65,35 +65,35 @@ discard block |
||
| 65 | 65 | // determiner le dossier de la base : $addr ou _DIR_DB |
| 66 | 66 | $f = _DIR_DB; |
| 67 | 67 | if ($addr && str_contains($addr, '/')) { |
| 68 | - $f = rtrim($addr, '/') . '/'; |
|
| 68 | + $f = rtrim($addr, '/').'/'; |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | // un nom de base demande et impossible d'obtenir la base, on s'en va : |
| 72 | 72 | // il faut que la base existe ou que le repertoire parent soit writable |
| 73 | - if ($db && !is_file($f .= $db . '.sqlite') && !is_writable(dirname($f))) { |
|
| 74 | - spip_log("base $f non trouvee ou droits en ecriture manquants", 'sqlite.' . _LOG_HS); |
|
| 73 | + if ($db && !is_file($f .= $db.'.sqlite') && !is_writable(dirname($f))) { |
|
| 74 | + spip_log("base $f non trouvee ou droits en ecriture manquants", 'sqlite.'._LOG_HS); |
|
| 75 | 75 | |
| 76 | 76 | return false; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | // charger les modules sqlite au besoin |
| 80 | 80 | if (!_sqlite_charger_version($sqlite_version)) { |
| 81 | - spip_log("Impossible de trouver/charger le module SQLite ($sqlite_version)!", 'sqlite.' . _LOG_HS); |
|
| 81 | + spip_log("Impossible de trouver/charger le module SQLite ($sqlite_version)!", 'sqlite.'._LOG_HS); |
|
| 82 | 82 | |
| 83 | 83 | return false; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | // chargement des constantes |
| 87 | 87 | // il ne faut pas definir les constantes avant d'avoir charge les modules sqlite |
| 88 | - $define = 'spip_sqlite' . $sqlite_version . '_constantes'; |
|
| 88 | + $define = 'spip_sqlite'.$sqlite_version.'_constantes'; |
|
| 89 | 89 | $define(); |
| 90 | 90 | |
| 91 | 91 | if (!$db) { |
| 92 | 92 | // si pas de db -> |
| 93 | 93 | // base temporaire tant qu'on ne connait pas son vrai nom |
| 94 | 94 | // pour tester la connexion |
| 95 | - $db = '_sqlite' . $sqlite_version . '_install'; |
|
| 96 | - $tmp = _DIR_DB . $db . '.sqlite'; |
|
| 95 | + $db = '_sqlite'.$sqlite_version.'_install'; |
|
| 96 | + $tmp = _DIR_DB.$db.'.sqlite'; |
|
| 97 | 97 | $link = spip_sqlite_open($tmp); |
| 98 | 98 | } else { |
| 99 | 99 | // Ouvrir (eventuellement creer la base) |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | if (!$link) { |
| 104 | - spip_log("Impossible d'ouvrir la base SQLite($sqlite_version) $f", 'sqlite.' . _LOG_HS); |
|
| 104 | + spip_log("Impossible d'ouvrir la base SQLite($sqlite_version) $f", 'sqlite.'._LOG_HS); |
|
| 105 | 105 | |
| 106 | 106 | return false; |
| 107 | 107 | } |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | $table = $regs[3]; |
| 199 | 199 | $suite = $regs[4]; |
| 200 | 200 | } else { |
| 201 | - spip_log("SQLite : Probleme de ALTER TABLE mal forme dans $query", 'sqlite.' . _LOG_ERREUR); |
|
| 201 | + spip_log("SQLite : Probleme de ALTER TABLE mal forme dans $query", 'sqlite.'._LOG_ERREUR); |
|
| 202 | 202 | |
| 203 | 203 | return false; |
| 204 | 204 | } |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | $i = 0; |
| 216 | 216 | $ouverte = false; |
| 217 | 217 | while ($do = array_shift($todo)) { |
| 218 | - $todo2[$i] = isset($todo2[$i]) ? $todo2[$i] . ',' . $do : $do; |
|
| 218 | + $todo2[$i] = isset($todo2[$i]) ? $todo2[$i].','.$do : $do; |
|
| 219 | 219 | $o = (str_contains($do, '(')); |
| 220 | 220 | $f = (str_contains($do, ')')); |
| 221 | 221 | if ($o && !$f) { |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | ) { |
| 242 | 242 | spip_log( |
| 243 | 243 | "SQLite : Probleme de ALTER TABLE, utilisation non reconnue dans : $do \n(requete d'origine : $query)", |
| 244 | - 'sqlite.' . _LOG_ERREUR |
|
| 244 | + 'sqlite.'._LOG_ERREUR |
|
| 245 | 245 | ); |
| 246 | 246 | |
| 247 | 247 | return false; |
@@ -337,10 +337,10 @@ discard block |
||
| 337 | 337 | |
| 338 | 338 | // pas geres en sqlite2 |
| 339 | 339 | case 'RENAME': |
| 340 | - $do = 'RENAME TO' . substr($do, 6); |
|
| 340 | + $do = 'RENAME TO'.substr($do, 6); |
|
| 341 | 341 | case 'RENAME TO': |
| 342 | 342 | if (!Sqlite::executer_requete("$debut $do", $serveur)) { |
| 343 | - spip_log("SQLite : Erreur ALTER TABLE / RENAME : $query", 'sqlite.' . _LOG_ERREUR); |
|
| 343 | + spip_log("SQLite : Erreur ALTER TABLE / RENAME : $query", 'sqlite.'._LOG_ERREUR); |
|
| 344 | 344 | |
| 345 | 345 | return false; |
| 346 | 346 | } |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | $colonnes = substr($colonne_origine, 1, -1); |
| 384 | 384 | if (str_contains(',', $colonnes)) { |
| 385 | 385 | spip_log('SQLite : Erreur, impossible de creer un index sur plusieurs colonnes' |
| 386 | - . " sans qu'il ait de nom ($table, ($colonnes))", 'sqlite.' . _LOG_ERREUR); |
|
| 386 | + . " sans qu'il ait de nom ($table, ($colonnes))", 'sqlite.'._LOG_ERREUR); |
|
| 387 | 387 | break; |
| 388 | 388 | } else { |
| 389 | 389 | $nom_index = $colonnes; |
@@ -398,12 +398,12 @@ discard block |
||
| 398 | 398 | |
| 399 | 399 | // pas geres en sqlite2 |
| 400 | 400 | case 'ADD COLUMN': |
| 401 | - $do = 'ADD' . substr($do, 10); |
|
| 401 | + $do = 'ADD'.substr($do, 10); |
|
| 402 | 402 | case 'ADD': |
| 403 | 403 | default: |
| 404 | 404 | if (!preg_match(',primary\s+key,i', $do)) { |
| 405 | 405 | if (!Sqlite::executer_requete("$debut $do", $serveur)) { |
| 406 | - spip_log("SQLite : Erreur ALTER TABLE / ADD : $query", 'sqlite.' . _LOG_ERREUR); |
|
| 406 | + spip_log("SQLite : Erreur ALTER TABLE / ADD : $query", 'sqlite.'._LOG_ERREUR); |
|
| 407 | 407 | |
| 408 | 408 | return false; |
| 409 | 409 | } |
@@ -423,7 +423,7 @@ discard block |
||
| 423 | 423 | } |
| 424 | 424 | $opts['field'] = [$colonne_ajoutee => $def]; |
| 425 | 425 | if (!_sqlite_modifier_table($table, [$colonne_ajoutee], $opts, $serveur)) { |
| 426 | - spip_log("SQLite : Erreur ALTER TABLE / ADD : $query", 'sqlite.' . _LOG_ERREUR); |
|
| 426 | + spip_log("SQLite : Erreur ALTER TABLE / ADD : $query", 'sqlite.'._LOG_ERREUR); |
|
| 427 | 427 | |
| 428 | 428 | return false; |
| 429 | 429 | } |
@@ -431,10 +431,10 @@ discard block |
||
| 431 | 431 | break; |
| 432 | 432 | } |
| 433 | 433 | // tout est bon, ouf ! |
| 434 | - spip_log("SQLite ($serveur) : Changements OK : $debut $do", 'sqlite.' . _LOG_INFO); |
|
| 434 | + spip_log("SQLite ($serveur) : Changements OK : $debut $do", 'sqlite.'._LOG_INFO); |
|
| 435 | 435 | } |
| 436 | 436 | |
| 437 | - spip_log("SQLite ($serveur) : fin ALTER TABLE OK !", 'sqlite.' . _LOG_INFO); |
|
| 437 | + spip_log("SQLite ($serveur) : fin ALTER TABLE OK !", 'sqlite.'._LOG_INFO); |
|
| 438 | 438 | |
| 439 | 439 | return true; |
| 440 | 440 | } |
@@ -502,9 +502,9 @@ discard block |
||
| 502 | 502 | * @return bool true si la base est créee. |
| 503 | 503 | **/ |
| 504 | 504 | function spip_sqlite_create_base($nom, $serveur = '', $option = true) { |
| 505 | - $f = $nom . '.sqlite'; |
|
| 505 | + $f = $nom.'.sqlite'; |
|
| 506 | 506 | if (!str_contains($nom, '/')) { |
| 507 | - $f = _DIR_DB . $f; |
|
| 507 | + $f = _DIR_DB.$f; |
|
| 508 | 508 | } |
| 509 | 509 | |
| 510 | 510 | $ok = new \PDO("sqlite:$f"); |
@@ -544,13 +544,13 @@ discard block |
||
| 544 | 544 | if (sql_showtable($nom, false, $serveur)) { |
| 545 | 545 | spip_log( |
| 546 | 546 | "Echec creation d'une vue sql ($nom) car celle-ci existe deja (serveur:$serveur)", |
| 547 | - 'sqlite.' . _LOG_ERREUR |
|
| 547 | + 'sqlite.'._LOG_ERREUR |
|
| 548 | 548 | ); |
| 549 | 549 | |
| 550 | 550 | return false; |
| 551 | 551 | } |
| 552 | 552 | |
| 553 | - $query = "CREATE VIEW $nom AS " . $query_select; |
|
| 553 | + $query = "CREATE VIEW $nom AS ".$query_select; |
|
| 554 | 554 | |
| 555 | 555 | return spip_sqlite_query($query, $serveur, $requeter); |
| 556 | 556 | } |
@@ -576,8 +576,8 @@ discard block |
||
| 576 | 576 | function spip_sqlite_create_index($nom, $table, $champs, $unique = '', $serveur = '', $requeter = true) { |
| 577 | 577 | if (!($nom || $table || $champs)) { |
| 578 | 578 | spip_log( |
| 579 | - "Champ manquant pour creer un index sqlite ($nom, $table, (" . implode(',', $champs) . '))', |
|
| 580 | - 'sqlite.' . _LOG_ERREUR |
|
| 579 | + "Champ manquant pour creer un index sqlite ($nom, $table, (".implode(',', $champs).'))', |
|
| 580 | + 'sqlite.'._LOG_ERREUR |
|
| 581 | 581 | ); |
| 582 | 582 | |
| 583 | 583 | return false; |
@@ -585,7 +585,7 @@ discard block |
||
| 585 | 585 | |
| 586 | 586 | // SQLite ne differentie pas noms des index en fonction des tables |
| 587 | 587 | // il faut donc creer des noms uniques d'index pour une base sqlite |
| 588 | - $nom = $table . '_' . $nom; |
|
| 588 | + $nom = $table.'_'.$nom; |
|
| 589 | 589 | // enlever d'eventuelles parentheses deja presentes sur champs |
| 590 | 590 | if (!is_array($champs)) { |
| 591 | 591 | if ($champs[0] == '(') { |
@@ -607,12 +607,12 @@ discard block |
||
| 607 | 607 | } else { |
| 608 | 608 | /* simuler le IF EXISTS - version 2 et sqlite < 3.3a */ |
| 609 | 609 | $a = spip_sqlite_showtable($table, $serveur); |
| 610 | - if (isset($a['key']['KEY ' . $nom])) { |
|
| 610 | + if (isset($a['key']['KEY '.$nom])) { |
|
| 611 | 611 | return true; |
| 612 | 612 | } |
| 613 | 613 | } |
| 614 | 614 | |
| 615 | - $query = 'CREATE ' . ($unique ? 'UNIQUE ' : '') . "INDEX$ifnotexists $nom ON $table (" . implode(',', $champs) . ')'; |
|
| 615 | + $query = 'CREATE '.($unique ? 'UNIQUE ' : '')."INDEX$ifnotexists $nom ON $table (".implode(',', $champs).')'; |
|
| 616 | 616 | $res = spip_sqlite_query($query, $serveur, $requeter); |
| 617 | 617 | if (!$requeter) { |
| 618 | 618 | return $res; |
@@ -680,7 +680,7 @@ discard block |
||
| 680 | 680 | $serveur = '', |
| 681 | 681 | $requeter = true |
| 682 | 682 | ) { |
| 683 | - $c = $groupby ? 'DISTINCT ' . (is_string($groupby) ? $groupby : implode(',', $groupby)) : ('*'); |
|
| 683 | + $c = $groupby ? 'DISTINCT '.(is_string($groupby) ? $groupby : implode(',', $groupby)) : ('*'); |
|
| 684 | 684 | $r = spip_sqlite_select( |
| 685 | 685 | "COUNT($c)", |
| 686 | 686 | $from, |
@@ -790,14 +790,14 @@ discard block |
||
| 790 | 790 | */ |
| 791 | 791 | function spip_sqlite_drop_index($nom, $table, $serveur = '', $requeter = true) { |
| 792 | 792 | if (!$nom && !$table) { |
| 793 | - spip_log("Champ manquant pour supprimer un index sqlite ($nom, $table)", 'sqlite.' . _LOG_ERREUR); |
|
| 793 | + spip_log("Champ manquant pour supprimer un index sqlite ($nom, $table)", 'sqlite.'._LOG_ERREUR); |
|
| 794 | 794 | |
| 795 | 795 | return false; |
| 796 | 796 | } |
| 797 | 797 | |
| 798 | 798 | // SQLite ne differentie pas noms des index en fonction des tables |
| 799 | 799 | // il faut donc creer des noms uniques d'index pour une base sqlite |
| 800 | - $index = $table . '_' . $nom; |
|
| 800 | + $index = $table.'_'.$nom; |
|
| 801 | 801 | $exist = ' IF EXISTS'; |
| 802 | 802 | |
| 803 | 803 | $query = "DROP INDEX$exist $index"; |
@@ -829,7 +829,7 @@ discard block |
||
| 829 | 829 | if ($s) { |
| 830 | 830 | $trace = debug_backtrace(); |
| 831 | 831 | if ($trace[0]['function'] != 'spip_sqlite_error') { |
| 832 | - spip_log("$s - $query - " . sql_error_backtrace(), 'sqlite.' . _LOG_ERREUR); |
|
| 832 | + spip_log("$s - $query - ".sql_error_backtrace(), 'sqlite.'._LOG_ERREUR); |
|
| 833 | 833 | } |
| 834 | 834 | } |
| 835 | 835 | |
@@ -876,14 +876,14 @@ discard block |
||
| 876 | 876 | $t = $link->errorInfo(); |
| 877 | 877 | $s = ltrim((string) $t[0], '0'); // 00000 si pas d'erreur |
| 878 | 878 | if ($s) { |
| 879 | - $s .= ' / ' . $t[1]; |
|
| 879 | + $s .= ' / '.$t[1]; |
|
| 880 | 880 | } // ajoute l'erreur du moteur SQLite |
| 881 | 881 | } else { |
| 882 | 882 | $s = ': aucune ressource sqlite (link)'; |
| 883 | 883 | } |
| 884 | 884 | |
| 885 | 885 | if ($s) { |
| 886 | - spip_log("Erreur sqlite $s", 'sqlite.' . _LOG_ERREUR); |
|
| 886 | + spip_log("Erreur sqlite $s", 'sqlite.'._LOG_ERREUR); |
|
| 887 | 887 | } |
| 888 | 888 | |
| 889 | 889 | return $s ?: 0; |
@@ -907,7 +907,7 @@ discard block |
||
| 907 | 907 | } |
| 908 | 908 | |
| 909 | 909 | $query = Sqlite::traduire_requete($query, $serveur); |
| 910 | - $query = 'EXPLAIN ' . $query; |
|
| 910 | + $query = 'EXPLAIN '.$query; |
|
| 911 | 911 | if (!$requeter) { |
| 912 | 912 | return $query; |
| 913 | 913 | } |
@@ -1076,7 +1076,7 @@ discard block |
||
| 1076 | 1076 | **/ |
| 1077 | 1077 | function spip_sqlite_insert($table, $champs, $valeurs, $desc = [], $serveur = '', $requeter = true) { |
| 1078 | 1078 | |
| 1079 | - $query = "INSERT INTO $table " . ($champs ? "$champs VALUES $valeurs" : 'DEFAULT VALUES'); |
|
| 1079 | + $query = "INSERT INTO $table ".($champs ? "$champs VALUES $valeurs" : 'DEFAULT VALUES'); |
|
| 1080 | 1080 | if ($r = spip_sqlite_query($query, $serveur, $requeter)) { |
| 1081 | 1081 | if (!$requeter) { |
| 1082 | 1082 | return $r; |
@@ -1131,8 +1131,8 @@ discard block |
||
| 1131 | 1131 | |
| 1132 | 1132 | $cles = $valeurs = ''; |
| 1133 | 1133 | if (is_countable($couples) ? count($couples) : 0) { |
| 1134 | - $cles = '(' . implode(',', array_keys($couples)) . ')'; |
|
| 1135 | - $valeurs = '(' . implode(',', $couples) . ')'; |
|
| 1134 | + $cles = '('.implode(',', array_keys($couples)).')'; |
|
| 1135 | + $valeurs = '('.implode(',', $couples).')'; |
|
| 1136 | 1136 | } |
| 1137 | 1137 | |
| 1138 | 1138 | return spip_sqlite_insert($table, $cles, $valeurs, $desc, $serveur, $requeter); |
@@ -1194,11 +1194,11 @@ discard block |
||
| 1194 | 1194 | |
| 1195 | 1195 | $champs = $valeurs = ''; |
| 1196 | 1196 | if ($couples !== []) { |
| 1197 | - $champs = '(' . implode(',', array_keys($couples)) . ')'; |
|
| 1198 | - $valeurs = '(' . implode(',', $couples) . ')'; |
|
| 1199 | - $query = $query_start . "$champs VALUES $valeurs"; |
|
| 1197 | + $champs = '('.implode(',', array_keys($couples)).')'; |
|
| 1198 | + $valeurs = '('.implode(',', $couples).')'; |
|
| 1199 | + $query = $query_start."$champs VALUES $valeurs"; |
|
| 1200 | 1200 | } else { |
| 1201 | - $query = $query_start . 'DEFAULT VALUES'; |
|
| 1201 | + $query = $query_start.'DEFAULT VALUES'; |
|
| 1202 | 1202 | } |
| 1203 | 1203 | |
| 1204 | 1204 | if ($requeter) { |
@@ -1330,7 +1330,7 @@ discard block |
||
| 1330 | 1330 | * @return string texte de sélection pour la requête |
| 1331 | 1331 | */ |
| 1332 | 1332 | function spip_sqlite_multi($objet, $lang) { |
| 1333 | - return 'EXTRAIRE_MULTI(' . $objet . ", '" . $lang . "') AS multi"; |
|
| 1333 | + return 'EXTRAIRE_MULTI('.$objet.", '".$lang."') AS multi"; |
|
| 1334 | 1334 | } |
| 1335 | 1335 | |
| 1336 | 1336 | |
@@ -1399,7 +1399,7 @@ discard block |
||
| 1399 | 1399 | function spip_sqlite_date_proche($champ, $interval, $unite) { |
| 1400 | 1400 | $op = (($interval <= 0) ? '>' : '<'); |
| 1401 | 1401 | |
| 1402 | - return "($champ $op datetime('" . date('Y-m-d H:i:s') . "', '$interval $unite'))"; |
|
| 1402 | + return "($champ $op datetime('".date('Y-m-d H:i:s')."', '$interval $unite'))"; |
|
| 1403 | 1403 | } |
| 1404 | 1404 | |
| 1405 | 1405 | |
@@ -1431,7 +1431,7 @@ discard block |
||
| 1431 | 1431 | && (!isset($desc['key']['PRIMARY KEY']) || $desc['key']['PRIMARY KEY'] !== $c) |
| 1432 | 1432 | ) { |
| 1433 | 1433 | spip_sqlite_alter($q = "TABLE $table CHANGE $c $c $d DEFAULT ''", $serveur); |
| 1434 | - spip_log("ALTER $q", 'repair' . _LOG_INFO_IMPORTANTE); |
|
| 1434 | + spip_log("ALTER $q", 'repair'._LOG_INFO_IMPORTANTE); |
|
| 1435 | 1435 | } |
| 1436 | 1436 | if ( |
| 1437 | 1437 | preg_match(',^(INTEGER),i', (string) $d) |
@@ -1441,7 +1441,7 @@ discard block |
||
| 1441 | 1441 | && (!isset($desc['key']['PRIMARY KEY']) || $desc['key']['PRIMARY KEY'] !== $c) |
| 1442 | 1442 | ) { |
| 1443 | 1443 | spip_sqlite_alter($q = "TABLE $table CHANGE $c $c $d DEFAULT '0'", $serveur); |
| 1444 | - spip_log("ALTER $q", 'repair' . _LOG_INFO_IMPORTANTE); |
|
| 1444 | + spip_log("ALTER $q", 'repair'._LOG_INFO_IMPORTANTE); |
|
| 1445 | 1445 | } |
| 1446 | 1446 | if ( |
| 1447 | 1447 | preg_match(',^(datetime),i', (string) $d) |
@@ -1451,7 +1451,7 @@ discard block |
||
| 1451 | 1451 | && (!isset($desc['key']['PRIMARY KEY']) || $desc['key']['PRIMARY KEY'] !== $c) |
| 1452 | 1452 | ) { |
| 1453 | 1453 | spip_sqlite_alter($q = "TABLE $table CHANGE $c $c $d DEFAULT '0000-00-00 00:00:00'", $serveur); |
| 1454 | - spip_log("ALTER $q", 'repair' . _LOG_INFO_IMPORTANTE); |
|
| 1454 | + spip_log("ALTER $q", 'repair'._LOG_INFO_IMPORTANTE); |
|
| 1455 | 1455 | } |
| 1456 | 1456 | } |
| 1457 | 1457 | |
@@ -1502,10 +1502,10 @@ discard block |
||
| 1502 | 1502 | // recherche de champs 'timestamp' pour mise a jour auto de ceux-ci |
| 1503 | 1503 | $couples = _sqlite_ajouter_champs_timestamp($table, $couples, $desc, $serveur); |
| 1504 | 1504 | |
| 1505 | - return spip_sqlite_query("REPLACE INTO $table (" . implode(',', array_keys($couples)) . ') VALUES (' . implode( |
|
| 1505 | + return spip_sqlite_query("REPLACE INTO $table (".implode(',', array_keys($couples)).') VALUES ('.implode( |
|
| 1506 | 1506 | ',', |
| 1507 | 1507 | $couples |
| 1508 | - ) . ')', $serveur); |
|
| 1508 | + ).')', $serveur); |
|
| 1509 | 1509 | } |
| 1510 | 1510 | |
| 1511 | 1511 | |
@@ -1592,7 +1592,7 @@ discard block |
||
| 1592 | 1592 | . _sqlite_calculer_expression('WHERE', $where) |
| 1593 | 1593 | . _sqlite_calculer_expression('GROUP BY', $groupby, ',') |
| 1594 | 1594 | . _sqlite_calculer_expression('HAVING', $having) |
| 1595 | - . ($orderby ? ("\nORDER BY " . _sqlite_calculer_order($orderby)) : '') |
|
| 1595 | + . ($orderby ? ("\nORDER BY "._sqlite_calculer_order($orderby)) : '') |
|
| 1596 | 1596 | . ($limit ? "\nLIMIT $limit" : ''); |
| 1597 | 1597 | |
| 1598 | 1598 | // dans un select, on doit renvoyer la requête en cas d'erreur |
@@ -1630,10 +1630,10 @@ discard block |
||
| 1630 | 1630 | // interdire la creation d'une nouvelle base, |
| 1631 | 1631 | // sauf si on est dans l'installation |
| 1632 | 1632 | if ( |
| 1633 | - !is_file($f = _DIR_DB . $db . '.sqlite') |
|
| 1633 | + !is_file($f = _DIR_DB.$db.'.sqlite') |
|
| 1634 | 1634 | && (!defined('_ECRIRE_INSTALL') || !_ECRIRE_INSTALL) |
| 1635 | 1635 | ) { |
| 1636 | - spip_log("Il est interdit de creer la base $db", 'sqlite.' . _LOG_HS); |
|
| 1636 | + spip_log("Il est interdit de creer la base $db", 'sqlite.'._LOG_HS); |
|
| 1637 | 1637 | |
| 1638 | 1638 | return false; |
| 1639 | 1639 | } |
@@ -1642,12 +1642,12 @@ discard block |
||
| 1642 | 1642 | // avec les identifiants connus |
| 1643 | 1643 | $index = $serveur ?: 0; |
| 1644 | 1644 | |
| 1645 | - if ($link = spip_connect_db('', '', '', '', '@selectdb@' . $db, $serveur, '', '')) { |
|
| 1645 | + if ($link = spip_connect_db('', '', '', '', '@selectdb@'.$db, $serveur, '', '')) { |
|
| 1646 | 1646 | if (($db == $link['db']) && $GLOBALS['connexions'][$index] = $link) { |
| 1647 | 1647 | return $db; |
| 1648 | 1648 | } |
| 1649 | 1649 | } else { |
| 1650 | - spip_log("Impossible de selectionner la base $db", 'sqlite.' . _LOG_HS); |
|
| 1650 | + spip_log("Impossible de selectionner la base $db", 'sqlite.'._LOG_HS); |
|
| 1651 | 1651 | } |
| 1652 | 1652 | |
| 1653 | 1653 | return false; |
@@ -1698,7 +1698,7 @@ discard block |
||
| 1698 | 1698 | $match = "^$match$"; |
| 1699 | 1699 | |
| 1700 | 1700 | return spip_sqlite_query( |
| 1701 | - "SELECT name FROM sqlite_master WHERE type='table' AND tbl_name REGEXP " . _q($match), |
|
| 1701 | + "SELECT name FROM sqlite_master WHERE type='table' AND tbl_name REGEXP "._q($match), |
|
| 1702 | 1702 | $serveur, |
| 1703 | 1703 | $requeter |
| 1704 | 1704 | ); |
@@ -1722,7 +1722,7 @@ discard block |
||
| 1722 | 1722 | $r = spip_sqlite_query( |
| 1723 | 1723 | 'SELECT name FROM sqlite_master WHERE' |
| 1724 | 1724 | . ' type=\'table\'' |
| 1725 | - . ' AND name=' . spip_sqlite_quote($table, 'string') |
|
| 1725 | + . ' AND name='.spip_sqlite_quote($table, 'string') |
|
| 1726 | 1726 | . ' AND name NOT LIKE \'sqlite_%\'', |
| 1727 | 1727 | $serveur, |
| 1728 | 1728 | $requeter |
@@ -1819,7 +1819,7 @@ discard block |
||
| 1819 | 1819 | // s'il y a une parenthèse fermante dans la clé |
| 1820 | 1820 | // ou dans la définition sans qu'il n'y ait une ouverture avant |
| 1821 | 1821 | if (str_contains($k, ')') || preg_match('/^[^\(]*\)/', (string) $def)) { |
| 1822 | - $fields[$k_precedent] .= ',' . $k . ' ' . $def; |
|
| 1822 | + $fields[$k_precedent] .= ','.$k.' '.$def; |
|
| 1823 | 1823 | continue; |
| 1824 | 1824 | } |
| 1825 | 1825 | |
@@ -1854,13 +1854,13 @@ discard block |
||
| 1854 | 1854 | . 'ORDER BY substr(type,2,1), name'; |
| 1855 | 1855 | $a = spip_sqlite_query($query, $serveur, $requeter); |
| 1856 | 1856 | while ($r = spip_sqlite_fetch($a, null, $serveur)) { |
| 1857 | - $key = str_replace($nom_table . '_', '', (string) $r['name']); // enlever le nom de la table ajoute a l'index |
|
| 1857 | + $key = str_replace($nom_table.'_', '', (string) $r['name']); // enlever le nom de la table ajoute a l'index |
|
| 1858 | 1858 | $keytype = 'KEY'; |
| 1859 | 1859 | if (str_contains((string) $r['sql'], 'UNIQUE INDEX')) { |
| 1860 | 1860 | $keytype = 'UNIQUE KEY'; |
| 1861 | 1861 | } |
| 1862 | 1862 | $colonnes = preg_replace(',.*\((.*)\).*,', '$1', (string) $r['sql']); |
| 1863 | - $keys[$keytype . ' ' . $key] = $colonnes; |
|
| 1863 | + $keys[$keytype.' '.$key] = $colonnes; |
|
| 1864 | 1864 | } |
| 1865 | 1865 | } |
| 1866 | 1866 | } // c'est une vue, on liste les champs disponibles simplement |
@@ -1907,7 +1907,7 @@ discard block |
||
| 1907 | 1907 | |
| 1908 | 1908 | $set = []; |
| 1909 | 1909 | foreach ($champs as $champ => $val) { |
| 1910 | - $set[] = $champ . "=$val"; |
|
| 1910 | + $set[] = $champ."=$val"; |
|
| 1911 | 1911 | } |
| 1912 | 1912 | if ($set !== []) { |
| 1913 | 1913 | return spip_sqlite_query( |
@@ -1962,7 +1962,7 @@ discard block |
||
| 1962 | 1962 | |
| 1963 | 1963 | $set = []; |
| 1964 | 1964 | foreach ($champs as $champ => $val) { |
| 1965 | - $set[$champ] = $champ . '=' . _sqlite_calculer_cite($val, $fields[$champ] ?? ''); |
|
| 1965 | + $set[$champ] = $champ.'='._sqlite_calculer_cite($val, $fields[$champ] ?? ''); |
|
| 1966 | 1966 | } |
| 1967 | 1967 | |
| 1968 | 1968 | // recherche de champs 'timestamp' pour mise a jour auto de ceux-ci |
@@ -1970,7 +1970,7 @@ discard block |
||
| 1970 | 1970 | $maj = _sqlite_ajouter_champs_timestamp($table, [], $desc, $serveur); |
| 1971 | 1971 | foreach ($maj as $champ => $val) { |
| 1972 | 1972 | if (!isset($set[$champ])) { |
| 1973 | - $set[$champ] = $champ . '=' . $val; |
|
| 1973 | + $set[$champ] = $champ.'='.$val; |
|
| 1974 | 1974 | } |
| 1975 | 1975 | } |
| 1976 | 1976 | |
@@ -1999,7 +1999,7 @@ discard block |
||
| 1999 | 1999 | */ |
| 2000 | 2000 | function _sqlite_init() { |
| 2001 | 2001 | if (!defined('_DIR_DB')) { |
| 2002 | - define('_DIR_DB', _DIR_ETC . 'bases/'); |
|
| 2002 | + define('_DIR_DB', _DIR_ETC.'bases/'); |
|
| 2003 | 2003 | } |
| 2004 | 2004 | if (!defined('_SQLITE_CHMOD')) { |
| 2005 | 2005 | define('_SQLITE_CHMOD', _SPIP_CHMOD); |
@@ -2105,9 +2105,9 @@ discard block |
||
| 2105 | 2105 | } |
| 2106 | 2106 | |
| 2107 | 2107 | // echapper les ' en '' |
| 2108 | - spip_log('Pas de methode ->quote pour echapper', 'sqlite.' . _LOG_INFO_IMPORTANTE); |
|
| 2108 | + spip_log('Pas de methode ->quote pour echapper', 'sqlite.'._LOG_INFO_IMPORTANTE); |
|
| 2109 | 2109 | |
| 2110 | - return ("'" . str_replace("'", "''", $v) . "'"); |
|
| 2110 | + return ("'".str_replace("'", "''", $v)."'"); |
|
| 2111 | 2111 | } |
| 2112 | 2112 | |
| 2113 | 2113 | |
@@ -2130,12 +2130,12 @@ discard block |
||
| 2130 | 2130 | $exp = "\n$expression "; |
| 2131 | 2131 | |
| 2132 | 2132 | if (!is_array($v)) { |
| 2133 | - return $exp . $v; |
|
| 2133 | + return $exp.$v; |
|
| 2134 | 2134 | } else { |
| 2135 | 2135 | if (strtoupper($join) === 'AND') { |
| 2136 | - return $exp . implode("\n\t$join ", array_map('_sqlite_calculer_where', $v)); |
|
| 2136 | + return $exp.implode("\n\t$join ", array_map('_sqlite_calculer_where', $v)); |
|
| 2137 | 2137 | } else { |
| 2138 | - return $exp . implode($join, $v); |
|
| 2138 | + return $exp.implode($join, $v); |
|
| 2139 | 2139 | } |
| 2140 | 2140 | } |
| 2141 | 2141 | } |
@@ -2169,17 +2169,17 @@ discard block |
||
| 2169 | 2169 | if (str_ends_with($k, '@')) { |
| 2170 | 2170 | // c'est une jointure qui se refere au from precedent |
| 2171 | 2171 | // pas de virgule |
| 2172 | - $res .= ' ' . $v; |
|
| 2172 | + $res .= ' '.$v; |
|
| 2173 | 2173 | } else { |
| 2174 | 2174 | if (!is_numeric($k)) { |
| 2175 | 2175 | $p = strpos((string) $v, ' '); |
| 2176 | 2176 | if ($p) { |
| 2177 | - $v = substr((string) $v, 0, $p) . " AS '$k'" . substr((string) $v, $p); |
|
| 2177 | + $v = substr((string) $v, 0, $p)." AS '$k'".substr((string) $v, $p); |
|
| 2178 | 2178 | } else { |
| 2179 | 2179 | $v .= " AS '$k'"; |
| 2180 | 2180 | } |
| 2181 | 2181 | } |
| 2182 | - $res .= ', ' . $v; |
|
| 2182 | + $res .= ', '.$v; |
|
| 2183 | 2183 | } |
| 2184 | 2184 | } |
| 2185 | 2185 | |
@@ -2315,13 +2315,13 @@ discard block |
||
| 2315 | 2315 | |
| 2316 | 2316 | $def_origine = sql_showtable($table_origine, false, $serveur); |
| 2317 | 2317 | if (!$def_origine || !isset($def_origine['field'])) { |
| 2318 | - spip_log("Alter table impossible sur $table_origine : table non trouvee", 'sqlite' . _LOG_ERREUR); |
|
| 2318 | + spip_log("Alter table impossible sur $table_origine : table non trouvee", 'sqlite'._LOG_ERREUR); |
|
| 2319 | 2319 | |
| 2320 | 2320 | return false; |
| 2321 | 2321 | } |
| 2322 | 2322 | |
| 2323 | 2323 | |
| 2324 | - $table_tmp = $table_origine . '_tmp'; |
|
| 2324 | + $table_tmp = $table_origine.'_tmp'; |
|
| 2325 | 2325 | |
| 2326 | 2326 | // 1) creer une table temporaire avec les modifications |
| 2327 | 2327 | // - DROP : suppression de la colonne |
@@ -2408,7 +2408,7 @@ discard block |
||
| 2408 | 2408 | } else { |
| 2409 | 2409 | // enlever KEY |
| 2410 | 2410 | $k = substr($k, 4); |
| 2411 | - $queries[] = "CREATE INDEX $table_destination" . "_$k ON $table_destination ($v)"; |
|
| 2411 | + $queries[] = "CREATE INDEX $table_destination"."_$k ON $table_destination ($v)"; |
|
| 2412 | 2412 | } |
| 2413 | 2413 | } |
| 2414 | 2414 | |
@@ -2419,7 +2419,7 @@ discard block |
||
| 2419 | 2419 | foreach ($queries as $q) { |
| 2420 | 2420 | if (!Sqlite::executer_requete($q, $serveur)) { |
| 2421 | 2421 | spip_log('SQLite : ALTER TABLE table :' |
| 2422 | - . " Erreur a l'execution de la requete : $q", 'sqlite.' . _LOG_ERREUR); |
|
| 2422 | + . " Erreur a l'execution de la requete : $q", 'sqlite.'._LOG_ERREUR); |
|
| 2423 | 2423 | Sqlite::annuler_transaction($serveur); |
| 2424 | 2424 | |
| 2425 | 2425 | return false; |
@@ -2509,27 +2509,27 @@ discard block |
||
| 2509 | 2509 | $enum = '(\s*\([^\)]*\))?'; |
| 2510 | 2510 | |
| 2511 | 2511 | $remplace = [ |
| 2512 | - '/enum' . $enum . '/is' => 'VARCHAR(255)', |
|
| 2512 | + '/enum'.$enum.'/is' => 'VARCHAR(255)', |
|
| 2513 | 2513 | '/COLLATE \w+_bin/is' => 'COLLATE BINARY', |
| 2514 | 2514 | '/COLLATE \w+_ci/is' => 'COLLATE NOCASE', |
| 2515 | 2515 | '/auto_increment/is' => '', |
| 2516 | 2516 | '/current_timestamp\(\)/is' => 'CURRENT_TIMESTAMP', // Fix export depuis mariaDB #4374 |
| 2517 | 2517 | '/(timestamp .* )ON .*$/is' => '\\1', |
| 2518 | 2518 | '/character set \w+/is' => '', |
| 2519 | - '/((big|small|medium|tiny)?int(eger)?)' . $num . '\s*unsigned/is' => '\\1 UNSIGNED', |
|
| 2519 | + '/((big|small|medium|tiny)?int(eger)?)'.$num.'\s*unsigned/is' => '\\1 UNSIGNED', |
|
| 2520 | 2520 | '/(text\s+not\s+null(\s+collate\s+\w+)?)\s*$/is' => "\\1 DEFAULT ''", |
| 2521 | - '/((char|varchar)' . $num . '\s+not\s+null(\s+collate\s+\w+)?)\s*$/is' => "\\1 DEFAULT ''", |
|
| 2521 | + '/((char|varchar)'.$num.'\s+not\s+null(\s+collate\s+\w+)?)\s*$/is' => "\\1 DEFAULT ''", |
|
| 2522 | 2522 | '/(datetime\s+not\s+null)\s*$/is' => "\\1 DEFAULT '0000-00-00 00:00:00'", |
| 2523 | 2523 | '/(date\s+not\s+null)\s*$/is' => "\\1 DEFAULT '0000-00-00'", |
| 2524 | 2524 | ]; |
| 2525 | 2525 | |
| 2526 | 2526 | // pour l'autoincrement, il faut des INTEGER NOT NULL PRIMARY KEY |
| 2527 | 2527 | $remplace_autocinc = [ |
| 2528 | - '/(big|small|medium|tiny)?int(eger)?' . $num . '/is' => 'INTEGER' |
|
| 2528 | + '/(big|small|medium|tiny)?int(eger)?'.$num.'/is' => 'INTEGER' |
|
| 2529 | 2529 | ]; |
| 2530 | 2530 | // pour les int non autoincrement, il faut un DEFAULT |
| 2531 | 2531 | $remplace_nonautocinc = [ |
| 2532 | - '/((big|small|medium|tiny)?int(eger)?' . $num . '\s+not\s+null)\s*$/is' => "\\1 DEFAULT 0", |
|
| 2532 | + '/((big|small|medium|tiny)?int(eger)?'.$num.'\s+not\s+null)\s*$/is' => "\\1 DEFAULT 0", |
|
| 2533 | 2533 | ]; |
| 2534 | 2534 | |
| 2535 | 2535 | if (is_string($query)) { |
@@ -2571,7 +2571,7 @@ discard block |
||
| 2571 | 2571 | return str_ireplace('BINARY', 'COLLATE BINARY', $champ); |
| 2572 | 2572 | } |
| 2573 | 2573 | if (preg_match(',^(char|varchar|(long|small|medium|tiny)?text),i', $champ)) { |
| 2574 | - return $champ . ' COLLATE NOCASE'; |
|
| 2574 | + return $champ.' COLLATE NOCASE'; |
|
| 2575 | 2575 | } |
| 2576 | 2576 | |
| 2577 | 2577 | return $champ; |
@@ -2661,7 +2661,7 @@ discard block |
||
| 2661 | 2661 | } else { |
| 2662 | 2662 | /* simuler le IF EXISTS - version 2 et sqlite < 3.3a */ |
| 2663 | 2663 | $a = spip_sqlite_showtable($nom, $serveur); |
| 2664 | - if (isset($a['key']['KEY ' . $nom])) { |
|
| 2664 | + if (isset($a['key']['KEY '.$nom])) { |
|
| 2665 | 2665 | return true; |
| 2666 | 2666 | } |
| 2667 | 2667 | } |
@@ -2669,7 +2669,7 @@ discard block |
||
| 2669 | 2669 | |
| 2670 | 2670 | $temporary = $temporary ? ' TEMPORARY' : ''; |
| 2671 | 2671 | |
| 2672 | - return "CREATE$temporary TABLE$ifnotexists $nom ($query" . ($keys ? ",$keys" : '') . ")\n"; |
|
| 2672 | + return "CREATE$temporary TABLE$ifnotexists $nom ($query".($keys ? ",$keys" : '').")\n"; |
|
| 2673 | 2673 | } |
| 2674 | 2674 | |
| 2675 | 2675 | |