Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hello !
Thanks you for this uselful module.
I am using PostgreSQL 8.
Under Views 3.3, if i try to use the countdown field, i obtain this message:
SQLSTATE[42883]: Undefined function: 7 ERROR: function unix_timestamp() does not exist LINE 1: ...e_entity_type, IF(unpublish_on AND unpublish_on > UNIX_TIMES... ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts.
I am not sure if PostgreSQL is the problem.
Comment | File | Size | Author |
---|---|---|---|
#12 | scheduler-1708488-postgres-12.patch | 1.41 KB | jonathan1055 |
Comments
Comment #1
jonathan1055 CreditAttribution: jonathan1055 commentedHi Jibus,
Is this still a problem for you? I've not had any experience with PostgreSQL databases, but it seems you are saying that the function unix_timestamp() is not implemented. I guess there must be an alternative, but this would usually be handled in Drupal's database abstraction layer.
If you are still getting this error, please re-open the issue and let us know what Drupal version you are running and what PostgreSQL version you have.
Thanks
Jonathan
Comment #2
jonathan1055 CreditAttribution: jonathan1055 commentedJust searched Drupal.org and this has been reported before:
#690322: Postgresql error: Function unix_timestamp() does not exist
#1538782: MySQL-specific unix_timestamp() is used in og_mailinglist.install
Seems that unix_timestamp() is a MySQL-specific function, and that PHP's time() is the preferred alternative which does the same thing. However, the actual line in scheduler_handler_field_scheduler_countdown.inc is within the query() function of the scheduler_handler_field_scheduler_countdown class.
Not sure how the php function would work here because it needs to be executed at run-time.
Comment #3
pmichelazzoHi people
Nobody with a solution for this problem? I have the same issue with the Scheduler module with PostgreSQL v9
Thanks
Comment #4
stefan.r CreditAttribution: stefan.r commentedFrom the Drupal docs:
Comment #5
stefan.r CreditAttribution: stefan.r commentedComment #7
stefan.r CreditAttribution: stefan.r commentedComment #8
stefan.r CreditAttribution: stefan.r commented4: scheduler-1708488-postgres-4.patch queued for re-testing.
Comment #9
jonathan1055 CreditAttribution: jonathan1055 commentedHi stefan.r
Thanks for your patch. I've been away for a few days, so not had chance to look at this yet. I will review it soon.
Jonathan
Comment #10
jonathan1055 CreditAttribution: jonathan1055 commentedThe change works fine. I tested the old and new countdowns in a the same view and they give the same result, apart from when the time was really near, when I noticed a one-second difference. But that does not matter at all.
I've only tested on MySQL, so if you confirm this works ok on PostgreSQL please mark the issue RTBC and I'll commit the change.
Jonathan
Comment #11
stefan.r CreditAttribution: stefan.r commentedThanks Jonathan, this patch actually didn't work on PostgreSQL as there was still an IF() statement.
Looks like time() is actually more accurate than REQUEST_TIME in this case as the user expects the countdown to be from when the page is displayed, not from when it's requested. So the 1 second difference should be gone now too :)
Revised patch attached, if you can test that one on MySQL as well we can RTBC this.
Comment #12
jonathan1055 CreditAttribution: jonathan1055 commentedI did not know that IF() is also not supported in PostgreSQL, so thanks for checking that. I have removed the '$time_field IS NOT NULL' check because '$time_field > now' should cater for that.
Regarding time() I think it is best to stick with REQUEST_TIME for two reasons: (a) better performance if a view has lots of scheduled nodes and (b) to be consistent across all the results within a view.
This patch works on MySQL - hopefully it will on PostgreSQL and you can mark it RTBC
Comment #13
stefan.r CreditAttribution: stefan.r commentedComment #15
jonathan1055 CreditAttribution: jonathan1055 commentedExcellent. Committed. 5649e31
Comment #16
pfrenssenGreat work, thanks!