zref resets equation numbers in align

The example shows that when I use the zref-perpage package, the equation numbers are reset (start at 1) when entering an align environment. The perpage package doesn't have this problem.

\documentclass{article}
\usepackage{amsmath}
\usepackage{zref-perpage}
\zmakeperpage{equation}
\renewcommand{\theequation}{\thezpage.\arabic{equation}}
\begin{document}
Equation:
$$1<2$$

Align:
\begin{align}
2&<3\\
&<4
\end{align}

Equation:
$$4<5$$

Align:
\begin{align}
5&<6\\
&<7
\end{align}

Equation:
$$7<8$$

\end{document}


zref-perpage gets confused because the material in align is processed twice. A simple patch fixes the issue: stepping the internal counter only in the non-measuring phase.

\documentclass{article}
\usepackage{amsmath}
\usepackage{zref-perpage}
\usepackage{xpatch}

\makeatletter
\xpatchcmd{\ZREF@@perpage@step}
{}{}
\makeatother

\zmakeperpage{equation}
\renewcommand{\theequation}{\thezpage.\arabic{equation}}
\begin{document}
Equation:
$$1<2$$

Align:
\begin{align}
2&<3\\
&<4
\end{align}

Equation:
$$4<5$$

Align:
\begin{align}
5&<6\\
&<7
\end{align}

Equation:
$$7<8$$

\end{document}