You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Can't reshare link with default expiration date #11396
the other user can't reshare the folder with the "share link" option
When he clicks on "share link" nothing happens.
The log says:
{"app":"PHP","message":"Call to a member function format() on a non-object at /usr/share/php/Doctrine/DBAL/Types/DateTimeType.php#53","level":3,"time":"2014-10-02T13:04:14+00:00"}
Sharing an own folder (not share by another user) with the "share link" option works.
owncloud 7.0.2.1 (debian package 7.0.2+dfsg-1~bpo70+1)
with postgres
on debian 7.6
Now it's even more strange.
I reproduced your steps. Most of the time creating the link is now working but then the expiration date is not saved (even if expiration date is forced). In oc_share the column expiration is null.
The request to share.php is
action=share&itemType=folder&itemSource=3770&shareType=3&shareWith=&permissions=1&itemSourceName=admin-test&expirationDate=2014-10-14+00%3A00%3A00
I can reopen the share dialog and set the expiration date and it's saved (expiration in oc_share is "2014-10-09 00:00:00".
The request to share.php is
action=setExpirationDate&itemType=folder&itemSource=3770&date=2014-10-14+00%3A00%3A00
I still try to reproduce the behavior when creating the link is not working and check the expiration date in the request of share.php and in the oc_share. But now it seems like at least this error is gone.
I never realized that the date had a "+" in the URL, did you change anything in the server configuration / PHP modules ? Some people reported having issues with URLs with "+" inside.
That could explain the strange date format issues you were having if the server internally converts it to a " " or something...
I think the "+" is just how Firebug displays the parameters. When I copy the parameters from another part of Firebug it looks like this:
action share
expirationDate 2014-10-14 00:00:00
itemSource 17
itemSourceName gallery
itemType folder
permissions 1
shareType 3
shareWith
I havent't changed anything on php configs.
But I found the cause of the original issue (can't reshare link). It only appeared at exactly one of my shared folders. And this one has an expiration date in the oc_share ("2014-10-01 09:00:00"). I don't know how this could happen. I haven't changed anything in the database. After I set the expiration to null, creating a link works. It doesn't matter if the expiration date is in the past or in the future.
My system is now Debian 7.8, ownCloud 8.0.3 (stable), package owncloud_8.0.3-1_all.deb, updated several times from 7.0, Apache 2.2.22-13+deb7u4, MySQL 5.5.43-0+deb7u1, PHP 5.4.39-0+deb7u2. All are current versions from repositories.
Only activated apps: Activity, Deleted files, Share Files, Versions, Video Viewer. No external storages, encryption or LDAP, or other extended things.
The scenario seems to be more complex to me. I also digged the database and source to understand what happens, but didn't find a solution unfortunately.
User A creates a directory, puts some files into it and shares it to user B (or more specific users).
User B can reshare files and subdirectories, either to users/groups or by link. At this point it works ok. As I explain below, this step may be missing, but it happened in practice and it illustrates one side of the problem.
User A shares the same directory also by link with an expiration period. I don't think it matters, if it is a default or changed expiration time.
Then user A shares the same directory to user C. This seems to work ok, but…
When user C tries to re-share this directory or something in it by link, this does not work. Clicking on checkbox in a sharing window does not open the link field.
The last click produces an error in owncloud.log:
{"app":"PHP","message":"Call to a member function format() on a non-object at /var/www/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Types/DateTimeType.php#53","level":3,"time":"2015-05-06 14:31:41"}
And client browser gets 500 Internal Server Error in responce to AJAX request in response to POST /cloud/index.php/core/ajax/share.php .
I looked into oc_share to check the difference between step 2 (healthy) and step 4 (sick) shares, and found that step 2 gives expiration NULL, but step 4 sets expiration value from sharing in step 3 somehow. And this $value gets somehow to DataTimeType.php line 53, as string, where it is expected to be an object with method.
Seems to me that 'expiration' field is for link sharing only (share_type==3), according to UI behaviour. In this case bug happens when a non-null value comes with another share_type's.
I also noticed that in /var/www/owncloud/lib/private/share/share.php, line 2085 the expiration parameter is passed to SQL query in a different way, with an explict datatype. Possibly call to exception place in DateTimeType.php originates from this bindValue(). But I am not sure.
In my opinion, the bug comes from inheritance of 'expiration' from one share to another. Either it happens when it should not, or is implemented incorrectly.
By now I 'cured' my step 4 shares with a query:
update oc_share set expiration=NULL where id in (… sick share id's list…);
After that re-sharing by link starts working with them as expected. But this fixed only consequences, not the bug. I also instructed some most active users that sharing by link should be the last on a file or directory. Sharing to user after that may give strange results, so should be done before.
@popov-d thanks a lot for the detailed step. I was able to reproduce this on 8.1.1.
I noticed that whenever an expiration date exists, any local share created after that will have the expiration date set to the local share ! This is wrong as expiration date only applies for link shares.
By now I have version 8.1.1 and bug is still there. I wrote a small script that runs a sql update like in idea 3, and put it into /etc/cron.hourly/. Once a few days it updates 1 record instead of usual 0. No more complains from users.
Of course, it will be nice to have a working solution inside OC. Maybe with a fixing query inside upgrade procedure.
Just applied this to my installation. From user's point of view, bug is gone, resharing works even after link with expiration. Nothing bad in log. But in database oc_share.expiration is still set. Just seems not to break anything now.
I removed my update script from cron.hourly. Will try to run it this way and write if anything happens.
I'll write a repair step to auto-clean this column in future versions of OC.
With the patch above having the expiration date in that column should now be harmless.
Activity
karlitschek commentedon Oct 2, 2014
@schiesbn
PVince81 commentedon Oct 6, 2014
I tried the following steps in v7.0.2 with PostgreSQL:
It works for me.
Please provide more detailed steps.
Has this folder ever be shared with link before ?
PVince81 commentedon Oct 6, 2014
Please also post the matching content of the
oc_sharetable at the end of your steps to see in what format the potential date might appearnicman42 commentedon Oct 7, 2014
Now it's even more strange.
I reproduced your steps. Most of the time creating the link is now working but then the expiration date is not saved (even if expiration date is forced). In oc_share the column expiration is null.
The request to share.php is
action=share&itemType=folder&itemSource=3770&shareType=3&shareWith=&permissions=1&itemSourceName=admin-test&expirationDate=2014-10-14+00%3A00%3A00
I can reopen the share dialog and set the expiration date and it's saved (expiration in oc_share is "2014-10-09 00:00:00".
The request to share.php is
action=setExpirationDate&itemType=folder&itemSource=3770&date=2014-10-14+00%3A00%3A00
I still try to reproduce the behavior when creating the link is not working and check the expiration date in the request of share.php and in the oc_share. But now it seems like at least this error is gone.
PVince81 commentedon Oct 7, 2014
I never realized that the date had a "+" in the URL, did you change anything in the server configuration / PHP modules ? Some people reported having issues with URLs with "+" inside.
That could explain the strange date format issues you were having if the server internally converts it to a " " or something...
nicman42 commentedon Oct 7, 2014
I think the "+" is just how Firebug displays the parameters. When I copy the parameters from another part of Firebug it looks like this:
action share
expirationDate 2014-10-14 00:00:00
itemSource 17
itemSourceName gallery
itemType folder
permissions 1
shareType 3
shareWith
I havent't changed anything on php configs.
But I found the cause of the original issue (can't reshare link). It only appeared at exactly one of my shared folders. And this one has an expiration date in the oc_share ("2014-10-01 09:00:00"). I don't know how this could happen. I haven't changed anything in the database. After I set the expiration to null, creating a link works. It doesn't matter if the expiration date is in the past or in the future.
enoch85 commentedon Mar 5, 2015
@noooz Tried oC 8?
popov-d commentedon May 6, 2015
Seems I just got this bug.
My system is now Debian 7.8, ownCloud 8.0.3 (stable), package owncloud_8.0.3-1_all.deb, updated several times from 7.0, Apache 2.2.22-13+deb7u4, MySQL 5.5.43-0+deb7u1, PHP 5.4.39-0+deb7u2. All are current versions from repositories.
Only activated apps: Activity, Deleted files, Share Files, Versions, Video Viewer. No external storages, encryption or LDAP, or other extended things.
The scenario seems to be more complex to me. I also digged the database and source to understand what happens, but didn't find a solution unfortunately.
The last click produces an error in owncloud.log:
{"app":"PHP","message":"Call to a member function format() on a non-object at /var/www/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Types/DateTimeType.php#53","level":3,"time":"2015-05-06 14:31:41"}
And client browser gets 500 Internal Server Error in responce to AJAX request in response to POST /cloud/index.php/core/ajax/share.php .
I looked into oc_share to check the difference between step 2 (healthy) and step 4 (sick) shares, and found that step 2 gives expiration NULL, but step 4 sets expiration value from sharing in step 3 somehow. And this $value gets somehow to DataTimeType.php line 53, as string, where it is expected to be an object with method.
Seems to me that 'expiration' field is for link sharing only (share_type==3), according to UI behaviour. In this case bug happens when a non-null value comes with another share_type's.
I also noticed that in /var/www/owncloud/lib/private/share/share.php, line 2085 the expiration parameter is passed to SQL query in a different way, with an explict datatype. Possibly call to exception place in DateTimeType.php originates from this bindValue(). But I am not sure.
In my opinion, the bug comes from inheritance of 'expiration' from one share to another. Either it happens when it should not, or is implemented incorrectly.
By now I 'cured' my step 4 shares with a query:
update oc_share set expiration=NULL where id in (… sick share id's list…);
After that re-sharing by link starts working with them as expected. But this fixed only consequences, not the bug. I also instructed some most active users that sharing by link should be the last on a file or directory. Sharing to user after that may give strange results, so should be done before.
PVince81 commentedon Aug 18, 2015
@rullzer
PVince81 commentedon Sep 17, 2015
@popov-d thanks a lot for the detailed step. I was able to reproduce this on 8.1.1.
I noticed that whenever an expiration date exists, any local share created after that will have the expiration date set to the local share ! This is wrong as expiration date only applies for link shares.
This could be part of the problem.
PVince81 commentedon Sep 17, 2015
Simplified steps:
I tried master (the new share dialog) and it works properly because the new code doesn't send the expiration date for user shares.
Let's find out if preventing this for regular shared on OC 8.1 works
PVince81 commentedon Sep 17, 2015
Ok, here is the explanation for the failing "format()" call.
See this line here: https://github.com/owncloud/core/blob/master/lib/private/share/share.php#L2214
There is logic that copies the values from the parent share to the child share.
But here the parent share is a user share and NOT a link share, so the expiration date was not parsed and is still a string. So when the new share gets created, the DB cannot automatically convert the string to a date object, hence the "format()" error above.
Now the problem is that such parent share should not have an expiration date in the first place.
Some ideas to fix this:
update oc_share set expiration=null where expiration is not null and share_type != 3;(remove expiration date from DB for non-link shares): Repair step to remove bogus expiration dates from non-link shares #19132Feedback is welcome.
popov-d commentedon Sep 17, 2015
Would it be enough to set expirationDate only for link shares? Just add condition to that line:
By now I have version 8.1.1 and bug is still there. I wrote a small script that runs a sql update like in idea 3, and put it into /etc/cron.hourly/. Once a few days it updates 1 record instead of usual 0. No more complains from users.
Of course, it will be nice to have a working solution inside OC. Maybe with a fixing query inside upgrade procedure.
PVince81 commentedon Sep 17, 2015
@popov-d that could do, yes.
I'm currently trying to find the smallest low-impact fix that could be backported.
PVince81 commentedon Sep 17, 2015
Here is my fix: #19122
It's a bit better because it also prevents the OCS share API and other places to return the expiration date when it's not supposed to be there.
popov-d commentedon Sep 17, 2015
Just applied this to my installation. From user's point of view, bug is gone, resharing works even after link with expiration. Nothing bad in log. But in database oc_share.expiration is still set. Just seems not to break anything now.
I removed my update script from cron.hourly. Will try to run it this way and write if anything happens.
PVince81 commentedon Sep 17, 2015
@popov-d thanks for the confirmation.
I'll write a repair step to auto-clean this column in future versions of OC.
With the patch above having the expiration date in that column should now be harmless.
PVince81 commentedon Sep 17, 2015
Repair step here: #19132