date_plugin_display_attachment::options(&$display) wrongly assumes an object as argument.
| Project: | Date |
| Version: | 6.x-2.4 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | reviewed & tested by the community |
warning: Attempt to modify property of non-object in [..]\sites\all\modules\contrib\date\includes\date_plugin_display_attachment.inc on line 24.
File: date/includes/date_plugin_display_attachment.inc
Class: date_plugin_display_attachment
Method: date_plugin_display_attachment::options(&$display)
<?php
function options(&$display) {
parent::options($display);
$display->display_options['style_plugin'] = 'date_nav';
$display->display_options['items_per_page'] = 0;
$display->display_options['row_plugin'] = '';
//$display->display_options['defaults']['style_plugin'] = FALSE;
$display->display_options['defaults']['style_options'] = FALSE;
$display->display_options['defaults']['items_per_page'] = FALSE;
$display->display_options['defaults']['row_plugin'] = FALSE;
$display->display_options['defaults']['row_options'] = FALSE;
}
?>Called here:
File: views/includes/base.inc, line 57
Class: views_object
Method: views_object::set_default_options()
<?php
/**
* Set default options.
* For backward compatibility, it sends the options array; this is a
* feature that will likely disappear at some point.
*/
function set_default_options() {
$this->_set_option_defaults($this->options, $this->option_definition());
// Retained for complex defaults plus backward compatibility.
$this->options($this->options);
}
?>Problems/Questions:
- Obviously the argument is an array, whereas the function assumes an object.
- Moreover, I get the idea the function is not intend to take $this->options as the argument.
- If the argument is supposed to be an object, then why the call by reference?
- Where is that function supposed to be called with an object?
The problem did not cause any error messages before I moved to PHP 5.3. But in this case, I think it's quite obvious that the error message (or warning) is justified.

