Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fork error #215

Closed
wants to merge 91 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
f3edf1a
Make the description a bit more accurate
abrain Jul 16, 2020
1c879bc
Convert any post, that is linked to a vehicle as a page ID, to a perm…
abrain Jul 16, 2020
1caa690
Show the post title if the external URL is indeed from this site
abrain Jul 16, 2020
7de3329
Only allow pages to be linked with vehicles by their ID. Change the P…
abrain Jul 16, 2020
2c45c04
Leave the column for UrlInput empty if the url is empty
abrain Jul 16, 2020
b913f48
Add the possibility to link pages or URLs with units for more informa…
abrain Jul 17, 2020
bb30f1d
Add a placeholder for the end time of an incident, closes #190
abrain Jul 17, 2020
2d4f575
Enable the %yearArchive% placeholder to be used in the footer templat…
abrain Jul 17, 2020
402cae0
Stop writing the current version to the database
abrain Jul 17, 2020
7af3a84
Minor naming change
abrain Jul 17, 2020
f2d79bf
Prepare for release
abrain Jul 17, 2020
aac02e1
Translated readme.txt into English
abrain Jul 18, 2020
e86bbe8
Keep the original german name for the plugin for now
abrain Jul 18, 2020
0a695fc
Bump stable tag to 1.7.0
abrain Jul 18, 2020
613c5be
Remove relations between Reports and Units when a Unit gets deleted, …
abrain Sep 23, 2020
1585663
Test against the most recent patches
abrain Sep 23, 2020
c35cac8
Add a weight to reports, so they can represent more than one incident…
abrain Sep 28, 2020
e1995ec
Version 1.7.1
abrain Sep 28, 2020
0139690
Let the Shortcode reportcount account for the weight of reports, fixe…
abrain Oct 12, 2020
caf647c
Add aria-current attribute if link leads to the currently displayed p…
abrain Oct 14, 2020
de5f06e
Fix the test for the [einsatzjahre] shortcode
abrain Oct 14, 2020
a99a74e
Improve code style and update the check for permalink collision in th…
abrain Oct 15, 2020
490bb56
Fix a bug where the incident numbers would not have been correctly up…
abrain Oct 15, 2020
1ec095d
Show sequential number as a range if the report represents more than …
abrain Oct 15, 2020
d2ad428
Version 1.7.2
abrain Oct 15, 2020
ccf92cd
Update dependencies
abrain Nov 4, 2020
f307154
Update to PHPUnit 6
abrain Nov 4, 2020
234836d
Use namespaced version
abrain Nov 4, 2020
b196d78
Bump WordPress requirement to 5.1 so we can enforce a minimum PHP ver…
abrain Nov 4, 2020
5be6c50
Test against the most recent patches
abrain Nov 4, 2020
caeebfd
Try to bump the minimum PHP version to 7.1
abrain Nov 4, 2020
f8e2653
Force the dependencies to be compatible with PHP 7.1
abrain Nov 4, 2020
4ff0c25
Officially bump the PHP minimum to 7.1
abrain Nov 4, 2020
8604464
Try to run the tests on PHP 7.4 unless defined otherwise
abrain Nov 4, 2020
bf63178
Update to PHPUnit 7
abrain Nov 4, 2020
a1a76b8
Run the tests on PHP 7.3 unless defined otherwise, as PHP 7.4 is only…
abrain Nov 4, 2020
743f3a7
Remove unused files
abrain Nov 5, 2020
beb2c70
Update PHPMD config
abrain Nov 5, 2020
0b74e05
Update config file to PHPUnit 7.5 schema and remove redundant attributes
abrain Nov 5, 2020
ccf573d
Pin xdebug to version 2 as long as PHPUnit 7 is used
abrain Jan 2, 2021
1514cef
Use the latest WordPress version as default
abrain Jan 2, 2021
4de7794
Uninstall the existing xdebug first
abrain Jan 2, 2021
f33b1ec
Fix coverage reporting
abrain Jan 3, 2021
bbc4834
Use full class name in callable
abrain Jan 13, 2021
822397f
Use fixed values in migrations
abrain Jan 13, 2021
a0f9f56
Register the Units as a taxonomy and adjust all related functions
abrain Jan 13, 2021
d8ae04f
Fix integration tests
abrain Jan 13, 2021
6131b36
Remove forgotten code
abrain Jan 14, 2021
86d67b8
Add data structure update and data migration background job
abrain Jan 15, 2021
e20d34c
Update Brain Monkey
abrain Jan 15, 2021
c8e322b
Add test for update and add missing functionality
abrain Jan 15, 2021
b0bb99c
Add test for data migration job
abrain Jan 15, 2021
136f2ef
Restructure data migration job
abrain Jan 15, 2021
1fdeb73
Minor code tweaks
abrain Jan 16, 2021
e8b3391
Increase the number of reports being processed per batch to 50
abrain Jan 16, 2021
1f14684
Make shortcodes with units backwards compatible by translating the un…
abrain Jan 21, 2021
f2a8617
Add test for reportcount shortcode
abrain Jan 21, 2021
922f1e5
Stop the block editor from showing the UI for Units
abrain Jan 21, 2021
ffa4567
Update the Unit IDs in the widgets if configured
abrain Jan 21, 2021
dd247a0
Remove obsolete capabilities for Units
abrain Jan 21, 2021
cf7dbbd
Adjust test for the fact that the Units do not have their own capabil…
abrain Jan 21, 2021
e443682
If no values of a taxonomy with custom UI have been selected, explici…
abrain Jan 21, 2021
c7b1e81
Update type hints
abrain Jan 21, 2021
5a3956b
Code style
abrain Jan 22, 2021
f4ed5d6
Enable the shortcode reportcount to filter by report status (actual e…
abrain Jan 22, 2021
900a68e
Templates: Add tag for featured image thumbnail
abrain Jan 22, 2021
6b328d5
Rewrite and enhance test for shortcode einsatzliste
abrain Jan 23, 2021
3546f2a
Pass the value directly, because the key always exists
abrain Jan 23, 2021
5a12b44
Enhance the ReportQuery and the shortcodes einsatzliste and reportcou…
abrain Jan 23, 2021
37e61d1
Add type definitions
abrain Jan 25, 2021
789ac96
Allow terms of the einsatzart taxonomy (incident type / incident cate…
abrain Jan 26, 2021
b29012e
Declare compatibility with WordPress 5.6
abrain Jan 26, 2021
3a2c008
Remove the social network that shall not be named
abrain Jan 26, 2021
aa705bd
Hide the selector for the parent term when creating a term for the ei…
abrain Jan 27, 2021
98bb762
Internationalization #136
abrain Jan 27, 2021
94ff070
Hide the selector for the parent term when creating a term for the fa…
abrain Jan 27, 2021
fa869b2
Remove the social network that shall not be named
abrain Jan 27, 2021
1bb2dde
Archived change log for 1.6.x
abrain Jan 27, 2021
eb80845
Prepare for release
abrain Jan 27, 2021
d3eca37
Rename new shortcode attribute to match taxonomy name
abrain Jan 28, 2021
4d9b06d
Bump stable tag
abrain Jan 28, 2021
3bd1e76
Move integration test for reports into the proper folder
abrain Jan 28, 2021
b8d215b
Don't test all the versions between the minimum requirement and the l…
abrain Jan 28, 2021
3ae05a0
The minimum requirement test should also test the minimum WordPress v…
abrain Jan 28, 2021
dbc1f48
Test for PHP 8.0 compatibility
abrain Jan 28, 2021
3e689a1
Update dependencies
abrain Jan 28, 2021
68cb3e1
Don't pass an object when it's not needed
abrain Jan 28, 2021
b2cf12a
Properly reference the class in callables instead of using a string
abrain Jan 28, 2021
caee826
Move unit tests into the unit tests folder
abrain Jan 29, 2021
dc3db50
Use the real object instead of mocking it, hopefully fixes tests with…
abrain Jan 29, 2021
657cde8
Merge branch 'develop' into develop
wackerm Jan 30, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Convert any post, that is linked to a vehicle as a page ID, to a perm…
…alink in the 'external URL' field
  • Loading branch information
abrain authored and wackerm committed Jan 30, 2021
commit 1c879bc2940455df06676ae55cd01f563d35ad1d
2 changes: 1 addition & 1 deletion src/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class Core
{
const VERSION = '1.6.7';
const DB_VERSION = 41;
const DB_VERSION = 50;

/**
* Statische Variable, um die aktuelle (einzige!) Instanz dieser Klasse zu halten
Expand Down
38 changes: 38 additions & 0 deletions src/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@

use WP_Error;
use wpdb;
use function delete_term_meta;
use function error_log;
use function get_permalink;
use function get_post_type;
use function get_term_meta;
use function update_option;
use function update_term_meta;

/**
*
Expand Down Expand Up @@ -75,6 +82,10 @@ public function doUpdate($currentDbVersion, $targetDbVersion)
if ($currentDbVersion < 41 && $targetDbVersion >= 41) {
$this->upgrade162();
}

if ($currentDbVersion < 50 && $targetDbVersion >= 50) {
$this->upgrade170();
}
}

/**
Expand Down Expand Up @@ -407,6 +418,33 @@ private function upgrade162()
update_option('einsatzvw_db_version', 41);
}

private function upgrade170()
{
global $wpdb;

/**
* From now on only pages should be stored in the fahrzeugpid term meta (as it used to be). All other post types
* should utilize the new 'external URL' term meta.
*/
$termIds = $wpdb->get_col("SELECT term_id FROM $wpdb->termmeta WHERE meta_key = 'fahrzeugpid' AND `meta_value` != '' AND term_id IN (SELECT term_id FROM $wpdb->term_taxonomy WHERE taxonomy = 'fahrzeug')");
foreach ($termIds as $termId) {
$postId = get_term_meta($termId, 'fahrzeugpid', true);
if (empty($postId) || get_post_type($postId) === 'page') {
// Either there is nothing to convert or it's a page (pages are the only post types to remain)
continue;
}

// Move anything that is not a page to the 'external URL' field
$permalink = get_permalink($postId);
if ($permalink !== false) {
update_term_meta($termId, 'vehicle_exturl', $permalink);
}
delete_term_meta($termId, 'fahrzeugpid');
}

update_option('einsatzvw_db_version', 50);
}

/**
* Fügt einen Bezeichner für eine Admin Notice der Liste der noch anzuzeigenden Notices hinzu
*
Expand Down
43 changes: 43 additions & 0 deletions tests/integration/UpgradeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@

use WP_UnitTestCase;
use wpdb;
use function get_permalink;
use function get_term_meta;
use function is_wp_error;
use function update_option;
use function update_term_meta;
use function wp_create_term;
use function wp_insert_post;

/**
* Class UpgradeTest
Expand Down Expand Up @@ -401,4 +408,40 @@ public function testUpgrade162WithTemplate()
$this->runUpgrade(40, 41);
$this->assertTrue('' === get_option('einsatzverwaltung_report_contentifempty'));
}

public function testUpgrade170ConvertPageIdToUrl()
{
// Create some terms for testing
$vehicle1 = wp_create_term('Test Vehicle 1', 'fahrzeug');
$vehicle1Id = $vehicle1['term_id'];
$vehicle2 = wp_create_term('Test Vehicle 2', 'fahrzeug');
$vehicle2Id = $vehicle2['term_id'];
$postTag = wp_create_term('Some tag');
$tagId = $postTag['term_id'];

// Create some test posts/pages and associate them with the terms
$post1Id = wp_insert_post(array('post_type' => 'post', 'post_title' => 'Some post'), true);
$pageId = wp_insert_post(array('post_type' => 'page', 'post_title' => 'Some page'), true);
$post2Id = wp_insert_post(array('post_type' => 'post', 'post_title' => 'Another post'), true);
if (is_wp_error($post1Id) || is_wp_error($pageId) || is_wp_error($post2Id)) {
$this->fail('Could not create posts');
}
update_term_meta($vehicle1Id, 'fahrzeugpid', $post1Id);
update_term_meta($vehicle2Id, 'fahrzeugpid', $pageId);
update_term_meta($tagId, 'fahrzeugpid', $post2Id);

$this->runUpgrade(41, 50);

// Check that the associated post got moved to the external URL field
$this->assertEmpty(get_term_meta($vehicle1Id, 'fahrzeugpid', true));
$this->assertEquals(get_permalink($post1Id), get_term_meta($vehicle1Id, 'vehicle_exturl', true));

// Check that the associated page stayed as it was
$this->assertEquals($pageId, get_term_meta($vehicle2Id, 'fahrzeugpid', true));
$this->assertEmpty(get_term_meta($vehicle2Id, 'vehicle_exturl', true));

// Check that another taxonomy term with the same term meta did not get changed
$this->assertEquals($post2Id, get_term_meta($tagId, 'fahrzeugpid', true));
$this->assertEmpty(get_term_meta($tagId, 'vehicle_exturl', true));
}
}