-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Repair step to remove bogus expiration dates from non-link shares #19132
Conversation
👍 |
* though it is not supported. This functions removes the expiration date from such entries. | ||
*/ | ||
private function removeExpirationDateFromNonLinkShares() { | ||
$sql = 'UPDATE `*PREFIX*share` SET `expiration`=null WHERE `expiration` IS NOT null AND `share_type` != ?'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SQL syntax for unequal is <>
not !=
Most DBs understand !=
but you never know how long stares at oracle
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use the query builder?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right... I copy-pasted from the orphaned shares code that also didn't use the query builder
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good apart from the comment |
Right, I wanted to run the OCI test locally |
171ce28
to
0e45fab
Compare
@PVince81 oracle doesn't like that:
|
Yeah... I'll use the query builder instead and the proper operator... |
0e45fab
to
b6929a9
Compare
I fixed the comparator, hoping it will work now with OCI. |
b6929a9
to
5e6453f
Compare
still issues with oracle:
|
public function testRemoveExpirationDateForNonLinkShares() { | ||
$sql = | ||
'INSERT INTO `*PREFIX*share` ' . | ||
'(share_type, share_with, uid_owner, item_type, item_source, item_target,' . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fails on oracle, no quotes in sight 😞
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gargglllllllbrlrlrlrlrl okay
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We all work in the service of the mighty Oracle 🔮
5e6453f
to
884bc2f
Compare
Backticks added and squashed |
* though it is not supported. This functions removes the expiration date from such entries. | ||
*/ | ||
private function removeExpirationDateFromNonLinkShares() { | ||
$sql = 'UPDATE `*PREFIX*share` SET `expiration`=null WHERE `expiration` IS NOT null AND `share_type` <> ?'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now you reverted it back? No more query builder?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I never pushed the query builder here because it didn't work.
Now that you fixed it I can move the query builder version to this branch.
Let me move this to the query builder |
884bc2f
to
32f30e2
Compare
Ok, I query buildered all the things, including the SQLs from the test case |
|
||
$userShare = $results[0]; | ||
$linkShare = $results[1]; | ||
$this->assertEquals($bogusShareId, $userShare['id'], 'sanity check'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
13:08:16 1) Test\Repair\RepairInvalidShares::testRemoveExpirationDateForNonLinkShares
13:08:16 sanity check
13:08:16 Failed asserting that '1' matches expected false.
13:08:16
13:08:16 /var/jenkins/workspace/core-ci-linux@2/database/oci/label/SLAVE/tests/lib/repair/repairinvalidshares.php:100
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$bogusShareId = $this->connection->lastInsertId();
This seems to return false. @nickvergessen didn't you mention that this is tricky on oracle?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I knew it, found the code:
core/lib/private/share/share.php
Lines 2303 to 2317 in 1911472
$id = \OC::$server->getDatabaseConnection()->lastInsertId(); | |
// Fallback, if lastInterId() doesn't work we need to perform a select | |
// to get the ID (seems to happen sometimes on Oracle) | |
if (!$id) { | |
$getId = \OC_DB::prepare(' | |
SELECT `id` | |
FROM`*PREFIX*share` | |
WHERE `uid_owner` = ? AND `item_target` = ? AND `item_source` = ? AND `stime` = ? | |
'); | |
$r = $getId->execute(array($shareData['uidOwner'], $shareData['itemTarget'], $shareData['itemSource'], $shareData['shareTime'])); | |
if ($r) { | |
$row = $r->fetchRow(); | |
$id = $row['id']; | |
} | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks... ok I'll rewrite the test to not rely on the id
32f30e2
to
1bd7d97
Compare
Replaced 'lastInsertId` with a select to get the id. |
@nickvergessen @MorrisJobke tests are green now 😄 |
->execute() | ||
->fetchAll(); | ||
|
||
$this->assertCount(2, $results); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should delete all existing shares in setUp()
, to avoid problems when a previous test one day creates a share
Tested with a group share:
Beside my comment above 👍 |
1bd7d97
to
6aed476
Compare
#19132 (comment) is still open @MorrisJobke |
Code looks good, agree with @nickvergessen about cleaning up before starting the test |
Feel free to change it yourself. Busy fixing IE8 (unless you want to swap with me) |
6aed476
to
8f2600a
Compare
Done and rebased |
@nickvergessen thanks |
👍 for @nickvergessen's changes, merging |
…date Repair step to remove bogus expiration dates from non-link shares
To clean up the mess by the bug that existed pre-8.2: #11396
The new share dialog doesn't set the expiration date for user shares any more, so cleaning that up should be permanent (hence the version check)
@MorrisJobke @nickvergessen @schiesbn @DeepDiver1975
(8.2 only)