diff options
45 files changed, 240 insertions, 216 deletions
diff --git a/app/CommonMark/XrefExtension.php b/app/CommonMark/XrefExtension.php index 1e7ced6803..4b6006115b 100644 --- a/app/CommonMark/XrefExtension.php +++ b/app/CommonMark/XrefExtension.php @@ -19,9 +19,7 @@ namespace Fisharebest\Webtrees\CommonMark; use Fisharebest\Webtrees\Tree; use League\CommonMark\ConfigurableEnvironmentInterface; -use League\CommonMark\Extension\Extension; use League\CommonMark\Extension\ExtensionInterface; -use League\CommonMark\Inline\Parser\InlineParserInterface; /** * Convert XREFs within markdown text to links diff --git a/app/Filter.php b/app/Filter.php index d84403ecd0..39a5f123e0 100644 --- a/app/Filter.php +++ b/app/Filter.php @@ -33,7 +33,6 @@ use League\CommonMark\Inline\Element\Text; use League\CommonMark\Inline\Parser\AutolinkParser; use League\CommonMark\Inline\Renderer\LinkRenderer; use League\CommonMark\Inline\Renderer\TextRenderer; -use Throwable; /** * Filter input and escape output. diff --git a/app/Http/Controllers/Admin/ChangesLogController.php b/app/Http/Controllers/Admin/ChangesLogController.php index 9d1f98e91a..e731949baa 100644 --- a/app/Http/Controllers/Admin/ChangesLogController.php +++ b/app/Http/Controllers/Admin/ChangesLogController.php @@ -29,6 +29,7 @@ use Fisharebest\Webtrees\Services\UserService; use Fisharebest\Webtrees\Tree; use Illuminate\Database\Capsule\Manager as DB; use Illuminate\Database\Query\Builder; +use Illuminate\Database\Query\Expression; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use stdClass; @@ -242,7 +243,7 @@ class ChangesLogController extends AbstractAdminController $query = DB::table('change') ->leftJoin('user', 'user.user_id', '=', 'change.user_id') ->join('gedcom', 'gedcom.gedcom_id', '=', 'change.gedcom_id') - ->select(['change.*', DB::raw("COALESCE(user_name, '<none>') AS user_name"), 'gedcom_name']); + ->select(['change.*', new Expression("COALESCE(user_name, '<none>') AS user_name"), 'gedcom_name']); if ($search !== '') { $query->where(static function (Builder $query) use ($search): void { diff --git a/app/Http/Controllers/Admin/ControlPanelController.php b/app/Http/Controllers/Admin/ControlPanelController.php index b1674f1eeb..bacc9abb44 100644 --- a/app/Http/Controllers/Admin/ControlPanelController.php +++ b/app/Http/Controllers/Admin/ControlPanelController.php @@ -45,6 +45,7 @@ use Fisharebest\Webtrees\Services\UserService; use Fisharebest\Webtrees\Tree; use Fisharebest\Webtrees\Webtrees; use Illuminate\Database\Capsule\Manager as DB; +use Illuminate\Database\Query\Expression; use Illuminate\Database\Query\JoinClause; use Illuminate\Support\Collection; use League\Flysystem\Adapter\Local; @@ -180,7 +181,7 @@ class ControlPanelController extends AbstractAdminController ->where('change.status', '=', 'pending'); }) ->groupBy('gedcom.gedcom_id') - ->pluck(DB::raw('COUNT(change_id)'), 'gedcom.gedcom_id') + ->pluck(new Expression('COUNT(change_id)'), 'gedcom.gedcom_id') ->all(); } @@ -194,7 +195,7 @@ class ControlPanelController extends AbstractAdminController return DB::table('gedcom') ->leftJoin('families', 'f_file', '=', 'gedcom_id') ->groupBy('gedcom_id') - ->pluck(DB::raw('COUNT(f_id)'), 'gedcom_id') + ->pluck(new Expression('COUNT(f_id)'), 'gedcom_id') ->map(static function (string $count) { return (int) $count; }); @@ -210,7 +211,7 @@ class ControlPanelController extends AbstractAdminController return DB::table('gedcom') ->leftJoin('individuals', 'i_file', '=', 'gedcom_id') ->groupBy('gedcom_id') - ->pluck(DB::raw('COUNT(i_id)'), 'gedcom_id') + ->pluck(new Expression('COUNT(i_id)'), 'gedcom_id') ->map(static function (string $count) { return (int) $count; }); @@ -226,7 +227,7 @@ class ControlPanelController extends AbstractAdminController return DB::table('gedcom') ->leftJoin('media', 'm_file', '=', 'gedcom_id') ->groupBy('gedcom_id') - ->pluck(DB::raw('COUNT(m_id)'), 'gedcom_id') + ->pluck(new Expression('COUNT(m_id)'), 'gedcom_id') ->map(static function (string $count) { return (int) $count; }); @@ -246,7 +247,7 @@ class ControlPanelController extends AbstractAdminController ->where('o_type', '=', 'NOTE'); }) ->groupBy('gedcom_id') - ->pluck(DB::raw('COUNT(o_id)'), 'gedcom_id') + ->pluck(new Expression('COUNT(o_id)'), 'gedcom_id') ->map(static function (string $count) { return (int) $count; }); @@ -266,7 +267,7 @@ class ControlPanelController extends AbstractAdminController ->where('o_type', '=', 'REPO'); }) ->groupBy('gedcom_id') - ->pluck(DB::raw('COUNT(o_id)'), 'gedcom_id') + ->pluck(new Expression('COUNT(o_id)'), 'gedcom_id') ->map(static function (string $count) { return (int) $count; }); @@ -282,7 +283,7 @@ class ControlPanelController extends AbstractAdminController return DB::table('gedcom') ->leftJoin('sources', 's_file', '=', 'gedcom_id') ->groupBy('gedcom_id') - ->pluck(DB::raw('COUNT(s_id)'), 'gedcom_id') + ->pluck(new Expression('COUNT(s_id)'), 'gedcom_id') ->map(static function (string $count) { return (int) $count; }); diff --git a/app/Http/Controllers/Admin/FixLevel0MediaController.php b/app/Http/Controllers/Admin/FixLevel0MediaController.php index e2437056a3..80b6d62bac 100644 --- a/app/Http/Controllers/Admin/FixLevel0MediaController.php +++ b/app/Http/Controllers/Admin/FixLevel0MediaController.php @@ -24,6 +24,7 @@ use Fisharebest\Webtrees\Media; use Fisharebest\Webtrees\Services\DatatablesService; use Fisharebest\Webtrees\Tree; use Illuminate\Database\Capsule\Manager as DB; +use Illuminate\Database\Query\Expression; use Illuminate\Database\Query\JoinClause; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; @@ -123,7 +124,7 @@ class FixLevel0MediaController extends AbstractAdminController ->on('individuals.i_file', '=', 'link.l_file') ->on('individuals.i_id', '=', 'link.l_from'); }) - ->where('i_gedcom', 'LIKE', DB::raw("'%\n1 OBJE @' || " . $prefix . "media.m_id || '@%'")) + ->where('i_gedcom', 'LIKE', new Expression("'%\n1 OBJE @' || " . $prefix . "media.m_id || '@%'")) ->orderBy('individuals.i_file') ->orderBy('individuals.i_id') ->orderBy('media.m_id') diff --git a/app/Http/Controllers/Admin/ImportThumbnailsController.php b/app/Http/Controllers/Admin/ImportThumbnailsController.php index 3ddcd82547..2cd257fbe6 100644 --- a/app/Http/Controllers/Admin/ImportThumbnailsController.php +++ b/app/Http/Controllers/Admin/ImportThumbnailsController.php @@ -23,6 +23,7 @@ use Fisharebest\Webtrees\I18N; use Fisharebest\Webtrees\Media; use Fisharebest\Webtrees\Tree; use Illuminate\Database\Capsule\Manager as DB; +use Illuminate\Database\Query\Expression; use Illuminate\Database\Query\JoinClause; use Intervention\Image\ImageManager; use Psr\Http\Message\ResponseInterface; @@ -238,7 +239,7 @@ class ImportThumbnailsController extends AbstractAdminController ->on('media_file.m_id', '=', 'media.m_id'); }) ->join('gedcom_setting', 'media.m_file', '=', 'gedcom_setting.gedcom_id') - ->where(DB::raw('setting_value || multimedia_file_refn'), '=', $file) + ->where(new Expression('setting_value || multimedia_file_refn'), '=', $file) ->select(['media.*']) ->distinct() ->get() diff --git a/app/Http/Controllers/Admin/LocationController.php b/app/Http/Controllers/Admin/LocationController.php index 432fdf5a3e..f3849cc1a4 100644 --- a/app/Http/Controllers/Admin/LocationController.php +++ b/app/Http/Controllers/Admin/LocationController.php @@ -25,6 +25,7 @@ use Fisharebest\Webtrees\Location; use Fisharebest\Webtrees\Services\GedcomService; use Fisharebest\Webtrees\Tree; use Illuminate\Database\Capsule\Manager as DB; +use Illuminate\Database\Query\Expression; use Illuminate\Database\Query\JoinClause; use Illuminate\Database\QueryException; use Psr\Http\Message\ResponseInterface; @@ -199,7 +200,7 @@ class LocationController extends AbstractAdminController ->leftJoin('placelocation AS p8', 'p8.pl_parent_id', '=', 'p7.pl_id') ->leftJoin('placelocation AS p9', 'p9.pl_parent_id', '=', 'p8.pl_id') ->where('p0.pl_parent_id', '=', $parent_id) - ->select([DB::raw('COUNT(*) AS child_count'), DB::raw('SUM(' . $expression . ') AS no_coord')]) + ->select([new Expression('COUNT(*) AS child_count'), new Expression('SUM(' . $expression . ') AS no_coord')]) ->first(); } diff --git a/app/Http/Controllers/Admin/MediaController.php b/app/Http/Controllers/Admin/MediaController.php index 0f80855345..f40ca8eb96 100644 --- a/app/Http/Controllers/Admin/MediaController.php +++ b/app/Http/Controllers/Admin/MediaController.php @@ -28,6 +28,7 @@ use Fisharebest\Webtrees\MediaFile; use Fisharebest\Webtrees\Services\DatatablesService; use Illuminate\Database\Capsule\Manager as DB; use Illuminate\Database\Query\Builder; +use Illuminate\Database\Query\Expression; use Illuminate\Database\Query\JoinClause; use Illuminate\Support\Collection; use Illuminate\Support\Str; @@ -93,7 +94,7 @@ class MediaController extends AbstractAdminController { $base_folders = DB::table('gedcom_setting') ->where('setting_name', '=', 'MEDIA_DIRECTORY') - ->select(DB::raw("setting_value || 'dummy.jpeg' AS path")); + ->select(new Expression("setting_value || 'dummy.jpeg' AS path")); return DB::table('media_file') ->join('gedcom_setting', 'gedcom_id', '=', 'm_file') @@ -101,7 +102,7 @@ class MediaController extends AbstractAdminController ->where('multimedia_file_refn', 'LIKE', '%/%') ->where('multimedia_file_refn', 'NOT LIKE', 'http://%') ->where('multimedia_file_refn', 'NOT LIKE', 'https://%') - ->select(DB::raw('setting_value || multimedia_file_refn AS path')) + ->select(new Expression('setting_value || multimedia_file_refn AS path')) ->union($base_folders) ->pluck('path') ->map(static function (string $path): string { @@ -209,7 +210,7 @@ class MediaController extends AbstractAdminController $sort_columns = [ 0 => 'multimedia_file_refn', - 2 => DB::raw('descriptive_title || multimedia_file_refn'), + 2 => new Expression('descriptive_title || multimedia_file_refn'), ]; switch ($files) { @@ -226,10 +227,10 @@ class MediaController extends AbstractAdminController ->where('multimedia_file_refn', 'NOT LIKE', 'https://%') ->select(['media.*', 'multimedia_file_refn', 'descriptive_title']); - $query->where(DB::raw('setting_value || multimedia_file_refn'), 'LIKE', $media_folder . '%'); + $query->where(new Expression('setting_value || multimedia_file_refn'), 'LIKE', $media_folder . '%'); if ($subfolders === 'exclude') { - $query->where(DB::raw('setting_value || multimedia_file_refn'), 'NOT LIKE', $media_folder . '%/%'); + $query->where(new Expression('setting_value || multimedia_file_refn'), 'NOT LIKE', $media_folder . '%/%'); } return $datatables_service->handle($request, $query, $search_columns, $sort_columns, function (stdClass $row): array { @@ -429,12 +430,12 @@ class MediaController extends AbstractAdminController ->where('multimedia_file_refn', 'LIKE', '%/%') ->where('multimedia_file_refn', 'NOT LIKE', 'http://%') ->where('multimedia_file_refn', 'NOT LIKE', 'https://%') - ->where(DB::raw('setting_value || multimedia_file_refn'), 'LIKE', $media_folder . '%') - ->select(DB::raw('setting_value || multimedia_file_refn AS path')) - ->orderBy(DB::raw('setting_value || multimedia_file_refn')); + ->where(new Expression('setting_value || multimedia_file_refn'), 'LIKE', $media_folder . '%') + ->select(new Expression('setting_value || multimedia_file_refn AS path')) + ->orderBy(new Expression('setting_value || multimedia_file_refn')); if ($subfolders === 'exclude') { - $query->where(DB::raw('setting_value || multimedia_file_refn'), 'NOT LIKE', $media_folder . '%/%'); + $query->where(new Expression('setting_value || multimedia_file_refn'), 'NOT LIKE', $media_folder . '%/%'); } return $query->pluck('path')->all(); diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php index 0eb2517d7c..3a877a0499 100644 --- a/app/Http/Controllers/AdminController.php +++ b/app/Http/Controllers/AdminController.php @@ -30,6 +30,7 @@ use Fisharebest\Webtrees\Repository; use Fisharebest\Webtrees\Source; use Fisharebest\Webtrees\Tree; use Illuminate\Database\Capsule\Manager as DB; +use Illuminate\Database\Query\Expression; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use stdClass; @@ -208,7 +209,7 @@ class AdminController extends AbstractBaseController ->where('gedcom_id', '=', $tree->id()) ->whereIn('page_parameter', [$xref1, $xref2]) ->groupBy('page_name') - ->pluck(DB::raw('SUM(page_count)'), 'page_name'); + ->pluck(new Expression('SUM(page_count)'), 'page_name'); foreach ($hits as $page_name => $page_count) { DB::table('hit_counter') diff --git a/app/Http/Controllers/AdminSiteController.php b/app/Http/Controllers/AdminSiteController.php index 04f665f38e..b75e5ca37c 100644 --- a/app/Http/Controllers/AdminSiteController.php +++ b/app/Http/Controllers/AdminSiteController.php @@ -31,6 +31,7 @@ use Fisharebest\Webtrees\Site; use Fisharebest\Webtrees\Tree; use Illuminate\Database\Capsule\Manager as DB; use Illuminate\Database\Query\Builder; +use Illuminate\Database\Query\Expression; use Illuminate\Support\Collection; use League\Flysystem\FilesystemInterface; use Psr\Http\Message\ResponseInterface; @@ -251,7 +252,7 @@ class AdminSiteController extends AbstractBaseController $query = DB::table('log') ->leftJoin('user', 'user.user_id', '=', 'log.user_id') ->leftJoin('gedcom', 'gedcom.gedcom_id', '=', 'log.gedcom_id') - ->select(['log.*', DB::raw("COALESCE(user_name, '<none>') AS user_name"), DB::raw("COALESCE(gedcom_name, '<none>') AS gedcom_name")]); + ->select(['log.*', new Expression("COALESCE(user_name, '<none>') AS user_name"), new Expression("COALESCE(gedcom_name, '<none>') AS gedcom_name")]); if ($from !== '') { $query->where('log_time', '>=', $from); diff --git a/app/Http/Controllers/AdminTreesController.php b/app/Http/Controllers/AdminTreesController.php index bac5a1adb1..b97d86ac48 100644 --- a/app/Http/Controllers/AdminTreesController.php +++ b/app/Http/Controllers/AdminTreesController.php @@ -44,6 +44,7 @@ use Fisharebest\Webtrees\SurnameTradition; use Fisharebest\Webtrees\Tree; use Illuminate\Database\Capsule\Manager as DB; use Illuminate\Database\Query\Builder; +use Illuminate\Database\Query\Expression; use Illuminate\Database\Query\JoinClause; use Illuminate\Support\Collection; use League\Flysystem\Filesystem; @@ -107,16 +108,16 @@ class AdminTreesController extends AbstractBaseController $q1 = DB::table('individuals') ->where('i_file', '=', $tree->id()) - ->select(['i_id AS xref', 'i_gedcom AS gedcom', DB::raw("'INDI' AS type")]); + ->select(['i_id AS xref', 'i_gedcom AS gedcom', new Expression("'INDI' AS type")]); $q2 = DB::table('families') ->where('f_file', '=', $tree->id()) - ->select(['f_id AS xref', 'f_gedcom AS gedcom', DB::raw("'FAM' AS type")]); + ->select(['f_id AS xref', 'f_gedcom AS gedcom', new Expression("'FAM' AS type")]); $q3 = DB::table('media') ->where('m_file', '=', $tree->id()) - ->select(['m_id AS xref', 'm_gedcom AS gedcom', DB::raw("'OBJE' AS type")]); + ->select(['m_id AS xref', 'm_gedcom AS gedcom', new Expression("'OBJE' AS type")]); $q4 = DB::table('sources') ->where('s_file', '=', $tree->id()) - ->select(['s_id AS xref', 's_gedcom AS gedcom', DB::raw("'SOUR' AS type")]); + ->select(['s_id AS xref', 's_gedcom AS gedcom', new Expression("'SOUR' AS type")]); $q5 = DB::table('other') ->where('o_file', '=', $tree->id()) ->whereNotIn('o_type', ['HEAD', 'TRLR']) @@ -125,7 +126,7 @@ class AdminTreesController extends AbstractBaseController ->where('gedcom_id', '=', $tree->id()) ->where('status', '=', 'pending') ->orderBy('change_id') - ->select(['xref', 'new_gedcom AS gedcom', DB::raw("'' AS type")]); + ->select(['xref', 'new_gedcom AS gedcom', new Expression("'' AS type")]); $rows = $q1 ->unionAll($q2) @@ -737,7 +738,7 @@ class AdminTreesController extends AbstractBaseController 'i_gedcom', ], static function (Builder $query) use ($tree1, $tree2): void { $query->select([ - DB::raw($tree2->id()), + new Expression($tree2->id()), 'i_id', 'i_rin', 'i_sex', @@ -755,7 +756,7 @@ class AdminTreesController extends AbstractBaseController 'f_numchil', ], static function (Builder $query) use ($tree1, $tree2): void { $query->select([ - DB::raw($tree2->id()), + new Expression($tree2->id()), 'f_id', 'f_husb', 'f_wife', @@ -772,7 +773,7 @@ class AdminTreesController extends AbstractBaseController 's_gedcom', ], static function (Builder $query) use ($tree1, $tree2): void { $query->select([ - DB::raw($tree2->id()), + new Expression($tree2->id()), 's_id', 's_name', 's_gedcom', @@ -786,7 +787,7 @@ class AdminTreesController extends AbstractBaseController 'm_gedcom', ], static function (Builder $query) use ($tree1, $tree2): void { $query->select([ - DB::raw($tree2->id()), + new Expression($tree2->id()), 'm_id', 'm_gedcom', ])->from('media') @@ -802,7 +803,7 @@ class AdminTreesController extends AbstractBaseController 'descriptive_title', ], static function (Builder $query) use ($tree1, $tree2): void { $query->select([ - DB::raw($tree2->id()), + new Expression($tree2->id()), 'm_id', 'multimedia_file_refn', 'multimedia_format', @@ -819,7 +820,7 @@ class AdminTreesController extends AbstractBaseController 'o_gedcom', ], static function (Builder $query) use ($tree1, $tree2): void { $query->select([ - DB::raw($tree2->id()), + new Expression($tree2->id()), 'o_id', 'o_type', 'o_gedcom', @@ -844,7 +845,7 @@ class AdminTreesController extends AbstractBaseController 'n_soundex_surn_dm', ], static function (Builder $query) use ($tree1, $tree2): void { $query->select([ - DB::raw($tree2->id()), + new Expression($tree2->id()), 'n_id', 'n_num', 'n_type', @@ -876,7 +877,7 @@ class AdminTreesController extends AbstractBaseController 'd_type', ], static function (Builder $query) use ($tree1, $tree2): void { $query->select([ - DB::raw($tree2->id()), + new Expression($tree2->id()), 'd_gid', 'd_day', 'd_month', @@ -897,7 +898,7 @@ class AdminTreesController extends AbstractBaseController 'l_to', ], static function (Builder $query) use ($tree1, $tree2): void { $query->select([ - DB::raw($tree2->id()), + new Expression($tree2->id()), 'l_from', 'l_type', 'l_to', @@ -1261,7 +1262,7 @@ class AdminTreesController extends AbstractBaseController ->where('i_id', '=', $old_xref) ->update([ 'i_id' => $new_xref, - 'i_gedcom' => DB::raw("REPLACE(i_gedcom, '0 @$old_xref@ INDI', '0 @$new_xref@ INDI')"), + 'i_gedcom' => new Expression("REPLACE(i_gedcom, '0 @$old_xref@ INDI', '0 @$new_xref@ INDI')"), ]); DB::table('families') @@ -1269,7 +1270,7 @@ class AdminTreesController extends AbstractBaseController ->where('f_file', '=', $tree->id()) ->update([ 'f_husb' => $new_xref, - 'f_gedcom' => DB::raw("REPLACE(f_gedcom, ' HUSB @$old_xref@', ' HUSB @$new_xref@')"), + 'f_gedcom' => new Expression("REPLACE(f_gedcom, ' HUSB @$old_xref@', ' HUSB @$new_xref@')"), ]); DB::table('families') @@ -1277,7 +1278,7 @@ class AdminTreesController extends AbstractBaseController ->where('f_file', '=', $tree->id()) ->update([ 'f_wife' => $new_xref, - 'f_gedcom' => DB::raw("REPLACE(f_gedcom, ' WIFE @$old_xref@', ' WIFE @$new_xref@')"), + 'f_gedcom' => new Expression("REPLACE(f_gedcom, ' WIFE @$old_xref@', ' WIFE @$new_xref@')"), ]); // Other links from families to individuals @@ -1292,7 +1293,7 @@ class AdminTreesController extends AbstractBaseController ->where('l_type', '=', $tag) ->where('f_file', '=', $tree->id()) ->update([ - 'f_gedcom' => DB::raw("REPLACE(f_gedcom, ' $tag @$old_xref@', ' $tag @$new_xref@')"), + 'f_gedcom' => new Expression("REPLACE(f_gedcom, ' $tag @$old_xref@', ' $tag @$new_xref@')"), ]); } @@ -1308,7 +1309,7 @@ class AdminTreesController extends AbstractBaseController ->where('link.l_type', '=', $tag) ->where('i_file', '=', $tree->id()) ->update([ - 'i_gedcom' => DB::raw("REPLACE(i_gedcom, ' $tag @$old_xref@', ' $tag @$new_xref@')"), + 'i_gedcom' => new Expression("REPLACE(i_gedcom, ' $tag @$old_xref@', ' $tag @$new_xref@')"), ]); } @@ -1341,7 +1342,7 @@ class AdminTreesController extends AbstractBaseController ->where('f_id', '=', $old_xref) ->update([ 'f_id' => $new_xref, - 'f_gedcom' => DB::raw("REPLACE(f_gedcom, '0 @$old_xref@ FAM', '0 @$new_xref@ FAM')"), + 'f_gedcom' => new Expression("REPLACE(f_gedcom, '0 @$old_xref@ FAM', '0 @$new_xref@ FAM')"), ]); // Links from individuals to families @@ -1356,7 +1357,7 @@ class AdminTreesController extends AbstractBaseController ->where('l_type', '=', $tag) ->where('i_file', '=', $tree->id()) ->update([ - 'i_gedcom' => DB::raw("REPLACE(i_gedcom, ' $tag @$old_xref@', ' $tag @$new_xref@')"), + 'i_gedcom' => new Expression("REPLACE(i_gedcom, ' $tag @$old_xref@', ' $tag @$new_xref@')"), ]); } @@ -1381,7 +1382,7 @@ class AdminTreesController extends AbstractBaseController ->where('s_id', '=', $old_xref) ->update([ 's_id' => $new_xref, - 's_gedcom' => DB::raw("REPLACE(s_gedcom, '0 @$old_xref@ SOUR', '0 @$new_xref@ SOUR')"), + 's_gedcom' => new Expression("REPLACE(s_gedcom, '0 @$old_xref@ SOUR', '0 @$new_xref@ SOUR')"), ]); DB::table('individuals') @@ -1394,7 +1395,7 @@ class AdminTreesController extends AbstractBaseController ->where('l_type', '=', 'SOUR') ->where('i_file', '=', $tree->id()) ->update([ - 'i_gedcom' => DB::raw("REPLACE(i_gedcom, ' SOUR @$old_xref@', ' SOUR @$new_xref@')"), + 'i_gedcom' => new Expression("REPLACE(i_gedcom, ' SOUR @$old_xref@', ' SOUR @$new_xref@')"), ]); DB::table('families') @@ -1407,7 +1408,7 @@ class AdminTreesController extends AbstractBaseController ->where('l_type', '=', 'SOUR') ->where('f_file', '=', $tree->id()) ->update([ - 'f_gedcom' => DB::raw("REPLACE(f_gedcom, ' SOUR @$old_xref@', ' SOUR @$new_xref@')"), + 'f_gedcom' => new Expression("REPLACE(f_gedcom, ' SOUR @$old_xref@', ' SOUR @$new_xref@')"), ]); DB::table('media') @@ -1420,7 +1421,7 @@ class AdminTreesController extends AbstractBaseController ->where('l_type', '=', 'SOUR') ->where('m_file', '=', $tree->id()) ->update([ - 'm_gedcom' => DB::raw("REPLACE(m_gedcom, ' SOUR @$old_xref@', ' SOUR @$new_xref@')"), + 'm_gedcom' => new Expression("REPLACE(m_gedcom, ' SOUR @$old_xref@', ' SOUR @$new_xref@')"), ]); DB::table('other') @@ -1433,7 +1434,7 @@ class AdminTreesController extends AbstractBaseController ->where('l_type', '=', 'SOUR') ->where('o_file', '=', $tree->id()) ->update([ - 'o_gedcom' => DB::raw("REPLACE(o_gedcom, ' SOUR @$old_xref@', ' SOUR @$new_xref@')"), + 'o_gedcom' => new Expression("REPLACE(o_gedcom, ' SOUR @$old_xref@', ' SOUR @$new_xref@')"), ]); break; case 'REPO': @@ -1443,7 +1444,7 @@ class AdminTreesController extends AbstractBaseController ->where('o_type', '=', 'REPO') ->update([ 'o_id' => $new_xref, - 'o_gedcom' => DB::raw("REPLACE(o_gedcom, '0 @$old_xref@ REPO', '0 @$new_xref@ REPO')"), + 'o_gedcom' => new Expression("REPLACE(o_gedcom, '0 @$old_xref@ REPO', '0 @$new_xref@ REPO')"), ]); DB::table('sources') @@ -1456,7 +1457,7 @@ class AdminTreesController extends AbstractBaseController ->where('l_type', '=', 'REPO') ->where('s_file', '=', $tree->id()) ->update([ - 's_gedcom' => DB::raw("REPLACE(s_gedcom, ' REPO @$old_xref@', ' REPO @$new_xref@')"), + 's_gedcom' => new Expression("REPLACE(s_gedcom, ' REPO @$old_xref@', ' REPO @$new_xref@')"), ]); break; @@ -1467,7 +1468,7 @@ class AdminTreesController extends AbstractBaseController ->where('o_type', '=', 'NOTE') ->update([ 'o_id' => $new_xref, - 'o_gedcom' => DB::raw("REPLACE(o_gedcom, '0 @$old_xref@ NOTE', '0 @$new_xref@ NOTE')"), + 'o_gedcom' => new Expression("REPLACE(o_gedcom, '0 @$old_xref@ NOTE', '0 @$new_xref@ NOTE')"), ]); DB::table('individuals') @@ -1480,7 +1481,7 @@ class AdminTreesController extends AbstractBaseController ->where('l_type', '=', 'NOTE') ->where('i_file', '=', $tree->id()) ->update([ - 'i_gedcom' => DB::raw("REPLACE(i_gedcom, ' NOTE @$old_xref@', ' NOTE @$new_xref@')"), + 'i_gedcom' => new Expression("REPLACE(i_gedcom, ' NOTE @$old_xref@', ' NOTE @$new_xref@')"), ]); DB::table('families') @@ -1493,7 +1494,7 @@ class AdminTreesController extends AbstractBaseController ->where('l_type', '=', 'NOTE') ->where('f_file', '=', $tree->id()) ->update([ - 'f_gedcom' => DB::raw("REPLACE(f_gedcom, ' NOTE @$old_xref@', ' NOTE @$new_xref@')"), + 'f_gedcom' => new Expression("REPLACE(f_gedcom, ' NOTE @$old_xref@', ' NOTE @$new_xref@')"), ]); DB::table('media') @@ -1506,7 +1507,7 @@ class AdminTreesController extends AbstractBaseController ->where('l_type', '=', 'NOTE') ->where('m_file', '=', $tree->id()) ->update([ - 'm_gedcom' => DB::raw("REPLACE(m_gedcom, ' NOTE @$old_xref@', ' NOTE @$new_xref@')"), + 'm_gedcom' => new Expression("REPLACE(m_gedcom, ' NOTE @$old_xref@', ' NOTE @$new_xref@')"), ]); DB::table('sources') @@ -1519,7 +1520,7 @@ class AdminTreesController extends AbstractBaseController ->where('l_type', '=', 'NOTE') ->where('s_file', '=', $tree->id()) ->update([ - 's_gedcom' => DB::raw("REPLACE(s_gedcom, ' NOTE @$old_xref@', ' NOTE @$new_xref@')"), + 's_gedcom' => new Expression("REPLACE(s_gedcom, ' NOTE @$old_xref@', ' NOTE @$new_xref@')"), ]); DB::table('other') @@ -1532,7 +1533,7 @@ class AdminTreesController extends AbstractBaseController ->where('l_type', '=', 'NOTE') ->where('o_file', '=', $tree->id()) ->update([ - 'o_gedcom' => DB::raw("REPLACE(o_gedcom, ' NOTE @$old_xref@', ' NOTE @$new_xref@')"), + 'o_gedcom' => new Expression("REPLACE(o_gedcom, ' NOTE @$old_xref@', ' NOTE @$new_xref@')"), ]); break; @@ -1542,7 +1543,7 @@ class AdminTreesController extends AbstractBaseController ->where('m_id', '=', $old_xref) ->update([ 'm_id' => $new_xref, - 'm_gedcom' => DB::raw("REPLACE(m_gedcom, '0 @$old_xref@ OBJE', '0 @$new_xref@ OBJE')"), + 'm_gedcom' => new Expression("REPLACE(m_gedcom, '0 @$old_xref@ OBJE', '0 @$new_xref@ OBJE')"), ]); DB::table('media_file') @@ -1562,7 +1563,7 @@ class AdminTreesController extends AbstractBaseController ->where('l_type', '=', 'OBJE') ->where('i_file', '=', $tree->id()) ->update([ - 'i_gedcom' => DB::raw("REPLACE(i_gedcom, ' OBJE @$old_xref@', ' OBJE @$new_xref@')"), + 'i_gedcom' => new Expression("REPLACE(i_gedcom, ' OBJE @$old_xref@', ' OBJE @$new_xref@')"), ]); DB::table('families') @@ -1575,7 +1576,7 @@ class AdminTreesController extends AbstractBaseController ->where('l_type', '=', 'OBJE') ->where('f_file', '=', $tree->id()) ->update([ - 'f_gedcom' => DB::raw("REPLACE(f_gedcom, ' OBJE @$old_xref@', ' OBJE @$new_xref@')"), + 'f_gedcom' => new Expression("REPLACE(f_gedcom, ' OBJE @$old_xref@', ' OBJE @$new_xref@')"), ]); DB::table('sources') @@ -1588,7 +1589,7 @@ class AdminTreesController extends AbstractBaseController ->where('l_type', '=', 'OBJE') ->where('s_file', '=', $tree->id()) ->update([ - 's_gedcom' => DB::raw("REPLACE(s_gedcom, ' OBJE @$old_xref@', ' OBJE @$new_xref@')"), + 's_gedcom' => new Expression("REPLACE(s_gedcom, ' OBJE @$old_xref@', ' OBJE @$new_xref@')"), ]); DB::table('other') @@ -1601,7 +1602,7 @@ class AdminTreesController extends AbstractBaseController ->where('l_type', '=', 'OBJE') ->where('o_file', '=', $tree->id()) ->update([ - 'o_gedcom' => DB::raw("REPLACE(o_gedcom, ' OBJE @$old_xref@', ' OBJE @$new_xref@')"), + 'o_gedcom' => new Expression("REPLACE(o_gedcom, ' OBJE @$old_xref@', ' OBJE @$new_xref@')"), ]); break; @@ -1612,7 +1613,7 @@ class AdminTreesController extends AbstractBaseController ->where('o_type', '=', $type) ->update([ 'o_id' => $new_xref, - 'o_gedcom' => DB::raw("REPLACE(o_gedcom, '0 @$old_xref@ $type', '0 @$new_xref@ $type')"), + 'o_gedcom' => new Expression("REPLACE(o_gedcom, '0 @$old_xref@ $type', '0 @$new_xref@ $type')"), ]); DB::table('individuals') @@ -1625,7 +1626,7 @@ class AdminTreesController extends AbstractBaseController ->where('l_type', '=', $type) ->where('i_file', '=', $tree->id()) ->update([ - 'i_gedcom' => DB::raw("REPLACE(i_gedcom, ' $type @$old_xref@', ' $type @$new_xref@')"), + 'i_gedcom' => new Expression("REPLACE(i_gedcom, ' $type @$old_xref@', ' $type @$new_xref@')"), ]); DB::table('families') @@ -1638,7 +1639,7 @@ class AdminTreesController extends AbstractBaseController ->where('l_type', '=', $type) ->where('f_file', '=', $tree->id()) ->update([ - 'f_gedcom' => DB::raw("REPLACE(f_gedcom, ' $type @$old_xref@', ' $type @$new_xref@')"), + 'f_gedcom' => new Expression("REPLACE(f_gedcom, ' $type @$old_xref@', ' $type @$new_xref@')"), ]); DB::table('media') @@ -1651,7 +1652,7 @@ class AdminTreesController extends AbstractBaseController ->where('l_type', '=', $type) ->where('m_file', '=', $tree->id()) ->update([ - 'm_gedcom' => DB::raw("REPLACE(m_gedcom, ' $type @$old_xref@', ' $type @$new_xref@')"), + 'm_gedcom' => new Expression("REPLACE(m_gedcom, ' $type @$old_xref@', ' $type @$new_xref@')"), ]); DB::table('sources') @@ -1664,7 +1665,7 @@ class AdminTreesController extends AbstractBaseController ->where('l_type', '=', $type) ->where('s_file', '=', $tree->id()) ->update([ - 's_gedcom' => DB::raw("REPLACE(s_gedcom, ' $type @$old_xref@', ' $type @$new_xref@')"), + 's_gedcom' => new Expression("REPLACE(s_gedcom, ' $type @$old_xref@', ' $type @$new_xref@')"), ]); DB::table('other') @@ -1677,7 +1678,7 @@ class AdminTreesController extends AbstractBaseController ->where('l_type', '=', $type) ->where('o_file', '=', $tree->id()) ->update([ - 'o_gedcom' => DB::raw("REPLACE(o_gedcom, ' $type @$old_xref@', ' $type @$new_xref@')"), + 'o_gedcom' => new Expression("REPLACE(o_gedcom, ' $type @$old_xref@', ' $type @$new_xref@')"), ]); break; } @@ -1980,7 +1981,7 @@ class AdminTreesController extends AbstractBaseController ->whereNotIn('o_type', ['HEAD', 'TRLR']) ->select(['o_id AS xref'])); - return DB::table(DB::raw('(' . $subquery1->toSql() . ') AS sub1')) + return DB::table(new Expression('(' . $subquery1->toSql() . ') AS sub1')) ->mergeBindings($subquery1) ->joinSub($subquery2, 'sub2', 'other_xref', '=', 'xref') ->count(); @@ -2000,8 +2001,8 @@ class AdminTreesController extends AbstractBaseController $sources = DB::table('sources') ->where('s_file', '=', $tree->id()) ->groupBy('s_name') - ->having(DB::raw('COUNT(s_id)'), '>', 1) - ->select([DB::raw('GROUP_CONCAT(s_id) AS xrefs')]) + ->having(new Expression('COUNT(s_id)'), '>', 1) + ->select([new Expression('GROUP_CONCAT(s_id) AS xrefs')]) ->pluck('xrefs') ->map(static function (string $xrefs) use ($tree): array { return array_map(static function (string $xref) use ($tree): Source { @@ -2025,8 +2026,8 @@ class AdminTreesController extends AbstractBaseController ->groupBy('d_fact') ->groupBy('n_type') ->groupBy('n_full') - ->having(DB::raw('COUNT(DISTINCT d_gid)'), '>', 1) - ->select([DB::raw('GROUP_CONCAT(d_gid) AS xrefs')]) + ->having(new Expression('COUNT(DISTINCT d_gid)'), '>', 1) + ->select([new Expression('GROUP_CONCAT(d_gid) AS xrefs')]) ->pluck('xrefs') ->map(static function (string $xrefs) use ($tree): array { return array_map(static function (string $xref) use ($tree): Individual { @@ -2037,10 +2038,10 @@ class AdminTreesController extends AbstractBaseController $families = DB::table('families') ->where('f_file', '=', $tree->id()) - ->groupBy(DB::raw('LEAST(f_husb, f_wife)')) - ->groupBy(DB::raw('GREATEST(f_husb, f_wife)')) - ->having(DB::raw('COUNT(f_id)'), '>', 1) - ->select([DB::raw('GROUP_CONCAT(f_id) AS xrefs')]) + ->groupBy(new Expression('LEAST(f_husb, f_wife)')) + ->groupBy(new Expression('GREATEST(f_husb, f_wife)')) + ->having(new Expression('COUNT(f_id)'), '>', 1) + ->select([new Expression('GROUP_CONCAT(f_id) AS xrefs')]) ->pluck('xrefs') ->map(static function (string $xrefs) use ($tree): array { return array_map(static function (string $xref) use ($tree): Family { @@ -2053,8 +2054,8 @@ class AdminTreesController extends AbstractBaseController ->where('m_file', '=', $tree->id()) ->where('descriptive_title', '<>', '') ->groupBy('descriptive_title') - ->having(DB::raw('COUNT(m_id)'), '>', 1) - ->select([DB::raw('GROUP_CONCAT(m_id) AS xrefs')]) + ->having(new Expression('COUNT(m_id)'), '>', 1) + ->select([new Expression('GROUP_CONCAT(m_id) AS xrefs')]) ->pluck('xrefs') ->map(static function (string $xrefs) use ($tree): array { return array_map(static function (string $xref) use ($tree): Media { @@ -2083,16 +2084,16 @@ class AdminTreesController extends AbstractBaseController { $subquery1 = DB::table('individuals') ->where('i_file', '=', $tree->id()) - ->select(['i_id AS xref', DB::raw("'INDI' AS type")]) + ->select(['i_id AS xref', new Expression("'INDI' AS type")]) ->union(DB::table('families') ->where('f_file', '=', $tree->id()) - ->select(['f_id AS xref', DB::raw("'FAM' AS type")])) + ->select(['f_id AS xref', new Expression("'FAM' AS type")])) ->union(DB::table('sources') ->where('s_file', '=', $tree->id()) - ->select(['s_id AS xref', DB::raw("'SOUR' AS type")])) + ->select(['s_id AS xref', new Expression("'SOUR' AS type")])) ->union(DB::table('media') ->where('m_file', '=', $tree->id()) - ->select(['m_id AS xref', DB::raw("'OBJE' AS type")])) + ->select(['m_id AS xref', new Expression("'OBJE' AS type")])) ->union(DB::table('other') ->where('o_file', '=', $tree->id()) ->whereNotIn('o_type', ['HEAD', 'TRLR']) @@ -2118,7 +2119,7 @@ class AdminTreesController extends AbstractBaseController ->whereNotIn('o_type', ['HEAD', 'TRLR']) ->select(['o_id AS xref'])); - return DB::table(DB::raw('(' . $subquery1->toSql() . ') AS sub1')) + return DB::table(new Expression('(' . $subquery1->toSql() . ') AS sub1')) ->mergeBindings($subquery1) ->joinSub($subquery2, 'sub2', 'other_xref', '=', 'xref') ->pluck('type', 'xref') diff --git a/app/Http/Controllers/GedcomFileController.php b/app/Http/Controllers/GedcomFileController.php index df6892fc56..0408875859 100644 --- a/app/Http/Controllers/GedcomFileController.php +++ b/app/Http/Controllers/GedcomFileController.php @@ -24,6 +24,7 @@ use Fisharebest\Webtrees\I18N; use Fisharebest\Webtrees\Services\TimeoutService; use Fisharebest\Webtrees\Tree; use Illuminate\Database\Capsule\Manager as DB; +use Illuminate\Database\Query\Expression; use Illuminate\Support\Str; use Psr\Http\Message\ResponseInterface; use Throwable; @@ -57,11 +58,11 @@ class GedcomFileController extends AbstractBaseController $import_offset = (int) DB::table('gedcom_chunk') ->where('gedcom_id', '=', $tree->id()) ->where('imported', '=', '1') - ->sum(DB::raw('LENGTH(chunk_data)')); + ->sum(new Expression('LENGTH(chunk_data)')); $import_total = (int) DB::table('gedcom_chunk') ->where('gedcom_id', '=', $tree->id()) - ->sum(DB::raw('LENGTH(chunk_data)')); + ->sum(new Expression('LENGTH(chunk_data)')); // Finished? if ($import_offset === $import_total) { @@ -115,7 +116,7 @@ class GedcomFileController extends AbstractBaseController case 'ASCII': DB::table('gedcom_chunk') ->where('gedcom_id', '=', $tree->id()) - ->update(['chunk_data' => DB::raw('CONVERT(CONVERT(chunk_data USING ascii) USING utf8)')]); + ->update(['chunk_data' => new Expression('CONVERT(CONVERT(chunk_data USING ascii) USING utf8)')]); break; case 'IBMPC': // IBMPC, IBM WINDOWS and MS-DOS could be anything. Mostly it means CP850. case 'IBM WINDOWS': @@ -125,7 +126,7 @@ class GedcomFileController extends AbstractBaseController // CP850 has extra letters with diacritics to replace box-drawing chars in CP437. DB::table('gedcom_chunk') ->where('gedcom_id', '=', $tree->id()) - ->update(['chunk_data' => DB::raw('CONVERT(CONVERT(chunk_data USING cp850) USING utf8)')]); + ->update(['chunk_data' => new Expression('CONVERT(CONVERT(chunk_data USING cp850) USING utf8)')]); break; case 'ANSI': // ANSI could be anything. Most applications seem to treat it as latin1. case 'WINDOWS': @@ -137,7 +138,7 @@ class GedcomFileController extends AbstractBaseController // Convert from ISO-8859-1 (western european) to UTF8. DB::table('gedcom_chunk') ->where('gedcom_id', '=', $tree->id()) - ->update(['chunk_data' => DB::raw('CONVERT(CONVERT(chunk_data USING latin1) USING utf8)')]); + ->update(['chunk_data' => new Expression('CONVERT(CONVERT(chunk_data USING latin1) USING utf8)')]); break; case 'CP1250': case 'ISO8859-2': @@ -147,13 +148,13 @@ class GedcomFileController extends AbstractBaseController // Convert from ISO-8859-2 (eastern european) to UTF8. DB::table('gedcom_chunk') ->where('gedcom_id', '=', $tree->id()) - ->update(['chunk_data' => DB::raw('CONVERT(CONVERT(chunk_data USING latin2) USING utf8)')]); + ->update(['chunk_data' => new Expression('CONVERT(CONVERT(chunk_data USING latin2) USING utf8)')]); break; case 'MACINTOSH': // Convert from MAC Roman to UTF8. DB::table('gedcom_chunk') ->where('gedcom_id', '=', $tree->id()) - ->update(['chunk_data' => DB::raw('CONVERT(CONVERT(chunk_data USING macroman) USING utf8)')]); + ->update(['chunk_data' => new Expression('CONVERT(CONVERT(chunk_data USING macroman) USING utf8)')]); break; case 'UTF8': case 'UTF-8': diff --git a/app/Http/Controllers/HomePageController.php b/app/Http/Controllers/HomePageController.php index 5107e96e19..3ab97b7dc2 100644 --- a/app/Http/Controllers/HomePageController.php +++ b/app/Http/Controllers/HomePageController.php @@ -39,6 +39,7 @@ use Fisharebest\Webtrees\Services\UserService; use Fisharebest\Webtrees\Tree; use Illuminate\Database\Capsule\Manager as DB; use Illuminate\Database\Query\Builder; +use Illuminate\Database\Query\Expression; use Illuminate\Support\Collection; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; @@ -285,7 +286,7 @@ class HomePageController extends AbstractBaseController ['gedcom_id', 'location', 'block_order', 'module_name'], static function (Builder $query) use ($tree): void { $query - ->select([DB::raw($tree->id()), 'location', 'block_order', 'module_name']) + ->select([new Expression($tree->id()), 'location', 'block_order', 'module_name']) ->from('block') ->where('gedcom_id', '=', -1); } @@ -455,7 +456,7 @@ class HomePageController extends AbstractBaseController ['user_id', 'location', 'block_order', 'module_name'], static function (Builder $query) use ($user): void { $query - ->select([DB::raw($user->id()), 'location', 'block_order', 'module_name']) + ->select([new Expression($user->id()), 'location', 'block_order', 'module_name']) ->from('block') ->where('user_id', '=', -1); } diff --git a/app/Http/Controllers/MediaFileController.php b/app/Http/Controllers/MediaFileController.php index 6dfc113557..d708c3190a 100644 --- a/app/Http/Controllers/MediaFileController.php +++ b/app/Http/Controllers/MediaFileController.php @@ -41,7 +41,6 @@ use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Throwable; use function addcslashes; -use function date_create; use function file_get_contents; use function response; use function strlen; diff --git a/app/Http/Middleware/RequestRouter.php b/app/Http/Middleware/RequestRouter.php index 1615138bb7..ba3e4dc16f 100644 --- a/app/Http/Middleware/RequestRouter.php +++ b/app/Http/Middleware/RequestRouter.php @@ -25,7 +25,6 @@ use Psr\Http\Server\MiddlewareInterface; use Psr\Http\Server\RequestHandlerInterface; use function app; use function explode; -use function preg_replace; /** * Take an HTTP request, and forward it to a webtrees RequestHandler. diff --git a/app/Module/BatchUpdateModule.php b/app/Module/BatchUpdateModule.php index 744570115c..c2bb0c110b 100644 --- a/app/Module/BatchUpdateModule.php +++ b/app/Module/BatchUpdateModule.php @@ -31,6 +31,7 @@ use Fisharebest\Webtrees\Repository; use Fisharebest\Webtrees\Source; use Fisharebest\Webtrees\Tree; use Illuminate\Database\Capsule\Manager as DB; +use Illuminate\Database\Query\Expression; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use stdClass; @@ -180,7 +181,7 @@ class BatchUpdateModule extends AbstractModule implements ModuleConfigInterface case 'INDI': $rows = DB::table('individuals') ->where('i_file', '=', $tree->id()) - ->select(['i_id AS xref', DB::raw("'INDI' AS type"), 'i_gedcom AS gedcom']) + ->select(['i_id AS xref', new Expression("'INDI' AS type"), 'i_gedcom AS gedcom']) ->get(); $tmp = array_merge($tmp, $rows->all()); @@ -189,7 +190,7 @@ class BatchUpdateModule extends AbstractModule implements ModuleConfigInterface case 'FAM': $rows = DB::table('families') ->where('f_file', '=', $tree->id()) - ->select(['f_id AS xref', DB::raw("'FAM' AS type"), 'f_gedcom AS gedcom']) + ->select(['f_id AS xref', new Expression("'FAM' AS type"), 'f_gedcom AS gedcom']) ->get(); $tmp = array_merge($tmp, $rows->all()); @@ -198,7 +199,7 @@ class BatchUpdateModule extends AbstractModule implements ModuleConfigInterface case 'SOUR': $rows = DB::table('sources') ->where('s_file', '=', $tree->id()) - ->select(['s_id AS xref', DB::raw("'SOUR' AS type"), 's_gedcom AS gedcom']) + ->select(['s_id AS xref', new Expression("'SOUR' AS type"), 's_gedcom AS gedcom']) ->get(); $tmp = array_merge($tmp, $rows->all()); @@ -207,7 +208,7 @@ class BatchUpdateModule extends AbstractModule implements ModuleConfigInterface case 'OBJE': $rows = DB::table('media') ->where('m_file', '=', $tree->id()) - ->select(['m_id AS xref', DB::raw("'OBJE' AS type"), 'm_gedcom AS gedcom']) + ->select(['m_id AS xref', new Expression("'OBJE' AS type"), 'm_gedcom AS gedcom']) ->get(); $tmp = array_merge($tmp, $rows->all()); diff --git a/app/Module/FamilyTreeStatisticsModule.php b/app/Module/FamilyTreeStatisticsModule.php index 994fb3fa42..57b580abbe 100644 --- a/app/Module/FamilyTreeStatisticsModule.php +++ b/app/Module/FamilyTreeStatisticsModule.php @@ -24,6 +24,7 @@ use Fisharebest\Webtrees\Services\ModuleService; use Fisharebest\Webtrees\Statistics; use Fisharebest\Webtrees\Tree; use Illuminate\Database\Capsule\Manager as DB; +use Illuminate\Database\Query\Expression; use Illuminate\Support\Str; use Psr\Http\Message\ServerRequestInterface; @@ -102,7 +103,7 @@ class FamilyTreeStatisticsModule extends AbstractModule implements ModuleBlockIn ->where('n_type', '<>', '_MARNM') ->whereNotIn('n_surn', ['@N.N.', '']) ->groupBy('n_surn') - ->orderByDesc(DB::raw('COUNT(n_surn)')) + ->orderByDesc(new Expression('COUNT(n_surn)')) ->take($number_of_surnames) ->pluck('n_surn'); @@ -111,9 +112,9 @@ class FamilyTreeStatisticsModule extends AbstractModule implements ModuleBlockIn foreach ($top_surnames as $top_surname) { $variants = DB::table('name') ->where('n_file', '=', $tree->id()) - ->where(DB::raw('n_surn /*! COLLATE utf8_bin */'), '=', $top_surname) + ->where(new Expression('n_surn /*! COLLATE utf8_bin */'), '=', $top_surname) ->groupBy('surname') - ->select([DB::raw('n_surname /*! COLLATE utf8_bin */ AS surname'), DB::raw('count(*) AS total')]) + ->select([new Expression('n_surname /*! COLLATE utf8_bin */ AS surname'), new Expression('count(*) AS total')]) ->pluck('total', 'surname') ->all(); diff --git a/app/Module/FrequentlyAskedQuestionsModule.php b/app/Module/FrequentlyAskedQuestionsModule.php index 3a602f9384..95c980234e 100644 --- a/app/Module/FrequentlyAskedQuestionsModule.php +++ b/app/Module/FrequentlyAskedQuestionsModule.php @@ -186,7 +186,7 @@ class FrequentlyAskedQuestionsModule extends AbstractModule implements ModuleCon ->from('block') ->where('module_name', '=', $this->name()) ->where('block_order', '>', $block_order) - ->select(DB::raw('MIN(block_order)')); + ->min('block_order'); }) ->select(['block_order', 'block_id']) ->first(); @@ -230,12 +230,12 @@ class FrequentlyAskedQuestionsModule extends AbstractModule implements ModuleCon $swap_block = DB::table('block') ->where('module_name', '=', $this->name()) - ->where('block_order', '=', static function (Builder $query) use ($block_order): void { + ->where('block_order', '=', function (Builder $query) use ($block_order): void { $query ->from('block') ->where('module_name', '=', $this->name()) ->where('block_order', '<', $block_order) - ->select(DB::raw('MAX(block_order)')); + ->max('block_order'); }) ->select(['block_order', 'block_id']) ->first(); diff --git a/app/Module/LoggedInUsersModule.php b/app/Module/LoggedInUsersModule.php index ca1e239aae..0e86e92b2d 100644 --- a/app/Module/LoggedInUsersModule.php +++ b/app/Module/LoggedInUsersModule.php @@ -21,7 +21,6 @@ use Fisharebest\Webtrees\I18N; use Fisharebest\Webtrees\Statistics; use Fisharebest\Webtrees\Tree; use Illuminate\Support\Str; -use Psr\Http\Message\ServerRequestInterface; /** * Class LoggedInUsersModule diff --git a/app/Module/LoginBlockModule.php b/app/Module/LoginBlockModule.php index 31756e02b6..98c6908535 100644 --- a/app/Module/LoginBlockModule.php +++ b/app/Module/LoginBlockModule.php @@ -22,7 +22,6 @@ use Fisharebest\Webtrees\I18N; use Fisharebest\Webtrees\Site; use Fisharebest\Webtrees\Tree; use Illuminate\Support\Str; -use Psr\Http\Message\ServerRequestInterface; /** * Class LoginBlockModule diff --git a/app/Module/SiteMapModule.php b/app/Module/SiteMapModule.php index 37e9d95964..2d796c62c4 100644 --- a/app/Module/SiteMapModule.php +++ b/app/Module/SiteMapModule.php @@ -30,6 +30,7 @@ use Fisharebest\Webtrees\Repository; use Fisharebest\Webtrees\Source; use Fisharebest\Webtrees\Tree; use Illuminate\Database\Capsule\Manager as DB; +use Illuminate\Database\Query\Expression; use Illuminate\Support\Collection; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; @@ -134,29 +135,29 @@ class SiteMapModule extends AbstractModule implements ModuleConfigInterface } else { $count_individuals = DB::table('individuals') ->groupBy('i_file') - ->select([DB::raw('COUNT(*) AS total'), 'i_file']) + ->select([new Expression('COUNT(*) AS total'), 'i_file']) ->pluck('total', 'i_file'); $count_media = DB::table('media') ->groupBy('m_file') - ->select([DB::raw('COUNT(*) AS total'), 'm_file']) + ->select([new Expression('COUNT(*) AS total'), 'm_file']) ->pluck('total', 'm_file'); $count_notes = DB::table('other') ->where('o_type', '=', 'NOTE') ->groupBy('o_file') - ->select([DB::raw('COUNT(*) AS total'), 'o_file']) + ->select([new Expression('COUNT(*) AS total'), 'o_file']) ->pluck('total', 'o_file'); $count_repositories = DB::table('other') ->where('o_type', '=', 'REPO') ->groupBy('o_file') - ->select([DB::raw('COUNT(*) AS total'), 'o_file']) + ->select([new Expression('COUNT(*) AS total'), 'o_file']) ->pluck('total', 'o_file'); $count_sources = DB::table('sources') ->groupBy('s_file') - ->select([DB::raw('COUNT(*) AS total'), 's_file']) + ->select([new Expression('COUNT(*) AS total'), 's_file']) ->pluck('total', 's_file'); $content = view('modules/sitemap/sitemap-index.xml', [ diff --git a/app/Module/ThemeSelectModule.php b/app/Module/ThemeSelectModule.php index 8d01247122..35a2af8c74 100644 --- a/app/Module/ThemeSelectModule.php +++ b/app/Module/ThemeSelectModule.php @@ -20,7 +20,6 @@ namespace Fisharebest\Webtrees\Module; use Fisharebest\Webtrees\I18N; use Fisharebest\Webtrees\Tree; use Illuminate\Support\Str; -use Psr\Http\Message\ServerRequestInterface; /** * Class ThemeSelectModule diff --git a/app/Module/TopSurnamesModule.php b/app/Module/TopSurnamesModule.php index 885a77bdc1..cd622520ef 100644 --- a/app/Module/TopSurnamesModule.php +++ b/app/Module/TopSurnamesModule.php @@ -23,6 +23,7 @@ use Fisharebest\Webtrees\I18N; use Fisharebest\Webtrees\Tree; use Fisharebest\Webtrees\Services\ModuleService; use Illuminate\Database\Capsule\Manager as DB; +use Illuminate\Database\Query\Expression; use Illuminate\Support\Str; use Psr\Http\Message\ServerRequestInterface; @@ -82,7 +83,7 @@ class TopSurnamesModule extends AbstractModule implements ModuleBlockInterface ->where('n_type', '<>', '_MARNM') ->whereNotIn('n_surn', ['@N.N.', '']) ->groupBy('n_surn') - ->orderByDesc(DB::raw('COUNT(n_surn)')) + ->orderByDesc(new Expression('COUNT(n_surn)')) ->take($num) ->pluck('n_surn'); @@ -91,9 +92,9 @@ class TopSurnamesModule extends AbstractModule implements ModuleBlockInterface foreach ($top_surnames as $top_surname) { $variants = DB::table('name') ->where('n_file', '=', $tree->id()) - ->where(DB::raw('n_surn /*! COLLATE utf8_bin */'), '=', $top_surname) + ->where(new Expression('n_surn /*! COLLATE utf8_bin */'), '=', $top_surname) ->groupBy('surname') - ->select([DB::raw('n_surname /*! COLLATE utf8_bin */ AS surname'), DB::raw('count(*) AS total')]) + ->select([new Expression('n_surname /*! COLLATE utf8_bin */ AS surname'), new Expression('count(*) AS total')]) ->pluck('total', 'surname') ->all(); diff --git a/app/Module/UserWelcomeModule.php b/app/Module/UserWelcomeModule.php index 88930b21ef..c8520b16f3 100644 --- a/app/Module/UserWelcomeModule.php +++ b/app/Module/UserWelcomeModule.php @@ -23,7 +23,6 @@ use Fisharebest\Webtrees\Individual; use Fisharebest\Webtrees\Services\ModuleService; use Fisharebest\Webtrees\Tree; use Illuminate\Support\Str; -use Psr\Http\Message\ServerRequestInterface; /** * Class UserWelcomeModule diff --git a/app/Module/WelcomeBlockModule.php b/app/Module/WelcomeBlockModule.php index 45436c3de6..1f22b6eddb 100644 --- a/app/Module/WelcomeBlockModule.php +++ b/app/Module/WelcomeBlockModule.php @@ -23,7 +23,6 @@ use Fisharebest\Webtrees\Services\ModuleService; use Fisharebest\Webtrees\Site; use Fisharebest\Webtrees\Tree; use Illuminate\Support\Str; -use Psr\Http\Message\ServerRequestInterface; /** * Class WelcomeBlockModule diff --git a/app/Place.php b/app/Place.php index 60e5f922b6..72f553005b 100644 --- a/app/Place.php +++ b/app/Place.php @@ -22,6 +22,7 @@ use Fisharebest\Webtrees\Module\ModuleListInterface; use Fisharebest\Webtrees\Module\PlaceHierarchyListModule; use Fisharebest\Webtrees\Services\ModuleService; use Illuminate\Database\Capsule\Manager as DB; +use Illuminate\Database\Query\Expression; use Illuminate\Support\Collection; /** @@ -146,7 +147,7 @@ class Place return DB::table('places') ->where('p_file', '=', $this->tree->id()) ->where('p_parent_id', '=', $this->id()) - ->orderBy(DB::raw('p_place /*! COLLATE ' . I18N::collation() . ' */')) + ->orderBy(new Expression('p_place /*! COLLATE ' . I18N::collation() . ' */')) ->pluck('p_place') ->map(function (string $place) use ($parent_text): Place { return new self($place . $parent_text, $this->tree); diff --git a/app/Report/ReportParserGenerate.php b/app/Report/ReportParserGenerate.php index ebf85de77d..4943ca5617 100644 --- a/app/Report/ReportParserGenerate.php +++ b/app/Report/ReportParserGenerate.php @@ -36,6 +36,7 @@ use Fisharebest\Webtrees\Place; use Fisharebest\Webtrees\Tree; use Illuminate\Database\Capsule\Manager as DB; use Illuminate\Database\Query\Builder; +use Illuminate\Database\Query\Expression; use Illuminate\Database\Query\JoinClause; use Illuminate\Support\Str; use stdClass; @@ -1863,7 +1864,7 @@ class ReportParserGenerate extends ReportParserBase case 'pending': $xrefs = DB::table('change') ->whereIn('change_id', function (Builder $query): void { - $query->select(DB::raw('MAX(change_id)')) + $query->select(new Expression('MAX(change_id)')) ->from('change') ->where('gedcom_id', '=', $this->tree->id()) ->where('status', '=', 'pending') diff --git a/app/Services/CalendarService.php b/app/Services/CalendarService.php index 150c54d722..74ab37fa69 100644 --- a/app/Services/CalendarService.php +++ b/app/Services/CalendarService.php @@ -33,6 +33,7 @@ use Fisharebest\Webtrees\Individual; use Fisharebest\Webtrees\Tree; use Illuminate\Database\Capsule\Manager as DB; use Illuminate\Database\Query\Builder; +use Illuminate\Database\Query\Expression; use Illuminate\Database\Query\JoinClause; use Illuminate\Support\Collection; use function preg_match_all; @@ -440,7 +441,7 @@ class CalendarService ->orWhere(static function (Builder $query): void { $query ->where('d_mon', '=', 6) - ->where(DB::raw('(7 * d_year + 1 % 19)'), '>=', 7); + ->where(new Expression('(7 * d_year + 1 % 19)'), '>=', 7); }); }); } diff --git a/app/Services/DatatablesService.php b/app/Services/DatatablesService.php index 7474682811..502dd43c58 100644 --- a/app/Services/DatatablesService.php +++ b/app/Services/DatatablesService.php @@ -18,8 +18,8 @@ declare(strict_types=1); namespace Fisharebest\Webtrees\Services; use Closure; -use Illuminate\Database\Capsule\Manager as DB; use Illuminate\Database\Query\Builder; +use Illuminate\Database\Query\Expression; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; @@ -67,12 +67,12 @@ class DatatablesService // Columns in datatables are numbered from zero. // Columns in MySQL are numbered starting with one. // If not specified, the Nth table column maps onto the Nth query column. - $sort_column = $sort_columns[$value['column']] ?? DB::raw(1 + $value['column']); + $sort_column = $sort_columns[$value['column']] ?? new Expression(1 + $value['column']); $query->orderBy($sort_column, $value['dir']); } } else { - $query->orderBy(DB::raw(1)); + $query->orderBy(new Expression(1)); } // Paginating diff --git a/app/Services/IndividualListService.php b/app/Services/IndividualListService.php index e7621e52b4..c22e742bf7 100644 --- a/app/Services/IndividualListService.php +++ b/app/Services/IndividualListService.php @@ -120,10 +120,10 @@ class IndividualListService } $rows = $query2 - ->select([DB::raw('SUBSTR(n_surn, 1, 1) AS initial'), DB::raw('COUNT(*) AS count')]) + ->select([new Expression('SUBSTR(n_surn, 1, 1) AS initial'), new Expression('COUNT(*) AS count')]) ->groupBy('initial') - ->orderBy(DB::raw("CASE initial WHEN '' THEN 1 ELSE 0 END")) - ->orderBy(DB::raw("CASE initial WHEN '@' THEN 1 ELSE 0 END")) + ->orderBy(new Expression("CASE initial WHEN '' THEN 1 ELSE 0 END")) + ->orderBy(new Expression("CASE initial WHEN '@' THEN 1 ELSE 0 END")) ->orderBy('initial') ->pluck('count', 'initial'); @@ -189,10 +189,10 @@ class IndividualListService } $rows = $query - ->select([DB::raw('UPPER(SUBSTR(n_givn, 1, 1)) AS initial'), DB::raw('COUNT(*) AS count')]) + ->select([new Expression('UPPER(SUBSTR(n_givn, 1, 1)) AS initial'), new Expression('COUNT(*) AS count')]) ->groupBy('initial') - ->orderBy(DB::raw("CASE initial WHEN '' THEN 1 ELSE 0 END")) - ->orderBy(DB::raw("CASE initial WHEN '@' THEN 1 ELSE 0 END")) + ->orderBy(new Expression("CASE initial WHEN '' THEN 1 ELSE 0 END")) + ->orderBy(new Expression("CASE initial WHEN '@' THEN 1 ELSE 0 END")) ->orderBy('initial') ->pluck('count', 'initial'); @@ -220,9 +220,9 @@ class IndividualListService $query = DB::table('name') ->where('n_file', '=', $this->tree->id()) ->select([ - DB::raw('UPPER(n_surn /*! COLLATE ' . I18N::collation() . ' */) AS n_surn'), - DB::raw('n_surname /*! COLLATE utf8_bin */ AS n_surname'), - DB::raw('COUNT(*) AS total'), + new Expression('UPPER(n_surn /*! COLLATE ' . I18N::collation() . ' */) AS n_surn'), + new Expression('n_surname /*! COLLATE utf8_bin */ AS n_surname'), + new Expression('COUNT(*) AS total'), ]) ->groupBy(['n_surn']) ->groupBy(['n_surname']) @@ -303,9 +303,9 @@ class IndividualListService } $query - ->orderBy(DB::raw("CASE n_surn WHEN '@N.N.' THEN 1 ELSE 0 END")) + ->orderBy(new Expression("CASE n_surn WHEN '@N.N.' THEN 1 ELSE 0 END")) ->orderBy($n_surn) - ->orderBy(DB::raw("CASE n_givn WHEN '@N.N.' THEN 1 ELSE 0 END")) + ->orderBy(new Expression("CASE n_givn WHEN '@N.N.' THEN 1 ELSE 0 END")) ->orderBy($n_givn); $list = []; @@ -364,7 +364,7 @@ class IndividualListService */ private function fieldWithCollation(string $field, string $collation): Expression { - return DB::raw($field . ' /*! COLLATE ' . $collation . ' */'); + return new Expression($field . ' /*! COLLATE ' . $collation . ' */'); } /** diff --git a/app/Services/ModuleService.php b/app/Services/ModuleService.php index b809f3f8a4..aca66edc1d 100644 --- a/app/Services/ModuleService.php +++ b/app/Services/ModuleService.php @@ -150,7 +150,6 @@ use Fisharebest\Webtrees\Module\MissingFactsReportModule; use Fisharebest\Webtrees\Module\ModuleAnalyticsInterface; use Fisharebest\Webtrees\Module\ModuleBlockInterface; use Fisharebest\Webtrees\Module\ModuleChartInterface; -use Fisharebest\Webtrees\Module\ModuleConfigInterface; use Fisharebest\Webtrees\Module\ModuleCustomInterface; use Fisharebest\Webtrees\Module\ModuleFooterInterface; use Fisharebest\Webtrees\Module\ModuleHistoricEventsInterface; diff --git a/app/Services/SearchService.php b/app/Services/SearchService.php index 3592658443..d284532990 100644 --- a/app/Services/SearchService.php +++ b/app/Services/SearchService.php @@ -93,7 +93,7 @@ class SearchService }); $prefix = DB::connection()->getTablePrefix(); - $field = DB::raw('COALESCE(' . $prefix . "husb_name.n_full, '') || COALESCE(" . $prefix . "wife_name.n_full, '')"); + $field = new Expression('COALESCE(' . $prefix . "husb_name.n_full, '') || COALESCE(" . $prefix . "wife_name.n_full, '')"); $this->whereTrees($query, 'f_file', $trees); $this->whereSearch($query, $field, $search); @@ -879,7 +879,7 @@ class SearchService } foreach ($search_terms as $search_term) { - $query->whereContains(DB::raw($field), $search_term); + $query->whereContains(new Expression($field), $search_term); } } diff --git a/app/Statistics/Google/ChartAge.php b/app/Statistics/Google/ChartAge.php index 41398c919d..3976af7ad9 100644 --- a/app/Statistics/Google/ChartAge.php +++ b/app/Statistics/Google/ChartAge.php @@ -21,6 +21,7 @@ use Fisharebest\Webtrees\I18N; use Fisharebest\Webtrees\Statistics\Service\CenturyService; use Fisharebest\Webtrees\Tree; use Illuminate\Database\Capsule\Manager as DB; +use Illuminate\Database\Query\Expression; use Illuminate\Database\Query\JoinClause; use stdClass; @@ -61,8 +62,8 @@ class ChartAge return DB::table('individuals') ->select([ - DB::raw('ROUND(AVG(' . $prefix . 'death.d_julianday2 - ' . $prefix . 'birth.d_julianday1) / 365.25, 1) AS age'), - DB::raw('ROUND((' . $prefix . 'death.d_year + 49) / 100) AS century'), + new Expression('ROUND(AVG(' . $prefix . 'death.d_julianday2 - ' . $prefix . 'birth.d_julianday1) / 365.25, 1) AS age'), + new Expression('ROUND((' . $prefix . 'death.d_year + 49) / 100) AS century'), 'i_sex AS sex' ]) ->join('dates AS birth', static function (JoinClause $join): void { diff --git a/app/Statistics/Google/ChartDistribution.php b/app/Statistics/Google/ChartDistribution.php index 3e828c4329..15d4fdf7c8 100644 --- a/app/Statistics/Google/ChartDistribution.php +++ b/app/Statistics/Google/ChartDistribution.php @@ -25,6 +25,7 @@ use Fisharebest\Webtrees\Statistics\Repository\PlaceRepository; use Fisharebest\Webtrees\Statistics\Service\CountryService; use Fisharebest\Webtrees\Tree; use Illuminate\Database\Capsule\Manager as DB; +use Illuminate\Database\Query\Expression; use Illuminate\Database\Query\JoinClause; use stdClass; @@ -232,7 +233,7 @@ class ChartDistribution ->on('n_file', '=', 'i_file'); }) ->where('n_file', '=', $this->tree->id()) - ->where(DB::raw('n_surn /*! COLLATE ' . I18N::collation() . ' */'), '=', $surname); + ->where(new Expression('n_surn /*! COLLATE ' . I18N::collation() . ' */'), '=', $surname); return $query->get()->all(); } diff --git a/app/Statistics/Google/ChartMarriageAge.php b/app/Statistics/Google/ChartMarriageAge.php index fec34e65c0..69d6fc67a1 100644 --- a/app/Statistics/Google/ChartMarriageAge.php +++ b/app/Statistics/Google/ChartMarriageAge.php @@ -21,6 +21,7 @@ use Fisharebest\Webtrees\I18N; use Fisharebest\Webtrees\Statistics\Service\CenturyService; use Fisharebest\Webtrees\Tree; use Illuminate\Database\Capsule\Manager as DB; +use Illuminate\Database\Query\Expression; use Illuminate\Database\Query\JoinClause; use stdClass; @@ -61,9 +62,9 @@ class ChartMarriageAge $male = DB::table('dates as married') ->select([ - DB::raw('ROUND(AVG(' . $prefix . 'married.d_julianday2 - ' . $prefix . 'birth.d_julianday1 - 182.5) / 365.25, 1) AS age'), - DB::raw('ROUND((' . $prefix . 'married.d_year + 49) / 100) AS century'), - DB::raw("'M' as sex") + new Expression('ROUND(AVG(' . $prefix . 'married.d_julianday2 - ' . $prefix . 'birth.d_julianday1 - 182.5) / 365.25, 1) AS age'), + new Expression('ROUND((' . $prefix . 'married.d_year + 49) / 100) AS century'), + new Expression("'M' as sex") ]) ->join('families as fam', static function (JoinClause $join): void { $join->on('fam.f_id', '=', 'married.d_gid') @@ -84,9 +85,9 @@ class ChartMarriageAge $female = DB::table('dates as married') ->select([ - DB::raw('ROUND(AVG(' . $prefix . 'married.d_julianday2 - ' . $prefix . 'birth.d_julianday1 - 182.5) / 365.25, 1) AS age'), - DB::raw('ROUND((' . $prefix . 'married.d_year + 49) / 100) AS century'), - DB::raw("'F' as sex") + new Expression('ROUND(AVG(' . $prefix . 'married.d_julianday2 - ' . $prefix . 'birth.d_julianday1 - 182.5) / 365.25, 1) AS age'), + new Expression('ROUND((' . $prefix . 'married.d_year + 49) / 100) AS century'), + new Expression("'F' as sex") ]) ->join('families as fam', static function (JoinClause $join): void { $join->on('fam.f_id', '=', 'married.d_gid') diff --git a/app/Statistics/Repository/FamilyRepository.php b/app/Statistics/Repository/FamilyRepository.php index 590acf0ba5..437ba68b4d 100644 --- a/app/Statistics/Repository/FamilyRepository.php +++ b/app/Statistics/Repository/FamilyRepository.php @@ -32,6 +32,7 @@ use Fisharebest\Webtrees\Statistics\Google\ChartNoChildrenFamilies; use Fisharebest\Webtrees\Tree; use Illuminate\Database\Capsule\Manager as DB; use Illuminate\Database\Query\Builder; +use Illuminate\Database\Query\Expression; use Illuminate\Database\Query\JoinClause; use function in_array; use stdClass; @@ -152,7 +153,7 @@ class FamilyRepository }) ->where('f_file', '=', $this->tree->id()) ->groupBy(['f_id', 'f_file']) - ->orderBy(DB::raw('COUNT(*)'), 'DESC') + ->orderBy(new Expression('COUNT(*)'), 'DESC') ->select('families.*') ->limit($total) ->get() @@ -317,7 +318,7 @@ class FamilyRepository ->where('link1.l_type', '=', 'CHIL') ->where('link1.l_file', '=', $this->tree->id()) ->distinct() - ->select(['link1.l_from AS family', 'link1.l_to AS ch1', 'link2.l_to AS ch2', DB::raw($prefix . 'child2.d_julianday2 - ' . $prefix . 'child1.d_julianday1 AS age')]) + ->select(['link1.l_from AS family', 'link1.l_to AS ch1', 'link2.l_to AS ch2', new Expression($prefix . 'child2.d_julianday2 - ' . $prefix . 'child1.d_julianday1 AS age')]) ->orderBy('age', 'DESC') ->take($total) ->get() @@ -545,7 +546,7 @@ class FamilyRepository $query = DB::table('families') ->where('f_file', '=', $this->tree->id()) ->groupBy('f_numchil') - ->select(['f_numchil', DB::raw('COUNT(*) AS total')]); + ->select(['f_numchil', new Expression('COUNT(*) AS total')]); if ($year1 >= 0 && $year2 >= 0) { $query @@ -696,7 +697,7 @@ class FamilyRepository }) ->where('l_file', '=', $this->tree->id()) ->where('l_type', '=', 'CHIL') - ->select(['l_from AS family_id', DB::raw('MIN(d_julianday1) AS min_birth_jd')]) + ->select(['l_from AS family_id', new Expression('MIN(d_julianday1) AS min_birth_jd')]) ->groupBy('family_id'); $query = DB::table('link') @@ -712,7 +713,7 @@ class FamilyRepository }) ->where('link.l_file', '=', $this->tree->id()) ->where('link.l_type', '=', 'CHIL') - ->select(['d_month', DB::raw('COUNT(*) AS total')]) + ->select(['d_month', new Expression('COUNT(*) AS total')]) ->groupBy(['d_month']); if ($year1 >= 0 && $year2 >= 0) { @@ -738,7 +739,7 @@ class FamilyRepository ->on('i_file', '=', 'l_file') ->on('i_id', '=', 'l_to'); }) - ->select(['d_month', 'i_sex', DB::raw('COUNT(*) AS total')]) + ->select(['d_month', 'i_sex', new Expression('COUNT(*) AS total')]) ->groupBy(['d_month', 'i_sex']); } @@ -821,7 +822,7 @@ class FamilyRepository ->where('childfamily.l_file', '=', $this->tree->id()) ->where('parentfamily.l_type', '=', $sex_field) ->where('childbirth.d_julianday2', '>', 'birth.d_julianday1') - ->select(['parentfamily.l_to AS id', DB::raw($prefix . 'childbirth.d_julianday2 - ' . $prefix . 'birth.d_julianday1 AS age')]) + ->select(['parentfamily.l_to AS id', new Expression($prefix . 'childbirth.d_julianday2 - ' . $prefix . 'birth.d_julianday1 AS age')]) ->take(1) ->orderBy('age', $age_dir) ->get() @@ -1020,7 +1021,7 @@ class FamilyRepository }) ->whereColumn('married.d_julianday1', '<', 'husbdeath.d_julianday2') ->groupBy('f_id') - ->select(['f_id AS family', DB::raw('MIN(' . $prefix . 'husbdeath.d_julianday2 - ' . $prefix . 'married.d_julianday1) AS age')]) + ->select(['f_id AS family', new Expression('MIN(' . $prefix . 'husbdeath.d_julianday2 - ' . $prefix . 'married.d_julianday1) AS age')]) ->get() ->all(); @@ -1041,7 +1042,7 @@ class FamilyRepository }) ->whereColumn('married.d_julianday1', '<', 'wifedeath.d_julianday2') ->groupBy('f_id') - ->select(['f_id AS family', DB::raw('MIN(' . $prefix . 'wifedeath.d_julianday2 - ' . $prefix . 'married.d_julianday1) AS age')]) + ->select(['f_id AS family', new Expression('MIN(' . $prefix . 'wifedeath.d_julianday2 - ' . $prefix . 'married.d_julianday1) AS age')]) ->get() ->all(); @@ -1062,7 +1063,7 @@ class FamilyRepository }) ->whereColumn('married.d_julianday1', '<', 'divorced.d_julianday2') ->groupBy('f_id') - ->select(['f_id AS family', DB::raw('MIN(' . $prefix . 'divorced.d_julianday2 - ' . $prefix . 'married.d_julianday1) AS age')]) + ->select(['f_id AS family', new Expression('MIN(' . $prefix . 'divorced.d_julianday2 - ' . $prefix . 'married.d_julianday1) AS age')]) ->get() ->all(); @@ -1273,11 +1274,11 @@ class FamilyRepository if ($age_dir === 'DESC') { $query ->whereColumn('wife.d_julianday1', '>=', 'husb.d_julianday1') - ->orderBy(DB::raw('MIN(' . $prefix . 'wife.d_julianday1) - MIN(' . $prefix . 'husb.d_julianday1)'), 'DESC'); + ->orderBy(new Expression('MIN(' . $prefix . 'wife.d_julianday1) - MIN(' . $prefix . 'husb.d_julianday1)'), 'DESC'); } else { $query ->whereColumn('husb.d_julianday1', '>=', 'wife.d_julianday1') - ->orderBy(DB::raw('MIN(' . $prefix . 'husb.d_julianday1) - MIN(' . $prefix . 'wife.d_julianday1)'), 'DESC'); + ->orderBy(new Expression('MIN(' . $prefix . 'husb.d_julianday1) - MIN(' . $prefix . 'wife.d_julianday1)'), 'DESC'); } return $query @@ -1400,7 +1401,7 @@ class FamilyRepository ->where('married.d_fact', '=', 'MARR') ->whereIn('married.d_type', ['@#DGREGORIAN@', '@#DJULIAN@']) ->whereColumn('married.d_julianday1', '>', 'birth.d_julianday1') - ->select(['f_id', 'birth.d_gid', DB::raw($prefix . 'married.d_julianday2 - ' . $prefix . 'birth.d_julianday1 AS age')]); + ->select(['f_id', 'birth.d_gid', new Expression($prefix . 'married.d_julianday2 - ' . $prefix . 'birth.d_julianday1 AS age')]); if ($year1 >= 0 && $year2 >= 0) { $query->whereBetween('married.d_year', [$year1, $year2]); @@ -1473,8 +1474,8 @@ class FamilyRepository }) ->where('f_file', '=', $this->tree->id()) ->where('married.d_julianday2', '>', 'birth.d_julianday1') - ->orderBy(DB::raw($prefix . 'married.d_julianday2 - ' . $prefix . 'birth.d_julianday1'), $age_dir) - ->select(['f_id AS famid', $sex_field, DB::raw($prefix . 'married.d_julianday2 - ' . $prefix . 'birth.d_julianday1 AS age'), 'i_id']) + ->orderBy(new Expression($prefix . 'married.d_julianday2 - ' . $prefix . 'birth.d_julianday1'), $age_dir) + ->select(['f_id AS famid', $sex_field, new Expression($prefix . 'married.d_julianday2 - ' . $prefix . 'birth.d_julianday1 AS age'), 'i_id']) ->take(1) ->get() ->first(); @@ -1656,7 +1657,7 @@ class FamilyRepository $query = DB::table('dates') ->where('d_file', '=', $this->tree->id()) ->where('d_fact', '=', 'MARR') - ->select(['d_month', DB::raw('COUNT(*) AS total')]) + ->select(['d_month', new Expression('COUNT(*) AS total')]) ->groupBy('d_month'); if ($year1 >= 0 && $year2 >= 0) { diff --git a/app/Statistics/Repository/IndividualRepository.php b/app/Statistics/Repository/IndividualRepository.php index cdf18d957e..c19517a58e 100644 --- a/app/Statistics/Repository/IndividualRepository.php +++ b/app/Statistics/Repository/IndividualRepository.php @@ -44,6 +44,7 @@ use Fisharebest\Webtrees\Statistics\Repository\Interfaces\IndividualRepositoryIn use Fisharebest\Webtrees\Tree; use Illuminate\Database\Capsule\Manager as DB; use Illuminate\Database\Query\Builder; +use Illuminate\Database\Query\Expression; use Illuminate\Database\Query\JoinClause; use stdClass; @@ -89,7 +90,7 @@ class IndividualRepository implements IndividualRepositoryInterface ->where('n_file', '=', $this->tree->id()) ->where('n_type', '<>', '_MARNM') ->where('n_givn', '<>', '@P.N.') - ->where(DB::raw('LENGTH(n_givn)'), '>', 1); + ->where(new Expression('LENGTH(n_givn)'), '>', 1); switch ($sex) { case 'M': @@ -106,7 +107,7 @@ class IndividualRepository implements IndividualRepositoryInterface $rows = $query ->groupBy(['n_givn']) - ->select(['n_givn', DB::raw('COUNT(distinct n_id) AS count')]) + ->select(['n_givn', new Expression('COUNT(distinct n_id) AS count')]) ->pluck('count', 'n_givn'); $nameList = []; @@ -501,8 +502,8 @@ class IndividualRepository implements IndividualRepositoryInterface foreach ($top_surnames as $top_surname) { $variants = DB::table('name') ->where('n_file', '=', $this->tree->id()) - ->where(DB::raw('n_surn /* COLLATE ' . I18N::collation() . ' */'), '=', $top_surname) - ->select('n_surn', DB::raw('COUNT(*) AS count')) + ->where(new Expression('n_surn /* COLLATE ' . I18N::collation() . ' */'), '=', $top_surname) + ->select('n_surn', new Expression('COUNT(*) AS count')) ->groupBy('n_surn') ->get() ->pluck('count', 'n_surn') @@ -655,7 +656,7 @@ class IndividualRepository implements IndividualRepositoryInterface public function statsBirthQuery(int $year1 = -1, int $year2 = -1): Builder { $query = DB::table('dates') - ->select(['d_month', DB::raw('COUNT(*) AS total')]) + ->select(['d_month', new Expression('COUNT(*) AS total')]) ->where('d_file', '=', $this->tree->id()) ->where('d_fact', '=', 'BIRT') ->whereIn('d_type', ['@#DGREGORIAN@', '@#DJULIAN@']) @@ -679,7 +680,7 @@ class IndividualRepository implements IndividualRepositoryInterface public function statsBirthBySexQuery(int $year1 = -1, int $year2 = -1): Builder { return $this->statsBirthQuery($year1, $year2) - ->select(['d_month', 'i_sex', DB::raw('COUNT(*) AS total')]) + ->select(['d_month', 'i_sex', new Expression('COUNT(*) AS total')]) ->join('individuals', static function (JoinClause $join): void { $join ->on('i_id', '=', 'd_gid') @@ -713,7 +714,7 @@ class IndividualRepository implements IndividualRepositoryInterface public function statsDeathQuery(int $year1 = -1, int $year2 = -1): Builder { $query = DB::table('dates') - ->select(['d_month', DB::raw('COUNT(*) AS total')]) + ->select(['d_month', new Expression('COUNT(*) AS total')]) ->where('d_file', '=', $this->tree->id()) ->where('d_fact', '=', 'DEAT') ->whereIn('d_type', ['@#DGREGORIAN@', '@#DJULIAN@']) @@ -737,7 +738,7 @@ class IndividualRepository implements IndividualRepositoryInterface public function statsDeathBySexQuery(int $year1 = -1, int $year2 = -1): Builder { return $this->statsDeathQuery($year1, $year2) - ->select(['d_month', 'i_sex', DB::raw('COUNT(*) AS total')]) + ->select(['d_month', 'i_sex', new Expression('COUNT(*) AS total')]) ->join('individuals', static function (JoinClause $join): void { $join ->on('i_id', '=', 'd_gid') @@ -789,7 +790,7 @@ class IndividualRepository implements IndividualRepositoryInterface } return $query - ->select(DB::raw($prefix . 'death.d_julianday2 - ' . $prefix . 'birth.d_julianday1 AS days')) + ->select(new Expression($prefix . 'death.d_julianday2 - ' . $prefix . 'birth.d_julianday1 AS days')) ->orderBy('days', 'desc') ->get() ->all(); @@ -819,7 +820,7 @@ class IndividualRepository implements IndividualRepositoryInterface $row = $this->birthAndDeathQuery($sex) ->orderBy('days', 'desc') - ->select(['individuals.*', DB::raw($prefix . 'death.d_julianday2 - ' . $prefix . 'birth.d_julianday1 AS days')]) + ->select(['individuals.*', new Expression($prefix . 'death.d_julianday2 - ' . $prefix . 'birth.d_julianday1 AS days')]) ->first(); if ($row === null) { @@ -971,7 +972,7 @@ class IndividualRepository implements IndividualRepositoryInterface $rows = $this->birthAndDeathQuery($sex) ->groupBy(['i_id', 'i_file']) ->orderBy('days', 'desc') - ->select(['individuals.*', DB::raw('MAX(' . $prefix . 'death.d_julianday2 - ' . $prefix . 'birth.d_julianday1) AS days')]) + ->select(['individuals.*', new Expression('MAX(' . $prefix . 'death.d_julianday2 - ' . $prefix . 'birth.d_julianday1) AS days')]) ->take($total) ->get(); @@ -1116,7 +1117,7 @@ class IndividualRepository implements IndividualRepositoryInterface return $query ->groupBy(['i_id', 'i_file']) - ->orderBy(DB::raw('MIN(d_julianday1)')) + ->orderBy(new Expression('MIN(d_julianday1)')) ->select('individuals.*') ->take($total) ->get() @@ -1264,7 +1265,7 @@ class IndividualRepository implements IndividualRepositoryInterface $prefix = DB::connection()->getTablePrefix(); $days = (int) $this->birthAndDeathQuery($sex) - ->select(DB::raw('AVG(' . $prefix . 'death.d_julianday2 - ' . $prefix . 'birth.d_julianday1) AS days')) + ->select(new Expression('AVG(' . $prefix . 'death.d_julianday2 - ' . $prefix . 'birth.d_julianday1) AS days')) ->value('days'); if ($show_years) { diff --git a/app/Tree.php b/app/Tree.php index 08e8b033d7..c40bb1b553 100644 --- a/app/Tree.php +++ b/app/Tree.php @@ -22,6 +22,7 @@ use Fisharebest\Webtrees\Functions\FunctionsExport; use Fisharebest\Webtrees\Functions\FunctionsImport; use Illuminate\Database\Capsule\Manager as DB; use Illuminate\Database\Query\Builder; +use Illuminate\Database\Query\Expression; use Illuminate\Database\Query\JoinClause; use Illuminate\Support\Collection; use Illuminate\Support\Str; @@ -255,7 +256,7 @@ class Tree ['gedcom_id', 'setting_name', 'setting_value'], static function (Builder $query) use ($tree_id): void { $query - ->select([DB::raw($tree_id), 'setting_name', 'setting_value']) + ->select([new Expression($tree_id), 'setting_name', 'setting_value']) ->from('gedcom_setting') ->where('gedcom_id', '=', -1); } @@ -265,7 +266,7 @@ class Tree ['gedcom_id', 'tag_type', 'resn'], static function (Builder $query) use ($tree_id): void { $query - ->select([DB::raw($tree_id), 'tag_type', 'resn']) + ->select([new Expression($tree_id), 'tag_type', 'resn']) ->from('default_resn') ->where('gedcom_id', '=', -1); } @@ -598,24 +599,24 @@ class Tree $union_families = DB::table('families') ->where('f_file', '=', $this->id) - ->select(['f_gedcom AS gedcom', 'f_id AS xref', DB::raw('LENGTH(f_id) AS len'), DB::raw('2 AS n')]); + ->select(['f_gedcom AS gedcom', 'f_id AS xref', new Expression('LENGTH(f_id) AS len'), new Expression('2 AS n')]); $union_sources = DB::table('sources') ->where('s_file', '=', $this->id) - ->select(['s_gedcom AS gedcom', 's_id AS xref', DB::raw('LENGTH(s_id) AS len'), DB::raw('3 AS n')]); + ->select(['s_gedcom AS gedcom', 's_id AS xref', new Expression('LENGTH(s_id) AS len'), new Expression('3 AS n')]); $union_other = DB::table('other') ->where('o_file', '=', $this->id) ->whereNotIn('o_type', ['HEAD', 'TRLR']) - ->select(['o_gedcom AS gedcom', 'o_id AS xref', DB::raw('LENGTH(o_id) AS len'), DB::raw('4 AS n')]); + ->select(['o_gedcom AS gedcom', 'o_id AS xref', new Expression('LENGTH(o_id) AS len'), new Expression('4 AS n')]); $union_media = DB::table('media') ->where('m_file', '=', $this->id) - ->select(['m_gedcom AS gedcom', 'm_id AS xref', DB::raw('LENGTH(m_id) AS len'), DB::raw('5 AS n')]); + ->select(['m_gedcom AS gedcom', 'm_id AS xref', new Expression('LENGTH(m_id) AS len'), new Expression('5 AS n')]); DB::table('individuals') ->where('i_file', '=', $this->id) - ->select(['i_gedcom AS gedcom', 'i_id AS xref', DB::raw('LENGTH(i_id) AS len'), DB::raw('1 AS n')]) + ->select(['i_gedcom AS gedcom', 'i_id AS xref', new Expression('LENGTH(i_id) AS len'), new Expression('1 AS n')]) ->union($union_families) ->union($union_sources) ->union($union_other) diff --git a/resources/views/calendar-page.phtml b/resources/views/calendar-page.phtml index 583d7cd698..202a56d8be 100644 --- a/resources/views/calendar-page.phtml +++ b/resources/views/calendar-page.phtml @@ -1,7 +1,8 @@ -<?php use Fisharebest\Webtrees\Auth; ?> -<?php use Fisharebest\Webtrees\Date; ?> -<?php use Fisharebest\Webtrees\Functions\FunctionsPrint; ?> -<?php use Fisharebest\Webtrees\I18N; ?> +<?php +use Fisharebest\Webtrees\Auth; +use Fisharebest\Webtrees\Date; +use Fisharebest\Webtrees\I18N; +?> <h2 class="wt-page-title"> <?= $title ?> diff --git a/resources/views/lists/media-table.phtml b/resources/views/lists/media-table.phtml index f8deb96f73..c8da947254 100644 --- a/resources/views/lists/media-table.phtml +++ b/resources/views/lists/media-table.phtml @@ -1,6 +1,9 @@ -<?php use Fisharebest\Webtrees\I18N; ?> -<?php use Illuminate\Database\Query\JoinClause; ?> -<?php use Illuminate\Database\Capsule\Manager as DB; ?> +<?php +use Fisharebest\Webtrees\I18N; +use Illuminate\Database\Capsule\Manager as DB; +use Illuminate\Database\Query\Expression; +use Illuminate\Database\Query\JoinClause; +?> <?php // Count the number of linked records. These numbers include private records. @@ -14,7 +17,7 @@ $count_individuals = DB::table('individuals') ->where('l_type', '=', 'NOTE') ->where('l_file', '=', $tree->id()) ->groupBy('l_to') - ->select(['l_to', DB::raw('COUNT(*) AS total')]) + ->select(['l_to', new Expression('COUNT(*) AS total')]) ->pluck('total', 'l_to') ->all(); @@ -26,7 +29,7 @@ $count_families = DB::table('families') ->where('l_type', '=', 'NOTE') ->where('l_file', '=', $tree->id()) ->groupBy('l_to') - ->select(['l_to', DB::raw('COUNT(*) AS total')]) + ->select(['l_to', new Expression('COUNT(*) AS total')]) ->pluck('total', 'l_to') ->all(); @@ -38,7 +41,7 @@ $count_sources = DB::table('sources') ->where('l_type', '=', 'NOTE') ->where('l_file', '=', $tree->id()) ->groupBy('l_to') - ->select(['l_to', DB::raw('COUNT(*) AS total')]) + ->select(['l_to', new Expression('COUNT(*) AS total')]) ->pluck('total', 'l_to') ->all(); ?> diff --git a/resources/views/lists/notes-table.phtml b/resources/views/lists/notes-table.phtml index 3e70c7552a..a042f1434f 100644 --- a/resources/views/lists/notes-table.phtml +++ b/resources/views/lists/notes-table.phtml @@ -1,6 +1,9 @@ -<?php use Fisharebest\Webtrees\I18N; ?> -<?php use Illuminate\Database\Query\JoinClause; ?> -<?php use Illuminate\Database\Capsule\Manager as DB; ?> +<?php +use Fisharebest\Webtrees\I18N; +use Illuminate\Database\Capsule\Manager as DB; +use Illuminate\Database\Query\Expression; +use Illuminate\Database\Query\JoinClause; +?> <?php // Count the number of linked records. These numbers include private records. @@ -14,7 +17,7 @@ $count_individuals = DB::table('individuals') ->where('l_type', '=', 'NOTE') ->where('l_file', '=', $tree->id()) ->groupBy('l_to') - ->select(['l_to', DB::raw('COUNT(*) AS total')]) + ->select(['l_to', new Expression('COUNT(*) AS total')]) ->pluck('total', 'l_to') ->all(); @@ -26,7 +29,7 @@ $count_families = DB::table('families') ->where('l_type', '=', 'NOTE') ->where('l_file', '=', $tree->id()) ->groupBy('l_to') - ->select(['l_to', DB::raw('COUNT(*) AS total')]) + ->select(['l_to', new Expression('COUNT(*) AS total')]) ->pluck('total', 'l_to') ->all(); @@ -38,7 +41,7 @@ $count_media = DB::table('media') ->where('l_type', '=', 'NOTE') ->where('l_file', '=', $tree->id()) ->groupBy('l_to') - ->select(['l_to', DB::raw('COUNT(*) AS total')]) + ->select(['l_to', new Expression('COUNT(*) AS total')]) ->pluck('total', 'l_to') ->all(); @@ -50,7 +53,7 @@ $count_sources = DB::table('sources') ->where('l_type', '=', 'NOTE') ->where('l_file', '=', $tree->id()) ->groupBy('l_to') - ->select(['l_to', DB::raw('COUNT(*) AS total')]) + ->select(['l_to', new Expression('COUNT(*) AS total')]) ->pluck('total', 'l_to') ->all(); ?> diff --git a/resources/views/lists/repositories-table.phtml b/resources/views/lists/repositories-table.phtml index c3e3c1e032..a2f0702548 100644 --- a/resources/views/lists/repositories-table.phtml +++ b/resources/views/lists/repositories-table.phtml @@ -1,6 +1,9 @@ -<?php use Fisharebest\Webtrees\I18N; ?> -<?php use Illuminate\Database\Query\JoinClause; ?> -<?php use Illuminate\Database\Capsule\Manager as DB; ?> +<?php +use Fisharebest\Webtrees\I18N; +use Illuminate\Database\Capsule\Manager as DB; +use Illuminate\Database\Query\Expression; +use Illuminate\Database\Query\JoinClause; +?> <?php // Count the number of linked records. These numbers include private records. @@ -14,7 +17,7 @@ $count_sources = DB::table('sources') ->where('l_type', '=', 'REPO') ->where('l_file', '=', $tree->id()) ->groupBy('l_to') - ->select(['l_to', DB::raw('COUNT(*) AS total')]) + ->select(['l_to', new Expression('COUNT(*) AS total')]) ->pluck('total', 'l_to') ->all(); ?> diff --git a/resources/views/lists/sources-table.phtml b/resources/views/lists/sources-table.phtml index 56e76382f7..488aed2c07 100644 --- a/resources/views/lists/sources-table.phtml +++ b/resources/views/lists/sources-table.phtml @@ -1,6 +1,9 @@ -<?php use Fisharebest\Webtrees\I18N; ?> -<?php use Illuminate\Database\Query\JoinClause; ?> -<?php use Illuminate\Database\Capsule\Manager as DB; ?> +<?php +use Fisharebest\Webtrees\I18N; +use Illuminate\Database\Capsule\Manager as DB; +use Illuminate\Database\Query\Expression; +use Illuminate\Database\Query\JoinClause; +?> <?php // Count the number of linked records. These numbers include private records. @@ -14,7 +17,7 @@ $count_individuals = DB::table('individuals') ->where('l_type', '=', 'SOUR') ->where('l_file', '=', $tree->id()) ->groupBy('l_to') - ->select(['l_to', DB::raw('COUNT(*) AS total')]) + ->select(['l_to', new Expression('COUNT(*) AS total')]) ->pluck('total', 'l_to') ->all(); @@ -26,7 +29,7 @@ $count_families = DB::table('families') ->where('l_type', '=', 'SOUR') ->where('l_file', '=', $tree->id()) ->groupBy('l_to') - ->select(['l_to', DB::raw('COUNT(*) AS total')]) + ->select(['l_to', new Expression('COUNT(*) AS total')]) ->pluck('total', 'l_to') ->all(); @@ -38,7 +41,7 @@ $count_media = DB::table('media') ->where('l_type', '=', 'SOUR') ->where('l_file', '=', $tree->id()) ->groupBy('l_to') - ->select(['l_to', DB::raw('COUNT(*) AS total')]) + ->select(['l_to', new Expression('COUNT(*) AS total')]) ->pluck('total', 'l_to') ->all(); @@ -51,7 +54,7 @@ $count_notes = DB::table('other') ->where('l_type', '=', 'SOUR') ->where('l_file', '=', $tree->id()) ->groupBy('l_to') - ->select(['l_to', DB::raw('COUNT(*) AS total')]) + ->select(['l_to', new Expression('COUNT(*) AS total')]) ->pluck('total', 'l_to') ->all(); ?> diff --git a/tests/TestCase.php b/tests/TestCase.php index c20868d2b1..c4cebb9458 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -27,7 +27,6 @@ use Fisharebest\Webtrees\Module\WebtreesTheme; use Fisharebest\Webtrees\Services\MigrationService; use Fisharebest\Webtrees\Services\TimeoutService; use Fisharebest\Webtrees\Services\UserService; -use GuzzleHttp\Psr7\ServerRequest; use Illuminate\Cache\ArrayStore; use Illuminate\Cache\Repository; use Illuminate\Database\Capsule\Manager as DB; diff --git a/tests/app/Services/HtmlServiceTest.php b/tests/app/Services/HtmlServiceTest.php index 6baa4e5ed0..335b5604f0 100644 --- a/tests/app/Services/HtmlServiceTest.php +++ b/tests/app/Services/HtmlServiceTest.php @@ -17,7 +17,6 @@ declare(strict_types=1); namespace Fisharebest\Webtrees\Services; -use Fisharebest\Webtrees\MockGlobalFunctions; use Fisharebest\Webtrees\TestCase; /** |
