WordPress Trac: Ticket #22803: current_user_can_for_blog() fatal errors in single sitehttps://core.trac.wordpress.org/ticket/22803
<p>
It calls switch_to_blog() unconditionally. It should not.
</p>
<p>
We must do an audit of all other switch_to_blog() calls.
</p>
<p>
<strong>Note to plugin authors:</strong> If your plugin suddenly starts causing a fatal error in a new release of WordPress, for God's sakes, <strong><em>THAT IS NOT NORMAL.</em></strong> Report it as a bug. Don't just fix it on your own.
</p>
en-usWordPress Trachttps://core.trac.wordpress.org/chrome/site/your_project_logo.pnghttps://core.trac.wordpress.org/ticket/22803
Trac 1.0.1nacinFri, 07 Dec 2012 07:33:49 GMTattachment sethttps://core.trac.wordpress.org/ticket/22803
https://core.trac.wordpress.org/ticket/22803
<ul>
<li><strong>attachment</strong>
set to <em>22803.diff</em>
</li>
</ul>
TicketmarkjaquithFri, 07 Dec 2012 07:38:51 GMTattachment sethttps://core.trac.wordpress.org/ticket/22803
https://core.trac.wordpress.org/ticket/22803
<ul>
<li><strong>attachment</strong>
set to <em>22803.2.diff</em>
</li>
</ul>
TicketmarkjaquithFri, 07 Dec 2012 07:41:33 GMThttps://core.trac.wordpress.org/ticket/22803#comment:1
https://core.trac.wordpress.org/ticket/22803#comment:1
<p>
Completed an audit. <tt>current_user_can_for_blog()</tt> was the only serious one. <tt>WP_Theme-&gt;get_allowed_on_site()</tt>, was the only other one of note. I independently found it and came up with the same fix as in nacin's <tt>22803.diff</tt>.
</p>
<p>
<tt>22803.2.diff</tt> includes nacin's fix and a simple 2x <tt>is_multisite()</tt> check for <tt>current_user_can_for_blog()</tt>.
</p>
TicketnacinFri, 07 Dec 2012 08:53:02 GMThttps://core.trac.wordpress.org/ticket/22803#comment:2
https://core.trac.wordpress.org/ticket/22803#comment:2
<p>
Note that the WP_Theme one is unchanged from 3.4, when that method was introduced, and requires calling get_allowed_on_site() with a blog_id of something other than the current blog, which doesn't occur in core outside of multisite. (wp_get_themes() will only pass a blog ID to it in multisite.) Haven't seen a single report of this error so far. But of course, it is good to fix.
</p>
TicketnacinFri, 07 Dec 2012 09:21:53 GMTstatus changed; keywords, owner sethttps://core.trac.wordpress.org/ticket/22803#comment:3
https://core.trac.wordpress.org/ticket/22803#comment:3
<ul>
<li><strong>keywords</strong>
<em>has-patch</em> <em>commit</em> added
</li>
<li><strong>owner</strong>
set to <em>ryan</em>
</li>
<li><strong>status</strong>
changed from <em>new</em> to <em>assigned</em>
</li>
</ul>
<p>
To ryan for commit.
</p>
TicketryanFri, 07 Dec 2012 09:53:28 GMTstatus changed; resolution sethttps://core.trac.wordpress.org/ticket/22803#comment:4
https://core.trac.wordpress.org/ticket/22803#comment:4
<ul>
<li><strong>status</strong>
changed from <em>assigned</em> to <em>closed</em>
</li>
<li><strong>resolution</strong>
set to <em>fixed</em>
</li>
</ul>
<p>
In <a class="changeset" href="https://core.trac.wordpress.org/changeset/23117" title="Make current_user_can_for_blog() safe to run single site.
Props nacin, ...">23117</a>:
</p>
<div class="message"><p>
Make current_user_can_for_blog() safe to run single site.<br />
</p>
<p>
Props nacin, MarkJaquith<br />
fixes <a class="closed ticket" href="https://core.trac.wordpress.org/ticket/22803" title="defect (bug): current_user_can_for_blog() fatal errors in single site (closed: fixed)">#22803</a><br />
</p>
</div>
Ticket