Error Establishing Database Connection on WordPress Login – Check Your Auth Settings

I recently downloaded a copy of my wordpress site to my local dev machine using the Duplicator plugin (works great by the way), and everything seemed to be working correctly, until I went to the wp-admin page. When trying to login via wp-admin I was presented with the message “Error establishing database connection.” Like most relatively intelligent individuals, I cracked open my wp-config file and checked, then re-checked, then re-re-checked my DB_USER, DB_PASSWORD, DB_HOST, and DB_NAME properties. As far as I could see they were all correct, yet the issue remained.

After a bit of poking around, I tried removing the “Authentication Unique Keys and Salts” section (the lines that define the keys and salts), saved the file out, and refreshed my wp-admin page. Voila! The login screen was presented as expected and I was able to successfully access my dashboard. Next, I added the keys and salts section back into wp-config, and re-saved the file. I feared this would re-introduce the isssue; however, it did not!

I’m not 100% sure on why this worked, but from the little bit of reading I did on the Authentication Unique Keys and Salts, it seems that pulling these out may have cleared out my user cookies, and forced a new cookie to be established which somehow resolved the database connectivity issue. I’m sure there’s a much better explanation to be had, but for now I’ve got work to do…

Flashbuilder 4.7 Stops Reporting Compiler Errors

I finally made the upgrade to Adobe Creative Cloud, and thus far I have been extremely pleased with the new product line (the most notable difference being the compilation time and general speed of both Flashbuilder and Flash Professional). But, as with any new Adobe product, there are also a fair amount of really annoying and hard to diagnose bugs. The latest issue to plague me was that Flashbuilder suddenly stopped reporting compilation errors. As always, this resulted in a few frustrating hours consulting Dr. Google without much progress. And, as (almost) always, I finally found a solution.

The Solution (at least this worked for me):
All I had to do to get Flashbuilder to start playing nicely and reporting compiler errors again was to delete the project from my workspace (right-click on the project in the project explorer and choose delete, but select the option to not delete the contents), then re-import the project back into Flashbuilder (right-click in project explorer, choose import, then browse to the folder containing your project). That was all it took for me! Hopefully this will save someone from hours of head banging (at this point my skull is harder than steel!).

Flashbuilder error occurred during Finding occurrences – java.lang.NullPointerException

The other day I started getting plagued by constant pop-ups in Flashbuilder notifying me that “An internal error occurred during: “Finding occurrences””, the details then outline that a “java.lang.NullPointerException” is to blame. The partial stack-trace was as follows:

!ENTRY org.eclipse.core.jobs 4 2 2013-07-10 17:47:41.466
!MESSAGE An internal error occurred during: "Finding occurrences".
!STACK 0
java.lang.NullPointerException
	at com.adobe.flexbuilder.codemodel.internal.common.AbstractTextDatabase.refresh(AbstractTextDatabase.java:250)
	at com.adobe.flexbuilder.codemodel.internal.search.BaseSearchDataProvider.processDeferredFiles(BaseSearchDataProvider.java:397)
	at com.adobe.flexbuilder.codemodel.internal.search.BaseSearchDataProvider.findOccurrences(BaseSearchDataProvider.java:238)
	at com.adobe.flexbuilder.codemodel.internal.search.ASSearchDataProvider.findOccurrences(ASSearchDataProvider.java:99)
	at com.adobe.flexbuilder.codemodel.internal.indices.SearchIndexGateway.getOccurrencesInternal(SearchIndexGateway.java:200)
	at com.adobe.flexbuilder.codemodel.internal.indices.SearchIndexGateway.getOccurrences(SearchIndexGateway.java:166)
	at com.adobe.flexide.as.core.search.MarkOccurrencesProcessor$ReferenceSearcher.run(MarkOccurrencesProcessor.java:115)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)

After a ton of googling on the error, the best solution I could find was to simply try and drag this window somewhere off the screen and ignore it. Unfortunately, this just wasn’t going to work for me; partly because Flashbuilder wouldn’t allow me to drag the window off screen, but mostly because I wanted to find a real fix! After a bunch of trial and error I was finally able to pin this down to a workspace error.

The Solution: For me the solution ended up being pretty simple. I made a backup copy of all the projects in my workspace, then deleted all the files (including the hidden ones) in my workspace. Next I pointed Flashbuilder at the now empty workspace directory (forcing it to recreate all the workspace files). Finally I imported the project folders that I had backed up. That seemed to do the trick for me. Now I’m just hoping that the same error doesn’t resurface in 20 minutes…

