Invalid SPListItem. The SPListItem provided is not compatible with a Publishing Page.

When I was trying to publish a  publishing page in my client side, I suddenly get the error message"Invalid SPListItem. The SPListItem provided is not compatible with a Publishing Page".
 
After surfing through internet for some time , I 've have found out the resolution and more than happy to share this to our community.
Resolution.
 
1.The simple thing is to try deactivate and reactive the publishing features both at site collection and site level.
 
2. If the above doesn't work then proceed to below PowerShell script.
 $site = Get-SPSite "http://www.mysites/  "
$web = $site.openweb()

 $correctId = $web.Lists["Pages"].ID $web.AllProperties["__PagesListId"] = $correctId.ToString()

$Web.AllProperties["__PublishingFeatureActivated"]="True" 

$web.Update()
3. The key point is PublishingFeatureActivated bag which has to be true .
 
Hope it helps. Happy Share Pointing :-)