#1
subscribing
#2
subscribing
#3
This problem happens to me when I run update.php.
* warning: Attempt to modify property of non-object in /var/www/html/sites/all/modules/date/includes/date_plugin_display_attachment.inc on line 24.* warning: Attempt to modify property of non-object in /var/www/html/sites/all/modules/date/includes/date_plugin_display_attachment.inc on line 25.
* warning: Attempt to modify property of non-object in /var/www/html/sites/all/modules/date/includes/date_plugin_display_attachment.inc on line 26.
* warning: Attempt to modify property of non-object in /var/www/html/sites/all/modules/date/includes/date_plugin_display_attachment.inc on line 28.
* warning: Attempt to modify property of non-object in /var/www/html/sites/all/modules/date/includes/date_plugin_display_attachment.inc on line 29.
* warning: Attempt to modify property of non-object in /var/www/html/sites/all/modules/date/includes/date_plugin_display_attachment.inc on line 30.
* warning: Attempt to modify property of non-object in /var/www/html/sites/all/modules/date/includes/date_plugin_display_attachment.inc on line 31.
#4
I encountered the same problem today while trying to bring a live site with Drupal 6.14 locally onto xampp 1.72 which is using PHP 5.3
I'll take a step back to an earlier version of xampp and see if it solves my problems.
Izzy
#5
Same here.
This is my first time with Drupal and i am getting the same error.
XAMPP 1.72 over windows here.
And i am getting this too:
warning: Parameter 1 to admin_menu_admin_menu() expected to be a reference, value given in F:\xampp\htdocs\drupal\includes\module.inc on line 471.
#6
This is happening to me on both Drupal 6.13 and 6.14 running php 5.3.
Running apache and php through Snow Leopard.
#7
I get the following errors with 6.14. Modules installed: Core 6.14, CCK 6.x-2.5, Calendar 6.x-2.2, Date 6.x-2.4, Views 6.x-2.6. This is a XP OS and xampp 1.7.2 which includes PHP 5.3.
warning: Attempt to modify property of non-object in C:\xampp-win32-1.7.2\xampp\htdocs\drupal-6.14\modules\date\includes\date_plugin_display_attachment.inc on line 24.
(lines 24-31)
warning: Attempt to modify property of non-object in C:\xampp-win32-1.7.2\xampp\htdocs\drupal-6.14\modules\calendar\includes\calendar_plugin_display_page.inc on line 47.
(lines 47-55)
warning: Attempt to modify property of non-object in C:\xampp-win32-1.7.2\xampp\htdocs\drupal-6.14\modules\calendar\includes\calendar_plugin_display_block.inc on line 50.
(lines 50-58)
warning: Attempt to modify property of non-object in C:\xampp-win32-1.7.2\xampp\htdocs\drupal-6.14\modules\calendar\includes\calendar_plugin_display_attachment.inc on line 164.
(lines 164-167) 5 Times
If I toggle off calendar I only get the warning: Attempt to modify property of non-object in C:\xampp-win32-1.7.2\xampp\htdocs\drupal-6.14\modules\date\includes\date_plugin_display_attachment.inc on line 24.
(lines 24-31) which would indicate the date and view are not playing well together.
If I toggle off view and calendar, all errors go away as well as my cunning plan to include the ability to define events with a calendar.
PS. I have no skills at fishing, I live off the kindness of those that can fish.
#8
The problem goes away with an earlier version of XAMPP with php 5.2.x
Also, if you are transferring data back and forth between test and live sites it was VERY important to make sure the xampp php version matches that on the live server.
Izzy
#9
Do you have a link for an earlier version of xampp with php 5.2.x?
#10
For the time being I wrote a band-aid that just works around the warning.
This probably does not solve the problem, but on production systems it at least keeps things a little quieter until a proper solution is made.
all this patch does is wrap the problematic section in the following if condition:
<?phpif (is_object($display)){
}
?>
#11
The XAMPP page gives a link to all earlier versions, they are housed on SourceForge. Look at the release notes to decide which you want. http://sourceforge.net/projects/xampp/files/
I believe,
1.6.8 uses php 5.2.6
1.70 uses php 5.2.8
1.7.1 uses 5.2.9
1.7.2 uses 5.3
#12
subscribe
#13
subscribing.
applied patch from #10 for the time being.
#14
subscribe
#15
Same problem here.
I use acquia-drupal-1.2.16.5106, PHP5.3 and Zend Server CE.
Just subscribe this to wait for the update.
#16
subscribe
The new PHP version is not only causing problems with Date...
I get errors with Admin and Views 2 !
I went back to PHP Version 5.2.9. Everything works fine now...
#17
subscribing. The bug doesn't seem to break any calendar functions, so I'll try just applying patch #10.
#18
subscribing
#19
subscribing
#20
subscribe
#10 works for me
#21
subscribe. does this work better?
<?phpif (is_object($display)) {
$display->display_options['style_plugin'] = 'date_nav';
$display->display_options['items_per_page'] = 0;
$display->display_options['row_plugin'] = '';
$display->display_options['defaults']['style_options'] = FALSE;
$display->display_options['defaults']['items_per_page'] = FALSE;
$display->display_options['defaults']['row_plugin'] = FALSE;
$display->display_options['defaults']['row_options'] = FALSE;
//$display->display_options['defaults']['style_plugin'] = FALSE;
}
else {
$display['display_options']['style_plugin'] = 'date_nav';
$display['display_options']['items_per_page'] = 0;
$display['display_options']['row_plugin'] = '';
$display['display_options']['defaults']['style_options'] = FALSE;
$display['display_options']['defaults']['items_per_page'] = FALSE;
$display['display_options']['defaults']['row_plugin'] = FALSE;
$display['display_options']['defaults']['row_options'] = FALSE;
//$display->display_options['defaults']['style_plugin'] = FALSE;
}
?>
#22
+1!
#23
I also have this warning.
Apache/2.2.13 (Win32) PHP/5.3.0
#24
No you should remove '&' in &$display argument.
In PHP 5.3 function must be: function options($display).
#25
+1
Agree with W32 that just removing the ampersand may be sufficient. Appears to be general php 5.3 pass by reference problem.
#26
I am also running PHP 5.3 and getting the error. I tried removing the & ampersand from the options function and I'm still getting the error.
So my date_plugin_display_attachment.inc line 22 reads:
function options($display) {
and i still the following errors when I visit the modules page:
* warning: Attempt to modify property of non-object in /home/drupal/drupal/sites/all/modules/date/includes/date_plugin_display_attachment.inc on line 24.
* warning: Attempt to modify property of non-object in /home/drupal/drupal/sites/all/modules/date/includes/date_plugin_display_attachment.inc on line 25.
* warning: Attempt to modify property of non-object in /home/drupal/drupal/sites/all/modules/date/includes/date_plugin_display_attachment.inc on line 26.
* warning: Attempt to modify property of non-object in /home/drupal/drupal/sites/all/modules/date/includes/date_plugin_display_attachment.inc on line 28.
* warning: Attempt to modify property of non-object in /home/drupal/drupal/sites/all/modules/date/includes/date_plugin_display_attachment.inc on line 29.
* warning: Attempt to modify property of non-object in /home/drupal/drupal/sites/all/modules/date/includes/date_plugin_display_attachment.inc on line 30.
* warning: Attempt to modify property of non-object in /home/drupal/drupal/sites/all/modules/date/includes/date_plugin_display_attachment.inc on line 31.
#27
Simply removing the ampersand did not work for me. Instead, I assumed that $display is an array. I'm not sure why it is expected to be an object, but I think I must be missing something.
This is related to an issue with the calendar module: http://drupal.org/node/613528, http://drupal.org/node/587424
#28
Confirmed that removing the ampersand doesn't work. To clarify, PBR still works just fine, but passing variables by reference at runtime (calling foo(&$bar) rather than defining function foo(&$baz) and passing $bar) has been deprecated. See http://php.net/manual/en/language.references.pass.php.
#29
Did some more digging... To the best of my understanding, the set_default_options() method in views_object (that ultimately calls this) exists mostly for backwards compatibility, and it always deals with arrays - not objects. So I'd agree that the warning is justified, and would add that patch #10 may break the backwards compatibility the function affords - albeit in a way harmless to most environments. In theory, it should only be getting an array, so testing whether it's an object should always result in a failure, leaving some defaults unset. It seems a better solution would be to do something similar to the else block in #21, manipulating the array as it was originally intended.
Anyone more familiar with the codebase, please feel free to correct me if I'm completely off-base here. :]
#30
Just tested the following fix; everything appears to work as it should. I just submitted a similar patch for review on the Calendar issue queue (http://drupal.org/node/613528#comment-2250424) for those interested. Review and feedback welcome!
#31
Patch works. I double checked by looking in the Views code for the
options()method. Only found one in the classviews_objectwhich is empty and does lack documentation of its parameters. But by looking around it seems usual for the$optionparameter to be an array, not an object.#32
Works for me as well.
#33
Nope, patch doesn´t work for me! this is the error i get upon clickin on save.
Parse error: parse error in C:\wamp\www\drupal-6_14\sites\all\modules\calendar\includes\calendar_plugin_display_page.inc on line 47
i edited the patch by hand and im pretty sure i did exactly as the patch mentioned.
any ideas?
#34
What you have above is an issue with the calendar module, where you have already posted. Please be sure that you are posting in the right issue queue in the future.
#35
subscribing