• Welcome to Simple Machines Community Forum. Please login or sign up.
October 25, 2021, 07:15:51 AM

News:

Want to get involved in developing SMF, then why not lend a hand on our github!


Package Manager Install/Uninstall and Tapatalk Plugin

Started by GL700Wing, September 02, 2020, 01:28:56 AM

Previous topic - Next topic

GL700Wing

September 02, 2020, 01:28:56 AM Last Edit: October 14, 2021, 08:35:27 PM by Diego Andrés
About six weeks ago I upgraded an SMF forum from SMF 2.0.16/Tapatalk Plugin 4.4.1 to SMF 2.0.17/Tapatalk Plugin 4.5.7 and following the upgrade users were reporting that Tapatalk was no longer reliably showing posts or topics - although results in the Tapatalk App were displayed reliably for 'New Posts' for other areas like 'Unread' and for most forums users either got a blank screen or, in some instances, only the sticky topics were listed (it seemed to be some sort of timeout issue that occurred after about 60 seconds).

Yesterday while I was doing some development work on the Post and PM Inline Attachments mod I discovered that it makes updates to some of the Tapatalk plugin files and, even there is no mention in the install information for that mod that Tapatalk should be installed first, it is not obvious when installing/uninstalling the Post and PM Inline Attachments mod that it actually updates any of the Tapatalk plugin files.

The Tapatalk plugin files that are updated by the Post and PM Inline Attachments mod are ./mobiquo/include/Display.php and ./mobiquo/include/Subs.php but because of the way the Package Manager lists files and because the files ./Sources/Display.php and ./Sources/Subs.php are also updated by the Post and PM Inline Attachments mod the actions for the Tapatalk plugin files are listed in the sections for the ./Sources/Display.php and ./Sources/Subs.php files respectively (see first attachment).

I realise that it is unusual for a mod to have filenames exactly the same as core SMF files - Tapatalk is the only mod I know of that does - but even so I think the Package Manager should always list the actions for non-core SMF files separately to the actions for core SMF files.  I found that by making the following code change in two locations in ./Sources/PackageManager.php I can get PackageManager to display the actions for the Tapatalk plugin files in separate sections (see second attachment).
Find:
// Lets get the last section of the file name.
if (isset($mod_action['filename']) && substr($mod_action['filename'], -13) != '.template.php')
$actual_filename = strtolower(substr(strrchr($mod_action['filename'], '/'), 1) . '||' . $action['filename']);
elseif (isset($mod_action['filename']) && preg_match('~([\w]*)/([\w]*)\.template\.php$~', $mod_action['filename'], $matches))
$actual_filename = strtolower($matches[1] . '/' . $matches[2] . '.template.php' . '||' . $action['filename']);
else
$actual_filename = $key;


Replace with:
// Lets get the last section of the file name.
// Added check for files that are not in either the Sources or Themes directories
// (eg, Tapatalk plug-in files which are in the mobiquo directory in the forum root directory)
if (isset($mod_action['filename']))
{
$inSources = strpos($mod_action['filename'], $boarddir . '/Sources/');
$inThemes = strpos($mod_action['filename'], $boarddir . '/Themes/');
}
if (isset($mod_action['filename']) && $inSources !== 0 && $inThemes !== 0)
$actual_filename = strtolower(substr($mod_action['filename'], strpos($mod_action['filename'], $boarddir) + strlen($boarddir) + 1));
elseif (isset($mod_action['filename']) && substr($mod_action['filename'], -13) != '.template.php')
$actual_filename = strtolower(substr(strrchr($mod_action['filename'], '/'), 1) . '||' . $action['filename']);
elseif (isset($mod_action['filename']) && preg_match('~([\w]*)/([\w]*)\.template\.php$~', $mod_action['filename'], $matches))
$actual_filename = strtolower($matches[1] . '/' . $matches[2] . '.template.php' . '||' . $action['filename']);
else
$actual_filename = $key;


However, and even though I installed/uninstalled the Post and PM Inline Attachments mod multiple times without any issues/errors after making the code change, what I don't know is if this code change will have any unintended consequences in the database.



PS:  Uninstalling and reinstalling the Post and PM Inline Attachments mod fixed the Tapatalk issue.
Life doesn't have to be perfect to be wonderful ...

Dzonny

Hey there.

Well, as far as I can see, Post and PM Inline Attachments mod also change for example, file hs4smf-Subs.php which is another mod, but Tapatalk, this mod, and any other changes in files outside of default SMF ones, is marked as not vital to installation of this mod.
That way, if one doesn't have that specific mod installed, they can continue with installation without impact to initial mod.

shawnb61

This is not an SMF bug...  Maybe more appropriate as  commentary for users of the other mod?
Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

Arantor

