Files
piratepoet/lib/WP
Fred. P 5912004c10 Fix: CPU usage and sending issue on slow host
On some slow host, the `newsletter` table get filled with
duplicated `notification_history` marked as `sending` that
never get sent.

To prevent this we've made the two following changes:
* We prevent firing `publis_*` hooks on post_type which
are excluded from search.
* We do not schedule a new post notification email if one
has an `notification_history` entry marked as `sending`.

[MAILPOET-1371]
2018-05-10 15:25:23 +02:00
..
2018-03-20 16:30:28 -04:00

<?php
namespace MailPoet\WP;

class Readme {
  static function parseChangelog($readme_txt, $limit = null) {
    // Extract changelog section of the readme.txt
    preg_match('/== Changelog ==(.*?)(\n==|$)/is', $readme_txt, $changelog);

    if(empty($changelog[1])) {
      return false;
    }

    // Get changelog entries
    $entries = preg_split('/\n(?=\=)/', trim($changelog[1]), -1, PREG_SPLIT_NO_EMPTY);

    if(empty($entries)) {
      return false;
    }

    $c = 0;
    $changelog = array();

    foreach($entries as $entry) {
      // Locate version header and changes list
      preg_match('/=(.*?)=(.*)/s', $entry, $parts);

      if(empty($parts[1]) || empty($parts[2])) {
        return false;
      }

      $header = trim($parts[1]);
      $list = trim($parts[2]);

      // Get individual items from the list
      $list = preg_split('/(^|\n)[\* ]*/', $list, -1, PREG_SPLIT_NO_EMPTY);

      $changelog[] = array(
        'version' => $header,
        'changes' => $list,
      );

      if(++$c == $limit) {
        break;
      }
    }

    return $changelog;
  }
}