summaryrefslogtreecommitdiff
path: root/includes/bootstrap.inc
diff options
context:
space:
mode:
authorDavid Rothstein <drothstein@gmail.com>2015-03-30 00:46:00 -0400
committerDavid Rothstein <drothstein@gmail.com>2015-03-30 00:46:00 -0400
commitbe97f50fba4c7c87b4332d30cf8e0f612b89bdb5 (patch)
treea25676e1073a0dafaa3abc0534b77c42b49dab74 /includes/bootstrap.inc
parentea48131869663312ab598d281197bc96bc8c1ac7 (diff)
downloadbrdo-be97f50fba4c7c87b4332d30cf8e0f612b89bdb5.tar.gz
brdo-be97f50fba4c7c87b4332d30cf8e0f612b89bdb5.tar.bz2
Issue #779482 by mikeytown2, sun, dalin, cam8001, segi, alexpott, Boobaa, Sweetchuck, jbrown, quicksketch: Installation failure when opcode cache is enabled
Diffstat (limited to 'includes/bootstrap.inc')
-rw-r--r--includes/bootstrap.inc31
1 files changed, 31 insertions, 0 deletions
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc
index 6a0ff7bc9..ac6fb143f 100644
--- a/includes/bootstrap.inc
+++ b/includes/bootstrap.inc
@@ -3511,3 +3511,34 @@ function drupal_check_memory_limit($required, $memory_limit = NULL) {
// - The memory limit is greater than the memory required for the operation.
return ((!$memory_limit) || ($memory_limit == -1) || (parse_size($memory_limit) >= parse_size($required)));
}
+
+/**
+ * Invalidates a PHP file from any active opcode caches.
+ *
+ * If the opcode cache does not support the invalidation of individual files,
+ * the entire cache will be flushed.
+ *
+ * @param string $filepath
+ * The absolute path of the PHP file to invalidate.
+ */
+function drupal_clear_opcode_cache($filepath) {
+ if (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 50300) {
+ // Below PHP 5.3, clearstatcache does not accept any function parameters.
+ clearstatcache();
+ }
+ else {
+ clearstatcache(TRUE, $filepath);
+ }
+
+ // Zend OPcache.
+ if (function_exists('opcache_invalidate')) {
+ opcache_invalidate($filepath, TRUE);
+ }
+ // APC.
+ if (function_exists('apc_delete_file')) {
+ // apc_delete_file() throws a PHP warning in case the specified file was
+ // not compiled yet.
+ // @see http://php.net/apc-delete-file
+ @apc_delete_file($filepath);
+ }
+}