No, it is a bug. Albeit a minor mostly aesthetic bug, driven by Tapatalk's shoddy implementation that starts by just copying half of Sources, but it is a bug.
No good deed goes unpunished
All helpful urges should be circumvented

shawnb61

Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

SychO

Checkout My Themes:
-

Potato  •  Ackerman  •  SunRise  •  NightBreeze

Arantor

Quote from: SychO on September 02, 2020, 11:54:34 AM
nice catch GL700Wing

I'd never noticed it because I'd never installed Tapatalk, and Tapatalk is the only mod I know of that ships clones of SMF files where mods might touch them.

If Tapatalk hadn't been so rubbish this would likely never have come up.
No good deed goes unpunished
All helpful urges should be circumvented

GL700Wing

I've been thinking about and working on this some more today and, provided that it does not cause any issues with how the Package Manager works, I think I have come up with a better solution for uniquely identifying files that are being updated where filenames are duplicated (eg, a file with the name of ABC.php that is being updated and which exists in multiple locations).  Also, I realise that the file name I referred to in my original post was incorrect - it should have been ./Sources/Packages.php

In ./Sources/Packages.php (two instances):
Find:
// Lets get the last section of the file name.
if (isset($mod_action['filename']) && substr($mod_action['filename'], -13) != '.template.php')
$actual_filename = strtolower(substr(strrchr($mod_action['filename'], '/'), 1) . '||' . $action['filename']);
elseif (isset($mod_action['filename']) && preg_match('~([\w]*)/([\w]*)\.template\.php$~', $mod_action['filename'], $matches))
$actual_filename = strtolower($matches[1] . '/' . $matches[2] . '.template.php' . '||' . $action['filename']);
else
$actual_filename = $key;


Replace with:
// Let's get the path of the file.
if (isset($mod_action['filename']))
{
$themedir = $boarddir . '/Themes/';
$inSourceDir = strpos($mod_action['filename'], $sourcedir . '/');
$inThemeDir = strpos($mod_action['filename'], $themedir . '/');
}
// If the file is not in either Sources or Themes ...
if (isset($mod_action['filename']) && $inSourceDir !== 0 && $inThemeDir !== 0)
$actual_filename = strtolower(substr($mod_action['filename'], strpos($mod_action['filename'], $boarddir) + strlen($boarddir) + 1));
// If the file is in Sources ...
elseif (isset($mod_action['filename']) && $inSourceDir === 0)
$actual_filename = strtolower(substr($mod_action['filename'], strpos($mod_action['filename'], $sourcedir) + strlen($sourcedir) + 1));
elseif (isset($mod_action['filename']) && substr($mod_action['filename'], -13) != '.template.php')
$actual_filename = strtolower(substr(strrchr($mod_action['filename'], '/'), 1) . '||' . $action['filename']);
elseif (isset($mod_action['filename']) && preg_match('~([\w]*)/([\w]*)\.template\.php$~', $mod_action['filename'], $matches))
$actual_filename = strtolower($matches[1] . '/' . $matches[2] . '.template.php' . '||' . $action['filename']);
// If the file is in Themes but is not a template file ...
elseif (isset($mod_action['filename']) && $inThemeDir === 0)
$actual_filename = strtolower(substr($mod_action['filename'], strpos($mod_action['filename'], $themedir) + strlen($themedir) + 1));
else
$actual_filename = $key;


The attached images demonstrate the behaviour of  the default ./Sources/Packages.php and the version I have updated.

Quote from: Arantor on September 02, 2020, 11:56:26 AM
I'd never noticed it because I'd never installed Tapatalk ...
Due to the way the Packager Manager currently lists the files to be updated you likely wouldn't have noticed it even if you had ...   ;)
Life doesn't have to be perfect to be wonderful ...

live627

Just thinking out loud: could all that code actually be simplified?

$actual_filename = isset($mod_action['filename']) ? strtr($mod_action['filename'], array(strtr($boarddir, '\\', '/') => '.')) : $key;

GL700Wing

Quote from: live627 on September 02, 2020, 10:45:27 PM
Just thinking out loud: could all that code actually be simplified?

$actual_filename = isset($mod_action['filename']) ? strtr($mod_action['filename'], array(strtr($boarddir, '\\', '/') => '.')) : $key;
Looks perfect!! (plus it made me realise I had a bug in the most recent code I'd posted) ...
Life doesn't have to be perfect to be wonderful ...

mark@123

Check this article
hxxp:www.tapatalk.com/download_SimpleMachines [nonactive]

GL700Wing

Quote from: mark@123 on October 09, 2020, 07:48:22 AM
Check this article
https://www.tapatalk.com/download_SimpleMachines
The issue I reported is not related to the installation of Tapatalk - it's related to the installation of SMF mods that update Tapatalk files after Tapatalk has been installed.
Life doesn't have to be perfect to be wonderful ...

Advertisement: