Skip to content

Repair step to remove bogus expiration dates from non-link shares - #19132

Merged
PVince81 merged 3 commits into
masterfrom
sharing-removebogusexpirationdate
Oct 1, 2015
Merged

PVince81 merged 3 commits into
masterfrom
sharing-removebogusexpirationdate

Conversation

@PVince81

Copy link
Copy Markdown
Contributor

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)

@PVince81 PVince81 added this to the 8.2-current milestone Sep 17, 2015
@karlitschek

Copy link
Copy Markdown
Contributor

👍

Comment thread lib/repair/repairinvalidshares.php Outdated

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Contributor Author

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rullzer because it's broken: #19314

@nickvergessen

Copy link
Copy Markdown
Contributor

Looks good apart from the comment

@PVince81

Copy link
Copy Markdown
Contributor Author

Right, I wanted to run the OCI test locally

@DeepDiver1975
DeepDiver1975 force-pushed the sharing-removebogusexpirationdate branch from 171ce28 to 0e45fab Compare September 23, 2015 10:12
@DeepDiver1975

Copy link
Copy Markdown
Contributor

@PVince81 oracle doesn't like that:

Test\Repair\RepairInvalidShares::testRemoveExpirationDateForNonLinkShares
Doctrine\DBAL\Exception\InvalidFieldNameException: An exception occurred while executing 'INSERT INTO "oc_share" (share_type, share_with, uid_owner, item_type, item_source, item_target,file_source, file_target, permissions, stime, expiration, token) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' with params [0, "recipientuser1", "user1", "folder", 123, "\/123", 123, "\/test", 1, 1443004205, "2015-09-25 00:00:00", null]:

ORA-00904: "TOKEN": invalid identifier

/var/jenkins/workspace/core-ci-linux@2/database/oci/label/SLAVE/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractOracleDriver.php:48
/var/jenkins/workspace/core-ci-linux@2/database/oci/label/SLAVE/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php:116
/var/jenkins/workspace/core-ci-linux@2/database/oci/label/SLAVE/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:996
/var/jenkins/workspace/core-ci-linux@2/database/oci/label/SLAVE/lib/private/db/connection.php:203
/var/jenkins/workspace/core-ci-linux@2/database/oci/label/SLAVE/tests/lib/repair/repairinvalidshares.php:60

@PVince81

Copy link
Copy Markdown
Contributor Author

Yeah... I'll use the query builder instead and the proper operator...

@PVince81

Copy link
Copy Markdown
Contributor Author

I fixed the comparator, hoping it will work now with OCI.

@PVince81
PVince81 force-pushed the sharing-removebogusexpirationdate branch from b6929a9 to 5e6453f Compare September 23, 2015 16:06
@DeepDiver1975

Copy link
Copy Markdown
Contributor

still issues with oracle:

Test\Repair\RepairInvalidShares::testRemoveExpirationDateForNonLinkShares
Doctrine\DBAL\Exception\InvalidFieldNameException: An exception occurred while executing 'INSERT INTO "oc_share" (share_type, share_with, uid_owner, item_type, item_source, item_target,file_source, file_target, permissions, stime, expiration, token) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' with params [0, "recipientuser1", "user1", "folder", 123, "\/123", 123, "\/test", 1, 1443025757, "2015-09-25 00:00:00", null]:

ORA-00904: "TOKEN": invalid identifier

/var/jenkins/workspace/core-ci-linux/database/oci/label/SLAVE/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractOracleDriver.php:48
/var/jenkins/workspace/core-ci-linux/database/oci/label/SLAVE/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php:116
/var/jenkins/workspace/core-ci-linux/database/oci/label/SLAVE/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:996
/var/jenkins/workspace/core-ci-linux/database/oci/label/SLAVE/lib/private/db/connection.php:203
/var/jenkins/workspace/core-ci-linux/database/oci/label/SLAVE/tests/lib/repair/repairinvalidshares.php:60

Copy link
Copy Markdown
Contributor

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 😞

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gargglllllllbrlrlrlrlrl okay

Copy link
Copy Markdown
Contributor Author

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 🔮

@PVince81
PVince81 force-pushed the sharing-removebogusexpirationdate branch from 5e6453f to 884bc2f Compare September 24, 2015 08:52
@PVince81

Copy link
Copy Markdown
Contributor Author

Backticks added and squashed

Comment thread lib/repair/repairinvalidshares.php Outdated

Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Contributor Author

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.

@PVince81

Copy link
Copy Markdown
Contributor Author

Let me move this to the query builder

@PVince81
PVince81 force-pushed the sharing-removebogusexpirationdate branch from 884bc2f to 32f30e2 Compare September 24, 2015 10:46
@PVince81

Copy link
Copy Markdown
Contributor Author

Ok, I query buildered all the things, including the SQLs from the test case

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Contributor

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:

$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'];
}
}
🙈

Copy link
Copy Markdown
Contributor Author

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

@PVince81
PVince81 force-pushed the sharing-removebogusexpirationdate branch from 32f30e2 to 1bd7d97 Compare September 28, 2015 10:42
@PVince81

Copy link
Copy Markdown
Contributor Author

Replaced 'lastInsertId` with a select to get the id.

@PVince81

Copy link
Copy Markdown
Contributor Author

@nickvergessen @MorrisJobke tests are green now 😄

Copy link
Copy Markdown
Contributor

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

@MorrisJobke

Copy link
Copy Markdown
Contributor

Tested with a group share:

  • doesn't remove the share date on master
  • remove the share date on this branch

Beside my comment above 👍

@MorrisJobke
MorrisJobke force-pushed the sharing-removebogusexpirationdate branch from 1bd7d97 to 6aed476 Compare September 29, 2015 08:28
@nickvergessen

Copy link
Copy Markdown
Contributor

#19132 (comment) is still open @MorrisJobke

@icewind1991

Copy link
Copy Markdown
Contributor

Code looks good, agree with @nickvergessen about cleaning up before starting the test

@PVince81

Copy link
Copy Markdown
Contributor Author

Feel free to change it yourself. Busy fixing IE8 (unless you want to swap with me)

@nickvergessen
nickvergessen force-pushed the sharing-removebogusexpirationdate branch from 6aed476 to 8f2600a Compare October 1, 2015 06:32
@nickvergessen

Copy link
Copy Markdown
Contributor

Done and rebased

@PVince81

PVince81 commented Oct 1, 2015

Copy link
Copy Markdown
Contributor Author

@nickvergessen thanks

@PVince81

PVince81 commented Oct 1, 2015

Copy link
Copy Markdown
Contributor Author

👍 for @nickvergessen's changes, merging

PVince81 pushed a commit that referenced this pull request Oct 1, 2015
…date

Repair step to remove bogus expiration dates from non-link shares
@PVince81
PVince81 merged commit 64994fa into master Oct 1, 2015
@PVince81
PVince81 deleted the sharing-removebogusexpirationdate branch October 1, 2015 08:38
@lock lock Bot locked as resolved and limited conversation to collaborators Aug 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants