<!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>[11544] sites/trunk: Trac: Add the ability to include Tickets that you've added a GitHub PR to, in the 'my patches' reports.</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="http://meta.trac.wordpress.org/changeset/11544">11544</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://meta.trac.wordpress.org/changeset/11544","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>dd32</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2022-02-10 09:38:45 +0000 (Thu, 10 Feb 2022)</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'>Trac: Add the ability to include Tickets that you've added a GitHub PR to, in the 'my patches' reports.

See https://core.trac.wordpress.org/my-patches + https://meta.trac.wordpress.org/report/12
Fixes <a href="http://meta.trac.wordpress.org/ticket/5596">#5596</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#sitestrunkapiwordpressorgpublic_htmldotorgtracprfunctionsphp">sites/trunk/api.wordpress.org/public_html/dotorg/trac/pr/functions.php</a></li>
<li><a href="#sitestrunkapiwordpressorgpublic_htmldotorgtracprindexphp">sites/trunk/api.wordpress.org/public_html/dotorg/trac/pr/index.php</a></li>
<li><a href="#sitestrunkapiwordpressorgpublic_htmldotorgtracprwebhookphp">sites/trunk/api.wordpress.org/public_html/dotorg/trac/pr/webhook.php</a></li>
<li><a href="#sitestrunktracwordpressorgtemplatessitehtml">sites/trunk/trac.wordpress.org/templates/site.html</a></li>
<li><a href="#sitestrunktracwordpressorgtemplateswporgheadhtml">sites/trunk/trac.wordpress.org/templates/wporg-head.html</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlstyletracwptracjs">sites/trunk/wordpress.org/public_html/style/trac/wp-trac.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkapiwordpressorgpublic_htmldotorgtracprfunctionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/api.wordpress.org/public_html/dotorg/trac/pr/functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/api.wordpress.org/public_html/dotorg/trac/pr/functions.php    2022-02-10 08:10:42 UTC (rev 11543)
+++ sites/trunk/api.wordpress.org/public_html/dotorg/trac/pr/functions.php      2022-02-10 09:38:45 UTC (rev 11544)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -102,11 +102,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px">  * Find a WordPress.org user by a Github login.
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-function find_wporg_user_by_github( $github_user ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+function find_wporg_user_by_github( $github_user, $what = 'user_login' ) {
</ins><span class="cx" style="display: block; padding: 0 10px">         global $wpdb;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        if ( ! in_array( $what, [ 'ID', 'user_login' ], true ) ) {
+               return false;
+       }
+
</ins><span class="cx" style="display: block; padding: 0 10px">         return $wpdb->get_var( $wpdb->prepare(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                "SELECT u.user_login
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         "SELECT u.{$what}
</ins><span class="cx" style="display: block; padding: 0 10px">                         FROM wporg_github_users g
</span><span class="cx" style="display: block; padding: 0 10px">                                JOIN {$wpdb->users} u ON g.user_id = u.ID
</span><span class="cx" style="display: block; padding: 0 10px">                        WHERE g.github_user = %s",
</span></span></pre></div>
<a id="sitestrunkapiwordpressorgpublic_htmldotorgtracprindexphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/api.wordpress.org/public_html/dotorg/trac/pr/index.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/api.wordpress.org/public_html/dotorg/trac/pr/index.php        2022-02-10 08:10:42 UTC (rev 11543)
+++ sites/trunk/api.wordpress.org/public_html/dotorg/trac/pr/index.php  2022-02-10 09:38:45 UTC (rev 11544)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6,17 +6,39 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> $trac          = preg_replace( '![^a-z]!', '', $_GET['trac'] ?? '' );
</span><span class="cx" style="display: block; padding: 0 10px"> $ticket        = intval( $_GET['ticket'] ?? 0 );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+$author        = wp_unslash( $_GET['author'] ?? '' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $authenticated = ! empty( $_GET['authenticated'] ); // Longer caches for logged out requests.
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-if ( empty( $trac ) || empty( $ticket ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+header( 'Content-Type: application/json' );
+header( 'Access-Control-Allow-Origin: *' );
+
+if ( empty( $trac ) || ( empty( $ticket ) && empty( $author ) ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px">         header( 'HTTP/1.0 400 Bad Request' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        header( 'Content-Type: application/json' );
-       die( '{"error":"Ticket number is invalid."}' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ die( '{"error":"Trac, Ticket number, or Author is invalid."}' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+// Type one: Return PRs by Author.
+if ( $author ) {
+       header( 'Cache-Control: max-age=' . HOUR_IN_SECONDS );
+       header( 'Expires: ' . gmdate( 'D, d M Y H:i:s \G\M\T', time() + HOUR_IN_SECONDS ) );
+
+       $user_id = get_user_by( 'slug', $author )->ID ?? 0;
+
+       $tickets = $wpdb->get_col( $wpdb->prepare(
+               "SELECT `ticket`
+               FROM `trac_github_prs`
+               WHERE trac = %s AND author = %d",
+               $trac,
+               $user_id
+       ) );
+
+       echo wp_json_encode( $tickets );
+       die();
+}
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Fetch any linked PRs
</span><span class="cx" style="display: block; padding: 0 10px"> $prs = $wpdb->get_results( $wpdb->prepare(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        "SELECT `repo`, `pr`, `data`, `last_checked`
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ "SELECT `repo`, `pr`, `data`, `last_checked`, `author`
</ins><span class="cx" style="display: block; padding: 0 10px">         FROM `trac_github_prs`
</span><span class="cx" style="display: block; padding: 0 10px">        WHERE trac = %s AND ticket = %s",
</span><span class="cx" style="display: block; padding: 0 10px">        $trac,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -64,11 +86,17 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        // TODO: catch the trac ticket changing and update the database.
</span><span class="cx" style="display: block; padding: 0 10px">                        unset( $data->data->trac_ticket );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        // Check if we now have an author for this PR, the author may link their account after creating the PR.
+                       if ( ! $data->author ) {
+                               $data->author = (int) find_wporg_user_by_github( $pr_data->user->name, 'ID' );
+                       }
+
</ins><span class="cx" style="display: block; padding: 0 10px">                         $wpdb->update(
</span><span class="cx" style="display: block; padding: 0 10px">                                'trac_github_prs',
</span><span class="cx" style="display: block; padding: 0 10px">                                [
</span><span class="cx" style="display: block; padding: 0 10px">                                        'data'         => json_encode( $pr_data ),
</span><span class="cx" style="display: block; padding: 0 10px">                                        'last_checked' => gmdate( 'Y-m-d H:i:s' ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                        'author'       => $data->author,
</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">                                        'repo' => $data->repo,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -97,10 +125,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> header( 'Cache-Control: max-age=' . $expiry );
</span><span class="cx" style="display: block; padding: 0 10px"> header( 'Expires: ' . gmdate( 'D, d M Y H:i:s \G\M\T', time() + $expiry ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-header( 'Content-Type: application/json' );
-header( 'Access-Control-Allow-Origin: *' );
</del><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> // Only return the actual PR data needed
</span><span class="cx" style="display: block; padding: 0 10px"> $prs = array_column( $prs, 'data' );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-echo wp_json_encode( $prs );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+echo wp_json_encode( $prs );
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of file
</span></span></pre></div>
<a id="sitestrunkapiwordpressorgpublic_htmldotorgtracprwebhookphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/api.wordpress.org/public_html/dotorg/trac/pr/webhook.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/api.wordpress.org/public_html/dotorg/trac/pr/webhook.php      2022-02-10 08:10:42 UTC (rev 11543)
+++ sites/trunk/api.wordpress.org/public_html/dotorg/trac/pr/webhook.php        2022-02-10 09:38:45 UTC (rev 11544)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -80,6 +80,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // Step 3. If not in DB, or $pr_data->trac_ticket isn't yet in the DB, add a new row of it.
</span><span class="cx" style="display: block; padding: 0 10px">                if ( $pr_data->trac_ticket && ( ! $existing_refs || ! $matched_existing_ref ) ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+                       $user_id = (int) find_wporg_user_by_github( $pr_data->user->name, 'ID' );
+
</ins><span class="cx" style="display: block; padding: 0 10px">                         $wpdb->insert(
</span><span class="cx" style="display: block; padding: 0 10px">                                'trac_github_prs',
</span><span class="cx" style="display: block; padding: 0 10px">                                [
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -90,6 +93,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                        'repo'         => $pr_repo,
</span><span class="cx" style="display: block; padding: 0 10px">                                        'pr'           => $pr_number,
</span><span class="cx" style="display: block; padding: 0 10px">                                        'data'         => json_encode( $_pr_data_no_ticket ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                        'author'       => $user_id,
</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="sitestrunktracwordpressorgtemplatessitehtml"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/trac.wordpress.org/templates/site.html</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/trac.wordpress.org/templates/site.html        2022-02-10 08:10:42 UTC (rev 11543)
+++ sites/trunk/trac.wordpress.org/templates/site.html  2022-02-10 09:38:45 UTC (rev 11544)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4,7 +4,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">      py:strip="">
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> <?python
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        scripts_version = '161'
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ scripts_version = '162'
</ins><span class="cx" style="display: block; padding: 0 10px">         project_slug = req.environ['HTTP_HOST'].split(':')[0].split('.')[0]
</span><span class="cx" style="display: block; padding: 0 10px">        wporg_endpoint = 'https://make.wordpress.org/' + project_slug + '/'
</span><span class="cx" style="display: block; padding: 0 10px">        is_bug_gardener = 'TICKET_EDIT_DESCRIPTION' in perm(resource)
</span></span></pre></div>
<a id="sitestrunktracwordpressorgtemplateswporgheadhtml"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/trac.wordpress.org/templates/wporg-head.html</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/trac.wordpress.org/templates/wporg-head.html  2022-02-10 08:10:42 UTC (rev 11543)
+++ sites/trunk/trac.wordpress.org/templates/wporg-head.html    2022-02-10 09:38:45 UTC (rev 11544)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -45,7 +45,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">   <style id="wp-block-library-inline-css" type="text/css">
</span><span class="cx" style="display: block; padding: 0 10px"> .has-text-align-justify{text-align:justify;}
</span><span class="cx" style="display: block; padding: 0 10px"> </style>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-  <link rel="stylesheet" id="wporg-global-header-footer-css" href="https://wordpress.org/wp-content/mu-plugins/pub-sync/blocks/global-header-footer/build/style.css?ver=1643748587" type="text/css" media="all"/>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  <link rel="stylesheet" id="wporg-global-header-footer-css" href="https://wordpress.org/wp-content/mu-plugins/pub-sync/blocks/global-header-footer/build/style.css?ver=1643748639" type="text/css" media="all"/>
</ins><span class="cx" style="display: block; padding: 0 10px">   <link rel="stylesheet" id="mediaelement-css" href="https://wordpress.org/wp-includes/js/mediaelement/mediaelementplayer-legacy.min.css?ver=4.2.16" type="text/css" media="all"/>
</span><span class="cx" style="display: block; padding: 0 10px">   <link rel="stylesheet" id="wp-mediaelement-css" href="https://wordpress.org/wp-includes/js/mediaelement/wp-mediaelement.min.css?ver=6.0-alpha-52660" type="text/css" media="all"/>
</span><span class="cx" style="display: block; padding: 0 10px">   <style id="global-styles-inline-css" type="text/css">
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlstyletracwptracjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/style/trac/wp-trac.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/style/trac/wp-trac.js       2022-02-10 08:10:42 UTC (rev 11543)
+++ sites/trunk/wordpress.org/public_html/style/trac/wp-trac.js 2022-02-10 09:38:45 UTC (rev 11544)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1665,6 +1665,17 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                        primaryGitRepoDesc = 'WordPress.org Meta GitHub mirror';
</span><span class="cx" style="display: block; padding: 0 10px">                                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                if ( ! trac ) {
+                                       return;
+                               }
+
+                               // Add ability to include GitHub tickets into a 'my-patches' report.
+                               // "Just" include a variable called '$GITHUBTICKETS' in the Query.
+                               var $warning = $("#warning.system-message:contains('GITHUBTICKETS')");
+                               if ( $warning.length ) {
+                                       renderReportLoadGitHubTickets( $warning );
+                               }
+
</ins><span class="cx" style="display: block; padding: 0 10px">                                 // This seems to be the easiest place to find the current Ticket ID..
</span><span class="cx" style="display: block; padding: 0 10px">                                var canonical = $( 'link[rel="canonical"]' ).prop( 'href' );
</span><span class="cx" style="display: block; padding: 0 10px">                                if ( canonical ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1671,7 +1682,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                        ticket = canonical.match( /\/ticket\/(\d+)$/ )[1];
</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">-                                if ( ! trac || ! ticket ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         if ( ! ticket ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                                         return;
</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">@@ -1734,6 +1745,40 @@
</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><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        function renderReportLoadGitHubTickets( $warning ) {
+                               var user = wpTracCurrentUser,
+                                       match = document.location.search.match( /USER=([^&]+)/ );
+                               if ( match ) {
+                                       user = match[1];
+                               }
+
+                               // Logged out requests without a user context.
+                               if ( 'anonymous' === user ) {
+                                       $warning.remove();
+                                       return;
+                               }
+
+                               $warning.html(
+                                       '<strong>Warning:</strong> Tickets with an attached GitHub PRs not included <button>Load PRs</button>'  
+                               );
+
+                               $warning.on( 'click', function() {
+                                       $(this).find('button').prop( 'disabled', 'disabled' ).text( 'Please wait..' );
+
+                                       $.ajax(
+                                               apiEndpoint
+                                                       + '?trac=' + trac
+                                                       + '&author=' + user
+                                                       + ( authenticated ? '&authenticated=1' : '' )
+                                       ).success( function( ticketList ) {
+                                               document.location = document.location.toString() +
+                                                       ( document.location.search ? '&' : '?' ) +
+                                                       'GITHUBTICKETS=' + ticketList.join(',');
+                                       } );
+                               } )
+
+                       }
+
</ins><span class="cx" style="display: block; padding: 0 10px">                         // Logic to determine what the PRs status is
</span><span class="cx" style="display: block; padding: 0 10px">                        function prStatus( data ) {
</span><span class="cx" style="display: block; padding: 0 10px">                                var stack = [],
</span></span></pre>
</div>
</div>

</body>
</html>