<!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" />
<title>[55745] trunk: Tests: Use the function `get_num_queries` across all unit tests.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { 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 { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#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>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/55745">55745</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/55745","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>spacedmonkey</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2023-05-11 10:05:51 +0000 (Thu, 11 May 2023)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Tests: Use the function `get_num_queries` across all unit tests.
Replace use of `$wpdb->num_queries` with a function call to `get_num_queries`. This improves readability and consistency between tests.
Props SergeyBiryukov, peterwilsoncc, spacedmonkey.
See <a href="https://core.trac.wordpress.org/ticket/57841">#57841</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkpackagelockjson">trunk/package-lock.json</a></li>
<li><a href="#trunktestsphpunittestsbookmarkgetBookmarksphp">trunk/tests/phpunit/tests/bookmark/getBookmarks.php</a></li>
<li><a href="#trunktestsphpunittestscommentgetPageOfCommentphp">trunk/tests/phpunit/tests/comment/getPageOfComment.php</a></li>
<li><a href="#trunktestsphpunittestscommentmetaCachephp">trunk/tests/phpunit/tests/comment/metaCache.php</a></li>
<li><a href="#trunktestsphpunittestscommentqueryphp">trunk/tests/phpunit/tests/comment/query.php</a></li>
<li><a href="#trunktestsphpunittestscommentwpUpdateCommentCountNowphp">trunk/tests/phpunit/tests/comment/wpUpdateCommentCountNow.php</a></li>
<li><a href="#trunktestsphpunittestscustomizemanagerphp">trunk/tests/phpunit/tests/customize/manager.php</a></li>
<li><a href="#trunktestsphpunittestsgeneralwpGetArchivesphp">trunk/tests/phpunit/tests/general/wpGetArchives.php</a></li>
<li><a href="#trunktestsphpunittestsmultisitenetworkphp">trunk/tests/phpunit/tests/multisite/network.php</a></li>
<li><a href="#trunktestsphpunittestsmultisitesitephp">trunk/tests/phpunit/tests/multisite/site.php</a></li>
<li><a href="#trunktestsphpunittestsmultisitesiteMetaphp">trunk/tests/phpunit/tests/multisite/siteMeta.php</a></li>
<li><a href="#trunktestsphpunittestsmultisitewpNetworkQueryphp">trunk/tests/phpunit/tests/multisite/wpNetworkQuery.php</a></li>
<li><a href="#trunktestsphpunittestsmultisitewpSiteQueryphp">trunk/tests/phpunit/tests/multisite/wpSiteQuery.php</a></li>
<li><a href="#trunktestsphpunittestsoptionupdateOptionphp">trunk/tests/phpunit/tests/option/updateOption.php</a></li>
<li><a href="#trunktestsphpunittestsoptionwpLoadAlloptionsphp">trunk/tests/phpunit/tests/option/wpLoadAlloptions.php</a></li>
<li><a href="#trunktestsphpunittestspostgetPageByPathphp">trunk/tests/phpunit/tests/post/getPageByPath.php</a></li>
<li><a href="#trunktestsphpunittestspostgetPagesphp">trunk/tests/phpunit/tests/post/getPages.php</a></li>
<li><a href="#trunktestsphpunittestspostgetPostClassphp">trunk/tests/phpunit/tests/post/getPostClass.php</a></li>
<li><a href="#trunktestsphpunittestspostqueryphp">trunk/tests/phpunit/tests/post/query.php</a></li>
<li><a href="#trunktestsphpunittestsquerycommentFeedphp">trunk/tests/phpunit/tests/query/commentFeed.php</a></li>
<li><a href="#trunktestsphpunittestsrestapiresttagscontrollerphp">trunk/tests/phpunit/tests/rest-api/rest-tags-controller.php</a></li>
<li><a href="#trunktestsphpunitteststermcachephp">trunk/tests/phpunit/tests/term/cache.php</a></li>
<li><a href="#trunktestsphpunitteststermgetTermphp">trunk/tests/phpunit/tests/term/getTerm.php</a></li>
<li><a href="#trunktestsphpunitteststermgetTermByphp">trunk/tests/phpunit/tests/term/getTermBy.php</a></li>
<li><a href="#trunktestsphpunitteststermgetTermsphp">trunk/tests/phpunit/tests/term/getTerms.php</a></li>
<li><a href="#trunktestsphpunitteststermgetTheTermsphp">trunk/tests/phpunit/tests/term/getTheTerms.php</a></li>
<li><a href="#trunktestsphpunitteststermisObjectInTermphp">trunk/tests/phpunit/tests/term/isObjectInTerm.php</a></li>
<li><a href="#trunktestsphpunitteststermmetaphp">trunk/tests/phpunit/tests/term/meta.php</a></li>
<li><a href="#trunktestsphpunitteststermqueryphp">trunk/tests/phpunit/tests/term/query.php</a></li>
<li><a href="#trunktestsphpunitteststermtermExistsphp">trunk/tests/phpunit/tests/term/termExists.php</a></li>
<li><a href="#trunktestsphpunitteststermwpGetObjectTermsphp">trunk/tests/phpunit/tests/term/wpGetObjectTerms.php</a></li>
<li><a href="#trunktestsphpunittestsuserqueryphp">trunk/tests/phpunit/tests/user/query.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkpackagelockjson"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/package-lock.json</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/package-lock.json 2023-05-11 09:01:55 UTC (rev 55744)
+++ trunk/package-lock.json 2023-05-11 10:05:51 UTC (rev 55745)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -11954,7 +11954,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> "from2-string": {
</span><span class="cx" style="display: block; padding: 0 10px"> "version": "1.1.0",
</span><span class="cx" style="display: block; padding: 0 10px"> "resolved": "https://registry.npmjs.org/from2-string/-/from2-string-1.1.0.tgz",
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- "integrity": "sha512-m8vCh+KnXXXBtfF2VUbiYlQ+nczLcntB0BrtNgpmLkHylhObe9WF1b2LZjBBzrZzA6P4mkEla6ZYQoOUTG8cYA==",
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ "integrity": "sha1-GCgrJ9CKJnyzAwzSuLSw8hKvdSo=",
</ins><span class="cx" style="display: block; padding: 0 10px"> "requires": {
</span><span class="cx" style="display: block; padding: 0 10px"> "from2": "^2.0.3"
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -21112,7 +21112,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> "promise-polyfill": {
</span><span class="cx" style="display: block; padding: 0 10px"> "version": "1.1.6",
</span><span class="cx" style="display: block; padding: 0 10px"> "resolved": "https://registry.npmjs.org/promise-polyfill/-/promise-polyfill-1.1.6.tgz",
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- "integrity": "sha512-7rrONfyLkDEc7OJ5QBkqa4KI4EBhCd340xRuIUPGCfu13znS+vx+VDdrT9ODAJHlXm7w4lbxN3DRjyv58EuzDg=="
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ "integrity": "sha1-zQTv9G9clcOn0EVZHXm14+AfEtc="
</ins><span class="cx" style="display: block; padding: 0 10px"> },
</span><span class="cx" style="display: block; padding: 0 10px"> "prompts": {
</span><span class="cx" style="display: block; padding: 0 10px"> "version": "2.4.2",
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -23251,7 +23251,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> "stream-from-promise": {
</span><span class="cx" style="display: block; padding: 0 10px"> "version": "1.0.0",
</span><span class="cx" style="display: block; padding: 0 10px"> "resolved": "https://registry.npmjs.org/stream-from-promise/-/stream-from-promise-1.0.0.tgz",
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- "integrity": "sha512-j84KLkudt+gr8KJ21RB02btPLx61uGbrLnewsWz6QKmsz8/c4ZFqXw6mJh5+G4oRN7DgDxdbjPxnpySpg1mUig=="
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ "integrity": "sha1-djaH9913fkyJT2QIMz/Gs/yKYbs="
</ins><span class="cx" style="display: block; padding: 0 10px"> },
</span><span class="cx" style="display: block; padding: 0 10px"> "stream-to-string": {
</span><span class="cx" style="display: block; padding: 0 10px"> "version": "1.2.0",
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -24519,7 +24519,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> "toposort": {
</span><span class="cx" style="display: block; padding: 0 10px"> "version": "2.0.2",
</span><span class="cx" style="display: block; padding: 0 10px"> "resolved": "https://registry.npmjs.org/toposort/-/toposort-2.0.2.tgz",
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- "integrity": "sha512-0a5EOkAUp8D4moMi2W8ZF8jcga7BgZd91O/yabJCFY8az+XSzeGyTKs0Aoo897iV1Nj6guFq8orWDS96z91oGg=="
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ "integrity": "sha1-riF2gXXRVZ1IvvNUILL0li8JwzA="
</ins><span class="cx" style="display: block; padding: 0 10px"> },
</span><span class="cx" style="display: block; padding: 0 10px"> "totalist": {
</span><span class="cx" style="display: block; padding: 0 10px"> "version": "1.1.0",
</span></span></pre></div>
<a id="trunktestsphpunittestsbookmarkgetBookmarksphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/bookmark/getBookmarks.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/bookmark/getBookmarks.php 2023-05-11 09:01:55 UTC (rev 55744)
+++ trunk/tests/phpunit/tests/bookmark/getBookmarks.php 2023-05-11 10:05:51 UTC (rev 55745)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -5,8 +5,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class Tests_Bookmark_GetBookmarks extends WP_UnitTestCase {
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_should_hit_cache() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $bookmarks = self::factory()->bookmark->create_many( 2 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $found1 = get_bookmarks(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -15,7 +13,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $found2 = get_bookmarks(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -24,12 +22,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSameSets( $found1, $found2 );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_adding_bookmark_should_bust_get_bookmarks_cache() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $bookmarks = self::factory()->bookmark->create_many( 2 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Prime cache.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -39,7 +35,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $bookmarks[] = wp_insert_link(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -55,7 +51,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEqualSets( $bookmarks, wp_list_pluck( $found2, 'link_id' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertGreaterThan( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertGreaterThan( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -62,8 +58,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 18356
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_orderby_rand_should_not_be_cached() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $bookmarks = self::factory()->bookmark->create_many( 2 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $found1 = get_bookmarks(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -72,7 +66,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $found2 = get_bookmarks(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -82,7 +76,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Equal sets != same order.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEqualSets( $found1, $found2 );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertGreaterThan( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertGreaterThan( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_exclude_param_gets_properly_parsed_as_list() {
</span></span></pre></div>
<a id="trunktestsphpunittestscommentgetPageOfCommentphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/comment/getPageOfComment.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/comment/getPageOfComment.php 2023-05-11 09:01:55 UTC (rev 55744)
+++ trunk/tests/phpunit/tests/comment/getPageOfComment.php 2023-05-11 10:05:51 UTC (rev 55745)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -100,8 +100,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 11334
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_subsequent_calls_should_hit_cache() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $p = self::factory()->post->create();
</span><span class="cx" style="display: block; padding: 0 10px"> $c = self::factory()->comment->create( array( 'comment_post_ID' => $p ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -108,11 +106,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Prime cache.
</span><span class="cx" style="display: block; padding: 0 10px"> $page_1 = get_page_of_comment( $c, array( 'per_page' => 3 ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> $page_2 = get_page_of_comment( $c, array( 'per_page' => 3 ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $page_1, $page_2 );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -119,8 +117,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 11334
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_cache_hits_should_be_sensitive_to_comment_type() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $p = self::factory()->post->create();
</span><span class="cx" style="display: block; padding: 0 10px"> $comment = self::factory()->comment->create(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -151,7 +147,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 2, $page_trackbacks );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> $page_comments = get_page_of_comment(
</span><span class="cx" style="display: block; padding: 0 10px"> $comment,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -161,7 +157,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 1, $page_comments );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertNotEquals( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertNotEquals( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunktestsphpunittestscommentmetaCachephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/comment/metaCache.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/comment/metaCache.php 2023-05-11 09:01:55 UTC (rev 55744)
+++ trunk/tests/phpunit/tests/comment/metaCache.php 2023-05-11 10:05:51 UTC (rev 55745)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -12,8 +12,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::update_comment_meta
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_update_comment_meta_cache_should_default_to_true() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $p = self::factory()->post->create( array( 'post_status' => 'publish' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $comment_ids = self::factory()->comment->create_post_comments( $p, 3 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -30,12 +28,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ( $comment_ids as $cid ) {
</span><span class="cx" style="display: block; padding: 0 10px"> get_comment_meta( $cid, 'foo', 'bar' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -44,8 +42,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::update_comment_meta
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_update_comment_meta_cache_true() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $p = self::factory()->post->create( array( 'post_status' => 'publish' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $comment_ids = self::factory()->comment->create_post_comments( $p, 3 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -63,12 +59,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ( $comment_ids as $cid ) {
</span><span class="cx" style="display: block; padding: 0 10px"> get_comment_meta( $cid, 'foo', 'bar' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -77,8 +73,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::update_comment_meta
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_update_comment_meta_cache_false() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $p = self::factory()->post->create( array( 'post_status' => 'publish' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $comment_ids = self::factory()->comment->create_post_comments( $p, 3 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -93,12 +87,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ( $comment_ids as $cid ) {
</span><span class="cx" style="display: block; padding: 0 10px"> get_comment_meta( $cid, 'foo', 'bar' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries + 3, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries + 3, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -107,8 +101,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::get_comment_meta
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_comment_meta_should_be_lazy_loaded_for_all_comments_in_comments_template() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $p = self::factory()->post->create( array( 'post_status' => 'publish' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $comment_ids = self::factory()->comment->create_post_comments( $p, 3 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -126,14 +118,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $cform = get_echo( 'comments_template' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // First request will hit the database.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> get_comment_meta( $comment_ids[0], 'sauce' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries + 1, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries + 1, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Second and third requests should be in cache.
</span><span class="cx" style="display: block; padding: 0 10px"> get_comment_meta( $comment_ids[1], 'sauce' );
</span><span class="cx" style="display: block; padding: 0 10px"> get_comment_meta( $comment_ids[2], 'sauce' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries + 1, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries + 1, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -144,8 +136,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::get_comment_meta
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_comment_meta_should_be_lazy_loaded_in_comment_feed_queries() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $posts = self::factory()->post->create_many( 2, array( 'post_status' => 'publish' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $now = time();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -173,19 +163,19 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // First comment will cause the cache to be primed.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'bar', get_comment_meta( $comments[0], 'foo', 'bar' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $num_queries++;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Second comment from the results should not cause more queries.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'bar', get_comment_meta( $comments[1], 'foo', 'bar' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // A comment from outside the results will not be primed.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'bar', get_comment_meta( $comments[4], 'foo', 'bar' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $num_queries++;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -194,8 +184,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::get_comment_meta
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_comment_meta_should_be_lazy_loaded_in_single_post_comment_feed_queries() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $posts = self::factory()->post->create_many( 2, array( 'post_status' => 'publish' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $now = time();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -224,19 +212,19 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // First comment will cause the cache to be primed.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'bar', get_comment_meta( $comments[0], 'foo', 'bar' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $num_queries++;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Second comment from the results should not cause more queries.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'bar', get_comment_meta( $comments[1], 'foo', 'bar' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // A comment from outside the results will not be primed.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'bar', get_comment_meta( $comments[4], 'foo', 'bar' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $num_queries++;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunktestsphpunittestscommentqueryphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/comment/query.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/comment/query.php 2023-05-11 09:01:55 UTC (rev 55744)
+++ trunk/tests/phpunit/tests/comment/query.php 2023-05-11 10:05:51 UTC (rev 55745)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3588,8 +3588,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_Comment_Query::query
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_comment_cache_key_should_ignore_custom_params() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $p = self::factory()->post->create();
</span><span class="cx" style="display: block; padding: 0 10px"> $c = self::factory()->comment->create( array( 'comment_post_ID' => $p ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3601,7 +3599,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $q2 = new WP_Comment_Query();
</span><span class="cx" style="display: block; padding: 0 10px"> $q2->query(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3612,7 +3610,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3629,7 +3627,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $q2 = new WP_Comment_Query(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3637,7 +3635,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertNotEquals( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertNotEquals( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3654,7 +3652,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $q2 = new WP_Comment_Query(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3662,7 +3660,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertNotEquals( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertNotEquals( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4427,7 +4425,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $q1_ids = wp_list_pluck( $q1->comments, 'comment_ID' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> $q2 = new WP_Comment_Query(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_id' => $p,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4437,7 +4435,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $q2_ids = wp_list_pluck( $q2->comments, 'comment_ID' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSameSets( $q1_ids, $q2_ids );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4590,9 +4588,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue( isset( $q->comments[0]->post_name ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries + 1, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries + 1, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4613,9 +4611,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue( isset( $q->comments[0]->post_name ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4629,7 +4627,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $comments = self::factory()->comment->create_many( 3, array( 'comment_post_ID' => self::$post_id ) );
</span><span class="cx" style="display: block; padding: 0 10px"> clean_comment_cache( $comments );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> $q = new WP_Comment_Query(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_id' => self::$post_id,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4645,7 +4643,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $found = wp_list_pluck( $q->comments, 'comment_ID' );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEqualSets( $comments, $found );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4692,7 +4690,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $q2 = new WP_Comment_Query(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4701,7 +4699,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4724,7 +4722,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $q = new WP_Comment_Query(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4733,7 +4731,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSameSets( array( $c ), $q->comments );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4766,7 +4764,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $q = new WP_Comment_Query(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4776,7 +4774,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $num_queries++;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSameSets( array( $c ), $q->comments );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4802,7 +4800,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_delete_comment( $c );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $q = new WP_Comment_Query(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4812,7 +4810,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $num_queries++;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSameSets( array(), $q->comments );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4838,7 +4836,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_trash_comment( $c );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $q = new WP_Comment_Query(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4848,7 +4846,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $num_queries++;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSameSets( array(), $q->comments );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4876,7 +4874,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_untrash_comment( $c );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $q = new WP_Comment_Query(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4886,7 +4884,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $num_queries++;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSameSets( array( $c ), $q->comments );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4912,7 +4910,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_spam_comment( $c );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $q = new WP_Comment_Query(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4922,7 +4920,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $num_queries++;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSameSets( array(), $q->comments );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4950,7 +4948,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_unspam_comment( $c );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $q = new WP_Comment_Query(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4960,7 +4958,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $num_queries++;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSameSets( array( $c ), $q->comments );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4982,7 +4980,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $number_of_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $number_of_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $query_2 = $q->query(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4992,7 +4990,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'count' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $number_of_queries + 1, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $number_of_queries + 1, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -5013,7 +5011,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'count' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $number_of_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $number_of_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $query_2 = $q->query(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -5023,7 +5021,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'count' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $number_of_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $number_of_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -5043,7 +5041,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'order' => 'ASC',
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $number_of_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $number_of_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $query_2 = $q->query(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -5053,7 +5051,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $number_of_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $number_of_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -5219,7 +5217,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'comments_pre_query', array( __CLASS__, 'filter_comments_pre_query' ), 10, 2 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $q = new WP_Comment_Query();
</span><span class="cx" style="display: block; padding: 0 10px"> $results = $q->query( array() );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -5227,7 +5225,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> remove_filter( 'comments_pre_query', array( __CLASS__, 'filter_comments_pre_query' ), 10, 2 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Make sure no queries were executed.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // We manually inserted a non-existing site and overrode the results with it.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( array( 555 ), $results );
</span></span></pre></div>
<a id="trunktestsphpunittestscommentwpUpdateCommentCountNowphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/comment/wpUpdateCommentCountNow.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/comment/wpUpdateCommentCountNow.php 2023-05-11 09:01:55 UTC (rev 55744)
+++ trunk/tests/phpunit/tests/comment/wpUpdateCommentCountNow.php 2023-05-11 10:05:51 UTC (rev 55745)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -14,16 +14,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_regular_post_updates_comment_count() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $post_id = self::factory()->post->create();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> self::factory()->comment->create_post_comments( $post_id, 1 );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( '1', get_comments_number( $post_id ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue( wp_update_comment_count_now( $post_id ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries + 2, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries + 2, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( '1', get_comments_number( $post_id ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -38,10 +36,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> self::factory()->comment->create_post_comments( $post_id, 1 );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( '100', get_comments_number( $post_id ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue( wp_update_comment_count_now( $post_id ) );
</span><span class="cx" style="display: block; padding: 0 10px"> // Only one query is made instead of two.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries + 1, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries + 1, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( '100', get_comments_number( $post_id ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunktestsphpunittestscustomizemanagerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/customize/manager.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/customize/manager.php 2023-05-11 09:01:55 UTC (rev 55744)
+++ trunk/tests/phpunit/tests/customize/manager.php 2023-05-11 10:05:51 UTC (rev 55745)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -271,7 +271,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 41039
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_fresh_site_flag_clearing() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wp_customize, $wpdb;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ global $wp_customize;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Make sure fresh site flag is cleared when publishing a changeset.
</span><span class="cx" style="display: block; padding: 0 10px"> update_option( 'fresh_site', '1' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -283,9 +283,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_load_alloptions();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Make sure no DB write is done when publishing and a site is already non-fresh.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $query_count = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $query_count = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> do_action( 'customize_save_after', $wp_customize );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $query_count, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $query_count, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunktestsphpunittestsgeneralwpGetArchivesphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/general/wpGetArchives.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/general/wpGetArchives.php 2023-05-11 09:01:55 UTC (rev 55744)
+++ trunk/tests/phpunit/tests/general/wpGetArchives.php 2023-05-11 10:05:51 UTC (rev 55745)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -16,13 +16,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 23206
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_archives_cache() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> self::factory()->post->create_many( 3, array( 'post_type' => 'post' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_cache_delete( 'last_changed', 'posts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse( wp_cache_get( 'last_changed', 'posts' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Cache is not primed, expect 1 query.
</span><span class="cx" style="display: block; padding: 0 10px"> $result = wp_get_archives(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -34,9 +32,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertIsString( $result );
</span><span class="cx" style="display: block; padding: 0 10px"> $time1 = wp_cache_get( 'last_changed', 'posts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotEmpty( $time1 );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries + 1, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries + 1, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Cache is primed, expect no queries.
</span><span class="cx" style="display: block; padding: 0 10px"> $result = wp_get_archives(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -47,7 +45,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertIsString( $result );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $time1, wp_cache_get( 'last_changed', 'posts' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Change args, resulting in a different query string. Cache is not primed, expect 1 query.
</span><span class="cx" style="display: block; padding: 0 10px"> $result = wp_get_archives(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -59,9 +57,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertIsString( $result );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $time1, wp_cache_get( 'last_changed', 'posts' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries + 1, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries + 1, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Cache is primed, expect no queries.
</span><span class="cx" style="display: block; padding: 0 10px"> $result = wp_get_archives(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -73,9 +71,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertIsString( $result );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $time1, wp_cache_get( 'last_changed', 'posts' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Change type. Cache is not primed, expect 1 query.
</span><span class="cx" style="display: block; padding: 0 10px"> $result = wp_get_archives(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -86,9 +84,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertIsString( $result );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $time1, wp_cache_get( 'last_changed', 'posts' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries + 1, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries + 1, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Cache is primed, expect no queries.
</span><span class="cx" style="display: block; padding: 0 10px"> $result = wp_get_archives(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -99,7 +97,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertIsString( $result );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $time1, wp_cache_get( 'last_changed', 'posts' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Change type. Cache is not primed, expect 1 query.
</span><span class="cx" style="display: block; padding: 0 10px"> $result = wp_get_archives(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -110,9 +108,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertIsString( $result );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $time1, wp_cache_get( 'last_changed', 'posts' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries + 1, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries + 1, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Cache is primed, expect no queries.
</span><span class="cx" style="display: block; padding: 0 10px"> $result = wp_get_archives(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -123,7 +121,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertIsString( $result );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $time1, wp_cache_get( 'last_changed', 'posts' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Change type. Cache is not primed, expect 1 query.
</span><span class="cx" style="display: block; padding: 0 10px"> $result = wp_get_archives(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -134,9 +132,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertIsString( $result );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $time1, wp_cache_get( 'last_changed', 'posts' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries + 1, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries + 1, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Cache is primed, expect no queries.
</span><span class="cx" style="display: block; padding: 0 10px"> $result = wp_get_archives(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -147,7 +145,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertIsString( $result );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $time1, wp_cache_get( 'last_changed', 'posts' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Change type. Cache is not primed, expect 1 query.
</span><span class="cx" style="display: block; padding: 0 10px"> $result = wp_get_archives(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -158,9 +156,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertIsString( $result );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $time1, wp_cache_get( 'last_changed', 'posts' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries + 1, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries + 1, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Cache is primed, expect no queries.
</span><span class="cx" style="display: block; padding: 0 10px"> $result = wp_get_archives(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -171,6 +169,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertIsString( $result );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $time1, wp_cache_get( 'last_changed', 'posts' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunittestsmultisitenetworkphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/multisite/network.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/multisite/network.php 2023-05-11 09:01:55 UTC (rev 55744)
+++ trunk/tests/phpunit/tests/multisite/network.php 2023-05-11 10:05:51 UTC (rev 55745)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -590,14 +590,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 42251
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_network_not_found_cache() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $new_network_id = $this->_get_next_network_id();
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNull( get_network( $new_network_id ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertNull( get_network( $new_network_id ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunktestsphpunittestsmultisitesitephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/multisite/site.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/multisite/site.php 2023-05-11 09:01:55 UTC (rev 55744)
+++ trunk/tests/phpunit/tests/multisite/site.php 2023-05-11 10:05:51 UTC (rev 55745)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2170,14 +2170,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 42251
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_site_not_found_cache() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $new_site_id = $this->_get_next_site_id();
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNull( get_site( $new_site_id ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertNull( get_site( $new_site_id ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunktestsphpunittestsmultisitesiteMetaphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/multisite/siteMeta.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/multisite/siteMeta.php 2023-05-11 09:01:55 UTC (rev 55744)
+++ trunk/tests/phpunit/tests/multisite/siteMeta.php 2023-05-11 10:05:51 UTC (rev 55745)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -220,8 +220,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_update_site_meta_cache() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> if ( ! is_site_meta_supported() ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -229,14 +227,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> update_site_meta( self::$site_id, 'foo', 'bar' );
</span><span class="cx" style="display: block; padding: 0 10px"> update_sitemeta_cache( array( self::$site_id ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> get_site_meta( self::$site_id, 'foo', true );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_query_update_site_meta_cache_true() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> if ( ! is_site_meta_supported() ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -250,14 +246,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> get_site_meta( self::$site_id, 'foo', true );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_query_update_site_meta_cache_false() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> if ( ! is_site_meta_supported() ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -271,9 +265,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> get_site_meta( self::$site_id, 'foo', true );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries + 1, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries + 1, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunktestsphpunittestsmultisitewpNetworkQueryphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/multisite/wpNetworkQuery.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/multisite/wpNetworkQuery.php 2023-05-11 09:01:55 UTC (rev 55744)
+++ trunk/tests/phpunit/tests/multisite/wpNetworkQuery.php 2023-05-11 10:05:51 UTC (rev 55745)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -428,8 +428,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 41347
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_wp_network_query_cache_with_different_fields_no_count() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $q = new WP_Network_Query();
</span><span class="cx" style="display: block; padding: 0 10px"> $query_1 = $q->query(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -438,7 +436,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'order' => 'ASC',
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $number_of_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $number_of_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $query_2 = $q->query(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -448,7 +446,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $number_of_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $number_of_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -455,8 +453,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 41347
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_wp_network_query_cache_with_different_fields_active_count() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $q = new WP_Network_Query();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $query_1 = $q->query(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -467,7 +463,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'count' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $number_of_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $number_of_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $query_2 = $q->query(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -477,7 +473,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'count' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $number_of_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $number_of_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -484,8 +480,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 41347
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_wp_network_query_cache_with_same_fields_different_count() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $q = new WP_Network_Query();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $query_1 = $q->query(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -496,7 +490,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $number_of_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $number_of_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $query_2 = $q->query(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -506,7 +500,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'count' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $number_of_queries + 1, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $number_of_queries + 1, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -568,11 +562,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 47599
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_networks_pre_query_filter_should_bypass_database_query() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'networks_pre_query', array( __CLASS__, 'filter_networks_pre_query' ), 10, 2 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $q = new WP_Network_Query();
</span><span class="cx" style="display: block; padding: 0 10px"> $results = $q->query( array() );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -580,7 +572,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> remove_filter( 'networks_pre_query', array( __CLASS__, 'filter_networks_pre_query' ), 10, 2 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Make sure no queries were executed.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // We manually inserted a non-existing site and overrode the results with it.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( array( 555 ), $results );
</span></span></pre></div>
<a id="trunktestsphpunittestsmultisitewpSiteQueryphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/multisite/wpSiteQuery.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/multisite/wpSiteQuery.php 2023-05-11 09:01:55 UTC (rev 55744)
+++ trunk/tests/phpunit/tests/multisite/wpSiteQuery.php 2023-05-11 10:05:51 UTC (rev 55745)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -779,7 +779,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 41197
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_wp_site_query_cache_with_different_fields_no_count() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
</del><span class="cx" style="display: block; padding: 0 10px"> $q = new WP_Site_Query();
</span><span class="cx" style="display: block; padding: 0 10px"> $query_1 = $q->query(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -789,7 +788,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'order' => 'ASC',
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $number_of_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $number_of_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $query_2 = $q->query(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -800,7 +799,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $number_of_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $number_of_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -807,7 +806,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 41197
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_wp_site_query_cache_with_different_fields_active_count() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
</del><span class="cx" style="display: block; padding: 0 10px"> $q = new WP_Site_Query();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $query_1 = $q->query(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -819,7 +817,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'count' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $number_of_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $number_of_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $query_2 = $q->query(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -830,7 +828,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'count' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $number_of_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $number_of_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -837,7 +835,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 41197
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_wp_site_query_cache_with_same_fields_different_count() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
</del><span class="cx" style="display: block; padding: 0 10px"> $q = new WP_Site_Query();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $query_1 = $q->query(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -860,7 +857,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'count' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $number_of_queries + 1, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $number_of_queries + 1, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1119,11 +1116,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 47599
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_sites_pre_query_filter_should_bypass_database_query() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'sites_pre_query', array( __CLASS__, 'filter_sites_pre_query' ), 10, 2 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $q = new WP_Site_Query();
</span><span class="cx" style="display: block; padding: 0 10px"> $results = $q->query( array() );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1131,7 +1126,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> remove_filter( 'sites_pre_query', array( __CLASS__, 'filter_sites_pre_query' ), 10, 2 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Make sure no queries were executed.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // We manually inserted a non-existing site and overrode the results with it.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( array( 555 ), $results );
</span></span></pre></div>
<a id="trunktestsphpunittestsoptionupdateOptionphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/option/updateOption.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/option/updateOption.php 2023-05-11 09:01:55 UTC (rev 55744)
+++ trunk/tests/phpunit/tests/option/updateOption.php 2023-05-11 10:05:51 UTC (rev 55745)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -28,7 +28,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::get_option
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_should_set_autoload_yes_for_nonexistent_option_when_autoload_param_is_missing() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
</del><span class="cx" style="display: block; padding: 0 10px"> $this->flush_cache();
</span><span class="cx" style="display: block; padding: 0 10px"> update_option( 'test_update_option_default', 'value' );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->flush_cache();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -36,9 +35,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Populate the alloptions cache, which includes autoload=yes options.
</span><span class="cx" style="display: block; padding: 0 10px"> wp_load_alloptions();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $before = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $before = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> $value = get_option( 'test_update_option_default' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $after = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $after = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $before, $after );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $value, 'value' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -52,7 +51,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::get_option
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_should_set_autoload_yes_for_nonexistent_option_when_autoload_param_is_yes() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
</del><span class="cx" style="display: block; padding: 0 10px"> $this->flush_cache();
</span><span class="cx" style="display: block; padding: 0 10px"> update_option( 'test_update_option_default', 'value', 'yes' );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->flush_cache();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -60,9 +58,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Populate the alloptions cache, which includes autoload=yes options.
</span><span class="cx" style="display: block; padding: 0 10px"> wp_load_alloptions();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $before = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $before = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> $value = get_option( 'test_update_option_default' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $after = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $after = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $before, $after );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $value, 'value' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -76,7 +74,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::get_option
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_should_set_autoload_no_for_nonexistent_option_when_autoload_param_is_no() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
</del><span class="cx" style="display: block; padding: 0 10px"> $this->flush_cache();
</span><span class="cx" style="display: block; padding: 0 10px"> update_option( 'test_update_option_default', 'value', 'no' );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->flush_cache();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -84,9 +81,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Populate the alloptions cache, which does not include autoload=no options.
</span><span class="cx" style="display: block; padding: 0 10px"> wp_load_alloptions();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $before = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $before = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> $value = get_option( 'test_update_option_default' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $after = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $after = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Database has been hit.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $before + 1, $after );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -101,7 +98,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::get_option
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_should_set_autoload_no_for_nonexistent_option_when_autoload_param_is_false() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
</del><span class="cx" style="display: block; padding: 0 10px"> $this->flush_cache();
</span><span class="cx" style="display: block; padding: 0 10px"> update_option( 'test_update_option_default', 'value', false );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->flush_cache();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -109,9 +105,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Populate the alloptions cache, which does not include autoload=no options.
</span><span class="cx" style="display: block; padding: 0 10px"> wp_load_alloptions();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $before = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $before = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> $value = get_option( 'test_update_option_default' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $after = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $after = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Database has been hit.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $before + 1, $after );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -126,7 +122,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::get_option
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_autoload_should_be_updated_for_existing_option_when_value_is_changed() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
</del><span class="cx" style="display: block; padding: 0 10px"> add_option( 'foo', 'bar', '', 'no' );
</span><span class="cx" style="display: block; padding: 0 10px"> $updated = update_option( 'foo', 'bar2', true );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue( $updated );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -136,10 +131,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Populate the alloptions cache, which includes autoload=yes options.
</span><span class="cx" style="display: block; padding: 0 10px"> wp_load_alloptions();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $before = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $before = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> $value = get_option( 'foo' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $before, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $before, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $value, 'bar2' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -151,7 +146,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::get_option
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_autoload_should_not_be_updated_for_existing_option_when_value_is_unchanged() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
</del><span class="cx" style="display: block; padding: 0 10px"> add_option( 'foo', 'bar', '', 'yes' );
</span><span class="cx" style="display: block; padding: 0 10px"> $updated = update_option( 'foo', 'bar', false );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse( $updated );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -161,11 +155,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Populate the alloptions cache, which includes autoload=yes options.
</span><span class="cx" style="display: block; padding: 0 10px"> wp_load_alloptions();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $before = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $before = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> $value = get_option( 'foo' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // 'foo' should still be autoload=yes, so we should see no additional querios.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $before, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $before, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $value, 'bar' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -177,7 +171,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::get_option
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_autoload_should_not_be_updated_for_existing_option_when_value_is_changed_but_no_value_of_autoload_is_provided() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
</del><span class="cx" style="display: block; padding: 0 10px"> add_option( 'foo', 'bar', '', 'yes' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Don't pass a value for `$autoload`.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -189,11 +182,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Populate the alloptions cache, which includes autoload=yes options.
</span><span class="cx" style="display: block; padding: 0 10px"> wp_load_alloptions();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $before = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $before = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> $value = get_option( 'foo' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // 'foo' should still be autoload=yes, so we should see no additional queries.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $before, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $before, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $value, 'bar2' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunktestsphpunittestsoptionwpLoadAlloptionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/option/wpLoadAlloptions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/option/wpLoadAlloptions.php 2023-05-11 09:01:55 UTC (rev 55744)
+++ trunk/tests/phpunit/tests/option/wpLoadAlloptions.php 2023-05-11 10:05:51 UTC (rev 55745)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -34,10 +34,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::wp_load_alloptions
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_if_alloptions_are_retrieved_from_cache() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
- $before = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $before = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_load_alloptions();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $after = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $after = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Database has not been hit.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $before, $after );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -49,14 +48,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::wp_load_alloptions
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_if_alloptions_are_retrieved_from_database() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> // Delete the existing cache first.
</span><span class="cx" style="display: block; padding: 0 10px"> wp_cache_delete( 'alloptions', 'options' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $before = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $before = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_load_alloptions();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $after = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $after = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Database has been hit.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $before + 1, $after );
</span></span></pre></div>
<a id="trunktestsphpunittestspostgetPageByPathphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/post/getPageByPath.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/post/getPageByPath.php 2023-05-11 09:01:55 UTC (rev 55744)
+++ trunk/tests/phpunit/tests/post/getPageByPath.php 2023-05-11 10:05:51 UTC (rev 55745)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -260,8 +260,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 36711
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_should_hit_cache() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $page = self::factory()->post->create(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_type' => 'page',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -273,11 +271,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $found = get_page_by_path( 'foo' );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $page, $found->ID );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $found = get_page_by_path( 'foo' );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $page, $found->ID );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -284,17 +282,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 36711
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_bad_path_should_be_cached() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> // Prime cache.
</span><span class="cx" style="display: block; padding: 0 10px"> $found = get_page_by_path( 'foo' );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNull( $found );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $found = get_page_by_path( 'foo' );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNull( $found );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -301,7 +297,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 36711
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_bad_path_served_from_cache_should_not_fall_back_on_current_post() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb, $post;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ global $post;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Fake the global.
</span><span class="cx" style="display: block; padding: 0 10px"> $post = self::factory()->post->create_and_get();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -310,11 +306,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $found = get_page_by_path( 'foo' );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNull( $found );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $found = get_page_by_path( 'foo' );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNull( $found );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> unset( $post );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -323,8 +319,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 36711
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_cache_should_not_match_post_in_different_post_type_with_same_path() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> register_post_type( 'wptests_pt' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $p1 = self::factory()->post->create(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -345,12 +339,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $found = get_page_by_path( 'foo' );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $p1, $found->ID );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $found = get_page_by_path( 'foo', OBJECT, 'wptests_pt' );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $p2, $found->ID );
</span><span class="cx" style="display: block; padding: 0 10px"> $num_queries++;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -357,8 +351,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 36711
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_cache_should_be_invalidated_when_post_name_is_edited() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $page = self::factory()->post->create(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_type' => 'page',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -377,12 +369,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $found = get_page_by_path( 'bar' );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $page, $found->ID );
</span><span class="cx" style="display: block; padding: 0 10px"> $num_queries++;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunktestsphpunittestspostgetPagesphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/post/getPages.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/post/getPages.php 2023-05-11 09:01:55 UTC (rev 55744)
+++ trunk/tests/phpunit/tests/post/getPages.php 2023-05-11 10:05:51 UTC (rev 55745)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -10,8 +10,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 23167
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_pages_cache() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> self::factory()->post->create_many( 3, array( 'post_type' => 'page' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_cache_delete( 'last_changed', 'posts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse( wp_cache_get( 'last_changed', 'posts' ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -20,7 +18,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertCount( 3, $pages );
</span><span class="cx" style="display: block; padding: 0 10px"> $time1 = wp_cache_get( 'last_changed', 'posts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotEmpty( $time1 );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ( $pages as $page ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertInstanceOf( 'WP_Post', $page );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -29,7 +27,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $pages = get_pages();
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertCount( 3, $pages );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $time1, wp_cache_get( 'last_changed', 'posts' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ( $pages as $page ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertInstanceOf( 'WP_Post', $page );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -39,18 +37,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $pages = get_pages( array( 'number' => 2 ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertCount( 2, $pages );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $time1, wp_cache_get( 'last_changed', 'posts' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries + 1, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries + 1, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ( $pages as $page ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertInstanceOf( 'WP_Post', $page );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Again. num_queries and last_changed should remain the same.
</span><span class="cx" style="display: block; padding: 0 10px"> $pages = get_pages( array( 'number' => 2 ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertCount( 2, $pages );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $time1, wp_cache_get( 'last_changed', 'posts' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ( $pages as $page ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertInstanceOf( 'WP_Post', $page );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -59,7 +57,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $pages = get_pages();
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertCount( 3, $pages );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $time1, wp_cache_get( 'last_changed', 'posts' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ( $pages as $page ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertInstanceOf( 'WP_Post', $page );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -68,13 +66,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> clean_post_cache( $pages[0]->ID );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotEquals( $time1, $time2 = wp_cache_get( 'last_changed', 'posts' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> get_post( $pages[0]->ID );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // last_changed bumped so num_queries should increment.
</span><span class="cx" style="display: block; padding: 0 10px"> $pages = get_pages( array( 'number' => 2 ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertCount( 2, $pages );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $time2, wp_cache_get( 'last_changed', 'posts' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries + 1, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries + 1, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ( $pages as $page ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertInstanceOf( 'WP_Post', $page );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -87,7 +85,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $new_changed_float = $this->_microtime_to_float( wp_cache_get( 'last_changed', 'posts' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertGreaterThan( $old_changed_float, $new_changed_float );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> $last_changed = wp_cache_get( 'last_changed', 'posts' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // num_queries should bump after wp_delete_post() bumps last_changed.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -94,7 +92,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $pages = get_pages();
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertCount( 2, $pages );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $last_changed, wp_cache_get( 'last_changed', 'posts' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries + 1, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries + 1, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ( $pages as $page ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertInstanceOf( 'WP_Post', $page );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -104,22 +102,20 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 43514
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_pages_cache_empty() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> wp_cache_delete( 'last_changed', 'posts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse( wp_cache_get( 'last_changed', 'posts' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $pages = get_pages(); // Database gets queried.
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries + 1, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries + 1, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $pages = get_pages(); // Database should not get queried.
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunktestsphpunittestspostgetPostClassphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/post/getPostClass.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/post/getPostClass.php 2023-05-11 09:01:55 UTC (rev 55744)
+++ trunk/tests/phpunit/tests/post/getPostClass.php 2023-05-11 10:05:51 UTC (rev 55745)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -121,8 +121,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @group cache
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_taxonomy_classes_hit_cache() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> register_taxonomy( 'wptests_tax', 'post' );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_post_terms( $this->post_id, array( 'foo', 'bar' ), 'wptests_tax' );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_post_terms( $this->post_id, array( 'footag', 'bartag' ), 'post_tag' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -131,10 +129,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> update_object_term_cache( $this->post_id, 'post' );
</span><span class="cx" style="display: block; padding: 0 10px"> update_meta_cache( 'post', $this->post_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $found = get_post_class( '', $this->post_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunittestspostqueryphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/post/query.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/post/query.php 2023-05-11 09:01:55 UTC (rev 55744)
+++ trunk/tests/phpunit/tests/post/query.php 2023-05-11 10:05:51 UTC (rev 55745)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -555,11 +555,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 36687
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_posts_pre_query_filter_should_bypass_database_query() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'posts_pre_query', array( __CLASS__, 'filter_posts_pre_query' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> $q = new WP_Query(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'fields' => 'ids',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -569,7 +567,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> remove_filter( 'posts_pre_query', array( __CLASS__, 'filter_posts_pre_query' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( array( 12345 ), $q->posts );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunktestsphpunittestsquerycommentFeedphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/query/commentFeed.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/query/commentFeed.php 2023-05-11 09:01:55 UTC (rev 55744)
+++ trunk/tests/phpunit/tests/query/commentFeed.php 2023-05-11 10:05:51 UTC (rev 55745)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -28,7 +28,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 36904
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_archive_comment_feed() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
</del><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'split_the_query', '__return_false' );
</span><span class="cx" style="display: block; padding: 0 10px"> $q1 = new WP_Query();
</span><span class="cx" style="display: block; padding: 0 10px"> $args = array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -42,12 +41,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'cache_results' => false,
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $q1->query( $args );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> $q2 = new WP_Query();
</span><span class="cx" style="display: block; padding: 0 10px"> $q2->query( $args );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue( $q2->is_comment_feed() );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse( $q2->is_singular() );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries + 1, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries + 1, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -87,7 +86,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 36904
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_single_comment_feed() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
</del><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( self::$post_ids[0] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $q1 = new WP_Query();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -103,12 +101,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $q1->query( $args );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> $q2 = new WP_Query();
</span><span class="cx" style="display: block; padding: 0 10px"> $q2->query( $args );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue( $q2->is_comment_feed() );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue( $q2->is_singular() );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries + 1, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries + 1, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunittestsrestapiresttagscontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/rest-api/rest-tags-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/rest-api/rest-tags-controller.php 2023-05-11 09:01:55 UTC (rev 55744)
+++ trunk/tests/phpunit/tests/rest-api/rest-tags-controller.php 2023-05-11 10:05:51 UTC (rev 55745)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1336,8 +1336,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 38504
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_object_term_queries_are_cached() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $tags = self::factory()->tag->create_many( 2 );
</span><span class="cx" style="display: block; padding: 0 10px"> $p = self::factory()->post->create();
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_object_terms( $p, $tags[0], 'post_tag' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1349,7 +1347,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> unset( $request, $response );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'GET', '/wp/v2/tags' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'post', $p );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1357,7 +1355,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $found_2 = wp_list_pluck( $response->data, 'id' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSameSets( $found_1, $found_2 );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunktestsphpunitteststermcachephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/term/cache.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/term/cache.php 2023-05-11 09:01:55 UTC (rev 55744)
+++ trunk/tests/phpunit/tests/term/cache.php 2023-05-11 10:05:51 UTC (rev 55745)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -101,8 +101,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_term_should_update_term_cache_when_passed_an_object() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> register_taxonomy( 'wptests_tax', 'post' );
</span><span class="cx" style="display: block; padding: 0 10px"> $term = self::factory()->term->create(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -116,7 +114,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Affirm that the cache is empty.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEmpty( wp_cache_get( $term, 'terms' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // get_term() will only be update the cache if the 'filter' prop is unset.
</span><span class="cx" style="display: block; padding: 0 10px"> unset( $term_object->filter );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -124,13 +122,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $term_object_2 = get_term( $term_object, 'wptests_tax' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // No new queries should have fired.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $term_object, $term_object_2 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_term_should_update_term_cache_when_passed_a_valid_term_identifier() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> register_taxonomy( 'wptests_tax', 'post' );
</span><span class="cx" style="display: block; padding: 0 10px"> $term = self::factory()->term->create(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -143,23 +139,21 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Affirm that the cache is empty.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEmpty( wp_cache_get( $term, 'terms' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Prime cache.
</span><span class="cx" style="display: block; padding: 0 10px"> $term_object = get_term( $term, 'wptests_tax' );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotEmpty( wp_cache_get( $term, 'terms' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries + 1, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries + 1, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $term_object_2 = get_term( $term, 'wptests_tax' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // No new queries should have fired.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries + 1, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries + 1, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $term_object, $term_object_2 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_term_by_should_update_term_cache_when_passed_a_valid_term_identifier() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> register_taxonomy( 'wptests_tax', 'post' );
</span><span class="cx" style="display: block; padding: 0 10px"> $term = self::factory()->term->create(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -172,17 +166,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Affirm that the cache is empty.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEmpty( wp_cache_get( $term, 'terms' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Prime cache.
</span><span class="cx" style="display: block; padding: 0 10px"> $term_object = get_term_by( 'id', $term, 'wptests_tax' );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotEmpty( wp_cache_get( $term, 'terms' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries + 1, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries + 1, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $term_object_2 = get_term( $term, 'wptests_tax' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // No new queries should have fired.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries + 1, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries + 1, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $term_object, $term_object_2 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -190,8 +184,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 30749
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_terms_should_update_cache_for_located_terms() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> register_taxonomy( 'wptests_tax', 'post' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $terms = self::factory()->term->create_many(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -208,13 +200,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $terms as $term_id ) {
</span><span class="cx" style="display: block; padding: 0 10px"> get_term( $term_id, 'wptests_tax' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> _unregister_taxonomy( 'wptests_tax' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -242,8 +234,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 21760
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_term_by_slug_cache() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $term_id = self::factory()->term->create(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'slug' => 'burrito',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -253,20 +243,20 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> clean_term_cache( $term_id, 'post_tag' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $term = get_term_by( 'slug', 'burrito', 'post_tag' );
</span><span class="cx" style="display: block; padding: 0 10px"> $num_queries = $num_queries + 2;
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'Taco', $term->name );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // This should now hit cache.
</span><span class="cx" style="display: block; padding: 0 10px"> $term = get_term_by( 'slug', 'burrito', 'post_tag' );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'Taco', $term->name );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( get_term( $term_id, 'post_tag' ), $term );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -273,8 +263,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 21760
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_term_by_slug_cache_update() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $term_id = self::factory()->term->create(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'slug' => 'burrito',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -284,27 +272,27 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> clean_term_cache( $term_id, 'post_tag' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $term = get_term_by( 'slug', 'burrito', 'post_tag' );
</span><span class="cx" style="display: block; padding: 0 10px"> $num_queries = $num_queries + 2;
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'Taco', $term->name );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // This should now hit cache.
</span><span class="cx" style="display: block; padding: 0 10px"> $term = get_term_by( 'slug', 'burrito', 'post_tag' );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'Taco', $term->name );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Update the tag which invalidates the cache.
</span><span class="cx" style="display: block; padding: 0 10px"> wp_update_term( $term_id, 'post_tag', array( 'name' => 'No Taco' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // This should not hit cache.
</span><span class="cx" style="display: block; padding: 0 10px"> $term = get_term_by( 'slug', 'burrito', 'post_tag' );
</span><span class="cx" style="display: block; padding: 0 10px"> $num_queries = $num_queries + 2;
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'No Taco', $term->name );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -311,8 +299,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 21760
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_term_by_name_cache() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $term_id = self::factory()->term->create(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'name' => 'Burrito',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -322,18 +308,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> clean_term_cache( $term_id, 'post_tag' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> get_term_by( 'name', 'Burrito', 'post_tag' );
</span><span class="cx" style="display: block; padding: 0 10px"> $num_queries = $num_queries + 2;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // This should now hit cache.
</span><span class="cx" style="display: block; padding: 0 10px"> $term = get_term_by( 'name', 'Burrito', 'post_tag' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( get_term( $term_id, 'post_tag' ), $term );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -340,8 +326,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 21760
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_term_by_name_cache_update() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $term_id = self::factory()->term->create(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'name' => 'Burrito',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -351,24 +335,24 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> clean_term_cache( $term_id, 'post_tag' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> get_term_by( 'name', 'Burrito', 'post_tag' );
</span><span class="cx" style="display: block; padding: 0 10px"> $num_queries = $num_queries + 2;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // This should now hit cache.
</span><span class="cx" style="display: block; padding: 0 10px"> get_term_by( 'name', 'Burrito', 'post_tag' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Update the tag which invalidates the cache.
</span><span class="cx" style="display: block; padding: 0 10px"> wp_update_term( $term_id, 'post_tag', array( 'slug' => 'taco' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // This should not hit cache.
</span><span class="cx" style="display: block; padding: 0 10px"> get_term_by( 'name', 'burrito', 'post_tag' );
</span><span class="cx" style="display: block; padding: 0 10px"> $num_queries = $num_queries + 2;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -375,8 +359,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 21760
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_invalidating_term_caches_should_fail_when_invalidation_is_suspended() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $term_id = self::factory()->term->create(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'name' => 'Burrito',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -385,7 +367,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> clean_term_cache( $term_id, 'post_tag' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> $last_changed = wp_cache_get( 'last_changed', 'terms' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $term1 = get_term_by( 'name', 'Burrito', 'post_tag' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -393,7 +375,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Verify the term is cached.
</span><span class="cx" style="display: block; padding: 0 10px"> $term2 = get_term_by( 'name', 'Burrito', 'post_tag' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $term1, $term2 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $suspend = wp_suspend_cache_invalidation();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -400,11 +382,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Update the tag.
</span><span class="cx" style="display: block; padding: 0 10px"> wp_update_term( $term_id, 'post_tag', array( 'name' => 'Taco' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Verify that the cached term still matches the initial cached term.
</span><span class="cx" style="display: block; padding: 0 10px"> $term3 = get_term_by( 'name', 'Burrito', 'post_tag' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $term1, $term3 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Verify that last changed has not been updated as part of an invalidation routine.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -418,8 +400,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 21760
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_term_by_does_not_prime_term_meta_cache() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $term_id = self::factory()->term->create(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'name' => 'Burrito',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -429,18 +409,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> add_term_meta( $term_id, 'foo', 'bar' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> clean_term_cache( $term_id, 'post_tag' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $term = get_term_by( 'name', 'Burrito', 'post_tag' );
</span><span class="cx" style="display: block; padding: 0 10px"> $num_queries = $num_queries + 2;
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertInstanceOf( 'WP_Term', $term );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $term_id, $term->term_id );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $term_meta = get_term_meta( $term_id, 'foo', true );
</span><span class="cx" style="display: block; padding: 0 10px"> $num_queries++;
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $term_meta, 'bar' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunktestsphpunitteststermgetTermphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/term/getTerm.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/term/getTerm.php 2023-05-11 09:01:55 UTC (rev 55744)
+++ trunk/tests/phpunit/tests/term/getTerm.php 2023-05-11 10:05:51 UTC (rev 55745)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -60,17 +60,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_passing_term_object_should_skip_database_query_when_filter_property_is_empty() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $term = self::factory()->term->create_and_get( array( 'taxonomy' => 'wptests_tax' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> clean_term_cache( $term->term_id, 'wptests_tax' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> unset( $term->filter );
</span><span class="cx" style="display: block; padding: 0 10px"> $term_a = get_term( $term, 'wptests_tax' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_passing_term_string_that_casts_to_int_0_should_return_null() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -82,18 +80,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_cache_should_be_populated_by_successful_fetch() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> clean_term_cache( $t, 'wptests_tax' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Prime cache.
</span><span class="cx" style="display: block; padding: 0 10px"> $term_a = get_term( $t, 'wptests_tax' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Second call shouldn't require a database query.
</span><span class="cx" style="display: block; padding: 0 10px"> $term_b = get_term( $t, 'wptests_tax' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $term_a, $term_b );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -196,19 +192,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 34533
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_shared_term_in_cache_should_be_ignored_when_specifying_a_different_taxonomy() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $terms = $this->generate_shared_terms();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Prime cache for 'wptests_tax'.
</span><span class="cx" style="display: block; padding: 0 10px"> get_term( $terms[0]['term_id'], 'wptests_tax' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Database should be hit again.
</span><span class="cx" style="display: block; padding: 0 10px"> $found = get_term( $terms[1]['term_id'], 'wptests_tax_2' );
</span><span class="cx" style="display: block; padding: 0 10px"> $num_queries++;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertInstanceOf( 'WP_Term', $found );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'wptests_tax_2', $found->taxonomy );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunitteststermgetTermByphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/term/getTermBy.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/term/getTermBy.php 2023-05-11 09:01:55 UTC (rev 55744)
+++ trunk/tests/phpunit/tests/term/getTermBy.php 2023-05-11 10:05:51 UTC (rev 55745)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -111,8 +111,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 14162
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_should_prime_term_cache() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> register_taxonomy( 'wptests_tax', 'post' );
</span><span class="cx" style="display: block; padding: 0 10px"> $t = self::factory()->term->create(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -123,18 +121,18 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> clean_term_cache( $t, 'wptests_tax' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> $found = get_term_by( 'slug', 'foo', 'wptests_tax' );
</span><span class="cx" style="display: block; padding: 0 10px"> $num_queries = $num_queries + 2;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertInstanceOf( 'WP_Term', $found );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $t, $found->term_id );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Calls to `get_term()` should now hit cache.
</span><span class="cx" style="display: block; padding: 0 10px"> $found2 = get_term( $t );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $t, $found->term_id );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunktestsphpunitteststermgetTermsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/term/getTerms.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/term/getTerms.php 2023-05-11 09:01:55 UTC (rev 55744)
+++ trunk/tests/phpunit/tests/term/getTerms.php 2023-05-11 10:05:51 UTC (rev 55745)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -134,11 +134,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 23326
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_terms_cache() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $this->set_up_three_posts_and_tags();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // last_changed and num_queries should bump.
</span><span class="cx" style="display: block; padding: 0 10px"> $terms = get_terms( 'post_tag', array( 'update_term_meta_cache' => false ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -145,15 +143,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertCount( 3, $terms );
</span><span class="cx" style="display: block; padding: 0 10px"> $time1 = wp_cache_get( 'last_changed', 'terms' );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotEmpty( $time1 );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries + 2, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries + 2, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Again. last_changed and num_queries should remain the same.
</span><span class="cx" style="display: block; padding: 0 10px"> $terms = get_terms( 'post_tag', array( 'update_term_meta_cache' => false ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertCount( 3, $terms );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $time1, wp_cache_get( 'last_changed', 'terms' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -167,21 +165,21 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Prime cache.
</span><span class="cx" style="display: block; padding: 0 10px"> $terms = get_terms( 'post_tag' );
</span><span class="cx" style="display: block; padding: 0 10px"> $time1 = wp_cache_get( 'last_changed', 'terms' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // num_queries should bump, last_changed should remain the same.
</span><span class="cx" style="display: block; padding: 0 10px"> $terms = get_terms( 'post_tag', array( 'number' => 2 ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertCount( 2, $terms );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $time1, wp_cache_get( 'last_changed', 'terms' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries + 1, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries + 1, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Again. last_changed and num_queries should remain the same.
</span><span class="cx" style="display: block; padding: 0 10px"> $terms = get_terms( 'post_tag', array( 'number' => 2 ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertCount( 2, $terms );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $time1, wp_cache_get( 'last_changed', 'terms' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -195,12 +193,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Prime cache.
</span><span class="cx" style="display: block; padding: 0 10px"> $terms = get_terms( 'post_tag' );
</span><span class="cx" style="display: block; padding: 0 10px"> $time1 = wp_cache_get( 'last_changed', 'terms' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Force last_changed to bump.
</span><span class="cx" style="display: block; padding: 0 10px"> wp_delete_term( $terms[0]->term_id, 'post_tag' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> $time2 = wp_cache_get( 'last_changed', 'terms' );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotEquals( $time1, $time2 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -208,15 +206,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $terms = get_terms( 'post_tag' );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertCount( 2, $terms );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $time2, wp_cache_get( 'last_changed', 'terms' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries + 1, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries + 1, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Again. last_changed and num_queries should remain the same.
</span><span class="cx" style="display: block; padding: 0 10px"> $terms = get_terms( 'post_tag' );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertCount( 2, $terms );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $time2, wp_cache_get( 'last_changed', 'terms' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // @todo Repeat with term insert and update.
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -848,13 +846,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 31118
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_child_of_should_skip_query_when_specified_parent_is_not_found_in_hierarchy_cache() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $terms = self::factory()->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $found = get_terms(
</span><span class="cx" style="display: block; padding: 0 10px"> 'wptests_tax',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -865,7 +861,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEmpty( $found );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2473,13 +2469,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 31118
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_parent_should_skip_query_when_specified_parent_is_not_found_in_hierarchy_cache() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $terms = self::factory()->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $found = get_terms(
</span><span class="cx" style="display: block; padding: 0 10px"> 'wptests_tax',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2490,7 +2484,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEmpty( $found );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2773,13 +2767,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $terms as $t ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'bar', get_term_meta( $t, 'foo', true ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries + 1, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries + 1, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2803,13 +2797,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $terms as $t ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'bar', get_term_meta( $t, 'foo', true ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries + 3, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries + 3, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2908,7 +2902,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $found = get_terms(
</span><span class="cx" style="display: block; padding: 0 10px"> 'wptests_tax',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2918,7 +2912,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotEmpty( $found );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2931,8 +2925,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 14162
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_should_prime_individual_term_cache_when_fields_is_all() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> register_taxonomy( 'wptests_tax', 'post' );
</span><span class="cx" style="display: block; padding: 0 10px"> $terms = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2944,9 +2936,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> $term0 = get_term( $terms[0] );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunktestsphpunitteststermgetTheTermsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/term/getTheTerms.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/term/getTheTerms.php 2023-05-11 09:01:55 UTC (rev 55744)
+++ trunk/tests/phpunit/tests/term/getTheTerms.php 2023-05-11 10:05:51 UTC (rev 55745)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -197,8 +197,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 36814
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_uncached_terms_should_be_primed_with_a_single_query() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> register_taxonomy( 'wptests_tax', 'post' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $terms = self::factory()->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -210,13 +208,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Clean cache for two of the terms.
</span><span class="cx" style="display: block; padding: 0 10px"> clean_term_cache( array( $terms[0], $terms[1] ), 'wptests_tax', false );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> $found = get_the_terms( self::$post_ids[0], 'wptests_tax' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSameSets( $terms, wp_list_pluck( $found, 'term_id' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $num_queries++;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunktestsphpunitteststermisObjectInTermphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/term/isObjectInTerm.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/term/isObjectInTerm.php 2023-05-11 09:01:55 UTC (rev 55744)
+++ trunk/tests/phpunit/tests/term/isObjectInTerm.php 2023-05-11 10:05:51 UTC (rev 55745)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -135,8 +135,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 32044
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_should_populate_and_hit_relationships_cache() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> register_taxonomy( 'wptests_tax', 'post' );
</span><span class="cx" style="display: block; padding: 0 10px"> $terms = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -143,13 +141,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $o = 12345;
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_object_terms( $o, $terms[0], 'wptests_tax' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue( is_object_in_term( $o, 'wptests_tax', $terms[0] ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $num_queries = $num_queries + 2;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse( is_object_in_term( $o, 'wptests_tax', $terms[1] ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -156,8 +154,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 32044
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_should_not_be_fooled_by_a_stale_relationship_cache() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> register_taxonomy( 'wptests_tax', 'post' );
</span><span class="cx" style="display: block; padding: 0 10px"> $terms = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -164,17 +160,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $o = 12345;
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_object_terms( $o, $terms[0], 'wptests_tax' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue( is_object_in_term( $o, 'wptests_tax', $terms[0] ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $num_queries = $num_queries + 2;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_object_terms( $o, $terms[1], 'wptests_tax' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue( is_object_in_term( $o, 'wptests_tax', $terms[1] ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $num_queries = $num_queries + 2;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunktestsphpunitteststermmetaphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/term/meta.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/term/meta.php 2023-05-11 09:01:55 UTC (rev 55744)
+++ trunk/tests/phpunit/tests/term/meta.php 2023-05-11 10:05:51 UTC (rev 55745)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -114,8 +114,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_term_meta_should_be_lazy_loaded_for_all_terms_in_wp_query_loop() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $p = self::factory()->post->create( array( 'post_status' => 'publish' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> register_taxonomy( 'wptests_tax', 'post' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -139,20 +137,20 @@
</span><span class="cx" style="display: block; padding: 0 10px"> the_post();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // First request will hit the database.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'bar', get_term_meta( $terms[0], 'foo', true ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $num_queries++;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Second and third requests should be in cache.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'bar', get_term_meta( $terms[1], 'foo', true ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'bar', get_term_meta( $terms[2], 'foo', true ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Querying a term not primed should result in a hit.
</span><span class="cx" style="display: block; padding: 0 10px"> $num_queries++;
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'bar', get_term_meta( $orphan_term, 'foo', true ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -186,8 +184,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 36593
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_lazy_load_term_meta_false() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $p = self::factory()->post->create( array( 'post_status' => 'publish' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> register_taxonomy( 'wptests_tax', 'post' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -210,14 +206,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $q->the_post();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Requests will hit the database.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'bar', get_term_meta( $terms[0], 'foo', true ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $num_queries++;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'bar', get_term_meta( $terms[1], 'foo', true ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $num_queries++;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunitteststermqueryphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/term/query.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/term/query.php 2023-05-11 09:01:55 UTC (rev 55744)
+++ trunk/tests/phpunit/tests/term/query.php 2023-05-11 10:05:51 UTC (rev 55745)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -456,8 +456,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @group cache
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_count_query_should_be_cached() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> register_taxonomy( 'wptests_tax_1', 'post' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $terms = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax_1' ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -472,7 +470,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $count = $query->get_terms();
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 2, $count );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $query = new WP_Term_Query(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -483,7 +481,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $count = $query->get_terms();
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 2, $count );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -803,11 +801,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 41246
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_terms_pre_query_filter_should_bypass_database_query() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'terms_pre_query', array( __CLASS__, 'filter_terms_pre_query' ), 10, 2 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $q = new WP_Term_Query();
</span><span class="cx" style="display: block; padding: 0 10px"> $results = $q->query(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -819,7 +815,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> remove_filter( 'terms_pre_query', array( __CLASS__, 'filter_terms_pre_query' ), 10, 2 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Make sure no queries were executed.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // We manually inserted a non-existing term and overrode the results with it.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( array( 555 ), $q->terms );
</span></span></pre></div>
<a id="trunktestsphpunitteststermtermExistsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/term/termExists.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/term/termExists.php 2023-05-11 09:01:55 UTC (rev 55744)
+++ trunk/tests/phpunit/tests/term/termExists.php 2023-05-11 10:05:51 UTC (rev 55745)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -320,7 +320,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::term_exists()
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_term_exists_caching() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
</del><span class="cx" style="display: block; padding: 0 10px"> register_taxonomy( 'wptests_tax', 'post' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $slug = __FUNCTION__;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -331,14 +330,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $t, term_exists( $slug ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $t, term_exists( $slug ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue( wp_delete_term( $t, 'wptests_tax' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertNull( term_exists( $slug ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries + 2, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries + 2, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Clean up.
</span><span class="cx" style="display: block; padding: 0 10px"> _unregister_taxonomy( 'wptests_tax' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -349,7 +348,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::term_exists()
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_term_exists_caching_suspend_cache_invalidation() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
</del><span class="cx" style="display: block; padding: 0 10px"> register_taxonomy( 'wptests_tax', 'post' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_suspend_cache_invalidation( true );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -362,9 +360,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $t, term_exists( $slug ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $t, term_exists( $slug ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries + 1, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries + 1, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_suspend_cache_invalidation( false );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Clean up.
</span></span></pre></div>
<a id="trunktestsphpunitteststermwpGetObjectTermsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/term/wpGetObjectTerms.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/term/wpGetObjectTerms.php 2023-05-11 09:01:55 UTC (rev 55744)
+++ trunk/tests/phpunit/tests/term/wpGetObjectTerms.php 2023-05-11 10:05:51 UTC (rev 55745)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -616,8 +616,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 10142
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_termmeta_cache_should_be_lazy_loaded_by_default() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> register_taxonomy( 'wptests_tax', 'post' );
</span><span class="cx" style="display: block; padding: 0 10px"> $terms = self::factory()->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> add_term_meta( $terms[0], 'foo', 'bar' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -629,13 +627,13 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $found = wp_get_object_terms( $p, 'wptests_tax' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $terms as $t ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'bar', get_term_meta( $t, 'foo', true ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries + 1, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries + 1, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -642,8 +640,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 10142
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_termmeta_cache_should_not_be_primed_when_update_term_meta_cache_is_false() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> register_taxonomy( 'wptests_tax', 'post' );
</span><span class="cx" style="display: block; padding: 0 10px"> $terms = self::factory()->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> add_term_meta( $terms[0], 'foo', 'bar' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -661,13 +657,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $terms as $t ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'bar', get_term_meta( $t, 'foo', true ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries + 3, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries + 3, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -674,8 +670,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 36932
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_termmeta_cache_should_be_primed_when_fields_is_all_with_object_id() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> register_taxonomy( 'wptests_tax', 'post' );
</span><span class="cx" style="display: block; padding: 0 10px"> $terms = self::factory()->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> add_term_meta( $terms[0], 'foo', 'bar' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -694,13 +688,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $terms as $t ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'bar', get_term_meta( $t, 'foo', true ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries + 1, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries + 1, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -707,8 +701,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 36932
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_termmeta_cache_should_be_primed_when_fields_is_ids() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> register_taxonomy( 'wptests_tax', 'post' );
</span><span class="cx" style="display: block; padding: 0 10px"> $terms = self::factory()->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> add_term_meta( $terms[0], 'foo', 'bar' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -727,13 +719,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $terms as $t ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'bar', get_term_meta( $t, 'foo', true ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries + 1, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries + 1, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -816,8 +808,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 14162
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_should_prime_cache_for_found_terms() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> register_taxonomy( 'wptests_tax', 'post' );
</span><span class="cx" style="display: block; padding: 0 10px"> $p = self::factory()->post->create();
</span><span class="cx" style="display: block; padding: 0 10px"> $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -831,9 +821,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> $term = get_term( $t );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -865,8 +855,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 14162
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_term_cache_should_be_primed_for_all_taxonomies() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> register_taxonomy( 'wptests_tax1', 'post' );
</span><span class="cx" style="display: block; padding: 0 10px"> register_taxonomy( 'wptests_tax2', 'post' );
</span><span class="cx" style="display: block; padding: 0 10px"> $p = self::factory()->post->create();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -888,10 +876,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSameSets( array( $t1, $t2 ), wp_list_pluck( $found, 'term_id' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> $term1 = get_term( $t1 );
</span><span class="cx" style="display: block; padding: 0 10px"> $term2 = get_term( $t2 );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunktestsphpunittestsuserqueryphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/user/query.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/user/query.php 2023-05-11 09:01:55 UTC (rev 55744)
+++ trunk/tests/phpunit/tests/user/query.php 2023-05-11 10:05:51 UTC (rev 55745)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1720,11 +1720,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 44169
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_users_pre_query_filter_should_bypass_database_query() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'users_pre_query', array( __CLASS__, 'filter_users_pre_query' ), 10, 2 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = $wpdb->num_queries;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px"> $q = new WP_User_Query(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'fields' => 'ID',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1734,7 +1732,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> remove_filter( 'users_pre_query', array( __CLASS__, 'filter_users_pre_query' ), 10, 2 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Make sure no queries were executed.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $num_queries, $wpdb->num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // We manually inserted a non-existing user and overrode the results with it.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( array( 555 ), $q->results );
</span></span></pre>
</div>
</div>
</body>
</html>