<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[12375] trunk/wp-admin: Don'
t fallback to the options database when retrieving *_per_page user options.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/12375">12375</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2009-12-11 23:14:43 +0000 (Fri, 11 Dec 2009)</dd>
</dl>
<h3>Log Message</h3>
<pre>Don't fallback to the options database when retrieving *_per_page user options. Props nacin. fixes <a href="http://trac.wordpress.org/ticket/11385">#11385</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadmincategoriesphp">trunk/wp-admin/categories.php</a></li>
<li><a href="#trunkwpadmineditcommentsphp">trunk/wp-admin/edit-comments.php</a></li>
<li><a href="#trunkwpadmineditpagesphp">trunk/wp-admin/edit-pages.php</a></li>
<li><a href="#trunkwpadminedittagsphp">trunk/wp-admin/edit-tags.php</a></li>
<li><a href="#trunkwpadminincludespostphp">trunk/wp-admin/includes/post.php</a></li>
<li><a href="#trunkwpadminincludestemplatephp">trunk/wp-admin/includes/template.php</a></li>
<li><a href="#trunkwpadminpluginsphp">trunk/wp-admin/plugins.php</a></li>
<li><a href="#trunkwpadminuploadphp">trunk/wp-admin/upload.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadmincategoriesphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/categories.php (12374 => 12375)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/categories.php        2009-12-11 17:18:29 UTC (rev 12374)
+++ trunk/wp-admin/categories.php        2009-12-11 23:14:43 UTC (rev 12375)
</span><span class="lines">@@ -166,10 +166,10 @@
</span><span class="cx"> if ( empty($pagenum) )
</span><span class="cx">         $pagenum = 1;
</span><span class="cx">
</span><del>-$cats_per_page = get_user_option('categories_per_page');
-if ( empty($cats_per_page) )
</del><ins>+$cats_per_page = (int) get_user_option( 'categories_per_page', 0, false );
+if ( empty( $cats_per_page ) || $cats_per_page < 1 )
</ins><span class="cx">         $cats_per_page = 20;
</span><del>-$cats_per_page = apply_filters('edit_categories_per_page', $cats_per_page);
</del><ins>+$cats_per_page = apply_filters( 'edit_categories_per_page', $cats_per_page );
</ins><span class="cx">
</span><span class="cx"> if ( !empty($_GET['s']) )
</span><span class="cx">         $num_cats = count(get_categories(array('hide_empty' => 0, 'search' => $_GET['s'])));
</span></span></pre></div>
<a id="trunkwpadmineditcommentsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/edit-comments.php (12374 => 12375)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/edit-comments.php        2009-12-11 17:18:29 UTC (rev 12374)
+++ trunk/wp-admin/edit-comments.php        2009-12-11 23:14:43 UTC (rev 12375)
</span><span class="lines">@@ -236,10 +236,10 @@
</span><span class="cx"> </p>
</span><span class="cx">
</span><span class="cx"> <?php
</span><del>-$comments_per_page = get_user_option('edit_comments_per_page');
-if ( empty($comments_per_page) )
</del><ins>+$comments_per_page = (int) get_user_option( 'edit_comments_per_page', 0, false );
+if ( empty( $comments_per_page ) || $comments_per_page < 1 )
</ins><span class="cx">         $comments_per_page = 20;
</span><del>-$comments_per_page = apply_filters('comments_per_page', $comments_per_page, $comment_status);
</del><ins>+$comments_per_page = apply_filters( 'comments_per_page', $comments_per_page, $comment_status );
</ins><span class="cx">
</span><span class="cx"> if ( isset( $_GET['apage'] ) )
</span><span class="cx">         $page = abs( (int) $_GET['apage'] );
</span></span></pre></div>
<a id="trunkwpadmineditpagesphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/edit-pages.php (12374 => 12375)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/edit-pages.php        2009-12-11 17:18:29 UTC (rev 12374)
+++ trunk/wp-admin/edit-pages.php        2009-12-11 23:14:43 UTC (rev 12375)
</span><span class="lines">@@ -228,9 +228,10 @@
</span><span class="cx"> $pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 0;
</span><span class="cx"> if ( empty($pagenum) )
</span><span class="cx">         $pagenum = 1;
</span><del>-$per_page = get_user_option('edit_pages_per_page');
-if ( empty( $per_page ) || $per_page < 0 )
</del><ins>+$per_page = (int) get_user_option( 'edit_pages_per_page', 0, false );
+if ( empty( $per_page ) || $per_page < 1 )
</ins><span class="cx">         $per_page = 20;
</span><ins>+$per_page = apply_filters( 'edit_pages_per_page', $per_page );
</ins><span class="cx">
</span><span class="cx"> $num_pages = ceil($wp_query->post_count / $per_page);
</span><span class="cx"> $page_links = paginate_links( array(
</span></span></pre></div>
<a id="trunkwpadminedittagsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/edit-tags.php (12374 => 12375)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/edit-tags.php        2009-12-11 17:18:29 UTC (rev 12374)
+++ trunk/wp-admin/edit-tags.php        2009-12-11 23:14:43 UTC (rev 12375)
</span><span class="lines">@@ -184,11 +184,11 @@
</span><span class="cx"> if ( empty($pagenum) )
</span><span class="cx">         $pagenum = 1;
</span><span class="cx">
</span><del>-$tags_per_page = get_user_option('edit_tags_per_page');
-if ( empty($tags_per_page) )
</del><ins>+$tags_per_page = (int) get_user_option( 'edit_tags_per_page', 0, false );
+if ( empty($tags_per_page) || $tags_per_page < 1 )
</ins><span class="cx">         $tags_per_page = 20;
</span><del>-$tags_per_page = apply_filters('edit_tags_per_page', $tags_per_page);
-$tags_per_page = apply_filters('tagsperpage', $tags_per_page); // Old filter
</del><ins>+$tags_per_page = apply_filters( 'edit_tags_per_page', $tags_per_page );
+$tags_per_page = apply_filters( 'tagsperpage', $tags_per_page ); // Old filter
</ins><span class="cx">
</span><span class="cx"> $page_links = paginate_links( array(
</span><span class="cx">         'base' => add_query_arg( 'pagenum', '%#%' ),
</span></span></pre></div>
<a id="trunkwpadminincludespostphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/post.php (12374 => 12375)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/post.php        2009-12-11 17:18:29 UTC (rev 12374)
+++ trunk/wp-admin/includes/post.php        2009-12-11 23:14:43 UTC (rev 12375)
</span><span class="lines">@@ -845,10 +845,10 @@
</span><span class="cx">                 $orderby = 'date';
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        $posts_per_page = get_user_option('edit_per_page');
-        if ( empty($posts_per_page) )
</del><ins>+        $posts_per_page = (int) get_user_option( 'edit_per_page', 0, false );
+        if ( empty( $posts_per_page ) || $posts_per_page < 1 )
</ins><span class="cx">                 $posts_per_page = 15;
</span><del>-        $posts_per_page = apply_filters('edit_posts_per_page', $posts_per_page);
</del><ins>+        $posts_per_page = apply_filters( 'edit_posts_per_page', $posts_per_page );
</ins><span class="cx">
</span><span class="cx">         wp("post_type=post&$post_status_q&posts_per_page=$posts_per_page&order=$order&orderby=$orderby");
</span><span class="cx">
</span><span class="lines">@@ -903,10 +903,10 @@
</span><span class="cx">         $q['cat'] = isset( $q['cat'] ) ? (int) $q['cat'] : 0;
</span><span class="cx">         $q['post_type'] = 'attachment';
</span><span class="cx">         $q['post_status'] = isset( $q['status'] ) && 'trash' == $q['status'] ? 'trash' : 'inherit';
</span><del>-        $media_per_page = get_user_option('upload_per_page');
-        if ( empty($media_per_page) )
</del><ins>+        $media_per_page = (int) get_user_option( 'upload_per_page', 0, false );
+        if ( empty( $media_per_page ) || $media_per_page < 1 )
</ins><span class="cx">                 $media_per_page = 20;
</span><del>-        $q['posts_per_page'] = $media_per_page;
</del><ins>+        $q['posts_per_page'] = apply_filters( 'upload_per_page', $media_per_page );
</ins><span class="cx">
</span><span class="cx">         $post_mime_types = get_post_mime_types();
</span><span class="cx">         $avail_post_mime_types = get_available_post_mime_types('attachment');
</span></span></pre></div>
<a id="trunkwpadminincludestemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/template.php (12374 => 12375)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/template.php        2009-12-11 17:18:29 UTC (rev 12374)
+++ trunk/wp-admin/includes/template.php        2009-12-11 23:14:43 UTC (rev 12375)
</span><span class="lines">@@ -3716,14 +3716,20 @@
</span><span class="cx">                         return '';
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        $option = str_replace('-', '_', "${screen}_per_page");
-        $per_page = get_user_option($option);
-        if ( empty($per_page) ) {
</del><ins>+        $option = str_replace( '-', '_', "${screen}_per_page" );
+        $per_page = (int) get_user_option( $option, 0, false );
+        if ( empty( $per_page ) || $per_page < 1 ) {
</ins><span class="cx">                 if ( 'plugins' == $screen )
</span><span class="cx">                         $per_page = 999;
</span><span class="cx">                 else
</span><span class="cx">                         $per_page = 20;
</span><span class="cx">         }
</span><ins>+        if ( 'edit_comments_per_page' == $option )
+                $per_page = apply_filters( 'comments_per_page', $per_page, isset($_REQUEST['comment_status']) ? $_REQUEST['comment_status'] : 'all' );
+        elseif ( 'categories' == $option )
+                $per_page = apply_filters( 'edit_categories_per_page', $per_page );
+        else
+                $per_page = apply_filters( $option, $per_page );
</ins><span class="cx">
</span><span class="cx">         $return = '<h5>' . __('Options') . "</h5>\n";
</span><span class="cx">         $return .= "<div class='screen-options'>\n";
</span></span></pre></div>
<a id="trunkwpadminpluginsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/plugins.php (12374 => 12375)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/plugins.php        2009-12-11 17:18:29 UTC (rev 12374)
+++ trunk/wp-admin/plugins.php        2009-12-11 23:14:43 UTC (rev 12375)
</span><span class="lines">@@ -350,10 +350,10 @@
</span><span class="cx"> //Paging.
</span><span class="cx"> $total_this_page = "total_{$status}_plugins";
</span><span class="cx"> $total_this_page = $$total_this_page;
</span><del>-$plugins_per_page = get_user_option('plugins_per_page');
-if ( empty($plugins_per_page) )
</del><ins>+$plugins_per_page = (int) get_user_option( 'plugins_per_page', 0, false );
+if ( empty( $plugins_per_page ) || $plugins_per_page < 1 )
</ins><span class="cx">         $plugins_per_page = 999;
</span><del>-$plugins_per_page = apply_filters('plugins_per_page', $plugins_per_page);
</del><ins>+$plugins_per_page = apply_filters( 'plugins_per_page', $plugins_per_page );
</ins><span class="cx">
</span><span class="cx"> $start = ($page - 1) * $plugins_per_page;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkwpadminuploadphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/upload.php (12374 => 12375)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/upload.php        2009-12-11 17:18:29 UTC (rev 12374)
+++ trunk/wp-admin/upload.php        2009-12-11 23:14:43 UTC (rev 12375)
</span><span class="lines">@@ -134,9 +134,10 @@
</span><span class="cx">
</span><span class="cx"> if ( isset($_GET['detached']) ) {
</span><span class="cx">
</span><del>-        $media_per_page = (int) get_user_option('upload_per_page');
-        if ( empty($media_per_page) )
</del><ins>+        $media_per_page = (int) get_user_option( 'upload_per_page', 0, false );
+        if ( empty($media_per_page) || $media_per_page < 1 )
</ins><span class="cx">                 $media_per_page = 20;
</span><ins>+        $media_per_page = apply_filters( 'upload_per_page', $media_per_page );
</ins><span class="cx">
</span><span class="cx">         if ( !empty($lost) ) {
</span><span class="cx">                 $start = ( (int) $_GET['paged'] - 1 ) * $media_per_page;
</span></span></pre>
</div>
</div>
</body>
</html>