What to do when Flashbuilder forgets how to debug Flash Pro files!

After finally getting FlashBuilder to successfully edit and debug Flash Professional projects I was feeling quite triumphant, not to mention ecstatic that I could get all the nice bells and whistles of the Flashbuilder debugger while publishing to Flash Pro! All was good for about three days, and then, in standard fashion, Flashbuilder just forgot how to debug my files and refused to open them in anything but Flash Pro! This was completely out of the blue. I published once and Flashbuilder played nicely, launched the debugger, and let me inspect my properties. I launch again, and it opens the file in Flash Pro with no debugging!!!

After a few minutes of banging my head into the nearest table top, I took a deep breath, counted to 10, rebooted my computer, and said a little prayer. Unfortunately, Flashbuilder was still hosed after the reboot. I then asked the Googs for some help. Not much luck their either. Finally, I decided to pull a hail-mary and open up Flashbuilder preferences. Here I finally had some success!

What happened: Flashbuilder lost track of where to the Flash Debug Player lives.

How to Fix it: Open FlashBuilder Preferences -> Flash Builder -> Debug and look for the input for “Standalone Adobe Flash Player (debug version)”. Click on browse, then browse your standalone Flash Player Debugger. Click ok, and run debug on your project! That should fix the issue (at least it did for me).

If you don’t have the standalone Flash Player Debugger installed, you can download it from Adobes site and unpackage it anywhere on your machine, then just point at the file and you’re good to go (hopefully).

Building Robotlegs SWC Using Maven – Failed to launch Flash Player

First, a little backstory on how I got to this error in the first place (bear with me). I recently start a project using Robotlegs 2.0.0. Since this version was just released, a lot of the extensions are still being ported over. In my case, I had need of the RelaxedEventMap extension, which I had used heavily with RL1. Thankfully, CReynders was kind enough to port the existing RL1 source over to an RL2 extension; however, porting the extension also required a few minor tweaks to the RL framework source. What this meant to me is that if I wanted to use the RelaxedEventMap extension, I would need to download the latest Robotlegs source from GitHub which contained the previously mentioned tweaks (i.e. I could no longer use the latest compiled version of the RL2 SWC). I didn’t assume this would be a big deal, that is, until I tried to compile my application using Flash Pro. The compile-time went from about 2 seconds using the compiled RL2 SWC, to upwards of 30 seconds when including the RL2 framework source. All this led me down the path of compiling the RL2 SWC myself for the first time (see, I told you’d I’d get to the point eventually!).

I won’t go into great detail on how to compile the source here (perhaps in a future article); however, I would like to touch on a very annoying error I ran into during this process. Keep in mind that I am on OSX, so this may or may not be applicable to you Windows users out there, but I think the concepts should still carry over. So after going through the process of getting all the Maven dependencies installed (which is outlined in the Maven-README.md file included in the RL2 download), I went ahead and ran “mvn clean install -s settings.xml.” After about 15 seconds I got the following error:

[BUILD FAILURE]
[ERROR] Failed to execute goal org.sonatype.flexmojos:flexmojos-maven-plugin:4.0-RC2:test-run (default-test-run) on project robotlegs-framework: Failed to launch Flash Player. Probably java was not able to find flashplayer.
[ERROR] Make sure flashplayer is available on PATH
[ERROR] or use -DflashPlayer.command=${flashplayer executable}
[ERROR] Read more at: https://docs.sonatype.org/display/FLEXMOJOS/Running+unit+tests: Cannot run program “Flash Player”: error=2, No such file or directory

Without going into too much detail on the extremely frustrating next couple of hours, I will get straight to the fix. On OSX Maven is looking for the flash player executable in your path; the trick is the name of the flash player executable. On OSX it must be “Flash Player”, on Windows it “FlashPlayer.exe”.

So to solve my problem, I downloaded the latest Flash Player (I chose to go with the Projector Content Debugger), unpackaged it, then copied the Flash Player Debugger executable to my /usr/local/bin directory (you can put it wherever you like, you just have to make sure to update and include the path in your PATH variable).

