Skip to content

Commit

Permalink
Merge branch 'hotfix/1.3.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
abrain committed Apr 1, 2018
2 parents 7b1df93 + b82068e commit 19c70ef
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/Import/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@ public function import($source, $mapping)
$metaValues['einsatz_mannschaft'] = sanitize_text_field($metaValues['einsatz_mannschaft']);
}

if (empty($metaValues) || !array_key_exists('einsatz_special', $metaValues) || empty($metaValues['einsatz_special'])) {
$metaValues['einsatz_special'] = '0';
}

// Neuen Beitrag anlegen
$postId = wp_insert_post($insertArgs, true);
if (is_wp_error($postId)) {
Expand Down
4 changes: 2 additions & 2 deletions src/einsatzverwaltung-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
*/
class Core
{
const VERSION = '1.3.3';
const DB_VERSION = 20;
const VERSION = '1.3.4';
const DB_VERSION = 21;

/**
* Statische Variable, um die aktuelle (einzige!) Instanz dieser Klasse zu halten
Expand Down
25 changes: 25 additions & 0 deletions src/einsatzverwaltung-update.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ public function doUpdate($currentDbVersion, $targetDbVersion)
if ($currentDbVersion < 20 && $targetDbVersion >= 20) {
$this->upgrade130();
}

if ($currentDbVersion < 21 && $targetDbVersion >= 21) {
$this->upgrade134();
}
}

/**
Expand Down Expand Up @@ -311,6 +315,27 @@ private function upgrade130()
update_option('einsatzvw_db_version', 20);
}

/**
* Adds a defined value (0) to the `special` annotation for all reports that did not have a value before
*
* @since 1.3.4
*/
private function upgrade134()
{
/** @var wpdb $wpdb */
global $wpdb;

$postIds = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_type = 'einsatz'");
$hasMetaKey = $wpdb->get_col("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = 'einsatz_special'");
$idsWithoutMetaKey = array_diff($postIds, $hasMetaKey);

foreach ($idsWithoutMetaKey as $id) {
add_post_meta($id, 'einsatz_special', 0, true);
}

update_option('einsatzvw_db_version', 21);
}

/**
* Fügt einen Bezeichner für eine Admin Notice der Liste der noch anzuzeigenden Notices hinzu
*
Expand Down
2 changes: 1 addition & 1 deletion src/einsatzverwaltung.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: Einsatzverwaltung
Plugin URI: https://einsatzverwaltung.abrain.de
Description: Verwaltung und Darstellung von Einsatzberichten der Feuerwehr und anderer Hilfsorganisationen
Version: 1.3.3
Version: 1.3.4
Author: Andreas Brain
Author URI: https://www.abrain.de
License: GPLv2
Expand Down
5 changes: 4 additions & 1 deletion src/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Tags: Feuerwehr, Hilfsorganisation, Öffentlichkeitsarbeit
Requires at least: 4.4.0
Tested up to: 4.9
Requires PHP: 5.3
Stable tag: 1.3.3
Stable tag: 1.3.4
License: GPLv2
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -72,6 +72,9 @@ Nein, mehr gibt es [hier](https://einsatzverwaltung.abrain.de/faq/).

== Changelog ==

= 1.3.4 =
* Fehler behoben, bei dem importierte Einsatzberichte, die nicht als besonders markiert waren, auf der Startseite angezeigt wurden, obwohl dort nur als besonders markierte auftauchen sollten

= 1.3.3 =
* Kompatibilit&auml;tsproblem mit "Page Builder by SiteOrigin" behoben
* Getestet mit WordPress 4.9
Expand Down
23 changes: 23 additions & 0 deletions tests/UpgradeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,4 +347,27 @@ public function testUpgrade130()
self::assertInternalType('array', get_option('einsatzverwaltung_admin_notices'));
self::assertContains('regenerateSlugs', get_option('einsatzverwaltung_admin_notices'));
}

public function testUpgrade134()
{
$reportFactory = new ReportFactory();
$reportIds = $reportFactory->create_many(5);
delete_post_meta($reportIds[1], 'einsatz_special');
delete_post_meta($reportIds[4], 'einsatz_special');
update_post_meta($reportIds[3], 'einsatz_special', 1);

self::assertEquals(0, get_post_meta($reportIds[0], 'einsatz_special', true));
self::assertEquals('', get_post_meta($reportIds[1], 'einsatz_special', true));
self::assertEquals(0, get_post_meta($reportIds[2], 'einsatz_special', true));
self::assertEquals(1, get_post_meta($reportIds[3], 'einsatz_special', true));
self::assertEquals('', get_post_meta($reportIds[4], 'einsatz_special', true));

$this->runUpgrade(20, 21);

self::assertEquals(0, get_post_meta($reportIds[0], 'einsatz_special', true));
self::assertEquals(0, get_post_meta($reportIds[1], 'einsatz_special', true));
self::assertEquals(0, get_post_meta($reportIds[2], 'einsatz_special', true));
self::assertEquals(1, get_post_meta($reportIds[3], 'einsatz_special', true));
self::assertEquals(0, get_post_meta($reportIds[4], 'einsatz_special', true));
}
}

0 comments on commit 19c70ef

Please sign in to comment.