Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various fixes #3781

Merged
merged 13 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion install/install_2-0.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function table_attachments()
array('name' => 'id_thumb', 'type' => 'int', 'size' => 10, 'unsigned' => true, 'default' => 0),
array('name' => 'id_msg', 'type' => 'int', 'size' => 10, 'unsigned' => true, 'default' => 0),
array('name' => 'id_member', 'type' => 'mediumint', 'size' => 8, 'unsigned' => true, 'default' => 0),
array('name' => 'id_folder', 'type' => 'tinyint', 'size' => 3, 'default' => 1),
array('name' => 'id_folder', 'type' => 'smallint', 'size' => 5, 'default' => 1),
array('name' => 'attachment_type', 'type' => 'tinyint', 'size' => 3, 'unsigned' => true, 'default' => 0),
array('name' => 'filename', 'type' => 'varchar', 'default' => '', 'size' => 255),
array('name' => 'file_hash', 'type' => 'varchar', 'default' => '', 'size' => 40),
Expand Down
24 changes: 24 additions & 0 deletions install/upgrade_2-0.php
Original file line number Diff line number Diff line change
Expand Up @@ -766,4 +766,28 @@ public function preparing_hideemail()
)
);
}

public function attachment_folder_column_title()
{
return 'Changing the attachment folder column to smallint.';
}

