vlad-ghita/image_upload — Issue #4: Problem when open_basedir enforced
Author: xfrenette
Created: 2012-03-08 22:50:08+00:00
State: open

When the PHP configuration "open_basedir" is set, an error occurs everytime I try to modify an already existing entry with an already set value for the Image Field. The problem doesn't occur when creating a new entry with an image, only when modifying.

Symphony version: 2.2.5
Image Upload version: 1.1.6
Tested on Windows Apache Server and Linux Apache.
To reproduce: set the PHP config "open_basedir" to the root directory of your website (also add the tmp folder PHP is using for the file uploads), create a section containing an Image Upload field, create a new entry, then modify the same entry.

Note: the problem doesn't occur if I use the original File Upload field instead.

It seems that [field.image_upload.php:240] fieldUpload::getMetaInfo() is trying to get meta information about the "/" file (the path of the file is only "/").

Error output:

file_exists() [function.file-exists]: open_basedir restriction in effect. File(/) is not within the allowed path(s): (C:\Windows\TEMP\;C:\Users\Xavier\www\ta\centrecommercialrdl.ca\)
An error occurred in C:\Users\Xavier\www\ta\centrecommercialrdl.ca\public\symphony\lib\toolkit\fields\field.upload.php around line 90
85: }
86:
87: public static function getMetaInfo($file, $type){
88: $meta = array();
89: var_dump($file);
90: if(!file_exists($file) || !is_readable($file)) return $meta;
91:
92: $meta['creation'] = DateTimeObj::get('c', filemtime($file));
93:
94: if(General::in_iarray($type, fieldUpload::$imageMimeTypes) && $array = @getimagesize($file)){

Backtrace:
[:0] GenericErrorHandler::handler();
[C:\Users\Xavier\www\ta\centrecommercialrdl.ca\public\symphony\lib\toolkit\fields\field.upload.php:90] file_exists();
[C:\Users\Xavier\www\ta\centrecommercialrdl.ca\public\extensions\image_upload\fields\field.image_upload.php:240] fieldUpload::getMetaInfo();
[C:\Users\Xavier\www\ta\centrecommercialrdl.ca\public\symphony\lib\toolkit\class.entry.php:250] fieldImage_upload->checkPostFieldData();
[C:\Users\Xavier\www\ta\centrecommercialrdl.ca\public\symphony\content\content.publish.php:859] Entry->checkPostData();
[C:\Users\Xavier\www\ta\centrecommercialrdl.ca\public\symphony\content\content.publish.php:40] contentPublish->__actionEdit();
[C:\Users\Xavier\www\ta\centrecommercialrdl.ca\public\symphony\content\content.publish.php:26] contentPublish->__switchboard();
[C:\Users\Xavier\www\ta\centrecommercialrdl.ca\public\symphony\lib\toolkit\class.administrationpage.php:242] contentPublish->action();
[C:\Users\Xavier\www\ta\centrecommercialrdl.ca\public\symphony\lib\core\class.administration.php:230] AdministrationPage->build();
[C:\Users\Xavier\www\ta\centrecommercialrdl.ca\public\symphony\lib\core\class.administration.php:383] Administration->__buildPage();
[C:\Users\Xavier\www\ta\centrecommercialrdl.ca\public\index.php:25] Administration->display();

Database Query Log:
SET character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'; [0.0001]
SET CHARACTER SET 'utf8'; [0.0001]
SELECT SQL_CACHE `session_data` FROM `sym_sessions` WHERE `session` = 'b25191639705ce2c739bd7fcdbc92474' LIMIT 1; [0.0003]
SELECT SQL_CACHE `name` FROM `sym_extensions` WHERE `status` = 'enabled'; [0.0002]
SELECT SQL_CACHE `id` FROM `sym_authors` WHERE `username` = 'admin' AND `password` = 'xxx' LIMIT 1; [0.0003]
UPDATE sym_authors SET `last_seen` = '2012-03-08 17:43:51' WHERE `id` = '1'; [0.0002]
SELECT SQL_CACHE * FROM `sym_authors` WHERE `id` IN (1) ORDER BY id ASC; [0.0001]
SELECT SQL_CACHE * FROM `sym_extensions`; [0.0003]
SELECT SQL_CACHE * FROM `sym_sections` ORDER BY `sortorder` ASC; [0.0004]
SELECT SQL_CACHE t1.name, t2.page, t2.delegate, t2.callback FROM `sym_extensions` as t1 INNER JOIN `sym_extensions_delegates` as t2 ON t1.id = t2.extension_id WHERE t1.status = 'enabled'; [0.0003]
SELECT SQL_CACHE `section_id` FROM `sym_entries` WHERE `id` = '14' LIMIT 1; [0.0002]
SELECT SQL_CACHE `s`.* FROM `sym_sections` AS `s` WHERE `s`.`id` = '1'; [0.0002]
SELECT SQL_CACHE `e`.id, `e`.section_id, e.`author_id`, UNIX_TIMESTAMP(e.`creation_date`) AS `creation_date` FROM `sym_entries` AS `e` WHERE 1 AND `e`.`id` IN ('14') AND `e`.`section_id` = '1'; [0.0002]
SELECT SQL_CACHE `id` FROM `sym_fields` WHERE `parent_section` = 1; [0.0002]
SELECT SQL_CACHE * FROM `sym_entries_data_1` WHERE `entry_id` IN (14) ORDER BY `id` ASC; [0.0002]
SELECT SQL_CACHE * FROM `sym_entries_data_2` WHERE `entry_id` IN (14) ORDER BY `id` ASC; [0.0002]
SELECT SQL_CACHE * FROM `sym_entries_data_3` WHERE `entry_id` IN (14) ORDER BY `id` ASC; [0.0002]
SELECT SQL_CACHE * FROM `sym_entries_data_4` WHERE `entry_id` IN (14) ORDER BY `id` ASC; [0.0002]
SELECT SQL_CACHE * FROM `sym_entries_data_7` WHERE `entry_id` IN (14) ORDER BY `id` ASC; [0.0001]
SELECT SQL_CACHE * FROM `sym_entries_data_8` WHERE `entry_id` IN (14) ORDER BY `id` ASC; [0.0002]
SELECT SQL_CACHE * FROM `sym_entries_data_51` WHERE `entry_id` IN (14) ORDER BY `id` ASC; [0.0001]
SELECT SQL_CACHE * FROM `sym_entries_data_50` WHERE `entry_id` IN (14) ORDER BY `id` ASC; [0.0001]
SELECT SQL_CACHE * FROM `sym_entries_data_32` WHERE `entry_id` IN (14) ORDER BY `id` ASC; [0.0001]
SELECT SQL_CACHE `id`, `element_name`, `type`, `location` FROM `sym_fields` WHERE `parent_section` = '1' ORDER BY `sortorder` ASC; [0.0002]
SELECT SQL_CACHE t1.* FROM sym_fields as t1 WHERE 1 AND t1.`id` = '1' LIMIT 1; [0.0001]
SELECT SQL_CACHE * FROM `sym_fields_input` WHERE `field_id` = '1' LIMIT 1; [0.0002]
SELECT SQL_CACHE t1.* FROM sym_fields as t1 WHERE 1 AND t1.`id` = '8' LIMIT 1; [0.0002]
SELECT SQL_CACHE * FROM `sym_fields_order_entries` WHERE `field_id` = '8' LIMIT 1; [0.0003]
SELECT SQL_CACHE t1.* FROM sym_fields as t1 WHERE 1 AND t1.`id` = '2' LIMIT 1; [0.0002]
SELECT SQL_CACHE * FROM `sym_fields_input` WHERE `field_id` = '2' LIMIT 1; [0.0002]
SELECT SQL_CACHE t1.* FROM sym_fields as t1 WHERE 1 AND t1.`id` = '3' LIMIT 1; [0.0002]
SELECT SQL_CACHE * FROM `sym_fields_textarea` WHERE `field_id` = '3' LIMIT 1; [0.0002]
SELECT SQL_CACHE t1.* FROM sym_fields as t1 WHERE 1 AND t1.`id` = '50' LIMIT 1; [0.0003]
SELECT SQL_CACHE * FROM `sym_fields_input` WHERE `field_id` = '50' LIMIT 1; [0.0002]
SELECT SQL_CACHE t1.* FROM sym_fields as t1 WHERE 1 AND t1.`id` = '51' LIMIT 1; [0.0002]
SELECT SQL_CACHE * FROM `sym_fields_input` WHERE `field_id` = '51' LIMIT 1; [0.0002]
SELECT SQL_CACHE t1.* FROM sym_fields as t1 WHERE 1 AND t1.`id` = '4' LIMIT 1; [0.0002]
SELECT SQL_CACHE * FROM `sym_fields_checkbox` WHERE `field_id` = '4' LIMIT 1; [0.0002]
SELECT SQL_CACHE t1.* FROM sym_fields as t1 WHERE 1 AND t1.`id` = '32' LIMIT 1; [0.0002]
SELECT SQL_CACHE * FROM `sym_fields_checkbox` WHERE `field_id` = '32' LIMIT 1; [0.0002]
SELECT SQL_CACHE t1.* FROM sym_fields as t1 WHERE 1 AND t1.`id` = '7' LIMIT 1; [0.0002]
SELECT SQL_CACHE * FROM `sym_fields_image_upload` WHERE `field_id` = '7' LIMIT 1; [0.0003]