Plugin Directory

Changeset 1046241


Ignore:
Timestamp:
12/16/2014 10:24:34 PM (11 years ago)
Author:
switzer
Message:

Update upgrade to only fix 10 posts at a time

Location:
advertising-manager/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • advertising-manager/trunk/advertising-manager.php

    r1045321 r1046241  
    77Author: Scott Switzer
    88Author URI: http://github.com/switzer
    9 Version: 3.5
     9Version: 3.5.1
    1010Text Domain: advman
    1111Domain Path: /languages
     
    3030
    3131
    32     define('ADVMAN_VERSION', '3.5');
     32    define('ADVMAN_VERSION', '3.5.1');
    3333    define('ADVMAN_PATH', dirname(__FILE__));
    3434    define('ADVMAN_LIB', ADVMAN_PATH . '/lib/Advman');
  • advertising-manager/trunk/deploy.txt

    r1045321 r1046241  
    3131    4.  In the readme file (Changelog)
    3232    5.  Upgrade Wordpress tested version in readme file (at the top)
    33     6.  in this build file (search for the version number 3.5 - there are a number of places in this file where the version exists)
     33    6.  in this build file (search for the version number 3.5.1 - there are a number of places in this file where the version exists)
    3434    7.  check the upgrade to make sure any version upgrades are correct
    3535
     
    4949- Tag the version in wordpress
    5050    cd ~/code/wordpress/advertising-manager
    51     svn cp trunk tags/3.5
    52     svn ci -m "tagging version 3.5"
     51    svn cp trunk tags/3.5.1
     52    svn ci -m "tagging version 3.5.1"
  • advertising-manager/trunk/lib/Advman/Upgrade.php

    r1045321 r1046241  
    1010        $version = Advman_Upgrade::_get_version($data);
    1111        Advman_Upgrade::_backup($data, $version);
    12         $versions = array('3.4', '3.4.2', '3.4.3', '3.4.7', '3.4.9', '3.4.12', '3.4.14', '3.4.15', '3.4.20', '3.4.25', '3.4.29', '3.5');
     12        $versions = array('3.4', '3.4.2', '3.4.3', '3.4.7', '3.4.9', '3.4.12', '3.4.14', '3.4.15', '3.4.20', '3.4.25', '3.4.29', '3.5.1');
    1313        foreach ($versions as $v) {
    1414            if (version_compare($version, $v, '<')) {
     
    3434    }
    3535
    36     static function advman_3_5(&$data)
     36    static function advman_3_5_1(&$data)
    3737    {
    3838        // Check to see if we need to migrate any old ad tags to new ad tags
     
    5050        );
    5151
    52         $args = array('numberposts' => -1, 'post_type' => array('post','page'), 'suppress_filters' => false);
    53         $posts = get_posts($args);
    5452        $found_posts = 0;
    5553        $found_ads = 0;
    56         foreach ($posts as $post) {
    57             $ad_found_in_post = false;
    58             if (!empty($post->post_content)) {
    59                 foreach ($patterns as $pattern) {
    60                     if (preg_match_all($pattern, $post->post_content, $matches)) {
    61                         if (!empty($matches[1])) {
    62                             for ($i=0; $i<sizeof($matches[1]); $i++) {
    63                                 $name = $matches[1][$i];
    64                                 $ad = Advman_Upgrade::_selectAd($data, $name);
    65                                 if (!$ad) {
    66                                     $name = html_entity_decode($name);
     54
     55        $offset = 0;
     56        $numberposts = 10;
     57
     58        $args = array('numberposts' => $numberposts, 'offset' => $offset, 'post_type' => array('post','page'), 'suppress_filters' => false);
     59        $posts = get_posts($args);
     60
     61        while ($posts) {
     62            foreach ($posts as $post) {
     63                $ad_found_in_post = false;
     64                if (!empty($post->post_content)) {
     65                    foreach ($patterns as $pattern) {
     66                        if (preg_match_all($pattern, $post->post_content, $matches)) {
     67                            if (!empty($matches[1])) {
     68                                for ($i=0; $i<sizeof($matches[1]); $i++) {
     69                                    $name = $matches[1][$i];
    6770                                    $ad = Advman_Upgrade::_selectAd($data, $name);
    68                                 }
    69                                 if (!$ad) {
    70                                     $name = str_replace(";","\\;",$name);
    71                                     $ad = Advman_Upgrade::_selectAd($data, $name);
    72                                 }
    73                                 if ($ad) {
    74                                     $found_ads++;
    75                                     if (!$ad_found_in_post) {
    76                                         $ad_found_in_post = true;
    77                                         $found_posts++;
     71                                    if (!$ad) {
     72                                        $name = html_entity_decode($name);
     73                                        $ad = Advman_Upgrade::_selectAd($data, $name);
     74                                    }
     75                                    if (!$ad) {
     76                                        $name = str_replace(";","\\;",$name);
     77                                        $ad = Advman_Upgrade::_selectAd($data, $name);
     78                                    }
     79                                    if ($ad) {
     80                                        $found_ads++;
     81                                        if (!$ad_found_in_post) {
     82                                            $ad_found_in_post = true;
     83                                            $found_posts++;
     84                                        }
    7885                                    }
    7986                                }
    80                             }
    81                         } else {
    82                             $found_ads++;
    83                             if (!$ad_found_in_post) {
    84                                 $ad_found_in_post = true;
    85                                 $found_posts++;
     87                            } else {
     88                                $found_ads++;
     89                                if (!$ad_found_in_post) {
     90                                    $ad_found_in_post = true;
     91                                    $found_posts++;
     92                                }
    8693                            }
    8794                        }
     
    8996                }
    9097            }
     98            $offset += $numberposts;
     99            $args = array('numberposts' => $numberposts, 'offset' => $offset, 'post_type' => array('post','page'), 'suppress_filters' => false);
     100            $posts = get_posts($args);
    91101        }
    92102        if ($found_ads) {
     
    116126        );
    117127
    118         $args = array('numberposts' => -1, 'post_type' => array('post','page'), 'suppress_filters' => false);
     128        $offset = 0;
     129        $numberposts = 10;
     130
     131        $args = array('numberposts' => $numberposts, 'offset' => $offset, 'post_type' => array('post','page'), 'suppress_filters' => false);
    119132        $posts = get_posts($args);
    120         foreach ($posts as $post) {
    121             if (!empty($post->post_content)) {
    122                 $post_content = $post->post_content;
    123                 foreach ($patterns as $pattern) {
    124                     if (preg_match_all($pattern, $post->post_content, $matches)) {
    125                         if (!empty($matches[1])) {
    126                             for ($i=0; $i<sizeof($matches[1]); $i++) {
    127                                 $name = $matches[1][$i];
    128                                 $ad = Advman_Upgrade::_selectAd($data, $name);
    129                                 if (!$ad) {
    130                                     $name = html_entity_decode($name);
     133
     134        while ($posts) {
     135            foreach ($posts as $post) {
     136                if (!empty($post->post_content)) {
     137                    $post_content = $post->post_content;
     138                    foreach ($patterns as $pattern) {
     139                        if (preg_match_all($pattern, $post->post_content, $matches)) {
     140                            if (!empty($matches[1])) {
     141                                for ($i = 0; $i < sizeof($matches[1]); $i++) {
     142                                    $name = $matches[1][$i];
    131143                                    $ad = Advman_Upgrade::_selectAd($data, $name);
     144                                    if (!$ad) {
     145                                        $name = html_entity_decode($name);
     146                                        $ad = Advman_Upgrade::_selectAd($data, $name);
     147                                    }
     148                                    if (!$ad) {
     149                                        $name = str_replace(";", "\\;", $name);
     150                                        $ad = Advman_Upgrade::_selectAd($data, $name);
     151                                    }
     152                                    if ($ad) {
     153                                        $search = $matches[0][$i];
     154                                        $replace = "[ad name=\"$name\"]";
     155                                        $post_content = str_replace($search, $replace, $post_content);
     156                                    }
    132157                                }
    133                                 if (!$ad) {
    134                                     $name = str_replace(";","\\;",$name);
    135                                     $ad = Advman_Upgrade::_selectAd($data, $name);
    136                                 }
    137                                 if ($ad) {
    138                                     $search = $matches[0][$i];
    139                                     $replace = "[ad name=\"$name\"]";
    140                                     $post_content = str_replace($search, $replace, $post_content);
    141                                 }
     158                            } else {
     159                                $search = str_replace("/", "", $pattern);
     160                                $replace = "[ad]";
     161                                $post_content = str_replace($search, $replace, $post_content);
    142162                            }
    143                         } else {
    144                             $search = str_replace("/","",$pattern);
    145                             $replace = "[ad]";
    146                             $post_content = str_replace($search, $replace, $post_content);
    147163                        }
    148                     }                }
    149                 if ($post->post_content != $post_content) {
    150                     $post->post_content = $post_content;
    151                     wp_update_post($post);
    152                 }
    153             }
     164                    }
     165                    if ($post->post_content != $post_content) {
     166                        $post->post_content = $post_content;
     167                        wp_update_post($post);
     168                    }
     169                }
     170            }
     171
     172            $offset += $numberposts;
     173            $args = array('numberposts' => $numberposts, 'offset' => $offset, 'post_type' => array('post','page'), 'suppress_filters' => false);
     174            $posts = get_posts($args);
    154175        }
    155176    }
  • advertising-manager/trunk/readme.txt

    r1045321 r1046241  
    55Requires at least: 2.5
    66Tested up to: 4.0.1
    7 Stable tag: 3.5
     7Stable tag: 3.5.1
    88License: GPLv2 or later
    99
     
    106106== Upgrade Notice ==
    107107
    108 = 3.5 =
    109 * Fixed shortcodes issue introduces with WP 4.0.1
    110 * Fixed messages that printed in debugging mode
    111 * Initial analytics screen
     108= 3.5.1 =
     109* Only update 10 posts at a time when upgrading shortcodes
    112110
    113111== Change Log ==
     112
     113= 3.5.1 =
     114* Only update 10 posts at a time when upgrading shortcodes
    114115
    115116= 3.5 =
Note: See TracChangeset for help on using the changeset viewer.