public function attachment_folder_column()
{
return array(
array(
'debug_title' => 'Changing the attachment folder column to smallint.',
'function' => function () {
$this->table->change_column('{db_prefix}attachments',
'id_folder',
array(
'type' => 'smallint',
'size' => 5,
'default' => 1
)
);
}
)
);
}
}
8 changes: 4 additions & 4 deletions sources/ElkArte/BBC/BBCParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ class BBCParser
/**
* BBCParser constructor.
*
* @param \BBC\Codes $bbc
* @param \BBC\Autolink|null $autolinker
* @param \BBC\HtmlParser|null $html_parser
* @param \BBC\MarkdownParser|null $markdown_parser
* @param Codes $bbc
* @param Autolink|null $autolinker
* @param HtmlParser|null $html_parser
* @param MarkdownParser|null $markdown_parser
*/
public function __construct(Codes $bbc, Autolink $autolinker = null, HtmlParser $html_parser = null, MarkdownParser $markdown_parser = null)
{
Expand Down
12 changes: 6 additions & 6 deletions sources/ElkArte/BBC/ParserWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,22 @@ final class ParserWrapper
/** @var array Disabled tags */
protected $disabled = array();

/** @var \BBC\Codes */
/** @var Codes */
protected $codes;

/** @var \BBC\BBCParser */
/** @var BBCParser */
protected $bbc_parser;

/** @var \BBC\SmileyParser */
/** @var SmileyParser */
protected $smiley_parser;

/** @var \BBC\HtmlParser */
/** @var HtmlParser */
protected $html_parser;

/** @var \BBC\Autolink */
/** @var Autolink */
protected $autolink_parser;

/** @var \BBC\MarkdownParser */
/** @var MarkdownParser */
protected $markdown_parser;

/** @var bool If smileys are enabled */
Expand Down
7 changes: 4 additions & 3 deletions sources/ElkArte/Controller/Attachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -789,14 +789,15 @@

$this->prepare_headers($filename, $eTag, $mime_type, 'inline', $real_filename, $do_cache);

if ($resize)
// do not resize for ;image
if ($resize && !isset($this->_req->query->ila, $this->_req->query->image))

Check warning on line 793 in sources/ElkArte/Controller/Attachment.php

View check run for this annotation

Codecov / codecov/patch

sources/ElkArte/Controller/Attachment.php#L793

Added line #L793 was not covered by tests
{
// Create a thumbnail image
$image = new Image($filename);

$filename .= '_thumb';
$max_width = $this->_req->isSet('thumb') && !empty($modSettings['attachmentThumbWidth']) ? $modSettings['attachmentThumbWidth'] : 250;
$max_height = $this->_req->isSet('thumb') && !empty($modSettings['attachmentThumbHeight']) ? $modSettings['attachmentThumbHeight'] : 250;
$max_width = $this->_req->isSet('thumb') && !empty($modSettings['attachmentThumbWidth']) ? $modSettings['attachmentThumbWidth'] : 300;
$max_height = $this->_req->isSet('thumb') && !empty($modSettings['attachmentThumbHeight']) ? $modSettings['attachmentThumbHeight'] : 300;

Check warning on line 800 in sources/ElkArte/Controller/Attachment.php

View check run for this annotation

Codecov / codecov/patch

sources/ElkArte/Controller/Attachment.php#L799-L800

Added lines #L799 - L800 were not covered by tests

$image->createThumbnail($max_width, $max_height, $filename, null, false);
}
Expand Down
12 changes: 6 additions & 6 deletions sources/ElkArte/Controller/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Search extends AbstractController
/** @var \ElkArte\Search\Search Holds the search object */
protected $_search;

/** @var null|\ElkArte\MessageTopicIcons The class that takes care of rendering the message icons */
/** @var null|MessageTopicIcons The class that takes care of rendering the message icons */
protected $_icon_sources;

/** @var array */
Expand Down Expand Up @@ -108,7 +108,7 @@ public function action_index()
* - Decodes and loads search parameters given in the URL (if any).
* - The form redirects to index.php?action=search;sa=results.
*
* @throws \ElkArte\Exceptions\Exception loadavg_search_disabled
* @throws Exception loadavg_search_disabled
* @uses Search template, searchform sub template
*
* @uses Search language file and Errors language when needed
Expand Down Expand Up @@ -211,7 +211,7 @@ public function action_search()
if (!empty($context['search_errors']))
{
Txt::load('Errors');
$context['search_errors']['messages'] = array();
$context['search_errors']['messages'] = [];
foreach ($context['search_errors'] as $search_error => $dummy)
{
if ($search_error === 'messages')
Expand Down Expand Up @@ -474,13 +474,13 @@ public function action_results()

try
{
$search_config = new ValuesContainer(array(
$search_config = new ValuesContainer([
'humungousTopicPosts' => $humungousTopicPosts,
'shortTopicPosts' => $shortTopicPosts,
'maxMessageResults' => $maxMessageResults,
'search_index' => empty($modSettings['search_index']) ? '' : $modSettings['search_index'],
'banned_words' => empty($modSettings['search_banned_words']) ? array() : explode(',', $modSettings['search_banned_words']),
));
'banned_words' => empty($modSettings['search_banned_words']) ? [] : explode(',', $modSettings['search_banned_words']),
]);
$context['topics'] = $this->_search->searchQuery(
new SearchApiWrapper($search_config, $this->_search->getSearchParams())
);
Expand Down
3 changes: 3 additions & 0 deletions sources/ElkArte/Controller/Unread.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ public function pre_dispatch()
// If empty, no preview at all
if (!empty($modSettings['message_index_preview']))
{
loadJavascriptFile('elk_toolTips.js', ['defer' => true]);
$context['message_index_preview'] = true;

// If 0 means everything
if (empty($modSettings['preview_characters']))
{
Expand Down
4 changes: 2 additions & 2 deletions sources/ElkArte/IlaIntegrate.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@
$alt = Util::htmlspecialchars($attachment['filename'] ?? 'X');
self::$typeTag = '
<a id="link_$1" data-lightboximage="$1" data-lightboxmessage="0" href="' . getUrl('action', ['action' => 'dlattach', 'attach' => '$1', 'image']) . '">
<img src="' . getUrl('action', ['action' => 'dlattach', 'attach' => '$1']) . $type . '" style="' . $style . '" alt="' . $alt . '" class="bbc_img ' . $class . '" loading="lazy" />
<img src="' . getUrl('action', ['action' => 'dlattach', 'attach' => '$1', 'ila' => '1']) . $type . '" style="' . $style . '" alt="' . $alt . '" class="bbc_img ' . $class . '" loading="lazy" />

Check warning on line 305 in sources/ElkArte/IlaIntegrate.php

View check run for this annotation

Codecov / codecov/patch

sources/ElkArte/IlaIntegrate.php#L305

Added line #L305 was not covered by tests
</a>';
}
// Not an image, determine a mime thumbnail or use a default thumbnail
Expand All @@ -328,7 +328,7 @@
}

/**
* This is prevents a little repetition and provides a some control for url tags
* This prevents a little repetition and provides a some control for url tags
*
* - Determines if the ILA is an image or not
* - Keeps track of attachment usage to prevent displaying below the post
Expand Down
2 changes: 1 addition & 1 deletion sources/ElkArte/Languages/Index/English.php
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@
$txt['topic_derived_from'] = 'Topic derived from %1$s';
$txt['edit'] = 'Edit';
$txt['quick_edit'] = 'Quick Edit';
$txt['post_options'] = 'More...';
$txt['post_options'] = 'Other Options';
$txt['quote_expand'] = 'Show Quote';

$txt['set_sticky'] = 'Pin';
Expand Down
5 changes: 5 additions & 0 deletions sources/ElkArte/Languages/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ private function logError($file, $found_fallback)
{
global $txt;

if ($file === '')
{
return;
}

if ($file !== 'Addons')
{
Errors::instance()->log_error(
Expand Down
14 changes: 8 additions & 6 deletions sources/ElkArte/Search/API/AbstractAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

namespace ElkArte\Search\API;

use ElkArte\Database\AbstractSearch;
use ElkArte\Database\QueryInterface;
use ElkArte\Helper\HttpReq;
use ElkArte\Helper\Util;
use ElkArte\Helper\ValuesContainer;
Expand Down Expand Up @@ -66,13 +68,13 @@
/** @var array Phrases not to be found in the search results (-"some phrase") */
protected $_excludedPhrases = [];

/** @var \ElkArte\Database\QueryInterface Database instance */
/** @var QueryInterface Database instance */
protected $_db;

/** @var \ElkArte\Helper\HttpReq HttpReq instance */
/** @var HttpReq HttpReq instance */
protected $_req;

/** @var \ElkArte\Database\AbstractSearch Search db instance */
/** @var AbstractSearch Search db instance */
protected $_db_search;

/** @var array Words excluded from indexes */
Expand Down Expand Up @@ -200,8 +202,8 @@
*/
public function searchSort($a, $b)
{
$x = Util::strlen($a) - (in_array($a, $this->_excludedWords) ? 1000 : 0);
$y = Util::strlen($b) - (in_array($b, $this->_excludedWords) ? 1000 : 0);
$x = Util::strlen($a) - (in_array($a, $this->_excludedWords, true) ? 1000 : 0);
$y = Util::strlen($b) - (in_array($b, $this->_excludedWords, true) ? 1000 : 0);

Check warning on line 206 in sources/ElkArte/Search/API/AbstractAPI.php

View check run for this annotation

Codecov / codecov/patch

sources/ElkArte/Search/API/AbstractAPI.php#L205-L206

Added lines #L205 - L206 were not covered by tests

return $y < $x ? 1 : ($y > $x ? -1 : 0);
}
Expand Down Expand Up @@ -261,6 +263,6 @@
{
global $modSettings;

return empty($modSettings['search_match_words']) || $no_regexp ? '%' . strtr($phrase, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $phrase), '\\\'') . '[[:>:]]';
return empty($modSettings['search_match_words']) || $no_regexp ? '%' . strtr($phrase, ['_' => '\\_', '%' => '\\%']) . '%' : '[[:<:]]' . addcslashes(preg_replace(['/([\[\]$.+*?|{}()])/'], ['[$1]'], $phrase), '\\\'') . '[[:>:]]';
}
}
22 changes: 11 additions & 11 deletions sources/ElkArte/Search/API/Custom.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
class Custom extends Standard
{
/** @var string This is the last version of ElkArte that this was tested on, to protect against API changes. */
public $version_compatible = 'ElkArte 2.0 dev';
public $version_compatible = 'ElkArte 2.0';

/** @var string This won't work with versions of ElkArte less than this. */
public $min_elk_version = 'ElkArte 1.0 Beta';
public $min_elk_version = 'ElkArte 1.0';

/** @var bool Is it supported? */
public $is_supported = true;
Expand Down Expand Up @@ -63,7 +63,7 @@ public function __construct($config, $searchParams)

$this->indexSettings = Util::unserialize($modSettings['search_custom_index_config']);

$this->bannedWords = empty($modSettings['search_stopwords']) ? array() : explode(',', $modSettings['search_stopwords']);
$this->bannedWords = empty($modSettings['search_stopwords']) ? [] : explode(',', $modSettings['search_stopwords']);
}

/**
Expand Down Expand Up @@ -95,9 +95,11 @@ public function prepareIndexes($word, &$wordsSearch, &$wordsExclude, $isExcluded
{
return;
}

foreach ($subwords as $subword)
{
if (Util::strlen($subword) >= $this->min_word_length && !in_array($subword, $this->bannedWords))
if (Util::strlen($subword) >= $this->min_word_length
&& !in_array($subword, $this->bannedWords, true))
{
$wordsSearch['indexed_words'][] = $subword;
if ($isExcluded !== false)
Expand Down Expand Up @@ -135,9 +137,7 @@ public function indexedWordQuery($words, $search_data)
// We can't do anything without this
$db_search = db_search();

$query_select = array(
'id_msg' => 'm.id_msg',
);
$query_select = ['id_msg' => 'm.id_msg',];
$query_inner_join = [];
$query_left_join = [];
$query_where = [];
Expand All @@ -151,15 +151,15 @@ public function indexedWordQuery($words, $search_data)
$count = 0;
foreach ($words['words'] as $regularWord)
{
$query_where[] = 'm.body' . (in_array($regularWord, $query_params['excluded_words']) ? ' {not_' : '{') . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? 'ilike} ' : 'rlike} ') . '{string:complex_body_' . $count . '}';
$query_where[] = 'm.body' . (in_array($regularWord, $query_params['excluded_words'], true) ? ' {not_' : '{') . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? 'ilike} ' : 'rlike} ') . '{string:complex_body_' . $count . '}';
$query_params['complex_body_' . ($count++)] = $this->prepareWord($regularWord, $search_data['no_regexp']);
}

// Modifiers such as specific user or specific board.
$query_where += $this->queryWhereModifiers($query_params);
$query_where = array_merge($query_where, $this->queryWhereModifiers($query_params));

// Modifiers to exclude words from the subject
$query_where += $this->queryExclusionModifiers($query_params, $search_data);
$query_where = array_merge($query_where, $this->queryExclusionModifiers($query_params, $search_data));

$numTables = 0;
$prev_join = 0;
Expand Down Expand Up @@ -216,7 +216,7 @@ public function postCreated($msgOptions, $topicOptions, $posterOptions)
{
$db->insert('ignore',
'{db_prefix}log_search_words',
array('id_word' => 'int', 'id_msg' => 'int'),
['id_word' => 'int', 'id_msg' => 'int'],
$inserts,
['id_word', 'id_msg']
);
Expand Down
12 changes: 6 additions & 6 deletions sources/ElkArte/Search/API/Fulltext.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
class Fulltext extends Standard
{
/** @var string This is the last version of ElkArte that this was tested on, to protect against API changes. */
public $version_compatible = 'ElkArte 2.0 dev';
public $version_compatible = 'ElkArte 2.0';

/** @var string This won't work with versions of ElkArte less than this. */
public $min_elk_version = 'ElkArte 1.0';
Expand All @@ -42,7 +42,7 @@ class Fulltext extends Standard
protected $min_word_length = 4;

/** @var array What databases support the fulltext index? */
protected $supported_databases = array('MySQL');
protected $supported_databases = ['MySQL'];

/**
* Fulltext::__construct()
Expand Down Expand Up @@ -79,9 +79,9 @@ protected function _getMinWordLength()
$request = $db_search->search_query('', '
SHOW VARIABLES
LIKE {string:fulltext_minimum_word_length}',
array(
[
'fulltext_minimum_word_length' => 'ft_min_word_len',
)
]
);
if ($request !== false && $request->num_rows() === 1)
{
Expand All @@ -104,7 +104,7 @@ public function prepareIndexes($word, &$wordsSearch, &$wordsExclude, $isExcluded
{
global $modSettings;

$subwords = text2words($word, false);
$subwords = text2words($word);

if (empty($modSettings['search_force_index']))
{
Expand Down Expand Up @@ -183,7 +183,7 @@ public function indexedWordQuery($words, $search_data)
{
foreach ($words['words'] as $regularWord)
{
$query_where[] = 'm.body' . (in_array($regularWord, $query_params['excluded_words']) ? ' {not_' : '{') . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? 'ilike} ' : 'rlike} ') . '{string:complex_body_' . $count . '}';
$query_where[] = 'm.body' . (in_array($regularWord, $query_params['excluded_words'], true) ? ' {not_' : '{') . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? 'ilike} ' : 'rlike} ') . '{string:complex_body_' . $count . '}';
$query_params['complex_body_' . ($count++)] = $this->prepareWord($regularWord, $search_data['no_regexp']);
}
}
Expand Down
Loading
Loading