No errors if install_node_export_import_from_file() fails

DamienMcKenna - March 15, 2009 - 16:53
Project:Install Profile API
Version:6.x-2.0
Component:CRUD functions and includes
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs work
Description

There are no messages displayed if install_node_export_import_from_file() fails, e.g. because the file either did not exist or could not be loaded.

#1

DamienMcKenna - March 15, 2009 - 16:54
Status:active» needs review

The attached file adds a dsm() to indicate the file could not be found or opened.

AttachmentSize
install_profile_api-n402642-export_errors.patch 524 bytes

#2

James Andres - March 20, 2009 - 21:16
Status:needs review» fixed

Seems sensible to me. Committed.

#3

dww - March 21, 2009 - 19:59
Status:fixed» needs work

where does the value of $file come from? %file or @file would be safer than !file.

#4

DamienMcKenna - March 21, 2009 - 22:48

dww: $file is one of the arguments.

#5

dww - March 21, 2009 - 23:28

That I understand. My point is where is $file coming from when this function is called? I know we're talking about an install profile, and therefore, user-supplied data isn't really a concern, but in general, it's better to be in the habit of writing secure code by default. Maybe this function is going to be reused in some context we don't anticipate. Better safe than sorry.

#6

DamienMcKenna - March 22, 2009 - 01:06

dww: the command would be executed like this:

<?php
// load the about_us page
install_node_export_import_from_file('about_us.inc', array('status'=>1), $user, FALSE);
?>

So the $file would be manually loaded by the admin.

#7

dww - March 22, 2009 - 08:19

Sorry, I keep phrasing my comments in the form of a question. I don't have a question at all. ;) I'm making a statement. Let me be more clear:

API functions shouldn't assume they know exactly how they're going to be called at all times in the future, so they should be written to be as safe as possible for any possible use-case. API functions that generate HTML sent to a browser should always sanitize potentially user-specified data using core's existing text filtering functions.

#8

James Andres - March 23, 2009 - 17:46

dww, I follow and agree.

I propose we consider a standard format for exported content that works with the install_profile_api project. Maybe the format is just a wrapper around the original export (eg: from views, content_copy, etc..). A standard format would have the following advantages, and disadvantages:

Advantages

  1. Exports can be parsed for sanity before import is attempted
  2. Files that contain exports can be detected, ie: a function like install_get_exports($type, $path) could be created
  3. Exports could be, more easily and safely, imported in batches
  4. Multiple exports could be contained in a single file, if the format we create supports this

Disadvantages

  1. Exports will be more difficult to create because, currently, each export follows a different style. All those styles will have to be merged, or wrapped.

Thoughts?

#9

anarcat - July 22, 2009 - 23:03
Status:needs work» postponed (maintainer needs more info)

I noticed this commit while doing the latest release notes... so I was under the impression this bug was fixed... could you try again with the latest release?

#10

anarcat - July 22, 2009 - 23:04
Status:postponed (maintainer needs more info)» needs work

Nevermind me, i got confused by the date. I'll remove this bug from the relnotes, there clearly seems to be issues remaining to discuss.

 
 

Drupal is a registered trademark of Dries Buytaert.