<?php

/*
 * Copyright 2012 Facebook, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

$root = dirname(dirname(__FILE__));
require_once $root.'/src/__phutil_library_init__.php';

/**
 * Adjust the runtime language configuration to be reasonable and inline with
 * expectations.
 */
function __phutil_adjust_php_ini() {
  error_reporting(E_ALL | E_STRICT);

  $config_map = array(
    'display_errors'  => true,
    'error_log'       => null,
  );

  foreach ($config_map as $config_key => $config_value) {
    ini_set($config_key, $config_value);
  }
}

__phutil_adjust_php_ini();

<?php

/*
 * Copyright 2012 Facebook, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

$root = dirname(dirname(__FILE__));
require_once $root.'/src/__phutil_library_init__.php';

/**
 * Adjust the runtime language configuration to be reasonable and inline with
 * expectations.
 */
function __phutil_adjust_php_ini() {
  error_reporting(E_ALL | E_STRICT);

  $config_map = array(
    'display_errors'  => true,
    'error_log'       => null,
  );

  foreach ($config_map as $config_key => $config_value) {
    ini_set($config_key, $config_value);
  }

  // There may be some kind of auto-prepend script configured which starts an
  // output buffer. Discard any such output buffers so messages can be sent to
  // stdout (if a user wants to capture output from a script, there are a large
  // number of ways they can accomplish it legitimately; historically, we ran
  // into this on only one install which had some bizarre configuration, but it
  // was difficult to diagnose because the symptom is "no messages of any
  // kind").
  while (ob_get_level() > 0) {
    ob_end_clean();
  }
}

__phutil_adjust_php_ini();

Move ob_get_level() script initialization check to libphutil from arcanist
Move ob_get_level() script initialization check to libphutil from arcanist

Summary: See D1950, D1951. We should always normalize any output buffering initialized in the environmen when running scripts.

Test Plan: Ran "arc".

Reviewers: btrahan, killermonk

Reviewed By: btrahan

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D1952
