News:

Wondering if this will always be free?  See why free is better.

Main Menu

Many 'Test Failed' with update from 2.0.15 to 2.0.16

Started by WantSome, December 30, 2019, 07:20:15 PM

Previous topic - Next topic

WantSome

Hello all. 

I tried the usual package update but got the following error:
QuoteThe package was downloaded to the server but it appears to be empty. Please check the "Packages" directory and the "Temp" sub-directory are both writeable. If you continue to experience this problem, you should try extracting the package on your PC and uploading the extracted files into a sub-directory in your "Packages" directory and try again.

So I downloaded the update and tried to install it as a normal package.  This has thrown up several issues during the test run and I am assuming it is because I have an older forum with several patches and mods.  However, normally I can find the problem with the failed tests, and figure out how to fix them by finding the likely part of the code that the test is looking for and editing it.  However in this latest patch there are quite a few 'test failed's that I can't seem to find at all, or don't trust that I have the right piece of code to fiddle with...

I'll take this one at a time, apologies for the wall of issues.  Any advice appreciated.



Issue 1
I can't seem to find force_ssl or even md5($user_settings['avatar'] or proxy/proxied
I wonder at what update this might have been added as I have patched through all smf updates so don't think I missed one (but it's possible).

./Sources/Load.php

Code: (Find) [Select]
if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false)
$user_settings['avatar'] = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($user_settings['avatar']) . '&hash=' . md5($user_settings['avatar'] . $image_proxy_secret);

Code: (Replace) [Select]
if (!empty($user_settings['avatar']))
$user_settings['avatar'] = get_proxied_url($user_settings['avatar']);






Issue 2

I was able to find global $user_profile, $modSettings, $board_info, $smcFunc; but the second line of the searched code does not exist.  Upon adding it, the whole site failed so I took it out again.  Still can't find 'proxy' anything in my Load.php file.

./Sources/Load.php

Code: (Find) [Select]
global $user_profile, $modSettings, $board_info, $smcFunc;
global $boardurl, $image_proxy_enabled, $image_proxy_secret

Code: (Add After) [Select]
, $user_info




Issue 3

As above, I can't find anything related to proxy and so am unable to figure out where this searched for code should exist.

./Sources/Load.php

Code: (Find) [Select]
if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false)
$row['avatar'] = $boardurl . '/proxy.php?request=' . urlencode($row['avatar']) . '&hash=' . md5($row['avatar'] . $image_proxy_secret);

Code: (Replace) [Select]
if (!empty($row['avatar']))
$row['avatar'] = get_proxied_url($row['avatar']);





Issue 4

It appears in my file that the searched line shows as (?:board|topic|page) (note the addition of |page).  Is it safe to assume this is the part it is looking for and add the 'add after' code manually? or will the |page cause issues going forward?

./Sources/QueryString.php

Code: (Find) [Select]
$buffer = preg_replace_callback('~"' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?"~', 'pathinfo_insert__preg_callback', $buffer);
   }
Code: (Add After) [Select]

// Be nice and try to inject session tokens into login forms since many older themes don't.
if ($user_info['is_guest'])
$buffer = preg_replace_callback(
'~(<form[^<]+action=login2(.+))</form>~iUs' . (!empty($context['utf8']) ? 'u' : ''),
function ($m) use ($context)
{
$repl = '';
if (strpos($m[0], $context['session_var']) === false)
$repl .= '<input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '"/>';

return $m[1] . $repl . '</form>';
},
$buffer
);





Issue 5

Almost all the changes to ./Sources/Subs-Db-mysql.php require a search containing the term mysquli which does not exist at all in my file.

One of the changes requires a search for /**  * Database error! which also does not exist in my file.

Should I just download the latest sources and replace the entire file with the new one?




Issue 6:

In my Subs.php file I can't find several of the code snippets it is searching for, and it appears that the word 'proxy' does not appear anywhere in my file.  This means several of the Subs.php changes can't be undertaken.

./Sources/Subs.php

Code: (Find) [Select]
'content' => '<img src="$1" alt="{alt}"{width}{height} class="bbc_img resized" />',
'validate' => function (&$tag, &$data, $disabled)
{
global $image_proxy_enabled, $image_proxy_secret, $boardurl;

$data = strtr($data, array('<br>' => ''));
if (strpos($data, 'http://') !== 0 && strpos($data, 'https://') !== 0)
$data = 'http://' . $data;

if (substr($data, 0, 8) != 'https://' && $image_proxy_enabled)
$data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret);
},

Code: (Replace) [Select]
'content' => '<img src="$1" alt="{alt}"{width}{height} class="bbc_img resized" />',
'validate' => function (&$tag, &$data, $disabled)
{
$data = strtr($data, array('<br>' => ''));
if (strpos($data, 'http://') !== 0 && strpos($data, 'https://') !== 0)
$data = 'http://' . $data;

$data = get_proxied_url($data);
},


Code: (Find) [Select]
'content' => '<img src="$1" alt="" class="bbc_img" />',
'validate' => function (&$tag, &$data, $disabled)
{
global $image_proxy_enabled, $image_proxy_secret, $boardurl;

$data = strtr($data, array('<br>' => ''));
if (strpos($data, 'http://') !== 0 && strpos($data, 'https://') !== 0)
$data = 'http://' . $data;

if (substr($data, 0, 8) != 'https://' && $image_proxy_enabled)
$data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret);
},

Code: (Replace) [Select]
'content' => '<img src="$1" alt="" class="bbc_img" />',
'validate' => function (&$tag, &$data, $disabled)
{
$data = strtr($data, array('<br>' => ''));
if (strpos($data, 'http://') !== 0 && strpos($data, 'https://') !== 0)
$data = 'http://' . $data;

$data = get_proxied_url($data);
},

Code: (Find) [Select]
if (substr($user_info['avatar']['url'], 0, 8) != 'https://' && $image_proxy_enabled)
$context['user']['avatar']['href'] = $boardurl . '/proxy.php?request=' . urlencode($user_info['avatar']['url']) . '&hash=' . md5($user_info['avatar']['url'] . $image_proxy_secret);
else
$context['user']['avatar']['href'] = $user_info['avatar']['url'];

Code: (Replace) [Select]
$context['user']['avatar']['href'] = get_proxied_url($user_info['avatar']['url']);





Issue 7

In    ./Sources/Themes.php I can't find this one code snippet - I can find parts of it scattered around but I am not sure which part I am meant to replace.

Code: (Find) [Select]
if (isset($_GET['th']) && $_GET['th'] == 0)
$_GET['th'] = $modSettings['theme_guests'];

updateMemberData((int) $_REQUEST['u'], array('id_theme' => (int) $_GET['th']));

if (!empty($_GET['vrt']))
{

Code: (Replace) [Select]
// An identifier of zero means that the user wants the forum default theme.
updateMemberData((int) $_REQUEST['u'], array('id_theme' => (int) $_GET['th']));

if (!empty($_GET['vrt']))
{
// Set the identifier to the forum default.
if (isset($_GET['th']) && $_GET['th'] == 0)
$_GET['th'] = $modSettings['theme_guests'];




WantSome

Thanks, I'll just add the new code and not worry about Issue 4.


WantSome

I made some experiments with my test forum.

On my test forum most of the 'test fail' items did not appear, and as a result I trusted that the testing site's code was 'neater' (i.e. not as badly corrupted by modifications and patches etc).

I was therefore better able to find the code segments the update was looking for, and modified my live site's code to reflect the test forum's code and the update was able to run with no issue.

I will mark this thread as solved for now and open a new topic if I come across any further issues with the update.

Advertisement: