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.
When saving a node that has a scheduled publish time but not unpublish time (because the node type is not configured to have one), I get this error:
notice: Undefined property: stdClass::$unpublish_on in /shared/vash/sandboxes/garfield/drupal6/www/sites/all/modules/scheduler/scheduler.module on line 583.
Looks like a case of not checking to see if such a variable would even be set. Should be a simple fix. I have not checked to see if the issue still exists in Drupal 7.
Comments
Comment #1
jonathan1055 CreditAttribution: jonathan1055 commentedHi Crell,
Yes at first glance is does appear to be a bug and simple to fix. But what I can't understand is how it has not been found and reported before. I took a break from supporting scheduler when the options were added to enable publishing and unpublishing independently, so I will have to check back with the code, but I still can't work out how no-one (including me) has not spotted this since then.
Patch coming up soon,
Jonathan
Comment #2
jonathan1055 CreditAttribution: jonathan1055 commentedJust checked the actual code line number, and I think you must be using 6.x-1.8 real (as of 27th Dec 2010), not the -dev version. Please can you confirm this?
Comment #3
Crell CreditAttribution: Crell commentedYes I was using the stable. Just what Drush downloaded when I asked for it.
Many D6 servers are not configured for E_ALL by default, but my dev box is. It actually takes work to suppress notices for me. :-) In D7, Drupal itself forces E_ALL anyway.
Comment #4
jonathan1055 CreditAttribution: jonathan1055 commentedHi,
Yes, of course most time E_ALL is not enabled. I use the devel module, and yes there are many other notices which are shown for all kinds of other modules - including some big and important modules!
Here is a patch, against the dev release of 15th May. If this sorts it, then I know we will have to fix the D7 version first, but I thought given as you are using D6 you should get the patch first.
Jonathan
Comment #5
Eric-Alexander Schaefer CreditAttribution: Eric-Alexander Schaefer commentedSo this problem has always been there we just did not see the warning?
Comment #6
Crell CreditAttribution: Crell commentedEric: That's common with E_NOTICE errors. That's why you should always develop under E_ALL. :-)
Comment #7
jonathan1055 CreditAttribution: jonathan1055 commentedI've checked the D7 code and this is not a problem, because it uses the EMPTY function, which does
not cause an error if the property is undefined.
Here is a slightly tidier patch for D6. Tested when updating a node type which has just publishing enabled, and
on another which has just unpublishing enabled, both already having a date set. Works ok for me, no errors,
but would be good for someone else to confirm.
Comment #8
jonathan1055 CreditAttribution: jonathan1055 commentedRetested my patch against 6.x-1.9+4 (dev 28th July 2013). Patch applies ok (with an offset due to other changes).
and
Both of these are fixed by the patch. Can someone else verify, then mark it RTBC.
Jonathan
Comment #9
Crell CreditAttribution: Crell commentedCode looks decent, but I have no D6 site around to test it with to verify.
Comment #10
pfrenssenI just checked if this bug also occurs on 7.x and higher but it does not. hook_nodeapi() has been replaced with hook_node_update() and the rewritten code uses !empty() which does not throw this notice.
Comment #12
jonathan1055 CreditAttribution: jonathan1055 commentedYes, see my comment in #7 Drupal7 is fine, this fix is only required for D6.
I will re-roll the patch in a/ b/ format then re-submit for testing.
Comment #13
jonathan1055 CreditAttribution: jonathan1055 commentedHere is the same code changes as in the patch in #7 but in a/ b/ format against the latest D6 dev
Comment #14
pfrenssenMakes sense, committed: ad6bfba.
Thanks!