FuelPHP unexpectedly returns Arr instead of data accessing REST controller with no format specified

When working with the REST Controller in FuelPHP and accessing it from your browser you see “Arr” when a format is not specified in the URL instead of the expected data in your default format. This is because of a setting in the rest.php config file (fuel/core/config/rest.php OR /fuel/app/config/rest.php).

Change:

<pre>’ignore_http_accept’ => false,</pre>

to:

<pre>’ignore_http_accept’ => true,</pre>

 

This is faster and will make your default the default format as expected.  If the client needs the data in another format they can specify it in the URL.

WordPress options in Standalone vs Multisite ( aka update_option vs update_site_option )

While researching how data needed to be migrated for Multisite functionality in BackupBuddy I’ve had to do a lot of digging into the differences between how options (and other) data is stored and retrieved in Standalone versus Multisite WordPress setups. This was an extremely confusing venture and not intuitive at all. I’ll start with a table of my resulting findings and explain from there. In this example I’m using update_option() and update_site_option(). The same structure is followed for transients and other data as well so this basis should work for you. It is important to note that when in a Multisite environment the terms site and blog are used interchangeably by WordPress core in code and mean the same or entirely different things depending on context. This is an unfortunate failure of WordPress and adds to the confusion.

  update_option update_site_option [global]
Standalone Site wp_options [local (effectively global)] wp_options [global]
Multisite Main Site or Network Admin wp_options [local] wp_sitemeta, site_id (aka network id) set [global]
Multisite Site (non-main site) wp_##_options [local] wp_sitemeta, site_id (aka network id) set [global]

In a Standalone WordPress installation update_option() stores data in the wp_options database table. The update_site_option() function falls back to update_option() when in standalone mode so there is really not much of a functional difference here. This data can be updated / retrieved anywhere in the WordPress installation so it’s effectively global. It’s best to use the proper one though in case the site is ever migrated into a network with BackupBuddy.

In a Multisite WordPress installation things get … weird and non-intuitive. The verbage used by WordPress is very confusing unfortunately. (Individual sites in a Network installation are called Sites — but in code they are often called blogs and you can have multiple blogs within a site (you can technically have multiple blogs within multiple sites within one Network but that’s another story…). Things vary depending on where you are so keep your eye out for this. If you are in the main site dashboard, main site front-end, or Network admin, update_option() will place data in wp_options. Data manipulated while in the Network Admin behaves as if it was manipulated within the Main Site (!). If you are in another of the Network’s site admin/dashboard that is not the main site and not the Network Admin then update_option() stores data in wp_##_options where ## is the ID number of the blog. These options are only available within the respective area. These are `local options`. If at any time you want to set an option that is globally accessible by its name anywhere in the entire network use update_site_option().

WordPress + Xampp on Mac Update Permissions Problem

If you are running WordPress on OS X using XAMPP for local development then you likely have tried to upload core or a plugin and encountered the following error while prompted for FTP Connect Information:

To perform the requested action, WordPress needs to access your web server.

This is because by default XAMPP runs as the user `nobody` on Mac and this causes some permissions issues. Additionally WordPress prior to upgrading writes a file to the system and then checks to see which user wrote the file. If this file does not match the user running PHP it will refuse to upgrade, even if write permissions existed. chmod 777 is not sufficient to get past this; you must have the correct user as well. I don’t know why they did this and if there’s a technical reason for it, but it’s annoying.

The solution: Edit your httpd.conf to run as your username for the user and staff for the group.

Open httpd.conf in TextEdit:

sudo open -e /Applications/XAMPP/xamppfiles/etc/httpd.conf

Change:

User nobody
Group nogroup

To:

User your_mac_username
Group staff

Restart Xampp and this should correct the problem; you can verify it worked by running in a .php file.

If you still encounter issues you can check a couple of other things. First verify ownership (most likely problem):

sudo chown -R your_mac_username:staff /path_to_webroot/www/

Next confirm permissions (you can change 777 if you need higher security):

sudo chmod -R 777 /path_to_webroot/www/

General Setup menu missing in Eventum

A couple of weeks into using Eventum, the bug tracking system made by the creators of MySQL, the General Setup section under Administration disappeared. This was where you would set up all of the Eventum-specific settings such as email configuration, notifications, etc. I was still able to add and manage projects but not configure Eventum itself. I discovered this post which offered a working fix for this problem. Here is the working solution they provided (works as of Eventum 2.3.1):

Apparently, it sometimes happens that your account is not registered as an ‘Admin’ account. You have find the id of your user account in the table ‘user’. Then find the corresponding row(s) in the table ‘project_user” and set the field ‘pru_role’ to ’7′.

George Carlin – Who Really Controls America

TRANSCRIPT:

There’s a reason that education sucks, and it’s the same reason it will never ever ever be fixed. It’s never going to get any better, don’t look for it. Be happy with what you’ve got. Because the owners of this country don’t want that. I’m talking about the real owners now, the big, wealthy, business interests that control all things and make the big decisions.

Forget the politicians, they’re irrelevant.

Politicians are put there to give you that idea that you have freedom of choice. You don’t. You have no choice. You have owners. They own you. They own everything. They own all the important land, they own and control the corporations, and they’ve long since bought and paid for the Senate, the Congress, the State Houses, and the City Halls. They’ve got the judges in their back pockets. And they own all the big media companies so they control just about all the news and information you get to hear.

They’ve got you by the balls.

They spend billions of dollars every year lobbying to get what they want. Well, we know what they want; they want more for themselves and less for everybody else. But I’ll tell you what they don’t want—they don’t want a population of citizens capable of critical thinking. They don’t want well informed, well educated people capable of critical thinking. They’re not interested in that. That doesn’t help them. That’s against their interest. You know something, they don’t want people that are smart enough to sit around their kitchen table and figure out how badly they’re getting fucked by a system that threw them overboard 30 fucking years ago.

They don’t want that, you know what they want?

They want obedient workers, obedient workers. People who are just smart enough to run the machines and do the paperwork and just dumb enough to passively accept all these increasingly shittier jobs with the lower pay, the longer hours, the reduced benefits, the end of overtime and the vanishing pension that disappears the minute you go to collect it.

And now they’re coming for your social security money.

They want your fucking retirement money; they want it back so they can give it to their criminal friends on Wall Street. And you know something? They’ll get it. They’ll get it all from you sooner or later because they own this fucking place. It’s a big club and you ain’t in it! You and I are not in the Big Club. By the way, it’s the same big club they use to beat you in the head with all day long when they tell you what to believe. All day long beating you over the head with their media telling you what to believe, what to believe, what to think and what to buy.

The table is tilted folks, the game is rigged.

Nobody seems to notice, nobody seems to care. Good honest hard working people, white collar, blue collar, it doesn’t matter what color shirt you have on. Good honest hard working people continue, these are people of modest means, continue to elect these rich cocksuckers who don’t give a fuck about them. They don’t give a fuck about you. They don’t give a fuck about…give a fuck about you! They don’t care about you at all, at all, at all.

And nobody seems to notice, nobody seems to care.

That’s what the owners count on, the fact that Americans are and will probably remain willfully ignorant of the big red, white, and blue dick that’s being jammed up their assholes everyday. Because the owners of this country know the truth, it’s called the American Dream, because you have to be asleep to believe it.

How to remove iTunes store and Ping arrows / buttons next to songs in Windows

Prior to iTunes 10 an arrow button would be placed next to the selected song, album, and artist. Clicking on any of these arrows / links would open the iTunes store. With the introduction of iTunes 10, this arrow has been enlarged and now sports the word “Ping” as this button is now used for Apple’s new Ping musical social network.

I hate these buttons with a passion.

The only thing I get out of them is anger when I accidentally click one of them. Apple of course has not included a way to easily disable these. Thankfully some resourceful users on the Apple discussion forums discovered a way to turn this junk off!

The Solution!

Run the following commands in your command line (Start -> Run -> cmd):

"C:\Program Files\iTunes\iTunes.exe" /setPrefInt hide-ping-dropdown 1
"C:\Program Files\iTunes\iTunes.exe" /setPrefInt show-store-link-arrows 0
"C:\Program Files\iTunes\iTunes.exe" /setPrefInt disablePingSidebar 1

If you’re running the 64 bit version of Windows when you will need to change “Program Files” above to “Program Files (x86)”.

Source of the fix. [apple.com forums]

Email notification to all thread commenters on reply in WordPress P2 theme

The following code added to the bottom of P2’s functions.php will allow P2 to send email notifications to all other responders in a comments thread.

// PluginBuddy Email Notification Patch for P2
// by Dustin Bolton on September 10, 2010.
// http://pluginbuddy.com http://site2.zirch.com
add_action( 'comment_post', 'email_notification' );
function email_notification( $comment_id ) {
	$emails = array();
	$comment = get_comment( $comment_id, ARRAY_A );
	
	// Get emails of all responders.
	$comments = get_comments( 'post_id=' . $comment['comment_post_ID'] );
	foreach( $comments as $this_comment ) {
		if ( $this_comment->comment_author_email != $comment['comment_author_email'] ) { // Only add emails that are not this comment poster.
			array_push( $emails, $this_comment->comment_author_email );
		}
	}
	
	$emails = array_unique( $emails ); // Strip all duplicate email addresses.
	
	// Get email address of thread starter to strip them from receiving replies since that is automatic in P2.
	$original_post = get_post( $comment['comment_post_ID'], ARRAY_A );
	$original_poster = get_userdata( $original_post['post_author'] );
	$emails = array_diff( $emails, array( $original_poster->user_email ) ); // Remove from array.
	
	// Send emails.
	foreach( $emails as $this_email ) {
		wp_mail( $this_email, 'P2 thread updated!', "There has been an update to a thread you posted in by " . $comment['comment_author'] . " on " . $comment['comment_date'] . ":\n\n" . $comment['comment_content'] );
	}
}
// End PluginBuddy Email Notification Patch.

There’s no such thing as safe driving. Abstinence only!

A friend of mine posted this on their Facebook. Very nice.

“The number one killer of young Americans is the automobile. However, the Secular Humanists dominating our schools refuse to acknowledge that the only safe driving is abstinence from driving. Instead, they advocate courses in “Driver Education,” in which teenagers are taught “Safe Driving,” and no attention is given to traditional values. They are even taught the use of “Seat Belts” (and some classes even give explicit demonstrations of the proper method of applying these belts!) with, at best, a passing mention that the protection provided by these belts is only partial. Clearly, this sends a mixed message to our young people: it appears to condone driving, and the more inquisitive will surely feel encouraged to experiment with driving.” [Original Source]

Submit unchecked checkbox value

I had never noticed before that submitting a form with unchecked checkboxes in it results in those checkboxes not being sent to the server at all. I had always assumed that a zero ( 0 ) would be sent for unchecked since a one ( 1 ) is sent when checked. Rather than add code to specifically handle these individual checkboxes, you can just add hidden inputs above the checkboxes in the HTML with a value of zero like this:

<input type="hidden" name="box1" value="0" /> <input type="checkbox" name="box1" value="1" />

This is a much simpler solution that doesn’t require writing any additional code or sending an array of checkboxes. I chose this method since I was using an automated Settings saver in PHP so it would be a pain to modify it and it could make the code more dirty.

Thanks to iamcam for writing about this.

James Lankford: A quick review

A lot of people I know are fans of James Lankford. He’s Christian and a big name in Oklahoma so he’s pretty set. Here are my impressions of his views from his website. This is quickly thrown together with no citations, spell-checking, or proof-reading. I may or may not come back and spruce things up.

Energy

For the security and prosperity of our country, we must allow more drilling, refining and distribution of American oil and natural gas.

The moratorium on drilling in the Gulf of Mexico must be lifted. Every energy company cannot be punished for the mistake of one company. There are thousands of safe wells in the Gulf and they should continue to function for our energy future and economic stability.

The moratorium on drilling is not blocking the functionality of existing wells. The moratorium is on drilling, not pumping oil. Drilling as in using a giant drill to dig deeper into the earth to reach out for oil. Hundreds of rigs in the Gulf are pumping oil while only three or so are drilling. Why on Earth would you try to protect more deep-water drilling knowing that we have obsolutely no technology to handle an emergency situation? There is not enough oil in the Gulf, or anywhere in the country for that matter, for our growing energy needs. We will run out eventually and pushing for more drilling is not a real solution and actually expedites the problem. Here is an MS paint graphic to help illustrate the problem (this is actually an underestimate):

Nuclear, wind, solar, hydro-electric and other energy options should be encouraged through regulatory reforms, rather than increased subsidies.

Wind, solar, geothermal, hydroelectric all show great promise for the distant future.

I do agree that these energy options must be encourages. However regulation reform is not sufficient. Oil is cheap and alternative energy sources will not be affordable until the price of oil has risen to reflect its coming scarcity. Subsidies provide funding to adopt these technologies before it is too late and we are scrambling. The view that we can further way to convert is sad and will only make transitions more difficult and costly in the future. Oil is not abundant and ever-flowing.

Family a.k.a. I don’t want to blatanty mention this is about homosexuality

At the heart of many of the problems facing our country stands an institution under siege. That institution is the American family.

I agree that the American family is failing — but not because of what Mr. Lankford is alluding to: gay marriage. The divorce rate is through the roof and it’s not because of an infiltration of rainbows. Plain and simple the government has no right to interfere in relationships as it is blatant discrimination to legally discriminate on legal contracts based on gender. There is no gray area here. It’s discrimination. The government must either allow same-sex marriages or not recognize opposite-sex ones, which I believe to be the best option as it removes the government from what is at heart a religious ceremony & contract. Additionally the idea that families are “under attack” is juvenile and only further plays off fear and ignorance.

Families must continue to be honored and protected.

Firstly, a family is not a mother, father, son, and daugter. This idea of ‘normalcy’ only serves to instill fear of things that are different. There is no normal and I don’t want the government forcing it’s idea of what’s normal upon me, my friends, or my family.

Financial

Congress should audit the Federal Reserve and privatize Fanny Mae and Freddie Mac. If “big banks” operate in a manner that puts their company at risk, they should be allowed to “fail” so they could reorganize in bankruptcy under new leadership.

I absolutely agree with this. The problem with our current government is that it’s not even capitalist anymore, it’s corporatist.

Healthcare

I do not have the responsibility to dictate for other people the choices they make in their lives.

Why is this not said on the ‘Families’ page?

In the past few months, a small group in the federal government decided that because 10% of the country does not have health care insurance (some of them by their choice), 100% of Americans must change their health insurance.

I am sincerely saddened by this quote for a multitude of reasons. 10% of Americans without health care coverage is 10% too many and those of that 10% that are uninsured by choice aren’t doing so because they don’t want coverage, they do so because it is too expensive for them to consider being worth it. This helps create more of a problem as the uninsured get ill or avoid going to the doctor or hospital when they need to and then others get stuck with absorbing the costs. I find it terribly troubling that so many in the Christian community are perfectly fine with this. They will fight tooth and nail to pay a penny to help pay for the less fortunate to be helped. This isn’t Christian, this just makes you a horrible human being. Secondly, the recent laws passed do no such thing as Mr. Lankford states where “100% of Americans” will need to change their health coverage. This is blatantly false. If you have coverage, it stays the same. Simple yet it’s still being spun here to instill fear.

The same Democrat party that talks on and on about a “woman’s right to choose” what to do with her body just told every man and woman in America when, where, and how they can get health care.

They did not tell anyone when, where, or how they can get healthcare that already has insurance. The health bill unfortunately was gutted beyond recognition (by the Republican extremists) and altered so they are now mandating all citizens be covered or purchase coverage from private corporations. This STILL doesn’t involve telling them when, where, or how they can get health care- only health insurance. A huge benefit to the new health care laws however is the removal of the whole pre-existing conditions mess which will save lives and actually allow people to purchase health insurance that previously could not.

The federal government is working to limit the number and role of insurance companies when we should be removing the barriers so that we have more companies and more competition.

I agree that if we are going to have for-profit health insurance companies that people need to be able to shop around and have options and also the ability to transfer to other plans and companies. Currently everyone is pretty much locked in.

We should encourage individuals to start their own health savings accounts (HSA). These allow people to buy catastrophic insurance and to put their money into a HSA so they can spend it for health care as they wish.

Unfortunately HSA’s do nothing to solve the problem. A single diagnosis can bankrupt families. Normal Americans cannot come close to affording the cost from tragic diagnosis by saving up, and insurance companies can easily drop them or cite pre-existing conditions prior to recent laws. Also unfortunately, many people are poor, despite what Mr. Lankford may think. When it comes between putting food on the table and healthcare, most will cut out the healthcare. This puts further strain on our system. Healthcare coverage is a social issue and would do best with everyone paying into the same system and without the overhead of profit. This is why a single payer system would work best. Everyone would keep their system doctors and hospitals but the insurance company wouldn’t be taking a cut of the money. Unfortunately however those better off financially don’t want to pay for help the poor. How is that a Christian stance here in Oklahoma?

Immigration

Copy-pasta from a comment left by a visitor on his site:

“We cannot bail out every inefficient government in the world by taking on their economic refugees.”
-James Lankford

“When an alien resides with you in your land, you shall not oppress the alien. The alien who resides with you shall be to you as the citizen among you; you shall love the alien as yourself, for you were aliens in the land of Egypt: I am the Lord your God.”
-God.

I understand we can’t take on everyone. This just isn’t feasible. However this outright hunt and dehumanization of immigrants is a scary way to approach this. Recent bills to ban healthcare to pregnant immigrants or block healthcare to an immigrant having a baby our outlandish. Strangely enough those most adamently against abortion are also for blocking an immigrant having a baby from receiving healthcare. Are immigrants not humans now? It all seems to be based on fear.

“Thank you , you are right! Something must be done about uninvited nonworking aliens not to mention terrorist coming over our border. Some have the argument that there are jobs that Americans won’t do that aliens will. Most of these picking and farm jobs can be handled by Americans if given the economic incentive and machinery. The aliens are cutting down on American inventivness to create solutions to labor problems.” – Site visitor

Obligatory “They took our jorbs!!!”

National Security

Our security budget is insane. We have enough nukes to blow up the entire planet multitudes over. Why must we always live in so much fear?

Second Amendment

I agree with Mr. Lankford here. If guns are banned then only the government and criminals will have guns. (and if you keep your gun, you have become a criminal.)

Spending

Stop spending so much money!

I concur. Spend less and when you do spend, spend wisely.

Taxes

I certainly agree that our current tax system is a mess and is full of loopholes. There is an entire industry surrounding filling out taxes.

Dustin Bolton – Software Engineer, Web & WordPress Developer