mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-25 19:38:53 +00:00
Compare commits
4 commits
fd65f7e1b4
...
0b1311572d
Author | SHA1 | Date | |
---|---|---|---|
|
0b1311572d | ||
|
d3bb7e5bd3 | ||
|
b9df5bbbf0 | ||
|
50cf4892ea |
4 changed files with 53 additions and 66 deletions
|
@ -33,7 +33,6 @@
|
|||
"ext-sodium": "*",
|
||||
"bantu/ini-get-wrapper": "~1.0",
|
||||
"carlos-mg89/oauth": "^0.8.15",
|
||||
"chita/topological_sort": "^3.0",
|
||||
"composer/composer": "^2.0",
|
||||
"composer/installers": "^1.9",
|
||||
"composer/package-versions-deprecated": "^1.11",
|
||||
|
|
43
phpBB/composer.lock
generated
43
phpBB/composer.lock
generated
|
@ -171,49 +171,6 @@
|
|||
},
|
||||
"time": "2025-02-08T12:14:07+00:00"
|
||||
},
|
||||
{
|
||||
"name": "chita/topological_sort",
|
||||
"version": "v3.0.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/CHItA/TopologicalSort.git",
|
||||
"reference": "9e0401c712d0c7cf012f264cc105669844d2479e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/CHItA/TopologicalSort/zipball/9e0401c712d0c7cf012f264cc105669844d2479e",
|
||||
"reference": "9e0401c712d0c7cf012f264cc105669844d2479e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^7.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"CHItA\\TopologicalSort\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Máté Bartus",
|
||||
"email": "mate.bartus@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "Topological sort function",
|
||||
"support": {
|
||||
"issues": "https://github.com/CHItA/TopologicalSort/issues",
|
||||
"source": "https://github.com/CHItA/TopologicalSort/tree/v3.0.1"
|
||||
},
|
||||
"time": "2021-01-04T21:31:59+00:00"
|
||||
},
|
||||
{
|
||||
"name": "composer/ca-bundle",
|
||||
"version": "1.5.6",
|
||||
|
|
|
@ -441,12 +441,15 @@ class content_visibility
|
|||
{
|
||||
$post_ids[] = (int) $row['post_id'];
|
||||
|
||||
if ($row['post_visibility'] != $visibility)
|
||||
if ($row['post_visibility'] != $visibility )
|
||||
{
|
||||
if ($row['post_postcount'] && !isset($poster_postcounts[(int) $row['poster_id']]))
|
||||
{
|
||||
$poster_postcounts[(int) $row['poster_id']] = 1;
|
||||
if($row['post_visibility'] != 0 || $visibility != ITEM_DELETED ){
|
||||
$poster_postcounts[(int) $row['poster_id']] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
else if ($row['post_postcount'])
|
||||
{
|
||||
$poster_postcounts[(int) $row['poster_id']]++;
|
||||
|
|
|
@ -14,21 +14,17 @@
|
|||
namespace phpbb\db\migration;
|
||||
|
||||
use Closure;
|
||||
use LogicException;
|
||||
use phpbb\config\config;
|
||||
use phpbb\db\driver\driver_interface;
|
||||
use phpbb\db\migrator;
|
||||
use phpbb\db\tools\tools_interface;
|
||||
use UnexpectedValueException;
|
||||
use CHItA\TopologicalSort\TopologicalSort;
|
||||
|
||||
/**
|
||||
* The schema generator generates the schema based on the existing migrations
|
||||
*/
|
||||
class schema_generator
|
||||
{
|
||||
use TopologicalSort;
|
||||
|
||||
/** @var config */
|
||||
protected $config;
|
||||
|
||||
|
@ -103,24 +99,56 @@ class schema_generator
|
|||
return $this->tables;
|
||||
}
|
||||
|
||||
$migrations = $this->class_names;
|
||||
$filter = function($class_name) {
|
||||
return !migrator::is_migration($class_name);
|
||||
};
|
||||
|
||||
$edges = function($class_name) {
|
||||
return $class_name::depends_on();
|
||||
};
|
||||
|
||||
$apply_for_each = function($class_name) {
|
||||
$this->apply_migration_to_schema($class_name);
|
||||
};
|
||||
|
||||
try
|
||||
$dependency_counts = [];
|
||||
$dependencies = [];
|
||||
$applicable_migrations = [];
|
||||
$migration_count = 0;
|
||||
foreach ($this->class_names as $class_name)
|
||||
{
|
||||
$this->topologicalSort($migrations, $edges, true, $apply_for_each, $filter);
|
||||
if (!migrator::is_migration($class_name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$migration_count++;
|
||||
$migration_dependencies = $class_name::depends_on();
|
||||
if (empty($migration_dependencies))
|
||||
{
|
||||
$applicable_migrations[] = $class_name;
|
||||
continue;
|
||||
}
|
||||
|
||||
$dependency_counts[$class_name] = count($migration_dependencies);
|
||||
foreach ($migration_dependencies as $migration_dependency)
|
||||
{
|
||||
$dependencies[$migration_dependency][] = $class_name;
|
||||
}
|
||||
}
|
||||
catch (LogicException $e)
|
||||
|
||||
$applied_migrations = 0;
|
||||
while (!empty($applicable_migrations))
|
||||
{
|
||||
$migration = array_pop($applicable_migrations);
|
||||
$this->apply_migration_to_schema($migration);
|
||||
++$applied_migrations;
|
||||
|
||||
if (!array_key_exists($migration, $dependencies))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$dependents = $dependencies[$migration];
|
||||
foreach ($dependents as $dependent)
|
||||
{
|
||||
$dependency_counts[$dependent]--;
|
||||
if ($dependency_counts[$dependent] === 0)
|
||||
{
|
||||
$applicable_migrations[] = $dependent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($migration_count !== $applied_migrations)
|
||||
{
|
||||
throw new UnexpectedValueException(
|
||||
"Migrations either have circular dependencies or unsatisfiable dependencies."
|
||||
|
|
Loading…
Add table
Reference in a new issue