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.
Many backported modules may use REQUEST_TIME so we need to safely define it.
Comment | File | Size | Author |
---|---|---|---|
#1 | mongodb_define_request_time_1179402.patch | 262 bytes | crea |
Comments
Comment #1
crea CreditAttribution: crea commentedComment #2
fgmI think this does not belong in the MongoDB (sub)module(s) : this is a very generic part of D7, and any D7 backport/compatibility like DBTNG, autoload or QueueAPI might want to define it too: testing for defined() does not make us safe against what can happen if another module chooses to define it.
While the proper solution would probably be to have a generic "backport" module which all such inter-version modules should use and rely upon, the safest course until this actually happens (if ever) is probably to have our own module-specific constant.
Comment #3
crea CreditAttribution: crea commentedyou are right
Comment #4
crea CreditAttribution: crea commentedIt can be also argued that if another module blindly defines the constant without checking its error in that module. We can't control other modules, but we can behave ourselves atleast.
The whole point of keeping using the constant was to minimize code difference between 6 & 7.
Comment #5
fgmMaybe someone should create a "backports" project to house all these little things found in all D7 backport modules ?
Comment #6
crea CreditAttribution: crea commentedOk let's gather opinions then
Comment #7
crea CreditAttribution: crea commentedIt's also worth to note that constants should be defined very early in the bootstrap process (regardless of whether you are using specific backported code or not). Moving it to a dedicated backports module would require loading the module code somehow. I think that complicates the whole scenario, making using of if(defined()) checks more appealing.
Comment #8
crea CreditAttribution: crea commentedOk, I think it's much easier just to use $_SERVER['REQUEST_TIME'] than to waste time in debates.
I also think that having separate code bases is inevitable http://drupal.org/node/1089504#comment-4655694 so closing this.