Skip to content

Commit

Permalink
aws bucket errors
Browse files Browse the repository at this point in the history
  • Loading branch information
voitto committed Apr 7, 2009
1 parent 8225bbc commit 654d3d8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 48 deletions.
3 changes: 1 addition & 2 deletions app/omb/plugins/omb.php
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,7 @@ function set_identity_from_nick(&$request,&$route) {

if ($id)
$request->set_param('id',$id);
else
trigger_error("Sorry, the person named ".$nick." could not be found.", E_USER_ERROR);

}


Expand Down
44 changes: 4 additions & 40 deletions app/omb/plugins/wp.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
}

function wp_create_nonce($action = -1) {
return wp_get_current_user();
global $current_user;
return $current_user;
}

function post_password_required() {
Expand Down Expand Up @@ -121,48 +122,11 @@ function &get_post(&$post, $output = OBJECT, $filter = 'raw') {
}

function do_action($tag, $arg = '') {
global $wp_filter, $wp_actions;

if ( is_array($wp_actions) )
$wp_actions[] = $tag;
else
$wp_actions = array($tag);

$args = array();

if ( is_array($arg) && 1 == count($arg) && is_object($arg[0]) ) // array(&$this)
$args[] =& $arg[0];
else
$args[] = $arg;

for ( $a = 2; $a < func_num_args(); $a++ )
$args[] = func_get_arg($a);

merge_filters($tag);

if ( !isset($wp_filter[$tag]) )
return;

do{
foreach( (array) current($wp_filter[$tag]) as $the_ )
if ( !is_null($the_['function']) )
call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));

} while ( next($wp_filter[$tag]) !== false );

global $db;
trigger_before('wp_head',$db,$db);
}

function merge_filters($tag) {
global $wp_filter, $merged_filters;

if ( isset($wp_filter['all']) && is_array($wp_filter['all']) )
$wp_filter[$tag] = array_merge($wp_filter['all'], (array) $wp_filter[$tag]);

if ( isset($wp_filter[$tag]) ){
reset($wp_filter[$tag]);
uksort($wp_filter[$tag], "strnatcasecmp");
}
$merged_filters[ $tag ] = true;
}

class wpdb {
Expand Down
15 changes: 10 additions & 5 deletions db/library/dbscript/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -577,8 +577,11 @@ function aws_delfile(&$rec, $pkvalue) {
$s3 = new S3( environment('awsAccessKey'), environment('awsSecretKey') );
if (!$s3)
trigger_error( 'Sorry, there was a problem connecting to Amazon Web Services', E_USER_ERROR );
if (!($s3->deleteObject(environment('awsBucket'), urlencode($aws_file))))
trigger_error( 'Sorry, there was a problem deleting the file from Amazon Web Services', E_USER_ERROR );
if ($s3->bucketExists(environment('awsBucket'))
&& $s3->objectExists(environment('awsBucket'),urlencode($aws_file))) {
if (!($s3->deleteObject(environment('awsBucket'), urlencode($aws_file))))
trigger_error( 'Sorry, there was a problem deleting the file from Amazon Web Services', E_USER_ERROR );
}
}


Expand All @@ -589,9 +592,11 @@ function aws_putfile(&$rec, $pkvalue) {
$s3 = new S3( environment('awsAccessKey'), environment('awsSecretKey') );
if (!$s3)
trigger_error( 'Sorry, there was a problem connecting to Amazon Web Services', E_USER_ERROR );
$result = $s3->putBucket( environment('awsBucket'), 'public-read' );
if (!$result)
trigger_error( 'Sorry, there was a problem creating the bucket '.environment('awsBucket').' at Amazon Web Services', E_USER_ERROR );
if (!$s3->bucketExists(environment('awsBucket'))) {
$result = $s3->putBucket( environment('awsBucket'), 'public-read' );
if (!$result)
trigger_error( 'Sorry, there was a problem creating the bucket '.environment('awsBucket').' at Amazon Web Services', E_USER_ERROR );
}
if (file_exists($this->file_upload[1])) {
if (!($s3->putObjectFile( $this->file_upload[1] , environment('awsBucket'), $file, 'public-read' )))
trigger_error( 'Sorry, there was a problem uploading the file to Amazon Web Services', E_USER_ERROR );
Expand Down
5 changes: 4 additions & 1 deletion db/library/dbscript/model.php
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,11 @@ function delete_from_post( &$req ) {
$s3 = new S3( environment('awsAccessKey'), environment('awsSecretKey') );
if (!$s3)
trigger_error( 'Sorry, there was a problem connecting to Amazon Web Services', E_USER_ERROR );
if (!($s3->deleteObject(environment('awsBucket'), urlencode($aws_file))))
if ($s3->bucketExists(environment('awsBucket'))
&& $s3->objectExists(environment('awsBucket'),urlencode($aws_file))) {
$result = $s3->deleteObject(environment('awsBucket'), urlencode($aws_file));
trigger_error( 'Sorry, there was a problem deleting the file from Amazon Web Services', E_USER_ERROR );
}
}

$result = $db->delete_record($rec);
Expand Down

0 comments on commit 654d3d8

Please sign in to comment.