How can I detect when a node is changed from 'Published' to 'Unpublished'? In hook_node_update(), I can easily tell the 'status' of a node (whether it's published or not) after it's been updated.

However, is there an easy way to check to see if the updated node was published, but now is not? (Or vice-versa)?

I think Rules might have some condition for 'node value has changed' or something along those lines, but I'd like to do this programmatically.

I found this issue by fago (developer of Rules) on drupal.org that seems to deal with this in Drupal 7, but a nice explanation would be appreciated.
Nevermind. After reading through the issue linked above (especially comment #38), I found that the $node object (any entity, actually) stores the 'original' cached copy in $entity->original.

So, I wanted to detect whether a node changed from 'status = 1' to 'status = 0' (this happens when the node is unpublished), and the following code does this:

&lt;?php
function custom_node_update($node) {
  if ($node-&gt;type == 'article') {
    // Act on the unpublishing of an article.
    if ($node-&gt;original-&gt;status == 1 &amp;&amp; $node-&gt;status == 0) {
      // Do something here.
    }
    // Act on the publishing of an article.
    if ($node-&gt;original-&gt;status == 0 &amp;&amp; $node-&gt;status == 1) {
      // Do something here.
    }
  }
}
?&gt;