Code Duplication    Length = 34-37 lines in 2 locations

lib/Command/FixUniqueId.php 1 location

@@ 72-108 (lines=37) @@
69
	}
70
71
72
	private function swapToShortenUniqueId() {
73
74
		$qb = $this->connection->getQueryBuilder();
75
76
		/** @noinspection PhpMethodParametersCountMismatchInspection */
77
		$qb->select('id', 'unique_id')
78
		   ->from(CoreRequestBuilder::TABLE_CIRCLES);
79
80
		$cursor = $qb->execute();
81
		while ($data = $cursor->fetch()) {
82
			$circleId = $data['id'];
83
84
			$shortenUniqueId = substr($data['unique_id'], 0, Circle::SHORT_UNIQUE_ID_LENGTH);
85
86
			$this->swapToShortenUniqueIdInTable(
87
				$circleId, $shortenUniqueId, CoreRequestBuilder::TABLE_GROUPS
88
			);
89
			$this->swapToShortenUniqueIdInTable(
90
				$circleId, $shortenUniqueId, CoreRequestBuilder::TABLE_LINKS
91
			);
92
//
93
//			$this->cleanBuggyDuplicateEntries(
94
//				$circleId, $shortenUniqueId, CoreRequestBuilder::TABLE_MEMBERS, 'user_id'
95
//			);
96
97
			$this->swapToShortenUniqueIdInTable(
98
				$circleId, $shortenUniqueId, CoreRequestBuilder::TABLE_MEMBERS
99
			);
100
101
			$this->swapToShortenUniqueIdInTable(
102
				$circleId, $shortenUniqueId, CoreRequestBuilder::TABLE_LINKS
103
			);
104
105
			$this->swapToShortenUniqueIdInShares($circleId, $shortenUniqueId);
106
		}
107
		$cursor->closeCursor();
108
	}
109
110
111
	private function swapToShortenUniqueIdInTable($circleId, $shortenUniqueId, $table) {

lib/Migration/UsingShortenUniqueIdInsteadOfCircleId.php 1 location

@@ 82-115 (lines=34) @@
79
	}
80
81
82
	private function swapToShortenUniqueId() {
83
84
		$qb = $this->connection->getQueryBuilder();
85
86
		/** @noinspection PhpMethodParametersCountMismatchInspection */
87
		$qb->select('id', 'unique_id')
88
		   ->from(CoreRequestBuilder::TABLE_CIRCLES);
89
90
		$cursor = $qb->execute();
91
		while ($data = $cursor->fetch()) {
92
			$circleId = $data['id'];
93
			$shortenUniqueId = substr($data['unique_id'], 0, Circle::SHORT_UNIQUE_ID_LENGTH);
94
95
			$this->swapToShortenUniqueIdInTable(
96
				$circleId, $shortenUniqueId, CoreRequestBuilder::TABLE_GROUPS
97
			);
98
			$this->swapToShortenUniqueIdInTable(
99
				$circleId, $shortenUniqueId, CoreRequestBuilder::TABLE_LINKS
100
			);
101
102
//			$this->cleanBuggyDuplicateEntries(
103
//				$circleId, $shortenUniqueId, CoreRequestBuilder::TABLE_MEMBERS, 'user_id'
104
//			);
105
			$this->swapToShortenUniqueIdInTable(
106
				$circleId, $shortenUniqueId, CoreRequestBuilder::TABLE_MEMBERS
107
			);
108
109
			$this->swapToShortenUniqueIdInTable(
110
				$circleId, $shortenUniqueId, CoreRequestBuilder::TABLE_LINKS
111
			);
112
			$this->swapToShortenUniqueIdInShares($circleId, $shortenUniqueId);
113
		}
114
		$cursor->closeCursor();
115
	}
116
117
118
	private function swapToShortenUniqueIdInTable($circleId, $shortenUniqueId, $table) {