I strongly recommend changing this:

$file = fopen($css, 'w') or die("can't open file");

It doesn't output a useful error message. It doesn't handle the error correctly.

:)

CommentFileSizeAuthor
#2 better-error-handling-979210-2.patch630 bytesrjmackay

Comments

rimian’s picture

diff --git a/imagebrowser.module b/imagebrowser.module
index 3684491..9e7ab16 100644
--- a/imagebrowser.module
+++ b/imagebrowser.module
@@ -984,7 +984,11 @@ function imagebrowser_rebuild_cache() {
cache_set('imagebrowser_styles', $styles);

$css = file_directory_path() . "/ibstyles.css";
- $file = fopen($css, 'w') or die("can't open file");
+ $file = fopen($css, 'w');
+ if(!$file) {
+ drupal_set_message(t('Image browser could not open CSS file.'), 'error');
+ return;
+ }
$data = NULL;
foreach($styles as $style) {
$data .= '.ibimage_'. $style['name'] ." {\r\n". $style['css'] ."\r\n}\r\n\r\n";

rjmackay’s picture

Priority: Normal » Major
Status: Active » Needs review
StatusFileSize
new630 bytes

Just hit this error. This is a really bad way to handle an error, especially in Drupal.
I've rolled rimian's comment into a patch - against current 6.x-2.x branch.

lazysoundsystem’s picture

Category: feature » bug
Status: Needs review » Reviewed & tested by the community

This is much better. Before, I was getting:

"can't open fileDrush command could not be completed."

and nothing more. This fixes the problem.

rjmackay’s picture

ping.
Any change we could get this committed?

igorik’s picture

subscribe.
is anybody maintain this module yet?