Overview
Comment:Fix: limitation du nombre d'itérations pour les cas où la page parent indique la page enfant comme parent!
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | stable
Files: files | file ages | folders
SHA1: 99c27ea18e0fb20cdd7c31b20cbd460c6cb764fd
User & Date: bohwaz on 2017-03-30 12:52:15
Other Links: manifest | tags
References
2020-12-08
23:25 Wiki page "Changelog/0.9" artifact: b9c916b4d1 user: bohwaz
Context
2017-04-10
00:40
Correction [a42abfebcb] Tri sur ID membre ne fonctionne pas check-in: 456b9f8b2d user: bohwaz tags: trunk, stable
2017-03-30
12:52
Fix: limitation du nombre d'itérations pour les cas où la page parent indique la page enfant comme parent! check-in: 99c27ea18e user: bohwaz tags: trunk, stable
2017-03-12
21:14
Correction bug où certains ID membres ne sont pas vus comme integer quand on a joué avec les numéros de membres check-in: 8d89f787d5 user: bohwaz tags: trunk, stable
Changes

Modified src/include/lib/Garradin/Wiki.php from [f4f8b19ea5] to [004bc8f304].

459
460
461
462
463
464
465

466
467
468
469
470
471
472
473
474
475
476





477
478
479
480
481
482
483
    public function listBackBreadCrumbs($id)
    {
        if ($id == 0)
            return [];

        $db = DB::getInstance();
        $flat = [];


        while ($id > 0)
        {
            $res = $db->simpleQuerySingle('SELECT parent, titre, uri
                FROM wiki_pages WHERE id = ? LIMIT 1;', true, (int)$id);

            $flat[] = [
                'id'        =>  $id,
                'titre'     =>  $res['titre'],
                'uri'       =>  $res['uri'],
            ];






            $id = (int)$res['parent'];
        }

        return array_reverse($flat);
    }








>

|









>
>
>
>
>







459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
    public function listBackBreadCrumbs($id)
    {
        if ($id == 0)
            return [];

        $db = DB::getInstance();
        $flat = [];
        $max = 0;

        while ($id > 0 && $max++ < 10)
        {
            $res = $db->simpleQuerySingle('SELECT parent, titre, uri
                FROM wiki_pages WHERE id = ? LIMIT 1;', true, (int)$id);

            $flat[] = [
                'id'        =>  $id,
                'titre'     =>  $res['titre'],
                'uri'       =>  $res['uri'],
            ];

            if ($id == $res['parent'])
            {
                throw new Exception('Parent! ' . $id . '/' . $res['parent']);
            }

            $id = (int)$res['parent'];
        }

        return array_reverse($flat);
    }

491
492
493
494
495
496
497


498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
                'titre' => 'Racine',
                'children' => $db->simpleStatementFetchAssocKey('SELECT id, parent, titre FROM wiki_pages
                    WHERE parent = ? ORDER BY transliterate_to_ascii(titre) COLLATE NOCASE;',
                    SQLITE3_ASSOC, 0)
            ]
        ];



        do
        {
            $parent = $db->simpleQuerySingle('SELECT parent FROM wiki_pages WHERE id = ? LIMIT 1;', false, (int)$id);

            $flat[$id] = [
                'id'        =>  $id,
                'parent'    =>  $id ? (int)$parent : null,
                'titre'     =>  $id ? (string)$db->simpleQuerySingle('SELECT titre FROM wiki_pages WHERE id = ? LIMIT 1;', false, (int)$id) : 'Racine',
                'children'  =>  $db->simpleStatementFetchAssocKey('SELECT id, parent, titre FROM wiki_pages
                    WHERE parent = ? ORDER BY transliterate_to_ascii(titre) COLLATE NOCASE;',
                    SQLITE3_ASSOC, (int)$id)
            ];

            $id = (int)$parent;
        }
        while ($id != 0);

        $tree = [];
        foreach ($flat as $id=>&$node)
        {
            if (is_null($node['parent']))
            {
                $tree[$id] = &$node;







>
>















|







497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
                'titre' => 'Racine',
                'children' => $db->simpleStatementFetchAssocKey('SELECT id, parent, titre FROM wiki_pages
                    WHERE parent = ? ORDER BY transliterate_to_ascii(titre) COLLATE NOCASE;',
                    SQLITE3_ASSOC, 0)
            ]
        ];

        $max = 0;

        do
        {
            $parent = $db->simpleQuerySingle('SELECT parent FROM wiki_pages WHERE id = ? LIMIT 1;', false, (int)$id);

            $flat[$id] = [
                'id'        =>  $id,
                'parent'    =>  $id ? (int)$parent : null,
                'titre'     =>  $id ? (string)$db->simpleQuerySingle('SELECT titre FROM wiki_pages WHERE id = ? LIMIT 1;', false, (int)$id) : 'Racine',
                'children'  =>  $db->simpleStatementFetchAssocKey('SELECT id, parent, titre FROM wiki_pages
                    WHERE parent = ? ORDER BY transliterate_to_ascii(titre) COLLATE NOCASE;',
                    SQLITE3_ASSOC, (int)$id)
            ];

            $id = (int)$parent;
        }
        while ($id != 0 && $max++ < 20);

        $tree = [];
        foreach ($flat as $id=>&$node)
        {
            if (is_null($node['parent']))
            {
                $tree[$id] = &$node;

Modified src/www/admin/wiki/index.php from [8a0b8d439a] to [eb50176436].

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
    $tpl->assign('can_edit', $wiki->canWritePage(Wiki::ECRITURE_NORMAL));
    $tpl->assign('can_read', true);
}
else
{
    $tpl->assign('can_read', $wiki->canReadPage($page['droit_lecture']));
    $tpl->assign('can_edit', $wiki->canWritePage($page['droit_ecriture']));
    $tpl->assign('children', $wiki->getList($page['uri'] == $config->get('accueil_wiki') ? 0 : $page['id'], true));
    $tpl->assign('breadcrumbs', $wiki->listBackBreadCrumbs($page['id']));
    $tpl->assign('auteur', $membres->getNom($page['contenu']['id_auteur']));

    $images = Fichiers::listLinkedFiles(Fichiers::LIEN_WIKI, $page['id'], true);

    if ($images && !$page['contenu']['chiffrement'])
    {







|







20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
    $tpl->assign('can_edit', $wiki->canWritePage(Wiki::ECRITURE_NORMAL));
    $tpl->assign('can_read', true);
}
else
{
    $tpl->assign('can_read', $wiki->canReadPage($page['droit_lecture']));
    $tpl->assign('can_edit', $wiki->canWritePage($page['droit_ecriture']));
    $tpl->assign('children', $wiki->getList($page_uri == '' ? 0 : $page['id'], true));
    $tpl->assign('breadcrumbs', $wiki->listBackBreadCrumbs($page['id']));
    $tpl->assign('auteur', $membres->getNom($page['contenu']['id_auteur']));

    $images = Fichiers::listLinkedFiles(Fichiers::LIEN_WIKI, $page['id'], true);

    if ($images && !$page['contenu']['chiffrement'])
    {