After submitting an image ad I got this error:
Fatal error: Cannot use object of type stdClass as array in /home/lohas/drupal5/modules/ad/image/ad_image.module on line 290

Changing line 290 from:
if ($file['list'] && file_exists($file['filepath'])) {
to:
if ($file->list && file_exists($file->filepath)) {

Seems to fix the issue.

Comments

mariuss’s picture

Same thing two lines down:
$image->fid = $file['fid'];
should probably be:
$image->fid = $file->fid;

jeremy’s picture

I'm unable to duplicate (with PHP set to log E_ALL). Please try again with the latest version of the ad.module and ad_image.module.

mariuss’s picture

Forgot to specify, using PHP 5.

And yes, the issues is still there. Very easy to fix.

jeremy’s picture

I just verified that the $file structure is an array, not an object. I don't know why it's an object for you. Are you using the core upload module?

(I am testing with Drupal 5, PHP 5 and E_ALL enabled)

mariuss’s picture

Yes, using core upload module.

duntuk’s picture

have the same problem on my end...

however, after the error, if i go to the admin ad listing, i see the ad was added...

however, it does not show up in the selected block (as a few others have noted)...

when debugging as noted:
http://YOURSITE.com/sites/all/modules/ad/adserve.php?g=group1t&c=none&p=...
i get this error:

Group: 'group1t'
Cache: 'none'
Quantity: '1'
Host: ''
Path: 'files'
Nids: ''
Files: '3'
Ad module installed in '/home/gnamxco/domains/gnamx.com/public_html/atwood/sites/all/modules/ad'.
Root drupal directory '/home/gnamxco/domains/gnamx.com/public_html/atwood'.
Using no cache.
Drupal bootstrap '7'.

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/gnamxco/domains/gnamx.com/public_html/atwood/sites/all/modules/ad/adserve.php:365) in /home/gnamxco/domains/gnamx.com/public_html/atwood/includes/bootstrap.inc on line 811

Warning: Cannot modify header information - headers already sent by (output started at /home/gnamxco/domains/gnamx.com/public_html/atwood/sites/all/modules/ad/adserve.php:365) in /home/gnamxco/domains/gnamx.com/public_html/atwood/includes/bootstrap.inc on line 488

Warning: Cannot modify header information - headers already sent by (output started at /home/gnamxco/domains/gnamx.com/public_html/atwood/sites/all/modules/ad/adserve.php:365) in /home/gnamxco/domains/gnamx.com/public_html/atwood/includes/bootstrap.inc on line 489

Warning: Cannot modify header information - headers already sent by (output started at /home/gnamxco/domains/gnamx.com/public_html/atwood/sites/all/modules/ad/adserve.php:365) in /home/gnamxco/domains/gnamx.com/public_html/atwood/includes/bootstrap.inc on line 490

Warning: Cannot modify header information - headers already sent by (output started at /home/gnamxco/domains/gnamx.com/public_html/atwood/sites/all/modules/ad/adserve.php:365) in /home/gnamxco/domains/gnamx.com/public_html/atwood/includes/bootstrap.inc on line 491
document.write('')

mariuss’s picture

I just verified that the $file structure is an array, not an object. I don't know why it's an object for you.

Still having this issue, need to patch every time there is a new version. Looked at the code again and just around the area where I patch, on line 292, there is the following statement:
$image = ad_image_validate_size((object)$file, $node->gid);

which clearly shows that $file is used as an object (also look into ad_image_validate_size).

duntuk, the ad is added for me as well, even if I see the error. But there is a row in the ad_image table which is not added because of the error, and this prevents the ad from working properly. You can add that row manually (aid is the corresponding id from the ads table and fid is the file id from the files table) or just apply my patch.

Marius

jeremy’s picture

Status: Active » Fixed

This problem has been reported by enough people, I've gone ahead and checked these changes into the 4.7.x and 5.x development trees.

dries’s picture

Status: Fixed » Closed (fixed)