Log http://www.bidon.ca/fr fr Configurer Virtualbox avec IE7, IE8, IE9 sous Debian GNU/Linux http://www.bidon.ca/fr/random/2010-03-13-configurer-virtualbox-pour-tester-ie7-ie8-sous-debian-gnulinux <div class="field field-name-body field-type-text-with-summary field-label-hidden view-mode-rss"><div class="field-items"><div class="field-item even"><p><em>(initialement écrit le 2010-03-13, mis à jour le 3 février 2012)</em></p> <p>Je dois régulièrement vérifier sites web pour m'assurer qu'ils fonctionnent correctement sous Internet Explorer. Jadis j'utilisais ies4linux (et wine), mais c'est lent, peu fiable (polices de caractères) et ne supporte que IE6.</p> <p>Voici comment installer VirtualBox, un émulateur libre (GPL) qui fonctionne sous GNU/Linux, Windows et Mac.</p> <h3>Installer VirtualBox sur Debian</h3> <p>Voici comment l'installer pour Debian (squeeze):</p> <pre><code># apt-get install virtualbox virtualbox-guest-additions-iso virtualbox-guest-utils </code></pre> <p>Le paquet Debian s'occupe de créer le bon groupe (vboxusers) et compiler les trucs nécessaires pour le noyau.</p> <h3>Obtenir des images VHD de Windows</h3> <p>Ensuite:</p> <ul> <li>Télécharger les images Windows de Microsoft: <a href="https://www.microsoft.com/download/en/details.aspx?displaylang=en&amp;id=11575">Internet Explorer Application Compatibility VPC Image</a>. Par exemple, pour IE7 sous Vista, il faut IE7-VIS1.exe, IE7-VIS2.rar et IE7-VIS3.rar. Attention, les fichiers font à peu près 700 Mo chaque.</li> <li>Décompresser l'archive (unrar x IE7-VIS1.exe), ce qui décompressera un fichier "vhd".</li> </ul> <p>Démarrer VirtualBox (du menu gnome ou de la ligne de commande) :</p> <ul> <li>Cliquer sur le bouton "Créer" (ou "Machine" -> "Créer")</li> <li>Donner un nom à la machine virtuelle (ex: "Windows 7 IE 9"), sélectionner le type de système d'exploitation (MS Windows, Version "Windows 7")</li> <li>Choisir suffisamment de mémoire vive (512 Mo est parfois un peu bas, j'ai tendance à allouer 768 Mo).</li> <li>IMPORTANT: pour IE8 / IE9, ne pas choisir de "disque d'amorçage". Décocher l'option complètement (virtualbox avertira que la machine ne sera pas fonctionnelle, continuer quand même).</li> </ul> <p><img src="/files/vbox-nodisk.jpg" alt="VirtualBox: ne pas créer de disque virtuel." /></p> <p>Une fois l'assistant terminé, de retour au panneau principal de VirtualBox, aller dans les configurations de la machine virtuelle:</p> <ul> <li>Sous l'onglet "Stockage", cliquer sur l'icône "+" à côté de "Contrôleur IDE". (Ne pas utiliser "SATA", car ceci causera un" écran bleu de la mort" (BSOD) de Windows.)</li> <li>puis sélectionner l'option "Choisir un disque existant", ce qui ouvrira un dialogue de sélection de fichier</li> <li>dans le filtre sous la liste de fichiers, sélectionner "tous les fichiers de disque dur virtuels" (si ce n'est pas déjà le cas), puis sélectionner le fichier "vhd".</li> </ul> <p><img src="/files/vbox-adddisk.jpg" alt="VirtualBox: ajouter un disque IDE." /></p> <p>On peut maintenant retourner à l'écran principal et démarrer la machine virtuelle:</p> <ul> <li>Le mot de passe dministrateur est "Password1".</li> <li>On peut sauter par dessus l'étape d'activation de Windows.</li> </ul> <p>Dans un terminal de Windows (command prompt), écrire:</p> <pre><code>slmgr –rearm </code></pre> <p>Ceci permettra d'utiliser Windows pendant 30 jours. On peut faire un "snapshot" de l'image et re-utiliser cette image sans problème, pour éviter de tout refaire l'installation après 30 jours.</p> <h3>Configurer la carte réseau</h3> <p><em>Mise à jour du 3 février 2012: ceci ne semble plus nécessaire.</em></p> <p>Pour faire fonctionner la carte réseau dans Windows7+IE8, j'ai dû faire les étapes suivantes:</p> <ul> <li>installer le paquet "virtualbox-guest-utils" pour avoir la fonctionalité de partage de répertoire entre Linux et Windows</li> <li>configurer la carte réseau dans VirtualBox pour qu'elle soit émulée en tant que "Intel PRO/1000"</li> <li>télécharger un pilote (driver) d'Intel pour Windows <a href="http://downloadcenter.intel.com/Detail_Desc.aspx?agr=Y&amp;ProdId=1878&amp;DwnldID=18717&amp;ProductFamily=Network+Connectivity&amp;ProductLine=Intel%C2%AE+Desktop+Adapters&amp;ProductProduct=Intel%C2%AE+PRO%2f1000+GT+Desktop+Adapter&amp;DownloadType=Drivers&amp;OSFullname=Windows+XP+Professional*&amp;lang=eng">ici</a></li> <li>activer le répertoire partagé dans Windows, puis installer le pilote (en exécutant le fichier, ce qui après 1001 avertissements et trucs légaux incompréhensibles, lance ensuite l'installation du truc)</li> </ul> <h3>Références</h3> <ul> <li><a href="http://www.virtualbox.org">Site web de VirtualBox</a></li> <li><a href="http://zytzagoo.net/blog/2009/03/20/howto-running-ie6-ie7-and-ie8-on-ubuntu-intrepid-810-using-virtualbox">HOWTO: Running IE6, IE7 and IE8 On Ubuntu Intrepid (8.10) Using VirtualBox</a></li> <li><a href="http://primozverdnik.com/2011/06/run-ie9-in-virtualbox-for-free/">Run IE9 in Virtualbox for free</a></li> </ul> </div></div></div><div class="field field-name-upload field-type-file field-label-hidden view-mode-rss"><div class="field-items"></div></div><section class="field field-name-taxonomy-vocabulary-1 field-type-taxonomy-term-reference field-label-above view-mode-rss clearfix"> <h2 class="field-label">Tag:&nbsp;</h2> <ul class="field-items"> <li class="field-item even"> <a href="/fr/category/tag/sysadmin">sysadmin</a> </li> <li class="field-item odd"> <a href="/fr/category/tag/debian">debian</a> </li> <li class="field-item even"> <a href="/fr/category/tag/virtualbox">virtualbox</a> </li> </ul> </section> Fri, 03 Feb 2012 19:49:06 +0000 mathieu 365 at http://www.bidon.ca http://www.bidon.ca/fr/random/2010-03-13-configurer-virtualbox-pour-tester-ie7-ie8-sous-debian-gnulinux#comments Make the Drupal 7 language switcher work with multi-lingual CiviCRM http://www.bidon.ca/fr/node/584 <div class="field field-name-body field-type-text-with-summary field-label-hidden view-mode-rss"><div class="field-items"><div class="field-item even"><p>The theme() function in Drupal 7 offers the possibility to specifiy a "context". This means that modules who used to call :</p> <pre><code>theme('list', $stuff); </code></pre> <p>Can now do:</p> <pre><code>theme('list__mystuff', $stuff); </code></pre> <p>Which allows themers to override the theme function for that specific case.</p> <p>In my use case, I want a language switcher that supports multi-lingual CiviCRM forms. The language switcher provided by the default locale block will drop any arguments in the URL, which means that pages such as:</p> <pre><code>/en/civicrm/contribute/transact?reset=1&amp;action=preview&amp;id=3&amp;lcMessages=en_US </code></pre> <p>Would be transformed to:</p> <pre><code>/fr/civicrm/contribute/transact </code></pre> <p>Therefore causing CiviCRM to output an error, since the page ID was not provided in the request.</p> <p>I'm not sure if this is the cleanest solution, but it works for me:</p> <p><pre> /** * Implements hook_links__locale_block() * make the language switcher work with civicrm * adapt and insert into your theme's template.php */ function yourthemename_links__locale_block($variables) { if (arg(0) == 'civicrm') { foreach ($variables['links'] as $lang => $attr) { $query = $_REQUEST; unset($query['IDS_request_uri']); unset($query['IDS_user_agent']); if ($lang == 'fr') { $query['lcMessages'] = 'fr_CA'; } else { $query['lcMessages'] = 'en_US'; } $variables['links'][$lang]['query'] = $query; } } return theme('links', $variables); } </pre></p> </div></div></div><div class="field field-name-upload field-type-file field-label-hidden view-mode-rss"><div class="field-items"></div></div><section class="field field-name-taxonomy-vocabulary-1 field-type-taxonomy-term-reference field-label-above view-mode-rss clearfix"> <h2 class="field-label">Tag:&nbsp;</h2> <ul class="field-items"> <li class="field-item even"> <a href="/fr/category/cat%C3%A9gorie/civicrm">civicrm</a> </li> </ul> </section> Mon, 30 Jan 2012 23:05:47 +0000 mathieu 584 at http://www.bidon.ca http://www.bidon.ca/fr/node/584#comments Meta: site web mis à jour à Drupal 7 http://www.bidon.ca/fr/random/2011-11-29-mise-a-jour-drupal-7 <div class="field field-name-body field-type-text-with-summary field-label-hidden view-mode-rss"><div class="field-items"><div class="field-item even"><p>J'ai mis à jour ce site web de Drupal 6 à 7. Comme vous pouvez le constater, ça brise une bonne partie du site (listes trop longues, titres en double, encore plus laid, etc).</p> <p>Pour le visuel, j'ai installé le thème <a href="http://www.drupal.org/project/sky">sky</a>, basé sur <a href="http://www.drupal.org/project/adaptivetheme">Adaptive Theme</a>.</p> <p>Je me suis dit que ça prendrait une éternité avant que je termines la mise à jour correctement, alors autant mieux faire la mise à jour et réparer plus tard. :-)</p> <p><em>Mise à jour:</em></p> <ul> <li><p>J'ai réussi à faire un visuel qui fait un peu mal aux yeux, mais quand même divertissant, en jouant 1-2h avec le thème Sky, et un peu de CSS maison. Je me suis amusé avec "-moz-transition".</p></li> <li><p>Je n'ai toujours pas réglé mon problème que Panels ne respecte pas les limites d'items configurées (i.e. afficher max 10 items). Alors pour l'instant j'ai changé la configuration de la page d'accueil pour avoir une seule vue. Les "bookmarks" font dur à cause de ça, mais je pense faire une refonte de ça.</p></li> <li><p>Le module <a href="http://www.drupal.org/project/boost">boost</a> ne fonctionnait pas très bien, et le principal développeur n'est pas très actif dernièrement, alors j'ai offert de lui donner un coup de main et j'ai obtenu les accès au dépôt git. Ce qui m'a fait perdre au moins 4-5 heures à lire les très intéressants rapports de bugs ouverts (environ 150, et 300 demandes de support).</p></li> <li><p>Toujours pas trouvé de solution aux titres en double, quoique je n'ai pas vraiment cherché non plus. <strong>Résolu:</strong> étrangement le thème imprimait le titre dans page.tpl.php et node.tpl.php. Il y a sans doute une option dans le thème que je n'ai pas compris, mais bon, j'ai mis en commentaire l'impression du titre dans node.tpl.php.</p></li> </ul> <p><em>Autre mises à jour:</em></p> <ul> <li><p>J'ai laissé tomber Panels, puisque je n'en avais pas vraiment besoin, et gérer les fils RSS est plus facile avec Context (permet de gérer les blocs plus rapidement). Il faut par contre que je trouve une solution pour faire revenir la 3e colonne, mais je vais trouver une façon de le présenter autrement (c'est pas du contenu qui change souvent, et ça surchargeait la page).</p></li> <li><p>J'ai porté les petits trucs qui fait plier/déplier les fils RSS, afficher le contenu des items (pour le faire flotter quand on place la souris sur le titre), etc. Le module "aggregator" semble s'être amélioré par rapport à D6, du moins j'ai trouvé ça beaucoup plus facile à modifier par des templates.</p></li> </ul> </div></div></div><div class="field field-name-field-icone field-type-image field-label-hidden view-mode-rss"> <div class="field-items"> <figure class="field-item"> <a href="/fr/random/2011-11-29-mise-a-jour-drupal-7"><img src="http://www.bidon.ca/sites/www.bidon.ca/files/styles/thumbnail/public/icones/druplicon_0.png" width="89" height="100" alt="" /></a> </figure> </div> </div> <div class="field field-name-upload field-type-file field-label-hidden view-mode-rss"><div class="field-items"></div></div><section class="field field-name-taxonomy-vocabulary-1 field-type-taxonomy-term-reference field-label-above view-mode-rss clearfix"> <h2 class="field-label">Tag:&nbsp;</h2> <ul class="field-items"> <li class="field-item even"> <a href="/fr/category/tag/drupal">drupal</a> </li> </ul> </section> Wed, 30 Nov 2011 04:48:28 +0000 mathieu 568 at http://www.bidon.ca http://www.bidon.ca/fr/random/2011-11-29-mise-a-jour-drupal-7#comments Installing CiviCRM SVN trunk with Aegir (on Debian/Ubuntu) http://www.bidon.ca/fr/random/2011-10-26-installing-civicrm-svn-trunk-aegir-debianubuntu <div class="field field-name-body field-type-text-with-summary field-label-hidden view-mode-rss"><div class="field-items"><div class="field-item even"><p>To install the latest SVN trunk version using Aegir (and provision_civicrm), the process is rather equivalent to the usual CiviCRM installation, except that you have to run "GenCode" (more on that later). The following instructions are for Debian/Ubuntu, mainly because installing Aegir on those environments is easier.</p> <h3>Aegir installation</h3> <p>Check the <a href="http://community.aegirproject.org/installing/debian">official installation instructions</a> for more information. In a nutshell:</p> <p>Add the following package repositories to your /etc/apt/sources.list:</p> <pre><code>deb http://debian.aegirproject.org stable main deb http://backports.debian.org/debian-backports squeeze-backports main </code></pre> <p>Update the package database:</p> <pre><code>apt-get update </code></pre> <p>Install Drush and Aegir:</p> <pre><code>apt-get install -t squeeze-backports drush apt-get install aegir apt-get install sudo </code></pre> <p>There is a <a href="http://community.aegirproject.org/1.4#Known_issues">known bug in Aegir 1.4</a>: if you had an issue with the drush_make installation, you can manually install it in /var/aegir/.drush/drush_make :</p> <pre><code>su - aegir drush dl drush_make-6.x-2.3 --destination=~/.drush </code></pre> <p>Then continue the Aegir installation if it had failed:</p> <pre><code>apt-get -f install </code></pre> <p>Configure sudo so that your user can sudo to the aegir user easily. If you are running Debian "squeeze" or later, you can add the following to a file such as /etc/sudoers.d/aegir-local (otherwise, use "visudo" to add to the main sudo config file):</p> <pre><code>your-username-here ALL=(aegir) NOPASSWD: ALL </code></pre> <h3>Installation of provision_civicrm</h3> <p>For the moment there are no regular releases of provision_civicrm, so doing a git checkout is recommended:</p> <pre><code>su - aegir cd /var/aegir/.drush/ git clone --branch 6.x-1.x git://git.drupal.org/project/provision_civicrm </code></pre> <h3>Create a new Aegir platform</h3> <p>Here is a sample drush make "makefile" for creating the platform (i.e. code base):</p> <p><pre> ; drush make API version api = 2</p> <p>; Drupal core core = 7.x</p> <p>; Download Drupal core projects[] = drupal</p> <p>; Modules projects[admin_menu][subdir] = contrib projects[admin_menu][version] = 3.0-rc1</p> <p>projects[devel][subdir] = contrib projects[devel][version] = 1.2</p> <p>projects[views][subdir] = contrib projects[views][version] = 3.0-rc1</p> <p>projects[ctools][subdir] = contrib projects[ctools][version] = 1.0-rc1</p> <p>projects[webform_civicrm][subdir] = contrib projects[webform_civicrm][version] = 2.0</p> <p>; Download CiviCRM from SVN libraries[civicrm][type] = "module" libraries[civicrm][destination] = "modules" libraries[civicrm][directory_name] = "civicrm" libraries[civicrm][download][type] = "svn" libraries[civicrm][download][url] = "http://svn.civicrm.org/civicrm/trunk"</p> <p>libraries[civicrm_l10n][destination] = "modules" libraries[civicrm_l10n][directory_name] = "civicrm" libraries[civicrm_l10n][download][type] = "get" libraries[civicrm_l10n][download][url] = "http://downloads.sourceforge.net/project/civicrm/civicrm-stable/4.0.7/civicrm-4.0.7-l10n.tar.gz" libraries[civicrm_l10n][overwrite] = TRUE </pre></p> <p>Save this in a file such as /var/aegir/makefiles/civicrm-4-svn.make</p> <p>Run drush make to create the platform:</p> <pre><code>sudo -i -u aegir mkdir ~/platforms/civicrm-4-svn-2011-10-26 cd ~/platforms/civicrm-4-svn-2011-10-26 drush make --working-copy ~/makefiles/civicrm-4-svn.make </code></pre> <p>The "--working-copy" parameter tells drush make to keep the ".svn" (or .git) files, so that you can use the platform for development.</p> <h3>Run GenCode</h3> <pre><code>cd ~/platforms/civicrm-4-svn-2011-10-26/sites/all/modules/civicrm/xml php GenCode schema/Schema.xml </code></pre> <h3>Add the platform to the Aegir front-end</h3> <ul> <li>Create content -> Platform <ul> <li>Enter a name, e.g. "CiviCRM SVN 2011-10-26"</li> <li>Path: /var/aegir/platforms/civicrm-4-svn-2011-10-26</li> </ul></li> </ul> <p>You are now ready to create sites.</p> </div></div></div><div class="field field-name-field-icone field-type-image field-label-hidden view-mode-rss"> <div class="field-items"> <figure class="field-item"> <a href="/fr/random/2011-10-26-installing-civicrm-svn-trunk-aegir-debianubuntu"><img src="http://www.bidon.ca/sites/www.bidon.ca/files/styles/thumbnail/public/icones/civicrmaegir.png" width="81" height="100" alt="" /></a> </figure> </div> </div> <div class="field field-name-upload field-type-file field-label-hidden view-mode-rss"><div class="field-items"></div></div><section class="field field-name-taxonomy-vocabulary-1 field-type-taxonomy-term-reference field-label-above view-mode-rss clearfix"> <h2 class="field-label">Tag:&nbsp;</h2> <ul class="field-items"> <li class="field-item even"> <a href="/fr/category/cat%C3%A9gorie/civicrm">civicrm</a> </li> <li class="field-item odd"> <a href="/fr/category/tag/aegir">aegir</a> </li> </ul> </section> Wed, 26 Oct 2011 17:53:33 +0000 mathieu 563 at http://www.bidon.ca http://www.bidon.ca/fr/random/2011-10-26-installing-civicrm-svn-trunk-aegir-debianubuntu#comments Common Drupal module developer beginner errors http://www.bidon.ca/fr/random/2011-08-13-few-common-drupal-programming-errors <div class="field field-name-body field-type-text-with-summary field-label-hidden view-mode-rss"><div class="field-items"><div class="field-item even"><p>Lately, I have been working with a few big and small web companies on Drupal-based projects. Whether it's for project analysis, training, debugging or performance, I often have to jump into other people's code which was rushed into production on short deadlines, as I have also received a lot of feedback.</p> <p>Here are a few simple tips for beginner Drupal module developers who are in a rush and will very likely need to cut corners by lack of budget or time, but who must at least make sure that the next person will not panic when reading their code.</p> <p>Sidenote: while a good project manager is essential in facilitating the whole process, they usually focus on facilitating (or moderating) the communication between parties (and taking care of paperwork, such as finalizing the contract and billing). Developers must also bear the responsibility of "delivering a project on time, on budget and with acceptable quality". (or am I making up excuses to justify cut corners? ;-)</p> <p>[toc]</p> <h3>Where is the custom code?</h3> <p>In your sites/all/modules directory, create 3 sub-directories:</p> <ul> <li>contrib: modules downloaded from drupal.org</li> <li>custom: home made modules</li> <li>patched: contrib modules which have been modified for some reason (usually because you applied a patch which is waiting to be reviewed in the project's issue queue, and each patched module has a clear documentation of why/how it was patched).</li> </ul> <p>I have seen some projects with modules all over the place, to the extent where I have gotten used to run a "find ./ -name '*.module'" to find them, or to look in the "system" table of the site database.</p> <p>Since I use Aegir for development and hosting, I also recommend putting all the commonly used modules (views, devel, admin_menu, etc) in sites/all/modules (and using "drush_make" to create those platforms). Less commonly used (including site-specific custom modules) should go in sites/[example.org]/modules. This way, we can quickly see the site-specific modules. <strong>Do not place modules in sites/default/modules</strong>, you may later on have multiple sites sharing that same Drupal code installation.</p> <h3>Custom code and namespace prefixes</h3> <p>A namespace is a short word that provides information about the context (ok, it's more than that, but I'm trying to be brief). It helps making sure that two modules do not use the same function or object name.</p> <p>For modules specific to the site, I usually prefix modules names with initials or an abbreviation referring to the site. For example, on "bidon.ca" I use the prefix "bdn" ("bidon" is French for "barrel", "container" or "useless").</p> <p>Some sample modules names could be: "bdnforms" (with all the hook_form_alter fun), bdnsnippets (for those small PHP snippets which may be included from nodes/blocks/views), etc.</p> <p>The only exception would be if creating a sub-module. For example: uc_bdn would have the code for use-cases specific to the store on my site (all Ubercart modules are prefixed with "uc").</p> <p>For service providers who re-use modules with various clients, instead of using a site-specific prefix, use a company-specific prefix.</p> <p>Drupal.org is the reference for module names. Unless you have published your module on drupal.org, you should not expect the module name to be unique.</p> <h3>PHP snippets should be in files, not nodes/blocs/views, and don't forget about the cron</h3> <p>There are times when it is necessary to enter PHP code directly in a node, block or view. Usually it's a last-resort hack.</p> <p>For example, maybe you need to write a very specific block to display on some pages. Usually this is done with a custom module that generates a block. Sometimes it may be a block that admins need to be able to update its content easily, but needs to include a few lines of PHP to calculate something dynamic (ex: the number of people who have signed a petition).</p> <p>If you don't have time to create a full custom module, create a function for that PHP snippet and store it in a general module or in your theme's template.php. This way, the code will be easy to find, re-use, maintain and there will be less risk that a site admin deletes the code by mistake. Don't forget to pass any variable to that function that would otherwise be available globally in the node/block/view.</p> <p>(thanks to mvc for this one!)</p> <p><strong>On putting PHP snippets in nodes and how it will likely break the cron:</strong> it is common to put a PHP snippet in a node in order to do a quick hack (run a db_query to fix a table, print something, etc.). However, when cron will run, it will try to index each node for the search engine, therefore executing the PHP code.</p> <p>This is very hard to debug once it happens (I usually end up doing a query in the database for nodes who have a PHP input filter, or inserting debug messages in the core cron indexing function).</p> <p>Here are two incidents I have noticed recently:</p> <ul> <li><p>a PHP snippet in a node was used to quickly export the contents of a table. It was generating a CSV file then calling the "die" function, hence halting the cron (and allowing anyone to download the CSV file just by running the cron.php).</p></li> <li><p>a PHP snippet in a node was doing a "drupal_goto" to redirect the visitor to another page (shame on me, I think I was responsible for that one).</p></li> </ul> <p>In both cases, the cron would simply stop running and would not display an error in the watchdog. We only noticed a week later in the status page that the cron had not run for a long time.</p> <h3>Correct use of the SQL functions to avoid injection attacks</h3> <p>The database functions in Drupal is a pretty big topic. For those in a very big rush, consider especially the following <strong>bad code</strong>:</p> <pre><code>db_query('INSERT INTO mytable (email, newsid) VALUES (' . $_POST['email'] . ', ' . $_POST['newsid'] . ')'); </code></pre> <p>The <strong>correct way in Drupal 6</strong> should be:</p> <pre><code>db_query('INSERT INTO {mytable} (email, newsid) VALUES ("%s", %d)', $_POST['email'], $_POST['email']); </code></pre> <p>The <strong>correct way in Drupal 7</strong> should be:</p> <pre><code>db_query('INSERT INTO {mytable} (email, newsid) VALUES (:email, :newsid)', array( ':email' =&gt; $_POST['email'], ':newsid' =&gt; $_POST['newsid'], )); </code></pre> <p>First, developers often forget to wrap table names in curly brackets, i.e. {mytable}. This is not for security, but for making it easier to prefix tables names if necessary (ex: if using simpletest).</p> <p>More importantly, in the initial example, the input was not validated at all. Hence, someone could enter the following string in the e-mail field: '; UPDATE {users} SET name = 'admin', pass = MD5('test') WHERE uid = 1; [...] and change the username and password to your superadmin account.</p> <p>If you are not familiar with the topic, search the web for "sql injection attacks".</p> <p>Note that the %s placeholder is for strings and %d is for decimal numbers, %f for floats, %b for blobs. In Drupal 7, it is no longer required to wrap %s placeholders in quotes. For more information: <a href="http://api.drupal.org/api/drupal/includes--database--database.inc/group/database/7">Drupal 7 database abstraction layer</a>, or <a href="http://api.drupal.org/api/drupal/includes--database.mysql-common.inc/function/db_query/6">db_query in Drupal 6</a>.</p> <p>Note that it is very rare to have to manipulate $_REQUEST variables directly. Usually in the form API you have access to the $form_state['values'] variables.</p> <p>You may also want to read about the <a href="http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_write_record/7">drupal_write_record()</a> function.</p> <h3>Custom scripts should use the Drupal API (don't hardcode database credentials!)</h3> <p>Whether it's custom migration scripts (in most cases the <a href="http://www.drupal.org/project/migrate">migrate</a> module is much more practical), a quick script to fix something in the database or a custom cron that doesn't play well with <a href="http://api.drupal.org/api/drupal/modules--system--system.api.php/function/hook_cron/7">hook_cron</a>, beginner Drupal developers (which doesn't mean that they are beginner developers) may try to save time by not using the Drupal API. After all, if it's a write once, use once, who cares.</p> <p>Here's how Drupal, or more precisely <a href="http://drupal.org/project/drush">drush</a>, can save you time:</p> <ul> <li>use "drush php-script" to execute the script. This way, drush does a full bootstrap of Drupal and everything is available, including db_query(). So there is no need to hardcode the database credentials in the script (those credentials will likely change often as you copy a site from various dev environments, to staging, to production).</li> <li>drush has a helpful <a href="http://api.drush.ws/api/function/drush_log/master">drush_log</a> function to log notices, success or error messages. Notices can be printed out from the command line by adding the "--debug" option.</li> <li>you can use the full Drupal API from drush, and drush itself also has a very useful API for creating new users and manipulating fields, plus many drush sub-modules which can save you a lot of time.</li> </ul> <h3>Sanitize output</h3> <p>This is straight from the excellent <a href="http://drupal.org/writing-secure-code">writing secure code</a> page on drupal.org:</p> <ul> <li>Use <a href="http://api.drupal.org/api/function/check_plain&quot;>">check_plain</a> or <a href="http://api.drupal.org/api/function/theme_placeholder">theme('placeholder')</a> for plain text.</li> <li>Use <a href="http://api.drupal.org/api/function/check_markup">check_markup</a> or <a href="http://api.drupal.org/api/function/filter_xss">filter_xss</a> for markup containing text.</li> <li>Use the <a href="http://api.drupal.org/api/function/t">t()</a> function with <code>@</code> or <code>%</code> placeholders to construct safe, translatable strings.</li> </ul> <p>A common mistake is to use arbitrary data in a call to "drupal_set_title":</p> <pre><code>drupal_set_title(t("Something: %name", $node-&gt;title)); </code></pre> <p>Should be:</p> <pre><code>drupal_set_title(t("Something: %name", check_plain($node-&gt;title))); </code></pre> <p>As with any other situation where you need to display data which had been entered by users. Data is not always filtered when it is stored in the database, so it needs to be filtered when it is displayed since this can affect other users (especially site administrators). Fore more information, search the web about cross-site-scripting (XSS).</p> <h3>Use git for change management</h3> <p>Help track down bugs and avoid really silly mistakes by using change management for your code, themes and Drupal configurations.</p> <p>My favorite trick is to version control Views by using the <a href="https://drupal.org/project/drush_views">drush_views</a> module to regularly export all views into a directory, then to commit the changes. This makes it easy to "diff" two revisions to see exactly what has changed and when. Using the <a href="http://www.drupal.org/project/features">features</a> module may be a cleaner solution, and since Features generates a bunch of code, you can do version control on that too.</p> <p>Git is easy to adopt. While the idea of having a "distributed source revision control system" may sound scary, in short, all it means is that you can have a git repository locally, without a server, or you can share changes to other servers too.</p> <p>If you don't have any experience with Git or with other source code revision tools (CVS, SVN), at the very least, create a local repository.</p> <p>On the command line, go to the top-level directory of your module or theme, then type:</p> <pre><code>git init git add * git commit -m "initial repository creation" </code></pre> <p>Every time you do a change, you can review and commit your changes:</p> <pre><code>git diff [optionally with the name of the file] git add [name of file] git commit -m "a summary description of your changes here" </code></pre> <p>And then you can review changes with:</p> <pre><code>git log </code></pre> <p>All that information to track the changes in your code are stored locally in a ".git" directory</p> <p>Git is easy to install on most Linux distributions ("apt-get install git" on Debian/Ubuntu or "yum install git-core" on CentOS/Fedora). There is also a lot of documentation for Mac OSX and Microsoft Windows. Windows users may also want to look at <a href="https://code.google.com/p/tortoisegit/">tortoisegit</a>.</p> <p>There is also great documentation to learn Git:</p> <ul> <li><a href="http://git-scm.com/">git-scm.com</a>, more specifically see the [documentation](http://git-scm.com/documentation] section.</li> <li>The <a href="http://progit.org/">Pro Git</a> book and website has a lot of freely available resources (the whole book is available online)</li> </ul> <p><em>Different philosophies: how many code repositories?</em></p> <p>There is no consensus on how to best manage the code:</p> <ul> <li>one repository per custom module, theme, configurations? (This is what I do, since if I want to version-control everything include code from drupal.org, I will create a "drush_make" makefile and put that into my version control. Has the inconvenience that if you are pushing your code to a remote server, you must have a repository for each of those modules, which may be a bit annoying to manage.)</li> <li>using git sub-modules? (Some people find this hard to use and confusing, not obvious how it works out when pulling modules from drupal.org)</li> <li>one repository for all custom modules? or all the sites/example.org/ directory? (This has the advantage of reflecting the fact that your site is "one project" and everything must be at a same given version, without the hassle of tracking core and contrib modules)</li> <li>one repository for the whole Drupal, include Drupal core (I find this unpractical when using Aegir, and do not feel the need to version-control contrib modules).</li> </ul> <p>In my opinion all of these options are valid. Use whatever suits you.</p> <h3>Use an issue tracking system and cross-reference with your code</h3> <p>An issue tracker, or bug tracker, helps track the feature requests and bug reports that help evolve your project.</p> <p>Instead of managing a pile scrap paper, napkins and random e-mails as a documentation for your project, enter them as feature requests and bug reports in your issue tracker. This is the best short and long term documentation for your project. Get your clients and colleagues to use it too. Instead of receiving e-mails from clients, ask them to open a new issue or comment in an existing one.</p> <p><a href="http://www.redmine.org/">Redmine</a>, for example, is a fast and simple to use. It installs easily with Debian (apt-get install redmine).</p> <p>A few recommendations:</p> <ul> <li>Refer to certain bugs or requests with their issue number, ex: "in feature #1234 about some-fancy-idea, ...". Even if it sounds weird, at least everyone can quickly access the issue and be sure of exactly what you are talking about. It also helps to keep discussions on focus.</li> <li>In meetings, get people to update the issues as you go, otherwise the comments get lost on random pieces of paper.</li> <li>A good issue title is probably as valuable as a good newspaper title. It also makes it easier to find old issues after some time.</li> <li>Cross-reference your issues (related to, child ticket of, ...). Makes it easier to find related issues and get a global idea. For example, if you have a issue about the theming of your website, and your site has 10 sections to theme, open one "meta" ticket for all the theming, then one child ticket for each section. If there have been 10 bugs reported about a specific functionality, mark them as related, eventually it will be handy (avoids regressions).</li> <li>Open one issue per topic. For example, if you had only one issue for the theming, but then in the comments you start having discussions about the bugs in the various sections, it will be very hard to see what is the overall status of the theming, and if the bugs reported in the comments really are being resolved.</li> </ul> <p>Ticket workflow: the status of your issue will evolve until it is closed. Make sure everyone has the same understanding of what each status means. For example:</p> <ul> <li>New: the issue was created (either by a developer or a client)</li> <li>Open: the issue was accepted by a developer and work has started on the issue</li> <li>Fixed: the issue is considered to be fixed by the developer</li> <li>Closed: the client has accepted the fix (the client should always be the one who closes the issue, especially if she created the issue initially)</li> </ul> <p>Should I go on? There are probably a lot of good references on this topic (please leave a comment if you have any suggestions).</p> <h3>Simplify the requirements, don't complicate the code</h3> <p>Often the client does not know what they want, want everything, they will learn as the project starts going live. The first iteration is always a big step for the client. The new project will have a lot of impact on their staff and users/clients, and they may want to change the priority of some aspects once they start testing/using it. Developers should not be afraid of raising issues about the relevance of feature requests.</p> <p>A few rules:</p> <ul> <li>If the requirements are hard to understand, don't work on assumptions, simplify the requirements first and have them validated by the client (write a short spec).</li> <li>If edge cases are hard to automate, the client probably may not mind not automating it (will it provide a good return on investment?) <ul> <li>or postpone it to a second phase, where those edge cases will become more clear ("we can automate it later, but first see if it's really worth it, how often this issues comes up").</li> </ul></li> <li>Compare to the existing/previous process. While the new one may not be perfect, is it better? How much do they want to invest to make it perfect? Can those improvements be made later?</li> <li>How many people are affected by the edge cases?</li> <li>Do you really want to have all those exceptions in your code? Can you move them to a separate sub-module?</li> </ul> <p>Important for developers: make sure you clearly document edge cases in the code, with a reference to the issue number.</p> <h3>Use Drupal coding standards</h3> <p>I initially found the Drupal coding standards a bit ridiculous and annoying at first, especially the "two spaces" indentation. Just get used to it. There's nothing worse than having to read through code that has been formatted in many various ways.</p> <p>Use the <a href="http://www.drupal.org/project/coder">coder</a> modules to validate your code. It has a lot of other good advice too.</p> <h3>Conclusion</h3> <p>What started out as an idea to write a quick "10 tips" article could almost be expanded into a book. It has helped me a lot to reflect on my work, and I hope it has given you a few ideas too. I didn't try to make it a how-to for anyone starting to work for Drupal, but rather a few words of caution for anyone already writing code, hacking, patching or tweaking Drupal code, especially to those who, like me, often write that code in a rush and forget about it afterwards.</p> <p>I tried to stick to the essentials, avoid the obvious comments. I assume that if a specific topic has raised an interest you will search for web for more information. Feel free to leave a comment or <a href="/en/contact">contact me</a> if you have any feedback.</p> <p>Many thanks to fellow colleagues, especially those from Koumbit, who have been the biggest influence of my current work habits (well, at least, the good ones!).</p> </div></div></div><div class="field field-name-upload field-type-file field-label-hidden view-mode-rss"><div class="field-items"></div></div><section class="field field-name-taxonomy-vocabulary-1 field-type-taxonomy-term-reference field-label-above view-mode-rss clearfix"> <h2 class="field-label">Tag:&nbsp;</h2> <ul class="field-items"> <li class="field-item even"> <a href="/fr/category/tag/drupal">drupal</a> </li> <li class="field-item odd"> <a href="/fr/category/tag/programmation">programmation</a> </li> </ul> </section> Sun, 14 Aug 2011 01:59:10 +0000 mathieu 549 at http://www.bidon.ca http://www.bidon.ca/fr/random/2011-08-13-few-common-drupal-programming-errors#comments Montréal - Saint-Sauveur, en vélo http://www.bidon.ca/fr/random/2011-07-24-montreal-saint-sauveur-en-velo <div class="field field-name-body field-type-text-with-summary field-label-hidden view-mode-rss"><div class="field-items"><div class="field-item even"><p>Je suis monté en vélo de Montréal à Saint-Sauveur (Laurentides). Ça devait faire au moins 2 ou 3 ans que je ne l'avais pas fait. Voici quelques notes pour mieux préparer le trajet la prochaine fois (dans 2 semaines!). <!--break--> <strong>Montée:</strong></p> <ul> <li>0h : Métro de la Concorde (9h15)</li> <li>1h15 : Blainville (10h30)</li> <li>2h15 : Saint-Jérôme (11h30)</li> <li>3h45 : Pont de la rivière, Piedmont, ~ kilomètre 18 (13h00)</li> <li>4h00 : Chemin Avila (13h15)</li> </ul> <p>Notes:</p> <ul> <li>Du métro de la Concorde, la piste cyclable est parallèle à la ligne de train. Il faut prendre le côté droit.</li> <li>Après l'axe Sainte-Rose (i.e. une fois rendu à la Gare Sainte-Rose), j'ai tourné à gauche pour traverser la rivière par la route 117 (où il y a une piste cyclable, mais ensuite il faut faire quelques kilomètres sur la route 117, jusqu'au Chemin de la Côte Saint-Louis E), ce qui est un peu plus court que de passer par le détour qui va au Bois-des-Filion.</li> <li>Ça m'a pris beaucoup de temps pour monter après Saint-Jérôme, puisqu'il était rendu midi et le soleil tappait fort. J'aurais dû partir plus tôt et faire une pause à Prévost.</li> </ul> <p><strong>Retour:</strong></p> <ul> <li>0h : départ Chemin Avila (9h00)</li> <li>0h45 : parc régional de la Rivière du Nord (9h40)</li> <li>2h15 : berge nord de Laval, petit parc près de la route 117 (11h10)</li> <li>3h00 : métro de la Concorde (12h00)</li> </ul> <p>Métro de la Concorde à Lionel-Groulx: 35 minutes (hors-pointe), le billet coûte 3$.</p> <p>Autres constatations:</p> <ul> <li>j'aurais dû prendre un cadenas plus léger que mon énorme cadenas Planet Bike (gros «U») que j'utilise à Montréal. Je barrais rarement mon vélo plus de 5 minutes et c'est loin d'être aussi risqué que le centre-ville de Montréal...</li> <li>j'avais encore mon lourd rack à vélo pour le siège de ma fille (en acier). Rendu à Saint-Sauveur, je l'ai changé pour un rack en aluminium.</li> <li><a href="http://www.openstreetmap.org">Open Street Map</a> ont d'excellentes cartes de pistes cyclables (voir le "cycle layer", accessible par l'icône bleu "+" dans le coin supérieur gauche de la carte)</li> </ul> </div></div></div><div class="field field-name-upload field-type-file field-label-hidden view-mode-rss"><div class="field-items"></div></div><section class="field field-name-taxonomy-vocabulary-1 field-type-taxonomy-term-reference field-label-above view-mode-rss clearfix"> <h2 class="field-label">Tag:&nbsp;</h2> <ul class="field-items"> <li class="field-item even"> <a href="/fr/category/tag/v%C3%A9lo">vélo</a> </li> </ul> </section> Sun, 24 Jul 2011 17:03:46 +0000 mathieu 546 at http://www.bidon.ca http://www.bidon.ca/fr/random/2011-07-24-montreal-saint-sauveur-en-velo#comments Netsweeper Inc: Système de censure «made in Canada» http://www.bidon.ca/fr/random/2011-07-11-syst%C3%A8me-de-censure-made-canada <div class="field field-name-body field-type-text-with-summary field-label-hidden view-mode-rss"><div class="field-items"><div class="field-item even"><p>Cette compagnie basée en Ontario se vante d'aider les gouvernements à censurer l'accès à Internet:</p> <p><cite>«A recent trend gaining more traction each day is Government bodies taking more responsibility and controlling what information is available and being viewed on the Internet within their region or country. Taking control of this resource for the protection of the greater population is termed Lawful Interception. Implementing Netsweeper in the core of national, government owned Telcos enables legislative bodies to enforce safe and positive Internet environments.»</cite></p> <p>Voir: <a href="http://www.netsweeper.com/index.php?page=netsw_gov">http://www.netsweeper.com/index.php?page=netsw_gov</a></p> <p>Mise à jour:</p> <ul><li>12 juin 2011: <a href="http://www.thestar.com/news/article/1007417--canadian-made-censorship">Canadian-made censorship</a> (The Star)</li> <li>10 juillet 2011: <a href="http://www.thestar.com/news/canada/article/1022745--canada-needs-clear-cyberspace-censorship-policy-watchdog-says">Canada needs clear cyberspace censorship policy, watchdog says</a> (The Star)</li> <li>12 juillet 2011: <a href="http://www.ledevoir.com/politique/canada/327223/censurer-internet-avec-de-la-technologie-canadienne">Censurer Internet avec de la technologie canadienne</a> (Le Devoir)</li> </ul></div></div></div><div class="field field-name-upload field-type-file field-label-hidden view-mode-rss"><div class="field-items"></div></div><section class="field field-name-taxonomy-vocabulary-1 field-type-taxonomy-term-reference field-label-above view-mode-rss clearfix"> <h2 class="field-label">Tag:&nbsp;</h2> <ul class="field-items"> <li class="field-item even"> <a href="/fr/category/tag/censure">censure</a> </li> <li class="field-item odd"> <a href="/fr/category/tag/politique">politique</a> </li> </ul> </section> Mon, 11 Jul 2011 12:00:23 +0000 mathieu 542 at http://www.bidon.ca http://www.bidon.ca/fr/random/2011-07-11-syst%C3%A8me-de-censure-made-canada#comments Désirez-vous vraiment utiliser votre voiture tous les jours? http://www.bidon.ca/fr/random/2011-06-21-d%C3%A9sirez-vous-vraiment <div class="field field-name-body field-type-text-with-summary field-label-hidden view-mode-rss"><div class="field-items"><div class="field-item even"><p>Même si on me dit qu'il y a encore des gens qui ressentent le besoin de méticuleusement imprimer chaque courriel, je suis un peu tanné de ces petits messages moralisateurs en pied de page de courriels.</p> <p>Tant qu'à être moralisateur, allons-y pour du vrai changement! Désirez-vous VRAIMENT prendre votre #@! de char tous les jours?</p> <h3>Pour le pied de page de courriels</h3> <p><img src="/files/desirez-vous.jpeg" alt="Désirez-vous vraiment prendre votre voiture tous les jours" /></p> <h3>Un classique ...</h3> <p><img src="/files/Good_Morning_Lemmings.jpg" alt="Good morning Lemmings!" /></p> <h3>Et sur la Rive Sud...</h3> <p><img src="/files/etat-pas-moyens-de-bouger.jpg" alt="Un État qui n'a pas les moyens d'effectuer des changements n'a pas les moyens de se maintenir." /></p> <p>«Un État qui n'a pas les moyens d'effectuer des changements n'a pas les moyens de se maintenir.» Source: <a href="http://www.ledevoir.com/societe/actualites-en-societe/325956/des-jeunes-s-attaquent-aux-travers-du-quebec-actuel">Le Devoir</a>.</p> <h3>Même votre GPS vous aime pas...</h3> <p><img src="/files/you-are-traffic.jpg" alt="You are traffic" /></p> <!--break--></div></div></div><div class="field field-name-upload field-type-file field-label-hidden view-mode-rss"><div class="field-items"></div></div><section class="field field-name-taxonomy-vocabulary-1 field-type-taxonomy-term-reference field-label-above view-mode-rss clearfix"> <h2 class="field-label">Tag:&nbsp;</h2> <ul class="field-items"> <li class="field-item even"> <a href="/fr/category/tag/transport">transport</a> </li> </ul> </section> Tue, 21 Jun 2011 14:23:08 +0000 mathieu 538 at http://www.bidon.ca http://www.bidon.ca/fr/random/2011-06-21-d%C3%A9sirez-vous-vraiment#comments Using the dynamic DNS feature of dns.he.net http://www.bidon.ca/fr/random/2011-06-16-using-dynamic-dns-feature-dnshenet <div class="field field-name-body field-type-text-with-summary field-label-hidden view-mode-rss"><div class="field-items"><div class="field-item even"><p><a href="http://www.tunnelbroker.net">tunnelbroker.net</a> (by Hurricane Electric) offers a free IPv6 tunnel service that you can use for at home or with servers in order to encourage IPv6 adoption. Since I'm using it for my home network, which includes a few minimal servers as well, I also use their excellent free DNS service. The DNS service includes "dynamic DNS" support, meaning that a computer on an IPv4 network can update its DNS regularly. For people like me using a lousy throttled by telecom monopolies home DSL connection with a dynamic IP, it can be useful to find my way back home if I'm on an IPv4 network (my IPv6 addresses being static).</p> <p>The feature is not very well documented in the DNS management interface, so in short:</p> <ul> <li>when creating a new "A" entry, check the box "Enable entry for dynamic dns" (it may display 127.0.0.1 as your IP, if you are connecting using IPv6, don't worry)</li> <li>after adding the new entry, a "refresh" icon will appear in the "DDNS" column of the DNS listing</li> <li>click on that icon to generate a new key which will be used as your password.</li> </ul> <p>We are now ready to configure it on the client (e.g. the computer on the lousy home DSL connection):</p> <ul> <li>install "ddclient" (apt-get install ddclient, on Debian/Ubuntu)</li> <li>the remote server is dyn.dns.he.net</li> <li>the username is the subdomain name, ex: www.example.org</li> <li>the password is the key that was generated earlier</li> <li>and enter again the subdomain, as being the entry that will be updated</li> </ul> <p>If you don't have the Debian installation-wizard, in other words, you need to put something similar to this in your /etc/ddclient.conf:</p> <pre><code>pid=/var/run/ddclient.pid protocol=dyndns2 use=if, if=ppp0 server=dyn.dns.he.net login=www.example.org password=somerandomkey www.example.org </code></pre> </div></div></div><div class="field field-name-field-icone field-type-image field-label-hidden view-mode-rss"> <div class="field-items"> <figure class="field-item"> <a href="/fr/random/2011-06-16-using-dynamic-dns-feature-dnshenet"><img src="http://www.bidon.ca/sites/www.bidon.ca/files/styles/thumbnail/public/icones/button-ipv6-small.png" width="100" height="35" alt="" /></a> </figure> </div> </div> <div class="field field-name-upload field-type-file field-label-hidden view-mode-rss"><div class="field-items"></div></div><section class="field field-name-taxonomy-vocabulary-1 field-type-taxonomy-term-reference field-label-above view-mode-rss clearfix"> <h2 class="field-label">Tag:&nbsp;</h2> <ul class="field-items"> <li class="field-item even"> <a href="/fr/category/tag/sysadmin">sysadmin</a> </li> <li class="field-item odd"> <a href="/fr/category/tag/ipv6">ipv6</a> </li> </ul> </section> Thu, 16 Jun 2011 17:15:41 +0000 mathieu 532 at http://www.bidon.ca http://www.bidon.ca/fr/random/2011-06-16-using-dynamic-dns-feature-dnshenet#comments Disque dur ressuscité http://www.bidon.ca/fr/random/2011-04-12-disque-dur-ressuscite <div class="field field-name-body field-type-text-with-summary field-label-hidden view-mode-rss"><div class="field-items"><div class="field-item even"><p>J'ai un disque dur qui est mort suite à une panne de courant. Je pensais que c'était juste le boîtier d'alimentation, mais le disque aussi ne fonctionnait plus. Près du connecteur électrique du disque on pouvait clairement voir qu'un bout avait brulé. J'avais des copies de sauvegardes, mais .. un répertoire en particulier où j'ai les photos de ma fille depuis un an n'étaient pas incluses dans la sauvegarde.</p> <p>En cherchant par hasard sur Internet, je suis tombé sur <a href="http://www.deadharddrive.com/">deadharddrive.com</a>, où quelqu'un explique qu'il a changé le contrôleur de son disque dûr (le PCB, printed circuit board) pour récupérer les données. Il y explique, entres autres, l'importance de la version du firmware (micro-logiciel) gravé dans la puce du contrôleur. Donc il ne fallait pas juste que je retrouve un Seagate de 500 Go, mais aussi avec le modèle ST350063AS, firmware 3.AAC, "site code" TK, etc. C'est un disque de quelques années, donc ce modèle exact ne se vend plus nulle part.</p> <!--break--><p>En lisant les forums de <a href="http://www.deadharddrive.com/">deadharddrive.com</a>, j'ai trouvé deux solutions pour remplacer le contrôleur:</p> <ul><li>Trouver un modèle usagé sur eBay, avec les exactes mêmes caractéristiques</li> <li>Commander le contrôleur à partir d'un magasin, ex: <a href="http://www.hkmingdi.com/enindex.asp">hkmingdi.com</a> (approx 15$ + frais d'expédition) et <a href="http://www.onepcbsolution.com">onepcbsolution.com</a> (approx 50$ + frais d'expédition)</li> </ul><p>Pour les deux magasins, j'ai dû leur écrire directement pour trouver le bon modèle de contrôleur. Seul <a href="http://www.hkmingdi.com/enindex.asp">hkmingdi.com</a> l'avait en stock.</p> <p>Ce qu'il faut savoir pour trouver le bon modèle:</p> <ul><li>Modèle, ex: Seagate Barracuda 7200.10 ST350063AS</li> <li>P/N, ex: "98J146-500"</li> <li>Firmware, ex: "3.AAC"</li> <li>Site code, ex: "TK"</li> <li>Date code, ex: "07423"</li> <li>Main chip number, ex: "100404225" - ceci est écrit sur une des grosses puces du PCB</li> <li>PCB number, ex: 100406533 REV A - ceci est écrit sur l'arrière du PCB, il faut donc le dévisser</li> </ul><p>Voici des photos du PCB, où l'on peut voir le bout brulé ainsi que le numéro principal de la grosse puce:</p> <p><img src="/files/seagate-pcb-1.jpg" /></p> <p>L'autre côté du PCB, où l'on voit le "PCB number" dans le coin:</p> <p><img src="/files/seagate-pcb-2.jpg" /></p> <p>Une chose importante à savoir: en usine les disques sont optimisés selon des micro-détails spécifiques à chaque unité. Il est donc possible qu'un PCB, même s'il est exactement du même modèle, ne fonctionne pas. Dans ce cas, une option est de demander à <a href="http://www.onepcbsolution.com">onepcbsolution.com</a> de faire le transfert du firmware de l'ancien PCB au nouveau.</p> <p>Bref, dans mon cas, ça s'est adonné que j'ai trouvé un disque de l'exact même modèle. J'ai changé les PCB (il suffit de dévisser/revisser, rien de compliqué, pas de soudure, pas d'ouverture du boîtier) et hop, disque ressuscité!</p> <p>À savoir pourquoi le disque a eu ce genre de problème, et pourquoi mon boîtier d'alimentation Antec généralement de bonne qualité a explosé malgré le fait qu'il était branché sur une batterie APC... mystère... En attendant, je vais m'assurer de vérifier mes copies de sauvegarde plus souvent, sans oublier que ceci est arrivé peu après le "<a href="http://www.worldbackupday.net/">world backup day</a>" (31 mars).</p> <p>AVERTISSEMENT: ceci est pour divertissement seulement. Si vous essayez ceci sur votre disque, c'est à vos risques et périls, ne me demandez pas pour de l'aide, allez lire des sources mieux documentées (telles que <a href="http://www.deadharddrive.com/">deadharddrive.com</a> et ses forums).</p> </div></div></div><div class="field field-name-upload field-type-file field-label-hidden view-mode-rss"><div class="field-items"></div></div><section class="field field-name-taxonomy-vocabulary-1 field-type-taxonomy-term-reference field-label-above view-mode-rss clearfix"> <h2 class="field-label">Tag:&nbsp;</h2> <ul class="field-items"> <li class="field-item even"> <a href="/fr/category/tag/sysadmin">sysadmin</a> </li> <li class="field-item odd"> <a href="/fr/category/tag/fail">fail</a> </li> </ul> </section> Tue, 12 Apr 2011 22:47:36 +0000 mathieu 458 at http://www.bidon.ca http://www.bidon.ca/fr/random/2011-04-12-disque-dur-ressuscite#comments