Skip to content

Instantly share code, notes, and snippets.

@peterchester
Created November 14, 2012 11:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterchester/4071534 to your computer and use it in GitHub Desktop.
Save peterchester/4071534 to your computer and use it in GitHub Desktop.
Postie 1.4.4 Patch #1
diff --git a/wp-content/plugins/postie/postie-functions.php b/wp-content/plugins/postie/postie-functions.php
index ddf4cd8daf8ed4bdeb30978733e472ea97d96abd..75a598b1b6f77cb47a612a3d39b53a115f14a1cb 100644
--- a/wp-content/plugins/postie/postie-functions.php
+++ b/wp-content/plugins/postie/postie-functions.php
@@ -1,11 +1,41 @@
<?php
-$revisions= WP_POST_REVISIONS;
-define('WP_POST_REVISIONS', false);
-//define('POSTIE_DEBUG', true);
-if (!ini_get('safe_mode')) {
- $original_mem_limit = ini_get('memory_limit');
- ini_set('memory_limit', -1);
- ini_set('max_execution_time', 300);
+
+function postie_disable_revisions( $restore = false ) {
+ global $_wp_post_type_features, $_postie_revisions;
+
+ if ( !$restore ) {
+ $_postie_revisions = false;
+ if ( isset( $_wp_post_type_features['post'] ) && isset( $_wp_post_type_features['post']['revisions'] ) ) {
+ $_postie_revisions = $_wp_post_type_features['post']['revisions'];
+ unset($_wp_post_type_features['post']['revisions']);
+ }
+ } else {
+ if ( $_postie_revisions ) {
+ $_wp_post_type_features['post']['revisions'] = $_postie_revisions;
+ }
+ }
+}
+
+function postie_increase_memory( $restore = false ) {
+ global $_postie_original_memory_limit, $_postie_original_max_execution_time;
+
+ if ( !ini_get('safe_mode') ) {
+ if ( !$restore ) {
+
+ $_postie_original_memory_limit = ini_get('memory_limit');
+ $_postie_original_max_execution_time = ini_get('max_execution_time');
+ ini_set('memory_limit', -1);
+ ini_set('max_execution_time', 300);
+
+ } else {
+ if ( isset($_postie_original_memory_limit) ) {
+ ini_set('memory_limit', $_postie_original_memory_limit);
+ }
+ if ( isset($_postie_original_max_execution_time) ) {
+ ini_set('max_execution_time', $_postie_original_max_execution_time);
+ }
+ }
+ }
}
//include_once (dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR."wp-admin" . DIRECTORY_SEPARATOR . "upgrade-functions.php");
@@ -42,6 +72,8 @@ if (!function_exists('fnmatch')) {
* This is the main handler for all of the processing
*/
function PostEmail($poster,$mimeDecodedEmail,$config) {
+ postie_disable_revisions();
+ postie_increase_memory();
extract($config);
$post_to_db=true;
@@ -200,6 +232,8 @@ function PostEmail($poster,$mimeDecodedEmail,$config) {
$recipients, false, false);
}
}
+ postie_disable_revisions( true );
+ postie_increase_memory( true );
}
/** FUNCTIONS **/
@@ -2582,9 +2616,4 @@ function VodafoneHandler(&$content, &$attachments){
}
}
-
-define('WP_POST_REVISIONS', $revisions);
-if (!ini_get('safe_mode')) {
- ini_set('memory_limit', $original_mem_limit);
-}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment