Shor's algorithm is a quantum algorithm to find a non-trivial factor of a composite integer $N$. It is assumed that $N$ is odd and not a perfect power.
The first step is to find the multiplicative order $r$ of $x$ modulo $N$, where $x$ is randomly chosen in the range 1 to $N-1$. If $r$ is even and $x^{r/2} \ne -1 \pmod{N}$, then either $\gcd(x^{r/2}-1, N)$ or $\gcd(x^{r/2}+1, N)$ is a non-trivial factor of $N$. Otherwise, we must repeat the algorithm with a different choice of $x$.
But is it really necessary to repeat the algorithm? Let's suppose that $N = pq$ where $p$ and $q$ are distinct odd primes. This is the most important case in practice, since arises in the RSA cryptosystem. We know that $x^r = 1 \pmod{N}$, so $r$ divides $\phi(N) = (p-1)(q-1)$. If $r \ge p+q$ then we can recover the sum of the prime factors, since $p + q = (N \mathop{\mathrm{mod}} r) + 1$. Once we know the sum and product, we can find $p$ and $q$ via the quadratic formula. Specifically,
$$\{p, q\} = \left\lbrace\frac12\left(S - \sqrt{S^2 - 4N\,}\right), \frac12\left(S + \sqrt{S^2 - 4N\,}\right)\right\rbrace$$
where $S = p + q$.
Is this argument correct, and has this variation on Shor's algorithm been investigated before? How likely is it to fail? It certainly fails if $p-1$ divides $q-1$ or vice versa. But this seems very unlikely.
Note that we don't need the exact period. It suffices to find any factor of $\phi(N)$ that is greater than or equal to $p+q$.