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

Behebe "Alle" Option verfügbar für CB Manager #1306

Draft
wants to merge 42 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
736e291
Changed none to "all" option for Restrictions
hansmorb Jul 9, 2023
3376208
Merge branch 'master' into bugfix/issue-1273
hansmorb Jul 12, 2023
e27dcb9
added tests for option sanitization and getting "All" option key
hansmorb Jul 12, 2023
c9f0a9e
fixed unit tests run unnecessarily
hansmorb Jul 12, 2023
2611930
Simplify comment
datengraben Aug 20, 2023
d529725
Add restriction migration
datengraben Aug 20, 2023
de24f14
Merge branch 'master' into bugfix/issue-1273
hansmorb Sep 19, 2023
245aa0c
Revert "Add restriction migration"
hansmorb Sep 20, 2023
9fdac64
added proper migration function #1273 and re-wrote upgrade methods
hansmorb Sep 20, 2023
c001356
added restriction validation upon post-save
hansmorb Sep 25, 2023
40594fb
fixed wrong constant used in some unit tests
hansmorb Sep 25, 2023
4b7825d
fixed expected returns for meta value "all" in all places
hansmorb Sep 25, 2023
3b0852e
added unit test for getByTimerange
hansmorb Sep 24, 2023
ad3c1b6
removed stuff left-over from cherry-pick
hansmorb Sep 25, 2023
d5395b6
merge master
hansmorb Oct 2, 2023
8d0c20a
only allow administrators to set restrictions for all items / locations
hansmorb Oct 2, 2023
c928e3b
only run validation upon publication of post
hansmorb Oct 2, 2023
4ea15f5
Merge branch 'master' into bugfix/issue-1273
hansmorb Oct 19, 2023
b8c67b8
Merge branch 'master' into bugfix/issue-1273
hansmorb Oct 22, 2023
402cd6f
safe-remove unused function after merge
hansmorb Oct 22, 2023
6cc8fc8
Merge branch 'master' into bugfix/issue-1273
hansmorb Oct 22, 2023
9766209
fixed var name for test
hansmorb Oct 22, 2023
161b5f5
fixed annotation
hansmorb Oct 26, 2023
e38ed95
re-added tests
hansmorb Oct 26, 2023
4905afc
added more annotations
hansmorb Oct 26, 2023
8fc4ef5
refactored filterPosts (removed support for empty item / location field)
hansmorb Oct 26, 2023
960b8d3
re-wrote upgrade methods
hansmorb Sep 21, 2023
ee75aab
removed test for function that does not exist (yet)
hansmorb Oct 26, 2023
0de13d1
Merge branch 'refactoring/upgrade' into bugfix/issue-1273
hansmorb Oct 26, 2023
e974b3d
removed function that has been moved
hansmorb Oct 26, 2023
70c9b12
Merge branch 'refactoring/upgrade' into bugfix/issue-1273
hansmorb Oct 26, 2023
88fedba
added task that we missed
hansmorb Oct 26, 2023
f20ef13
added PHPdocs
hansmorb Oct 26, 2023
2c4fbd6
fixed syntax for new installations
hansmorb Oct 26, 2023
dbfe232
added more comments
hansmorb Oct 26, 2023
fed0699
Fix phpcs issues on new file
datengraben Oct 27, 2023
8204702
removes import and adds type annotation
datengraben Oct 27, 2023
04f5310
Add comments/phpdoc
datengraben Oct 27, 2023
d1ddb09
Merge branch 'refactoring/upgrade' into bugfix/issue-1273
hansmorb Oct 27, 2023
eaff0e9
Merge branch 'master' into bugfix/issue-1273
hansmorb Oct 30, 2023
e388287
clean up changelist
hansmorb Oct 30, 2023
b4d3932
Merge branch 'master' into bugfix/issue-1273
hansmorb Jan 4, 2024
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
33 changes: 33 additions & 0 deletions src/Migration/Migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use CommonsBooking\Wordpress\CustomPostType\Item;
use CommonsBooking\Wordpress\CustomPostType\Location;
use CommonsBooking\Wordpress\CustomPostType\Timeframe;
use CommonsBooking\Wordpress\CustomPostType\CustomPostType;
use Exception;
use WP_Post;
use WP_Query;
Expand Down Expand Up @@ -61,6 +62,11 @@ public static function migrateAll() {
'complete' => 0,
'failed' => 0,
],
'restrictions' => [
'index' => 0,
hansmorb marked this conversation as resolved.
Show resolved Hide resolved
'complete' => 0,
'failed' => 0,
],
'bookingCodes' => [
'index' => 0,
'complete' => 0,
Expand Down Expand Up @@ -106,6 +112,10 @@ public static function migrateAll() {
'repoFunction' => 'getBookings',
'migrationFunction' => 'migrateBooking',
],
'restrictions' => [
'repoFunction' => 'getRestrictions',
'migrationFunction' => 'migrateRestriction',
],
'bookingCodes' => [
'repoFunction' => 'getBookingCodes',
'migrationFunction' => 'migrateBookingCode',
Expand Down Expand Up @@ -567,6 +577,29 @@ public static function migrateBooking( $booking ): bool {
return self::savePostData( $existingPost, $postData, $postMeta );
}

public static function migrateRestriction( $restriction ): bool {

// Nothing to change for migration
$postData = array();
// Nothing to change for migration
$postMeta = array();

$existingPost = self::getExistingPost( $restriction['id'], \CommonsBooking\Wordpress\CustomPostType\Restriction::$postType );

// Conditionally migrate
$restrictionItems = get_post_meta( $existingPost->ID, \CommonsBooking\Model\Restriction::META_ITEM_ID );
if ( empty( $restrictionItems) ) {
$postMeta[ \CommonsBooking\Model\Restriction::META_ITEM_ID ] = CustomPostType::SELECTION_ALL_POSTS;
}

$restrictionLocations = get_post_meta( $existingPost->ID, \CommonsBooking\Model\Restriction::META_LOCATION_ID );
if ( empty( $restrictionLocations) ) {
$postMeta[ \CommonsBooking\Model\Restriction::META_LOCATION_ID ] = CustomPostType::SELECTION_ALL_POSTS;
}

return self::savePostData( $existingPost, $postData, $postMeta );
}

/**
* Migrates CB1 Booking Code to CB2.
*
Expand Down