Skip to content

Commit

Permalink
PHP8 / Contao 4.13 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
hschottm committed May 31, 2022
1 parent 8fc9d65 commit 86fe5f3
Show file tree
Hide file tree
Showing 24 changed files with 899 additions and 658 deletions.
4 changes: 2 additions & 2 deletions classes/TagHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public static function getSavedURLParams($objInput)
}
if (count($arrParams))
{
$strParams = join($arrParams, '&');
$strParams = implode('&', $arrParams);
}
return $strParams;
}
Expand Down Expand Up @@ -123,7 +123,7 @@ public function deleteIncompleteRecords($table, $new_records, $parent_table, $ch
->fetchEach('tid');
if (count($ids))
{
$this->Database->prepare("DELETE FROM tl_tag WHERE tid IN (" . join($ids, ",") . ") AND from_table = ?")
$this->Database->prepare("DELETE FROM tl_tag WHERE tid IN (" . implode(",", $ids) . ") AND from_table = ?")
->execute($table);
}
}
Expand Down
14 changes: 7 additions & 7 deletions classes/TagList.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,19 +129,19 @@ public function getRelatedTagList($for_tags, $blnExcludeUnpublishedItems = true)
{
array_push($keys, 'from_table = ?');
}
$objTags = $this->Database->prepare("SELECT $tagfield, COUNT($tagfield) as count FROM $tagtable WHERE (" . join($keys, " OR ") . ") AND tid IN (" . join($ids, ",") . ") GROUP BY $tagfield ORDER BY $tagfield ASC")
$objTags = $this->Database->prepare("SELECT $tagfield, COUNT($tagfield) as count FROM $tagtable WHERE (" . implode(" OR ", $keys) . ") AND tid IN (" . implode(",", $ids) . ") GROUP BY $tagfield ORDER BY $tagfield ASC")
->execute($this->forTable);
}
else
{
if (strlen($this->forTable))
{
$objTags = $this->Database->prepare("SELECT $tagfield, COUNT($tagfield) as count FROM $tagtable WHERE from_table = ? AND tid IN (" . join($ids, ",") . ") GROUP BY $tagfield ORDER BY $tagfield ASC")
$objTags = $this->Database->prepare("SELECT $tagfield, COUNT($tagfield) as count FROM $tagtable WHERE from_table = ? AND tid IN (" . implode(",", $ids) . ") GROUP BY $tagfield ORDER BY $tagfield ASC")
->execute($this->forTable);
}
else
{
$objTags = $this->Database->prepare("SELECT $tagfield, COUNT($tagfield) as count FROM $tagtable WHERE tid IN (" . join($ids, ",") . ") GROUP BY $tagfield ORDER BY $tagfield ASC")
$objTags = $this->Database->prepare("SELECT $tagfield, COUNT($tagfield) as count FROM $tagtable WHERE tid IN (" . implode(",", $ids) . ") GROUP BY $tagfield ORDER BY $tagfield ASC")
->execute();
}
}
Expand All @@ -162,21 +162,21 @@ public function getRelatedTagList($for_tags, $blnExcludeUnpublishedItems = true)
{
array_push($keys, 'from_table = ?');
}
$count = count($this->Database->prepare("SELECT tid FROM $tagtable WHERE $tagfield = ? AND (" . join($keys, " OR ") . ") AND tid IN (" . join($ids, ",") . ")")
$count = count($this->Database->prepare("SELECT tid FROM $tagtable WHERE $tagfield = ? AND (" . implode(" OR ", $keys) . ") AND tid IN (" . implode(",", $ids) . ")")
->execute(array_merge(array($objTags->tag), $this->forTable))
->fetchAllAssoc());
}
else
{
if (strlen($this->forTable))
{
$count = count($this->Database->prepare("SELECT tid FROM $tagtable WHERE $tagfield = ? AND from_table = ? AND tid IN (" . join($ids, ",") . ")")
$count = count($this->Database->prepare("SELECT tid FROM $tagtable WHERE $tagfield = ? AND from_table = ? AND tid IN (" . implode(",", $ids) . ")")
->execute($objTags->tag, $this->forTable)
->fetchAllAssoc());
}
else
{
$count = count($this->Database->prepare("SELECT $tagfield, COUNT($tagfield) as count FROM $tagtable WHERE $tagfield = ? AND tid IN (" . join($ids, ",") . ")")
$count = count($this->Database->prepare("SELECT $tagfield, COUNT($tagfield) as count FROM $tagtable WHERE $tagfield = ? AND tid IN (" . implode(",", $ids) . ")")
->execute($objTags->tag)
->fetchAllAssoc());
}
Expand Down Expand Up @@ -369,7 +369,7 @@ protected function getArticlesForPages()
$time = time();

// Get published articles
$pids = join($this->arrPages, ",");
$pids = implode(",", $this->arrPages);
if (strlen($this->inColumn))
{
$objArticles = $this->Database->prepare("SELECT id, title, alias, inColumn, cssID FROM tl_article WHERE inColumn = ? AND pid IN (" . $pids . ") " . (!BE_USER_LOGGED_IN ? " AND (start='' OR start<?) AND (stop='' OR stop>?) AND published=1" : "") . " ORDER BY sorting")
Expand Down
8 changes: 4 additions & 4 deletions classes/TagListArticles.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function getRelatedTagList($for_tags, $blnExcludeUnpublishedItems = true)
$ids = array();
for ($i = 0; $i < count($for_tags); $i++)
{
$arr = $this->Database->prepare("SELECT DISTINCT tl_tag.tid FROM tl_tag, tl_article WHERE tl_tag.tid = tl_article.id AND from_table = ? AND tl_tag.tid IN (" . join($this->arrArticles, ',') . ") AND tag = ?" . (!BE_USER_LOGGED_IN ? " AND (start='' OR start<?) AND (stop='' OR stop>?) AND published=1" : "") . " ORDER BY tl_tag.tid ASC")
$arr = $this->Database->prepare("SELECT DISTINCT tl_tag.tid FROM tl_tag, tl_article WHERE tl_tag.tid = tl_article.id AND from_table = ? AND tl_tag.tid IN (" . implode(',', $this->arrArticles) . ") AND tag = ?" . (!BE_USER_LOGGED_IN ? " AND (start='' OR start<?) AND (stop='' OR stop>?) AND published=1" : "") . " ORDER BY tl_tag.tid ASC")
->execute(array('tl_article', $for_tags[$i], time(), time()))
->fetchEach('tid');
if ($i == 0)
Expand All @@ -45,7 +45,7 @@ public function getRelatedTagList($for_tags, $blnExcludeUnpublishedItems = true)
$arrCloudTags = array();
if (count($ids))
{
$objTags = $this->Database->prepare("SELECT tag, COUNT(tag) as count FROM tl_tag, tl_article WHERE tl_tag.tid = tl_article.id AND from_table = ?" . (!BE_USER_LOGGED_IN ? " AND (start='' OR start<?) AND (stop='' OR stop>?) AND published=1" : "") . " AND tl_tag.tid IN (" . join($ids, ",") . ") GROUP BY tag ORDER BY tag ASC")
$objTags = $this->Database->prepare("SELECT tag, COUNT(tag) as count FROM tl_tag, tl_article WHERE tl_tag.tid = tl_article.id AND from_table = ?" . (!BE_USER_LOGGED_IN ? " AND (start='' OR start<?) AND (stop='' OR stop>?) AND published=1" : "") . " AND tl_tag.tid IN (" . implode(",", $ids) . ") GROUP BY tag ORDER BY tag ASC")
->execute('tl_article', time(), time());
$list = "";
$tags = array();
Expand All @@ -55,7 +55,7 @@ public function getRelatedTagList($for_tags, $blnExcludeUnpublishedItems = true)
{
if (!in_array($objTags->tag, $for_tags))
{
$count = count($this->Database->prepare("SELECT tl_tag.tid FROM tl_tag, tl_article WHERE tl_tag.tid = tl_article.id AND tag = ?" . (!BE_USER_LOGGED_IN ? " AND (start='' OR start<?) AND (stop='' OR stop>?) AND published=1" : "") . " AND from_table = ? AND tl_tag.tid IN (" . join($ids, ",") . ")")
$count = count($this->Database->prepare("SELECT tl_tag.tid FROM tl_tag, tl_article WHERE tl_tag.tid = tl_article.id AND tag = ?" . (!BE_USER_LOGGED_IN ? " AND (start='' OR start<?) AND (stop='' OR stop>?) AND published=1" : "") . " AND from_table = ? AND tl_tag.tid IN (" . implode(",", $ids) . ")")
->execute($objTags->tag, time(), time(), 'tl_article')
->fetchAllAssoc());
array_push($tags, array('tag_name' => $objTags->tag, 'tag_count' => $count));
Expand All @@ -76,7 +76,7 @@ public function getTagList($blnExcludeUnpublishedItems = true)
{
if (count($this->arrArticles))
{
$objTags = $this->Database->prepare("SELECT tag, COUNT(tag) as count FROM tl_tag, tl_article WHERE tl_tag.tid = tl_article.id AND from_table = ?" . (!BE_USER_LOGGED_IN ? " AND (start='' OR start<?) AND (stop='' OR stop>?) AND published=1" : "") . " AND tl_tag.tid IN (" . join($this->arrArticles, ',') . ") GROUP BY tag ORDER BY tag ASC")
$objTags = $this->Database->prepare("SELECT tag, COUNT(tag) as count FROM tl_tag, tl_article WHERE tl_tag.tid = tl_article.id AND from_table = ?" . (!BE_USER_LOGGED_IN ? " AND (start='' OR start<?) AND (stop='' OR stop>?) AND published=1" : "") . " AND tl_tag.tid IN (" . implode(',', $this->arrArticles) . ") GROUP BY tag ORDER BY tag ASC")
->execute('tl_article', time(), time());
$list = "";
$tags = array();
Expand Down
12 changes: 6 additions & 6 deletions classes/TagListContentElements.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function getRelatedTagList($for_tags, $blnExcludeUnpublishedItems = true)
$ids = array();
for ($i = 0; $i < count($for_tags); $i++)
{
$arr = $this->Database->prepare("SELECT DISTINCT tl_tag.tid FROM tl_tag, tl_content WHERE tl_tag.tid = tl_content.id AND from_table = ? AND tl_tag.tid IN (" . join($this->arrContentElements, ',') . ") AND tag = ?" . (!BE_USER_LOGGED_IN ? " AND (start='' OR start<?) AND (stop='' OR stop>?) AND invisible<>1" : "") . " ORDER BY tl_tag.tid ASC")
$arr = $this->Database->prepare("SELECT DISTINCT tl_tag.tid FROM tl_tag, tl_content WHERE tl_tag.tid = tl_content.id AND from_table = ? AND tl_tag.tid IN (" . implode(',', $this->arrContentElements) . ") AND tag = ?" . (!BE_USER_LOGGED_IN ? " AND (start='' OR start<?) AND (stop='' OR stop>?) AND invisible<>1" : "") . " ORDER BY tl_tag.tid ASC")
->execute(array('tl_content', $for_tags[$i], time(), time()))
->fetchEach('tid');
if ($i == 0)
Expand All @@ -45,7 +45,7 @@ public function getRelatedTagList($for_tags, $blnExcludeUnpublishedItems = true)
$arrCloudTags = array();
if (count($ids))
{
$objTags = $this->Database->prepare("SELECT tag, COUNT(tag) as count FROM tl_tag, tl_content WHERE tl_tag.tid = tl_content.id AND from_table = ?" . (!BE_USER_LOGGED_IN ? " AND (start='' OR start<?) AND (stop='' OR stop>?) AND invisible<>1" : "") . " AND tl_tag.tid IN (" . join($ids, ",") . ") GROUP BY tag ORDER BY tag ASC")
$objTags = $this->Database->prepare("SELECT tag, COUNT(tag) as count FROM tl_tag, tl_content WHERE tl_tag.tid = tl_content.id AND from_table = ?" . (!BE_USER_LOGGED_IN ? " AND (start='' OR start<?) AND (stop='' OR stop>?) AND invisible<>1" : "") . " AND tl_tag.tid IN (" . implode(",", $ids) . ") GROUP BY tag ORDER BY tag ASC")
->execute('tl_content', time(), time());
$list = "";
$tags = array();
Expand All @@ -55,7 +55,7 @@ public function getRelatedTagList($for_tags, $blnExcludeUnpublishedItems = true)
{
if (!in_array($objTags->tag, $for_tags))
{
$count = count($this->Database->prepare("SELECT tl_tag.tid FROM tl_tag, tl_content WHERE tl_tag.tid = tl_content.id AND tag = ?" . (!BE_USER_LOGGED_IN ? " AND (start='' OR start<?) AND (stop='' OR stop>?) AND invisible<>1" : "") . " AND from_table = ? AND tl_tag.tid IN (" . join($ids, ",") . ")")
$count = count($this->Database->prepare("SELECT tl_tag.tid FROM tl_tag, tl_content WHERE tl_tag.tid = tl_content.id AND tag = ?" . (!BE_USER_LOGGED_IN ? " AND (start='' OR start<?) AND (stop='' OR stop>?) AND invisible<>1" : "") . " AND from_table = ? AND tl_tag.tid IN (" . implode(",", $ids) . ")")
->execute($objTags->tag, 'tl_content', time(), time())
->fetchAllAssoc());
array_push($tags, array('tag_name' => $objTags->tag, 'tag_count' => $count));
Expand All @@ -76,7 +76,7 @@ public function getTagList($blnExcludeUnpublishedItems = true)
{
if (count($this->arrContentElements))
{
$objTags = $this->Database->prepare("SELECT tag, COUNT(tag) as count FROM tl_tag, tl_content WHERE tl_tag.tid = tl_content.id AND from_table = ?" . (!BE_USER_LOGGED_IN ? " AND (start='' OR start<?) AND (stop='' OR stop>?) AND invisible<>1" : "") . " AND tl_tag.tid IN (" . join($this->arrContentElements, ',') . ") GROUP BY tag ORDER BY tag ASC")
$objTags = $this->Database->prepare("SELECT tag, COUNT(tag) as count FROM tl_tag, tl_content WHERE tl_tag.tid = tl_content.id AND from_table = ?" . (!BE_USER_LOGGED_IN ? " AND (start='' OR start<?) AND (stop='' OR stop>?) AND invisible<>1" : "") . " AND tl_tag.tid IN (" . implode(',', $this->arrContentElements) . ") GROUP BY tag ORDER BY tag ASC")
->execute('tl_content', time(), time());
$list = "";
$tags = array();
Expand Down Expand Up @@ -116,9 +116,9 @@ protected function getContentElementsForPages()
if (count($this->arrPages))
{
$time = time();
$arrArticles = $this->Database->prepare("SELECT id FROM tl_article WHERE pid IN (" . join($this->arrPages, ',') . ") " . (!BE_USER_LOGGED_IN ? " AND (start='' OR start<?) AND (stop='' OR stop>?) AND published=1" : "") . " ORDER BY sorting")
$arrArticles = $this->Database->prepare("SELECT id FROM tl_article WHERE pid IN (" . implode(',', $this->arrPages) . ") " . (!BE_USER_LOGGED_IN ? " AND (start='' OR start<?) AND (stop='' OR stop>?) AND published=1" : "") . " ORDER BY sorting")
->execute($time, $time)->fetchEach('id');
$this->arrContentElements = $this->Database->prepare("SELECT id FROM tl_content WHERE pid IN (" . join($arrArticles, ',') . ") " . (!BE_USER_LOGGED_IN ? " AND invisible<>1" : "") . " ORDER BY sorting")
$this->arrContentElements = $this->Database->prepare("SELECT id FROM tl_content WHERE pid IN (" . implode(',', $arrArticles) . ") " . (!BE_USER_LOGGED_IN ? " AND invisible<>1" : "") . " ORDER BY sorting")
->execute()->fetchEach('id');
}
}
Expand Down
8 changes: 4 additions & 4 deletions classes/TagListEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function getRelatedTagList($for_tags, $blnExcludeUnpublishedItems = true)
$ids = array();
for ($i = 0; $i < count($for_tags); $i++)
{
$arr = $this->Database->prepare("SELECT DISTINCT tl_tag.tid FROM tl_tag, tl_calendar_events WHERE tl_tag.tid = tl_calendar_events.id AND tl_calendar_events.pid IN ('" . join($this->arrCalendars, "','") . "') AND from_table = ? AND tag = ?" . (!BE_USER_LOGGED_IN ? " AND (start='' OR start<?) AND (stop='' OR stop>?) AND published=1" : "") . " ORDER BY tl_tag.tid ASC")
$arr = $this->Database->prepare("SELECT DISTINCT tl_tag.tid FROM tl_tag, tl_calendar_events WHERE tl_tag.tid = tl_calendar_events.id AND tl_calendar_events.pid IN ('" . implode("','", $this->arrCalendars) . "') AND from_table = ? AND tag = ?" . (!BE_USER_LOGGED_IN ? " AND (start='' OR start<?) AND (stop='' OR stop>?) AND published=1" : "") . " ORDER BY tl_tag.tid ASC")
->execute(array('tl_calendar_events', $for_tags[$i], time(), time()))
->fetchEach('tid');
if ($i == 0)
Expand All @@ -43,7 +43,7 @@ public function getRelatedTagList($for_tags, $blnExcludeUnpublishedItems = true)
$arrCloudTags = array();
if (count($ids))
{
$objTags = $this->Database->prepare("SELECT tag, COUNT(tag) as count FROM tl_tag, tl_calendar_events WHERE tl_tag.tid = tl_calendar_events.id AND tl_calendar_events.pid IN ('" . join($this->arrCalendars, "','") . "') AND from_table = ? AND tl_tag.tid IN (" . join($ids, ",") . ")" . (!BE_USER_LOGGED_IN ? " AND (start='' OR start<?) AND (stop='' OR stop>?) AND published=1" : "") . " GROUP BY tag ORDER BY tag ASC")
$objTags = $this->Database->prepare("SELECT tag, COUNT(tag) as count FROM tl_tag, tl_calendar_events WHERE tl_tag.tid = tl_calendar_events.id AND tl_calendar_events.pid IN ('" . implode("','", $this->arrCalendars) . "') AND from_table = ? AND tl_tag.tid IN (" . implode(",", $ids) . ")" . (!BE_USER_LOGGED_IN ? " AND (start='' OR start<?) AND (stop='' OR stop>?) AND published=1" : "") . " GROUP BY tag ORDER BY tag ASC")
->execute('tl_calendar_events', time(), time());
$list = "";
$tags = array();
Expand All @@ -53,7 +53,7 @@ public function getRelatedTagList($for_tags, $blnExcludeUnpublishedItems = true)
{
if (!in_array($objTags->tag, $for_tags))
{
$count = count($this->Database->prepare("SELECT tl_tag.tid FROM tl_tag, tl_calendar_events WHERE tl_tag.tid = tl_calendar_events.id AND tl_calendar_events.pid IN ('" . join($this->arrCalendars, "','") . "') AND tag = ? AND from_table = ?" . (!BE_USER_LOGGED_IN ? " AND (start='' OR start<?) AND (stop='' OR stop>?) AND published=1" : "") . " AND tl_tag.tid IN (" . join($ids, ",") . ")")
$count = count($this->Database->prepare("SELECT tl_tag.tid FROM tl_tag, tl_calendar_events WHERE tl_tag.tid = tl_calendar_events.id AND tl_calendar_events.pid IN ('" . implode("','", $this->arrCalendars) . "') AND tag = ? AND from_table = ?" . (!BE_USER_LOGGED_IN ? " AND (start='' OR start<?) AND (stop='' OR stop>?) AND published=1" : "") . " AND tl_tag.tid IN (" . implode(",", $ids) . ")")
->execute($objTags->tag, 'tl_calendar_events', time(), time())
->fetchAllAssoc());
array_push($tags, array('tag_name' => $objTags->tag, 'tag_count' => $count));
Expand All @@ -74,7 +74,7 @@ public function getTagList($blnExcludeUnpublishedItems = true)
{
if (count($this->arrCalendars))
{
$objTags = $this->Database->prepare("SELECT tag, COUNT(tag) as count FROM tl_tag, tl_calendar_events WHERE tl_tag.tid = tl_calendar_events.id AND tl_calendar_events.pid IN ('" . join($this->arrCalendars, "','") . "') AND from_table = ?" . (!BE_USER_LOGGED_IN ? " AND (start='' OR start<?) AND (stop='' OR stop>?) AND published=1" : "") . " GROUP BY tag ORDER BY tag ASC")
$objTags = $this->Database->prepare("SELECT tag, COUNT(tag) as count FROM tl_tag, tl_calendar_events WHERE tl_tag.tid = tl_calendar_events.id AND tl_calendar_events.pid IN ('" . implode("','", $this->arrCalendars) . "') AND from_table = ?" . (!BE_USER_LOGGED_IN ? " AND (start='' OR start<?) AND (stop='' OR stop>?) AND published=1" : "") . " GROUP BY tag ORDER BY tag ASC")
->execute('tl_calendar_events', time(), time());
$list = "";
$tags = array();
Expand Down
4 changes: 2 additions & 2 deletions classes/TagListMembers.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function getRelatedTagList($for_tags, $blnExcludeUnpublishedItems = true)
$arrCloudTags = array();
if (count($ids))
{
$objTags = $this->Database->prepare("SELECT tag, COUNT(tag) as count FROM tl_tag, tl_member WHERE tl_tag.tid = tl_member.id AND from_table = ? AND tl_tag.tid IN (" . join($ids, ",") . ") GROUP BY tag ORDER BY tag ASC")
$objTags = $this->Database->prepare("SELECT tag, COUNT(tag) as count FROM tl_tag, tl_member WHERE tl_tag.tid = tl_member.id AND from_table = ? AND tl_tag.tid IN (" . implode(",", $ids) . ") GROUP BY tag ORDER BY tag ASC")
->execute('tl_member');
$list = "";
$tags = array();
Expand All @@ -61,7 +61,7 @@ public function getRelatedTagList($for_tags, $blnExcludeUnpublishedItems = true)
{
if (!in_array($objTags->tag, $for_tags))
{
$count = count($this->Database->prepare("SELECT tl_tag.tid FROM tl_tag, tl_member WHERE tl_tag.tid = tl_member.id AND tag = ? AND from_table = ? AND tl_tag.tid IN (" . join($ids, ",") . ")")
$count = count($this->Database->prepare("SELECT tl_tag.tid FROM tl_tag, tl_member WHERE tl_tag.tid = tl_member.id AND tag = ? AND from_table = ? AND tl_tag.tid IN (" . implode(",", $ids) . ")")
->execute($objTags->tag, 'tl_member')
->fetchAllAssoc());
array_push($tags, array('tag_name' => $objTags->tag, 'tag_count' => $count));
Expand Down
Loading

0 comments on commit 86fe5f3

Please sign in to comment.