From 9d7994f3594af13c1ede0a0b1e100fa8157a1b5f Mon Sep 17 00:00:00 2001 From: "marcimat@rezo.net" <> Date: Sun, 18 Sep 2011 11:14:05 +0000 Subject: [PATCH] =?UTF-8?q?Gagner=2015=20secondes=20sur=20l'installation?= =?UTF-8?q?=20du=20plugin=20en=20SQLite,=20passant=20de=2017s=20=C3=A0=202?= =?UTF-8?q?s=20chez=20moi.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Lorsque l'on peuple spip_types_documents, on utilise sql_insertq_multi() si la table est vide, sinon sql_replace_multi(). --- base/medias.php | 34 +++++++++++++++++++++++----------- paquet.xml | 2 +- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/base/medias.php b/base/medias.php index 6b22d115..207a7c23 100644 --- a/base/medias.php +++ b/base/medias.php @@ -187,6 +187,8 @@ function creer_base_types_doc($serveur='') { include_spip('base/typedoc'); include_spip('base/abstract_sql'); + $insertions = array(); + foreach ($tables_mime as $extension => $type_mime) { if (isset($tables_images[$extension])) { $titre = $tables_images[$extension]; @@ -212,17 +214,27 @@ function creer_base_types_doc($serveur='') { $media = "audio"; elseif (preg_match(",^video/,",$type_mime) OR in_array($type_mime,array('application/ogg','application/x-shockwave-flash','application/mp4'))) $media = "video"; - - // Init ou Re-init ==> replace pas insert - sql_replace('spip_types_documents', - array('mime_type' => $type_mime, - 'titre' => $titre, - 'inclus' => $inclus, - 'extension' => $extension, - 'media' => $media, - 'upload' => 'oui' - ), - '', $serveur); + + $insertions[] = array( + 'mime_type' => $type_mime, + 'titre' => $titre, + 'inclus' => $inclus, + 'extension' => $extension, + 'media' => $media, + 'upload' => 'oui' + ); + } + + if ($insertions) { + + // Re-init : replace + if (sql_countsel('spip_types_documents')) { + sql_replace_multi('spip_types_documents', $insertions, '', $serveur); + // Init : insert + } else { + sql_insertq_multi('spip_types_documents', $insertions, '', $serveur); + } + } } diff --git a/paquet.xml b/paquet.xml index 2760decf..1af2b220 100644 --- a/paquet.xml +++ b/paquet.xml @@ -1,7 +1,7 @@ <paquet prefix="medias" categorie="multimedia" - version="2.4.0" + version="2.4.1" etat="test" compatibilite="[3.0.0-alpha2;[" logo="prive/themes/spip/images/portfolio-32.png" -- GitLab