Now the next issue: The Flash Player package that you download is actually called “Flash Player”; however, the executable inside of this package is named Flash Player Debugger (remember how I mentioned it MUST be called Flash Player). To fix this (again Mac only instructions, not sure about Windows for this one, sorry) right-click on the Flash Player package, and select “show package contents.” Next click into “contents”, then “MacOS.” Inside of MacOS you should find the Flash Player Debugger executable (might be called something else depending on which package you downloaded). Whatever the filename is, change it to “Flash Player”.

The last step is to make sure that this file is in your PATH. There are plenty of instructions out there on how to updated your PATH variable, and it’s different on each OS and users system, so I won’t cover that here; however, you will need to make sure that the following path is included in your PATH: “{Path to your flash player installation}/Flash Player.app/Contents/MacOS”. So for my setup, it would look like this: /usr/local/bin/Flash Player.app/Contents/MacOS.

After getting all this corrected, I re-ran the maven build process and everything worked beautifully! One last gotcha, when Maven compiles the Robotlegs 2 SWC, it places it in the “target” directory. This may be logical to people with more Maven experience, but I’m a newb so it’s a gotcha to me! Hope this helps!

PhoneGap Android Errors – ANDROID_BIN=”${ANDROID_BIN:=$( which android )}” – GeekGoneNomad

While trying to get PhoneGap setup, I ran into an issue when creating a test android project. I was trying to run the following command to create my android project:

./create ~/Desktop/android-project com.example.android android_project

When I ran this command I immediately received an error:

An unexpected error occurred: ANDROID_BIN="${ANDROID_BIN:=$( which android )}" exited with 1
Deleting project...

After checking my .bash_profile paths, and a bunch of digging, I finally found the cause of the issue. If you open up the create file (phonegap-2.4.0/lib/android/bin/create), there is a line that lists ANDROID_BIN=”${ANDROID_BIN:=$( which android )}”. The “which android” is the cause of the issue (or at least it seemed to be in my case). If you replace this line with the full path to your android tools (as listed below) it should resolve the issue. My final line looked like this:

ANDROID_BIN=/Users/ktyacke/DEV/adt-bundle-mac-x86_64-20130219/sdk/tools/android

There is also another solution that has seemed to work for many people and is (in my opinion) a better and less obtrusive one than what I outlined above. That being said, this next fix did not work for me. If it works for you, I’d suggest you use it, and use the first fix as a fallback in case it does not work for you.

The second fix is to add the Android SDK to your Path environment variables. You can find detailed instructions on how to setup these environment variables for both Windows and Mac OSX in the PhoneGap documentation under sections 3A and 3B.

AS3 Regular Expression Global Flag

I’ve been playing around with using Regular Expressions in AS3 using the RegExp class, and recently ran into an issue where only a single result was being returned when running my regex against a string that should have contained multiple results.

To give a bit more detail, I was trying to parse all of the tags out of an HTML document. I went about doing this by using the match() method of the String class, which returns an Array containing all the matches found in the given String. The basic code was as follows:

var imgRegExp:RegExp = /<img[^>]+>/;
var imgTags:Array = data.match( imgRegExp );
// This returns only a single result!

As noted in my comment, this would always return an Array containing only one result (even though I could see multiple matches in the string).

The Solution:
The reason my search was only returning a single result was that I did not include the global flag in my RegExp. The reason I did include it is that I had never heard of it. For those of you that have also not heard of it: “When the g (global) flag is not included, a regular expression matches no more than one match.” Luckily, its’ implementation is quite simple. All you need to do is include “g” at the end of your expression.

So to update my original code to include all matches:

//note the g at at the end of the expression
var imgRegExp:RegExp = /<img[^>]+>/g; 
var imgTags:Array = data.match( imgRegExp );
// This returns ALL <img> tags

There are also some additional flags that you can include in your Regular Expressions, you can read about them all here: http://help.adobe.com/en_US/as3/dev/WS5b3ccc516d4fbf351e63e3d118a9b90204-7ea7.html

AS3 – Removing Elements While Iterating Over an Array

I recently ran into an issue where I had a foreach loop iterating over an ArrayCollection of objects. Inside the loop, I was doing a simple check to see if the current object contained a matching property, if it did, I then removed it from the collection. I soon realized that the number of elements being removed didn’t quite match up to what I would have expected. The cause was quite simple: When removing items from a collection, you update the length of that collection, which in-turn breaks your iteration. This seemed like a very common problem (which I found to be true after a bit of googling), and luckily there are a number of ways to solve this. The very simple solution which I ended up implementing is as follows:

