Skip to content

Instantly share code, notes, and snippets.

@acouch
Last active Dec 23, 2015
Embed
What would you like to do?
Drupal 7.23 vs Pressflow 7
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc
index d27f8d1..44f3c72 100644
--- a/includes/bootstrap.inc
+++ b/includes/bootstrap.inc
@@ -717,6 +717,22 @@ function drupal_settings_initialize() {
}
$is_https = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on';
+ // Load environmental config, if present.
+ if (isset($_SERVER['PRESSFLOW_SETTINGS'])) {
+ $pressflow_settings = json_decode($_SERVER['PRESSFLOW_SETTINGS'], TRUE);
+ foreach ($pressflow_settings as $key => $value) {
+ // One level of depth should be enough for $conf and $database.
+ if ($key == 'conf') {
+ foreach($value as $conf_key => $conf_value) {
+ $conf[$conf_key] = $conf_value;
+ }
+ }
+ else {
+ $$key = $value;
+ }
+ }
+ }
+
if (isset($base_url)) {
// Parse fixed base URL from settings.php.
$parts = parse_url($base_url);
@@ -2428,6 +2444,17 @@ function _drupal_bootstrap_database() {
function _drupal_bootstrap_variables() {
global $conf;
+ // Pressflow Smart Start
+ if (!empty($GLOBALS['databases']) && variable_get('pressflow_smart_start', FALSE)) {
+ try {
+ $result = db_query('SELECT s.name FROM {system} s WHERE s.name = :name', array(':name' => 'system'));
+ } catch (Exception $e) {
+ // Redirect to the installer if an essential table is missing.
+ include_once DRUPAL_ROOT . '/includes/install.inc';
+ install_goto('install.php');
+ }
+ }
+
// Initialize the lock system.
require_once DRUPAL_ROOT . '/' . variable_get('lock_inc', 'includes/lock.inc');
lock_initialize();
diff --git a/includes/common.inc b/includes/common.inc
index 262e1c5..b0b8cba 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -3558,7 +3558,7 @@ function drupal_build_css_cache($css) {
$uri = $map[$key];
}
- if (empty($uri) || !file_exists($uri)) {
+ if (empty($uri) || !drupal_aggregated_file_exists($uri)) {
// Build aggregate CSS file.
foreach ($css as $stylesheet) {
// Only 'file' stylesheets can be aggregated.
@@ -4896,6 +4896,20 @@ function drupal_add_tabledrag($table_id, $action, $relationship, $group, $subgro
drupal_add_js($settings, 'setting');
}
+function drupal_aggregated_file_exists($uri) {
+ if (function_exists('apc_fetch')) {
+ $exists = apc_fetch('file_exists_' . $uri);
+ if (!$exists && file_exists($uri)) {
+ $exists = TRUE;
+ apc_store('file_exists_' . $uri, TRUE, 86400);
+ }
+ }
+ else {
+ $exists = file_exists($uri);
+ }
+ return $exists;
+}
+
/**
* Aggregates JavaScript files into a cache file in the files directory.
*
@@ -4935,7 +4949,7 @@ function drupal_build_js_cache($files) {
$uri = $map[$key];
}
- if (empty($uri) || !file_exists($uri)) {
+ if (empty($uri) || !drupal_aggregated_file_exists($uri)) {
// Build aggregate JS file.
foreach ($files as $path => $info) {
if ($info['preprocess']) {
@@ -4943,6 +4957,10 @@ function drupal_build_js_cache($files) {
$contents .= file_get_contents($path) . ";\n";
}
}
+
+ // Allow modules to act on the js_cache before writing to disk.
+ drupal_alter('js_cache', $contents);
+
// Prefix filename to prevent blocking by firewalls which reject files
// starting with "ad*".
$filename = 'js_' . drupal_hash_base64($contents) . '.js';
diff --git a/modules/system/system.api.php b/modules/system/system.api.php
index 2c529d4..3781166 100644
--- a/modules/system/system.api.php
+++ b/modules/system/system.api.php
@@ -747,6 +747,26 @@ function hook_js_alter(&$javascript) {
}
/**
+ * Perform necessary alterations to the concatenated JavaScript before it is
+ * presented on the page.
+ *
+ * @param $contents
+ * A string of the concatenated JavaScript.
+ *
+ * @see drupal_build_js_cache()
+ */
+function hook_js_cache_alter(&$contents) {
+ $header = <<<HEADER
+/**
+ * Powered by Pressflow
+ * http://pressflow.org
+ */
+HEADER;
+
+ $contents = $header . "\n" . $contents;
+}
+
+/**
* Registers JavaScript/CSS libraries associated with a module.
*
* Modules implementing this return an array of arrays. The key to each
diff --git a/sites/default/default.settings.php b/sites/default/default.settings.php
index 40f552e..279dd69 100644
--- a/sites/default/default.settings.php
+++ b/sites/default/default.settings.php
@@ -551,3 +551,13 @@ $conf['404_fast_html'] = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"
* Remove the leading hash signs to disable.
*/
# $conf['allow_authorize_operations'] = FALSE;
+
+/**
+ * Smart start:
+ *
+ * If you would prefer to be redirected to the installation system when a
+ * valid settings.php file is present but no tables are installed, remove
+ * the leading hash sign below.
+ */
+# $conf['pressflow_smart_start'] = TRUE;
+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment