Note: Tagging this as "base system" because I seem to remember that "documentation" is not used in the core queue.

Problem description

drupal_bootstrap() give s a useful reference for external scripts on how to bootstrap Drupal. After #1540136: Simplify index.php by moving DRUPAL_ROOT to bootstrap.inc following this documentation will lead to a PHP error, however.

Proposed resolution

Instead of saying:

 *   define('DRUPAL_ROOT', '/path/to/drupal');
 *   require_once DRUPAL_ROOT . '/core/includes/bootstrap.inc';
 *   drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

we should say

 *   require_once '/path/to/drupal/core/includes/bootstrap.inc';
 *   drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

Because bootstrap.inc now defines DRUPAL_ROOT and defining the same constant twice leads to a PHP error.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

longwave’s picture

In your suggestion DRUPAL_ROOT is still used but will not be defined. This should be something like:

 * @code
 *   require_once 'path/to/drupal/core/includes/bootstrap.inc';
 *   drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
 * @endcode
tstoeckler’s picture

Sorry, it's late here.
Obviously,

 * @code
*   require_once DRUPAL_ROOT . '/core/includes/bootstrap.inc';
*   drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
* @endcode

does not work as DRUPAL_ROOT is defined in bootstrap.inc. #fail

Updated the issue summary accordingly.

tstoeckler’s picture

Oops, that was a crosspost. Yeah...

tstoeckler’s picture

Issue summary: View changes

Updated issue summary.

chx’s picture

Component: base system » documentation

It is definitely used in the core queue.

chx’s picture

Issue summary: View changes

Updated issue summary.

StephaneQ’s picture

Status: Active » Needs review
FileSize
564 bytes
chx’s picture

Status: Needs review » Reviewed & tested by the community

That looks good.

chx’s picture

Issue summary: View changes

Updated issue summary.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Nice catch.

Committed and pushed to 8.x. Thanks!

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

rewritten issue summary