The Solution:
Instead of using a foreach loop, I switched to using a for loop. I then iterate over the collection backwards so that any updates to its’ length have no effect on the iteration.

var myID:uint = 1;
var myCollection:ArrayCollection;
// some code to add Objects to myCollection which
// contain an <em>id</em> property.
 
protected function removeByFor():void
{
	var len:uint = myCollection.length-1;
	for (var x:int = len; x >= 0; x--) 
	{
		if( myCollection.getItemAt(x).id == myID )
		{
			myCollection.removeItemAt( x );
		}
	} 
}

That’s all there is to it. It’s quite simply when you stop to think about it, but when banging out code at the speed of light, who has time to think.. ;-)

FlashBuilder 4.6 Broken Workspace FIX

I’ve been running into a plaguing issue lately with FlashBuilder 4.6, and that is that every few days/weeks/other random increment of time, my workspace will become corrupt, and I will no longer be able to open it. The signifier (for me) of a corrupt workspace is generally that FlashBuilder freezes while I am in the middle of coding some (usually extremely important and time-sensitive update), then when I try to restart the application it hangs on the “Loading Workbench” portion of the startup sequence. Thankfully, I found THIS post written by Valentin Romonov which outlines a fix for the problem that doesn’t involve deleting the entire .metadata folder of the workspace (which then forces you to reset up all preferences, ties to version control systems, layouts, etc.).

The fix is quite simple: go into your project directory, and locate a file called .snap which is listed under the following path on Mac OSX: .metadata/.plugins/org.eclipse.core.resources Once you have deleted this file, simply restart FlashBuilder and you should be good to go! *Note that you will need to turn on hidden files in order to see the .metadata folder, instructions on how to do that can be found HERE.

A big thanks to Valentin Romonov for blogging about this fix, it has saved me a LOT of time and frustration!

Debugging Flash/Flex Apps in Google Chrome (and killing the cache)

Since switching over to Google Chrome as my default browse some months back, I have had one persistent (see also annoying) issue: I have been unable to get the Flash Debugger to run properly in Chrome. I initially tried a number of fixes, none of which seemed to resolve the issue. Eventually, I gave up, and simply started using FireFox for debugging. Fast-forward a few months, and I am now ready to bail on FireFox due to memory usage issues (my Macbook AIR has almost gone up in smoke a few times thanks to these lil problems). To add to the fire, I have also been dealing with the HUGELY bothersome (and very common) issue of the browser caching my .swf files while I am debugging (i.e. I run debug, and the file displayed is a cached version, so I end up trying to resolve bugs that may not even exist anymore). So this morning, sitting in a cafe in Little Italy (San Diego), listening to the rain falling softly on the concrete outside, I decided it was high time I tackle theses issues. Luckily for me (and you), the solutions came quickly, and I now have Google Chrome debugging my flash builds, and running the latest build every time no less!

Debugging in Chrome:

Aaron West wrote a nice blog post outlining the how to make sure Google Chrome is using the debug version of the flash player here: http://www.aaronwest.net/blog/index.cfm/2010/4/27/Configuring-Chrome-with-Flash-Player-Debugger . Aaron did a very nice job of explaining the changes necessary to make force Chrome to use the debug player, so I will not reiterate them here; however, I will add one thing (which turned out to be the missing link for me): In order to find the correct Flash plugin to disable, you may first need to click the “Details” link in the upper right-hand corner of the screen. Doing this will expand the list of plugins (in my case, there were 2) and allow you to disable the correct one.

Debugging Flash/Flex Apps in Google Chrome (and killing the cache)

 

 

 

 

 

 

 

 

 

 

 

 

Disabling Caching:

I saw a number of fixes for the caching issue, some of them better than others, but none quite as elegant as I would hope (i.e. a setting in Chrome to simple disable caching). Then I came across a blog post by Andre Gil’s (sorry for the spelling, I don’t know how to make the fancy accent over the e), which outlined a very nice solution in which Andre had written a small application that essentially gives you the option to launch Google Chrome with the cache disabled. You can get the app, and read about its’ use in the section titled “Cache Problems” of the following post: http://blog.somepixels.net/2010/05/how-to-develop-and-debug-flex-on-google-chrome/

 

That’s all folks. Now get back to work, and happy debugging!

 

**Update**

I am still having some issues with caching. Currently, I have found that I most often have to do a hard-refresh in Chrome in order to force it to load the latest build of the .swf. I will be working on finding a solution for this and will update once I have it!