I'm using AWS SimpleDB for my site, however if I udpate an attribute with something completely different, searching that property with either the new value or the old value are both returning the same record.
Let's say the 'login' property's current value is 'dev'. I then change that value to 'myvar'.
$response = $this->simpledb->select(vsprintf(select * from mydomain where login='%s',array('myvar')),array('ConsistentRead' => 'true'));
# returns the newly updated row
$response = $this->simpledb->select(vsprintf(select * from mydomain where login='%s',array('dev')),array('ConsistentRead' => 'true'));
# returns the same row even though 'login' has changed
Am I doing something wrong with the consistent read argument? I have no clue why this is happening. Also, it's been about a half hour and this issue is still happening, I highly doubt it takes AWS that long to propagate changes across servers.
Anyone have any ideas?
I did not realize this at the time, but I was using v1 of the SDK, after updating to V2 all consistency issues were solved.
Related
Good day,
I have been struggling with this for the past few hours but admittedly I'm not very familiar with Laravel.
I use this row of code to generate a cookie:
return Response::make(view("/play"))->withCookie(cookie('username', $request->input('username'), 60000));
I have logged $request->input('username') and it is not empty,
the application goes to the /play view but when I use Cookie::get('username')in a later method in another Controller later on it returns null.
picture of cookie storage it also does not appear empty in the browser.
Does anyone know why this is happening and how to fix it?
try Request()->cookie('username')
I'm trying to make Youtube v3 Data API work on my website.
I shamelessly copied this code from google's code samples, and it is not working. The error message showed is this:
An client error occurred: All cacheable requests must have creation dates.
I previously had issues with API keys as I forgot almost everything about APIs in general and I just thought this sample would have been useful to remember things. I managed to generate the appropriate key and now I know for sure it isn't the real problem.
Sadly Google didn't find posts related to this issue, except two links to the actual Php Library that I implemented in my site to make everything work. By looking at it closely I noticed a developer comment that could be useful.
$rawDate = $resp->getResponseHeader('date');
$parsedDate = strtotime($rawDate);
if (empty($rawDate) || false == $parsedDate) {
// We can't default this to now, as that means future cache reads
// will always pass with the logic below, so we will require a
// date be injected if not supplied.
throw new Google_Exception("All cacheable requests must have creation dates.");
}
I can understand english pretty well but I really don't know what to do now.
I even tried to add some sort of date in the request in my code, but it isn't working (you can laugh):
// Call the search.list method to retrieve results matching the specified
// query term.
$searchResponse = $youtube->search->listSearch('id,snippet', array(
'q' => $_GET['q'],
'maxResults' => $_GET['maxResults'],
'date' => strtotime(),
));
An client error occurred: (list) unknown parameter: 'date'
Any tips? Thank you in advance
EDIT: I know, this PHP library is currently in beta, but there must be some workaround.
EDIT 2: I found a temporary work around. I inverted the logic gate of that 'if' in the Php Library and now it works. But I don't like doing this, and I won't mark this as solved. At least if you know the reason of the bug please explain it to me, I'm really interested.
Using PHP 5.5.12
Using CakePHP 2.6.7
Running
debug($url); // output = "http://google.co.uk"
debug(parse_url($url));
/* output = array(
'host' => '*****',
'scheme' => 'http'
)
*/
I had been using this without trouble but now copy/pasting a section of my code to have it as method (to save repeating myself) has started giving me this output. But testing it back in the same place I had it originally gives me this output too.
Can anyone explain why the hostname is stars and why the rest of the array doesn't appear (I realise all other elements should be expected to be NULL)?
Edit
Just tried it again with a url that had a path to a page after the host. The path shows up fine but the host is still starred out.
Partial Answer
Just thought to try debug(parse_url($url)['host']) and it prints the host correctly. I realised that the other elements would only be set if they exist in the url.
However, can anyone explain why printing out the array prints several stars instead of the hostname even though it is definitely stored there?
The reason this happens is because of how debug() works. Many moons ago people were not pleased that they could accidentally have their database credentials dumped out in error pages (which use the same underlying code as debug()). Because of this, debug() and Debugger::export() blacklist a set of array keys that could have database credentials. The following keys are replaced with ***'s:
password
login
host
database
port
prefix
schema
So I'm building this small REST API for a part of a website so I can load comments asynchronously, after the main content has loaded. But every time my dataset goes above 25 entries the variable where I store the comments becomes completely inaccessible.
This is exactly the database find operation I'm doing:
// A nice default before responding
$response = array('status'=>'error','message'=>'Request incomplete');
// [...] Some validation stuff
// $response is perfectly accessible here
$response = $this->Comment->find(
'threaded',
array(
'conditions' => array(
'Comment.object_class' => $query['object_class'],
'Comment.object_id' => $query['object_id'] ,
'Comment.status' => 'approved'
),
'order' => 'Comment.created ASC'
// No limits, I need all the comments
)
);
// $response is not accessible anymore
// So my JSON response below comes absolutely empty;
$this->set('response',$response);
$this->set('_serialize',array('response'));
By the time I use $this->set('_serialize',array('response')); to be able to send the JSON response the $comments variable is still inaccessible, so my response comes back empty, at 0 length, which of course is pretty bothersome and very confusing.
I've experienced this problem before and have found that it solves by requesting a limited set of entries, but in this case I need the entire comment list, don't wanna do several requests and kill the purpose. Is there a limit to what Cake can retrieve from the database and keep usable in the Controllers? Am I missing something here?
I also tried "manually " doing a json_encode($response); but since the problem is that the $response var is inaccessible/empty then of course it fails as well.
The json response does work for some 25 comments or less, but many of the website entries have more comments than that, up to 100 comments! How can I solve this weird issue?
So after souting the Internet in search of a concrete answer and ending up in the #cakephp IRC channel, a very kind fellow suggested my data may have some encoding mistakes.
Turns out he was correct about it, and the comments table still had some comments that were encoded as latin1. Back in the day I moved the database to utf8, but it was just a charset change, not an actual text encoding conversion for every entry.
After a quick search I found this post which instructs you about how to move loads of data from latin1 to utf8 with three simple cli lines.
I hope this serves someone else that may encouter this issue and doesn't know what to do about it :)
Thanks to those who commented on the question.
I've got a script that uploads files perfectly fine into buckets. However, one particular bucket has been given a cname so that it can be accessed directly, apparently it has been assigned this using CloudFront.
I'm no expert in this field, but basically, instead of accessing the bucket via:
http://mybucket.mysite.com.s3.amazonaws.com/thing.txt, it allows you to access it via:
http://mybucket.mysite.com/thing.txt
It performs the put fine by the looks of it, when I do a response on the callback, it says it's all done but the last element in the array swaps the bucket and the endpoint around, so it looks like this: https://s3.amazonaws.com/mybucket.mysite.com/thing.txt
However, when I use any other bucket it uploads correctly and returns the correct ObjectURL.
Having had a search around google and this site, I can't seem to find a solution so any help would be magic.
I'm using an older version of the AWS PHP 2 sdk, currently using 2.2.1.
Edit: even stranger still, when I pass the bucket through the isValidBucketName method, it returns true.
Just in case anyone else ever encounters this issue, the problem was that when executing the put, the SDK automatically assumes that you are trying to connect to a bucket in the US region. So I needed to specify what region the bucket is in, in my case EU_WEST_1, so when you set up your config array, be sure to provide this value, eg.
$config = array(
'key' => 'your-key'
, 'secret' => 'your-secret'
, 'region' => Region::EU_WEST_1
);
Being sure to include the Aws\Common\Enum\Region in the class.