A simple way to debug a php application in production mode

How to Get Start & End dates of a Week by given Date

A simple way to debug a php application in production mode

The following function gets start and end date of a week for a given date supplied in valid date string format. In the following function $week is the number of week in the year. For example the current week is week number 43. In the following function $year is year in YYYY format. For example, current year which is 2016. Here is the function to get start date and end date by a given date. For example

function _getWeekStartEndDatesByDate($current_date) {
$week = date('W', strtotime($current_date));
$year = date('Y', strtotime($current_date));
return _getWeekStartEndDatesByWeekAndYear($week, $year);

function _getWeekStartEndDatesByWeekAndYear($week, $year) {
$dto = new DateTime();
$result['start'] = $dto->setISODate($year, $week, 0)->format('Y-m-d');
$result['end'] = $dto->setISODate($year, $week, 6)->format('Y-m-d');
return $result;

I hope someone finds it helpful.

How to add or remove a git submodule?

While a git sub module could be added with a single line command such as:

git submodule add https://github.com/UrlToRepository.git foldernameofrepository

it can be cumbersome to remove a submodule. There are various steps involved such as given in the next paragraph.

To remove a submodule you need to:

  1. Delete the relevant section from the .gitmodules file.
  2. Stage the .gitmodules changes git add .gitmodules
  3. Delete the relevant section from .git/config.
  4. Run git rm --cached path_to_submodule (no trailing slash).
  5. Run rm -rf .git/modules/path_to_submodule
  6. Commit git commit -m "Removed submodule <name>"
  7. Delete the now untracked submodule files
    rm -rf path_to_submodule

To update all submodule within a repository one would do:

git submodule foreach git pull origin master

Taken from Stackoverflow page https://goo.gl/RVfc1q, answered by John Douthat

How to set Cakephp paginator url for custom Route

I was making a url route like this:

Router::connect('/ca/assets', array('plugin' => 'file_manager', 'controller' => 'file_manager', 'action' => 'assets', 'ca'));

It worked alright with normal urls as- /ca/assets. However when i used paginator in view as

echo $this->Paginator->numbers();

it generates url as- /assets/ca/page:2

I tried different things and at the end, as a work around to this problem I figured out that the following trick works. So make some heck in the $this->Paginator->options() function as the following:

'url'=>array('controller' => 'ca', 'controller'=>'action', 'plugin'=>false)

Facebook share 404 not found fix DNS ipv6

I moved my website to new VPS server. After adding new articles when I tried to share a post it showed 404 not found error with not featured images. I went to Facebook sharing debugger too where I normally would go if I see missing featured image or “old” title which I would have set at the time of publishing a post.

How do we refresh content if we see old content while sharing?

Yes sometimes, I set a post title and featured image in a wordpress post and publish it.  Then I do FB share. Minutes later realize something wrong with the post title and I would change post title or featured image and then go to share it again. This time it would show me the old post title and featured images. So “refresh” it I would got to Facebook sharing debugger to re-scrape it using the facebook-scrap-again-button button.

Well, this was not the point of discussion here. Facebook sharing worked just fine for me but when I moved my website to new VPS server. After some research over Google and Stackoverflow I learned that Facebook used IPV6 address to scrap your website data. As the settings of IPV6 was not correct for my website domain it just could not find and hence scrap my websites and its posts. So what to do now?

Either, I needed to set correct IPV6 values for my domain or to disable ipv6 altogether in order to make it working. Following some instructions for more experienced guys I decided to disable ipv6 on my server. As my server runs on Centos 7 I followed this guide https://www.unixmen.com/disable-ipv6-centos-7/ to turn it off. I restarted the server and to my pleasant surprise I could scrap my pages successfully again! No more 404 not found errors!

If you like this post please share it!



WordPress admin ajax 403 Forbidden issue fix

Update Jun 03, 2016:

As a new update when you try to do this action it gives you an option to whitelist the action in question. Something like this.

wordpress-admin-ajax-403-forbidden-issue-fix-whitelistSo it solves this issue for the current user.

Old (outdated ?) story

I am using popular Newspaper theme on few of my websites. While editing theme settings from admin end it suddenly stopped saving theme settings. I tried different thing including inspect element and hence found this in the console. (see admin ajax 403 forbidden message) Continue reading