Skip to content

fix update to remove shares where file doesn't exist on postgres - #6016

Closed
jmcclelland wants to merge 7 commits into
owncloud:masterfrom
jmcclelland:update-shares-postgres
Closed

jmcclelland wants to merge 7 commits into
owncloud:masterfrom
jmcclelland:update-shares-postgres

Conversation

@jmcclelland

Copy link
Copy Markdown
Contributor

Without patch, breaks with: Failed to upgrade "files_sharing".
Exception="SQLSTATE[22P02]: Invalid text representation: 7 ERROR:
invalid input syntax for integer: "5,179""

See: #5758

Without patch, breaks with: Failed to upgrade "files_sharing".
Exception="SQLSTATE[22P02]: Invalid text representation: 7 ERROR:
invalid input syntax for integer: "5,179""

See: owncloud#5758
@ghost

ghost commented Nov 24, 2013

Copy link
Copy Markdown

Can one of the admins verify this patch?

@DeepDiver1975

Copy link
Copy Markdown
Contributor

@jmcclelland Thanks a lot for your contribution!
Contributions to the core repo require a signed contributors agreement http://owncloud.org/about/contributor-agreement/

Alternatively you can add a comment here where you state that this contribution is MIT licensed.

@DeepDiver1975

Copy link
Copy Markdown
Contributor

This patch requires tests on ALL supported databases (sqlite, mysql, postgres, Oracle and mssql).

Best would be to have a unit test covering this code piece

@ghost

ghost commented Nov 24, 2013

Copy link
Copy Markdown

@jmcclelland

Copy link
Copy Markdown
Contributor Author

My contribution in is MIT licensed

@karlitschek

Copy link
Copy Markdown
Contributor

Looks good. 👍 @schiesbn @bantu What do you think?

@bantu

bantu commented Nov 28, 2013

Copy link
Copy Markdown

Not sure whether we support subqueries.

Comment thread apps/files_sharing/appinfo/update.php Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The delete query should be using the primary key, i.e. id.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This line is way too long. Even too long to do a proper review.

@karlitschek

Copy link
Copy Markdown
Contributor

@jmcclelland Any chance this can be done without subqueries? Thanks

@MorrisJobke

Copy link
Copy Markdown
Contributor

@karlitschek Just for interest: Why aren't we support subqueries?

@karlitschek

Copy link
Copy Markdown
Contributor

@kabum It has to work with all databases. I'm fine if it works everywhere but I'm not sure at the moment. :-)

@jmcclelland

Copy link
Copy Markdown
Contributor Author

I've never spent so much time on a one line patch that I didn't even write :).

Well, I've committed a fix with shorter lines and no sub-queries, however, it hasn't been properly tested.

Comment thread apps/files_sharing/appinfo/update.php Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Closing ) in string here.

@karlitschek

Copy link
Copy Markdown
Contributor

@schiesbn Can you have a look?

Comment thread apps/files_sharing/appinfo/update.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.

This need to be:

$findShares = \OC_DB::prepare('SELECT `*PREFIX*share`.`id` ' .

@DeepDiver1975

Copy link
Copy Markdown
Contributor

This patch requires tests on ALL supported databases (sqlite, mysql, postgres, Oracle and mssql).

Best would be to have a unit test covering this code piece

The only way to make sure this code is properly working is a unit test - as suggested many times.

Comment thread apps/files_sharing/appinfo/update.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.

need to be:

$result = $removeShares->execute(array($share['id']));

@schiessle

Copy link
Copy Markdown
Contributor

@jmcclelland Upgrade works fine with the changes mentioned by @bantu and me. Can you update your branch, so that we can merge your changes? Thanks!

@jmcclelland

Copy link
Copy Markdown
Contributor Author

All changes have been committed except the unit test. Unfortunately I don't have time to write a unit test but would welcome someone else to do it.

@julienfastre

Copy link
Copy Markdown

Hi,

I think unit test are a good practice.

However, I encountered the problem this pull request should avoid. I applied the changes and this saved my life :-)

I have a Postgresq install (version 9.1) + apache 2.4 and php 5.5. I was migrating from 5.0.14 to 6.0.1 when I had problem : "the migration of fail_sharing failed".

MorrisJobke pushed a commit that referenced this pull request Feb 19, 2014
Without patch, breaks with: Failed to upgrade "files_sharing".
Exception="SQLSTATE[22P02]: Invalid text representation: 7 ERROR:
invalid input syntax for integer: "5,179""

See: #5758

removing unnecessary cruft - no parameter is set, none to pass.

#5758

removing subquery, making more readable

See: #6016 (comment)

parameters to sql calls should be arrays

#6016

boosting version to ensure fix gets executed

properly escaping the sql select statement

removing extraneous closing paren.
@schiessle

Copy link
Copy Markdown
Contributor

@jmcclelland Thanks for contributing this fix! We moved to commits over to #7293 so that we can add some unit tests and merge it.

@schiessle schiessle closed this Feb 28, 2014
MorrisJobke pushed a commit that referenced this pull request Mar 13, 2014
Without patch, breaks with: Failed to upgrade "files_sharing".
Exception="SQLSTATE[22P02]: Invalid text representation: 7 ERROR:
invalid input syntax for integer: "5,179""

See: #5758

removing unnecessary cruft - no parameter is set, none to pass.

#5758

removing subquery, making more readable

See: #6016 (comment)

parameters to sql calls should be arrays

#6016

boosting version to ensure fix gets executed

properly escaping the sql select statement

removing extraneous closing paren.
@lock lock Bot locked as resolved and limited conversation to collaborators Aug 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants