urlReferrer and opening new browser tab

To open particular URL in a new tab, you have at least two possibilities:

  • click a link with middle button (usually under mouse wheel) or
  • open a blank tab and copy-paste URL to URL bar.

There is slight difference it this (at least in Chrome) when it comes to urlReferrer in Yii:

  • in first case browser sets referrer correctly (i.e. Yii::app()->request->uUrlReferrer contains a valid URL),
  • in second approach URL referrer IS NOT set (i.e. Yii::app()->request->urlReferrer is an empty string).

The second situation is obvious. Opening a new tab means that browser does not have a history for it and thus it is unable to set urlReferrer correctly. However, it is better to keep this information in mind. If you rely on this information, you may get yourself (or your code) into a problem.

CGridView: the summaryText maddnes!

I’m finishing entry phase of my first big project (first big project, where I’m key project manager and lead developer, to be precise). Right now I’m after four days of sleeping for 5 hours and coding for remaining 19 hours each day. My brain simply bowls. In this specific situation, I’ve crafted a helper method, which makes mad-laughing or mad-screaming, each time I see it.

Read More “CGridView: the summaryText maddnes!”

The unlink function returns TRUE on non-existing files!

Is seems, that unlink() returns FALSE only, if file, that is about to be deleted, exists and there was a problem removing it. If file wasn’t there, when unlink tried to remove it, it still does return TRUE. Keep that in mind!

This seems to be reasonable. Logic, that I see here is:

You wanted me to delete that file and… swoosh… it is gone. It doesn’t matter, that I had nothing to do with its deletion, right?

For some this could be surprising — unlink() function returns logic value about whether file, that should be deleted is deleted. It’s return value says nothing about whether actual deletion process occurred.

For me this is not only surprising, but also wrong! Dear PHP, I wanted you to “delete” this file (which you didn’t). Not, to “make sure it is gone” (which, we may agree, that you did).

Dealing with ‘No external storage available’ error in Android 4.3

I’ve been cleaning internal storage (the only one, that I have) on my Google Nexus phone and it seems that I remove a bit too much… My storage stopped responding and when I went to gallery or photo camera I saw a beautiful message, saying:

No external storage available.

If you’re facing the same or similar problem, you may find solution in this post. However, I must warn you that most likely you’re going to loose everything on that storage!

Read More “Dealing with ‘No external storage available’ error in Android 4.3”

Key difference between GPL and BSD licenses

For the project, I’m working on, I came over Plupload library, which is dual-licensed on GPL+OEM model. Since paying commercial license (OEM) in this project is not an option, I told my boss, that we can’t use this library, because we’d have to publish all our project’s sources as open source (base GPL licensing requirement).

He told me, that this is not true, because both PHP and Yii, that we use, are licensed in the same model.

I was so sure, that I’m correct, that I immediately made some research and wrote this article as a summary of all my findings. I was more than happy to prove my boss, that he is wrong! :>

If you think similarly to my boss, then you should definitely read this post.

Read More “Key difference between GPL and BSD licenses”

Upload files via AJAX and fill up other model properties in the same time

There’s a comment to Yii 1.1: XUpload Workflow Wiki article, made by MeDroogie, who asks, how to handle situation, where file is correctly uploaded (via AJAX, in separate layer, handled by upload action), but form submission itself fails, as form processing action stops on some model’s validation errors.

I had the same problem with other AJAX uploader, that I think, I solved gracefully.

Keep in mind, that since solution, that I’m discussing in this article, is part of proprietary project, I cannot share any code. This is purely design or theoretical discussion.

Read More “Upload files via AJAX and fill up other model properties in the same time”

Remove file from repository and from all revisions [updated]

Say, that you have commited to a Git repository, a file, that contains sensitive or confidential information. You want to literally purge it from the repository history.

Simple git rm --cached <file> won’t do the trick. It will remove a file from the repository (keeping it in your working directory), but it will still keep the file in history. What now?

Read More “Remove file from repository and from all revisions [updated]”