I created a content type. When a registered user enters content, everything is fine. When an anonymous user enters information, the content posts but I get the following:
Notice: Undefined property: stdClass::$timezone in rate_expiration_node_insert() (line 184 of /home/MySite/public_html/MySite.com/sites/all/modules/rate/expiration/rate_expiration.module).
184 $timezone = is_null($user->timezone) ? variable_get('date_default_timezone', 0) : $user->timezone;
185 if (!is_numeric($timezone)) {
186 // Convert textual timezone to numeric offset.
187 $timezone = new DateTimeZone($timezone);
188 $timezone = $timezone->getOffset(new DateTime('now', $timezone));
Note: Content type/Display settings set to "Don't display post information"
Does the code above account for an anonymous user(s)?
Rate 7.x-1.3
Drupal 7.10 - all modules up to date
Comment | File | Size | Author |
---|---|---|---|
#9 | rate-is_null_fix-1421016-9.patch | 1.65 KB | nicrodgers |
#1 | rate_expiration-timezone_notice-1421016-1.patch | 680 bytes | InternetDevels |
Comments
Comment #1
InternetDevels CreditAttribution: InternetDevels commentedThere is no timezone for anonymous user so to prevent notice isset() needed
Comment #2
xbrianx CreditAttribution: xbrianx commentedI am getting the same issue.
Comment #3
xbrianx CreditAttribution: xbrianx commentedI tried the patch but am still getting the notice on commerce checkouts
Comment #4
fabul CreditAttribution: fabul commentedBonjour,
Dans le fichier sites/all/modules/rate/expiration/rate_expiration.module
remplacer
$timezone = is_null($user->timezone) ? variable_get('date_default_timezone', 0) : $user->timezone;
Par
$timezone = (!isset($user->timezone)||is_null($user->timezone)) ? variable_get('date_default_timezone', 0) : $user->timezone;
Et le module fonctionnera mieux.
J'espère que cette solution permettra aux auteurs de corriger le module.
Comment #5
xbrianx CreditAttribution: xbrianx commentedThat replacement worked Kalamityjane
Comment #6
leymannx#4 worked! Even in French ;) Thank you.
Comment #7
DamienMcKenna@InternetDevels: Please set the issue status to "Needs review" when you upload a patch, that way people know that there's a patch that needs review. Only change the status to "Patch (to be ported)" when there's an existing patch for one branch that needs to be ported to another branch, e.g. if someone fixes a bug for 7.x-1.x and the patch needs to be backported to 6.x-1.x.
Comment #8
DamienMcKennaLets see if this can be tested against the current 7.x-1.x codebase.
Comment #9
nicrodgersI suggest changing is_null() to empty() as this handles the case where we have an empty string. (I had this whilst reacting on a commerce checkout rule).
Here's a patch that converts the three is_null($user->timezone) ifs to empty(), which seems to work for me.
Comment #10
brad.bulger CreditAttribution: brad.bulger commentedapplied the patch in 9 to 1.7 and it's working fine for me.
Comment #11
erwangel CreditAttribution: erwangel commentedPatch #9 applied to 1.7 working for me also. By the occasion, I think the test
$timezone = empty($user->timezone) ? variable_get('date_default_timezone', 0) : $user->timezone;
near line 203, inside the
foreach ($widgets as $widget) {
is unnecessary because it is already done at the beginning of the function just some lines before.Comment #12
RoloDMonkey CreditAttribution: RoloDMonkey at FFW commented@erwangel,
I agree with you, but can you file a separate issue for refactoring that code?
Comment #13
RoloDMonkey CreditAttribution: RoloDMonkey at FFW commentedI ran into this notice-level error today while running Behat tests. The patch in comment #9 worked for me. Setting to RTBC.