mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-28 17:02:04 +03:00
Made page-save HTML formatting much more efficient
Replaced the existing xpath-heavy system with a more manual traversal approach. Fixes following slow areas of old system: - Old system would repeat ID-setting action for elements (Headers could be processed up to three times). - Old system had a few very open xpath queries for headers. - Old system would update links on every ID change, which triggers it's own xpath query for links, leading to exponential scaling issues. New system only does one xpath query for links when changes are needed. Added test to cover. For #3932
This commit is contained in:
@ -732,4 +732,23 @@ class PageContentTest extends TestCase
|
||||
|
||||
$this->assertStringContainsString('<p id="bkmrk-%C2%A0"> </p>', $page->refresh()->html);
|
||||
}
|
||||
|
||||
public function test_page_save_with_many_headers_and_links_is_reasonable()
|
||||
{
|
||||
$page = $this->entities->page();
|
||||
|
||||
$content = '';
|
||||
for ($i = 0; $i < 500; $i++) {
|
||||
$content .= "<table><tbody><tr><td><h5 id='header-{$i}'>Simple Test</h5><a href='#header-{$i}'></a></td></tr></tbody></table>";
|
||||
}
|
||||
|
||||
$time = time();
|
||||
$this->asEditor()->put($page->getUrl(), [
|
||||
'name' => $page->name,
|
||||
'html' => $content,
|
||||
])->assertRedirect();
|
||||
|
||||
$timeElapsed = time() - $time;
|
||||
$this->assertLessThan(3, $timeElapsed);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user