Testare Drupal 10 in locale

Risolvere il problema del 404 not found che si verifica quando si tenta di effettuare il CRUD di un campo su un’entità di Drupal 10.

Quasi sicuramente se sei arrivato qui significa che all’aggiunta di un campo su un tipo di contenuto di Drupal 10, hai ricevuto un errore 404 e lo stesso ti sarà successo in modifica o delete del campo di un entità.

Se sei fortunato, come descritto da Halt nell’issue #2743633 su drupal.org il problema potrebbe essere generato dal comando php che ti consente di lanciare il webserver in ascolto su una certa porta.

Normalmente il comando che si lancia è:

php -S localhost:8000

Che ti consente, navigando con il browser su quell’host, di vedere la tua installazione Drupal 10. Tuttavia tale comando risulta insufficiente, in quanto bisogna dargli in pasto un file che è incluso nell’installazione Drupal, ovvero “.ht.router.php“.

TODO immagine boyscout che giura

Utilizzando il comando il problema non si verifica più, parola di boy scout.

php -S localhost:8888 .ht.router.php

Aprendo il file .ht.router.php scopriamo subito il suo proposito leggendo il commento in testa:

/**
 * @file
 * Router script for the built-in PHP web server.
 *
 * The built-in web server should only be used for development and testing as it
 * has a number of limitations that makes running Drupal on it highly insecure
 * and somewhat limited.
 *
 * Note that:
 * - The server is single-threaded, any requests made during the execution of
 *   the main request will hang until the main request has been completed.
 * - The web server does not enforce any of the settings in .htaccess in
 *   particular a remote user will be able to download files that normally would
 *   be protected from direct access such as .module files.
 *
 * The router script is needed to work around a bug in PHP, see
 * https://bugs.php.net/bug.php?id=61286.
 *
 * Usage:
 * php -S localhost:8888 .ht.router.php
 *
 * @see http://php.net/manual/en/features.commandline.webserver.php
 */

Cosa che significa sostanzialmente:

  • che questo file andrebbe lanciato solo per finalità di testing e sviluppo
  • che non è sicuro
  • che è limitato, ad esempio dal fatto che è single thread

Buon Drupal 10 🙂