mirror of
https://github.com/typecho/typecho.git
synced 2025-04-21 02:01:52 +02:00
Fixes for PHP 8.1 compatibility (#1293)
* Fixes for PHP 8.1 compatibility * Fixes for PHP 8.1 compatibility * 优化写法 * remove mixed type * fix nullable column * fix query filter * recover * recover fileds * recover * Update Text.php * Update Text.php Co-authored-by: joyqi <joyqi@users.noreply.github.com>
This commit is contained in:
parent
9c075dcdf0
commit
047bd17f19
@ -91,7 +91,7 @@ $isAllPosts = ('on' == $request->get('__typecho_all_posts') || 'on' == \Typecho\
|
||||
(isset($request->uid) ? '?uid=' . htmlspecialchars($request->get('uid')) : '') : '')); ?>"><?php _e('« 取消筛选'); ?></a>
|
||||
<?php endif; ?>
|
||||
<input type="text" class="text-s" placeholder="<?php _e('请输入关键字'); ?>"
|
||||
value="<?php echo htmlspecialchars($request->keywords); ?>" name="keywords"/>
|
||||
value="<?php echo htmlspecialchars($request->keywords ?? ''); ?>" name="keywords"/>
|
||||
<select name="category">
|
||||
<option value=""><?php _e('所有分类'); ?></option>
|
||||
<?php \Widget\Metas\Category\Rows::alloc()->to($category); ?>
|
||||
|
@ -482,7 +482,7 @@ EOF;
|
||||
*/
|
||||
public static function filterSearchQuery(?string $query): string
|
||||
{
|
||||
return str_replace('-', ' ', self::slugName($query));
|
||||
return isset($query) ? str_replace('-', ' ', self::slugName($query)) : '';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -498,7 +498,7 @@ EOF;
|
||||
*/
|
||||
public static function slugName(?string $str, ?string $default = null, int $maxLength = 128): ?string
|
||||
{
|
||||
$str = trim($str);
|
||||
$str = trim($str ?? '');
|
||||
|
||||
if (!strlen($str)) {
|
||||
return $default;
|
||||
|
@ -91,7 +91,7 @@ class Config implements \Iterator, \ArrayAccess
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function rewind()
|
||||
public function rewind(): void
|
||||
{
|
||||
reset($this->currentConfig);
|
||||
}
|
||||
@ -113,7 +113,7 @@ class Config implements \Iterator, \ArrayAccess
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function next()
|
||||
public function next(): void
|
||||
{
|
||||
next($this->currentConfig);
|
||||
}
|
||||
@ -231,7 +231,7 @@ class Config implements \Iterator, \ArrayAccess
|
||||
* @param mixed $offset
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function offsetSet($offset, $value)
|
||||
public function offsetSet($offset, $value): void
|
||||
{
|
||||
$this->currentConfig[$offset] = $value;
|
||||
}
|
||||
@ -239,7 +239,7 @@ class Config implements \Iterator, \ArrayAccess
|
||||
/**
|
||||
* @param mixed $offset
|
||||
*/
|
||||
public function offsetUnset($offset)
|
||||
public function offsetUnset($offset): void
|
||||
{
|
||||
unset($this->currentConfig[$offset]);
|
||||
}
|
||||
|
@ -44,6 +44,10 @@ class Text extends Element
|
||||
*/
|
||||
protected function inputValue($value)
|
||||
{
|
||||
$this->input->setAttribute('value', htmlspecialchars($value));
|
||||
if (isset($value)) {
|
||||
$this->input->setAttribute('value', htmlspecialchars($value));
|
||||
} else {
|
||||
$this->input->removeAttribute('value');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -487,6 +487,11 @@ class Contents extends Base implements QueryInterface
|
||||
*/
|
||||
public function filter(array $value): array
|
||||
{
|
||||
/** 处理默认空值 */
|
||||
$value['title'] = $value['title'] ?? '';
|
||||
$value['text'] = $value['text'] ?? '';
|
||||
$value['slug'] = $value['slug'] ?? '';
|
||||
|
||||
/** 取出所有分类 */
|
||||
$value['categories'] = $this->db->fetchAll($this->db
|
||||
->select()->from('table.metas')
|
||||
@ -494,7 +499,7 @@ class Contents extends Base implements QueryInterface
|
||||
->where('table.relationships.cid = ?', $value['cid'])
|
||||
->where('table.metas.type = ?', 'category'), [Rows::alloc(), 'filter']);
|
||||
|
||||
$value['category'] = null;
|
||||
$value['category'] = '';
|
||||
$value['directory'] = [];
|
||||
|
||||
/** 取出第一个分类作为slug条件 */
|
||||
|
Loading…
x
Reference in New Issue
Block a user