Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EZP-30681: Fixed double slash in path_identification_string after moveSubtree #2671

Merged
merged 2 commits into from
Aug 26, 2019

Conversation

SerheyDolgushev
Copy link
Contributor

@SerheyDolgushev SerheyDolgushev commented Jun 19, 2019

Question Answer
JIRA issue EZP-30681
Bug/Improvement yes
New feature no
Target version master
BC breaks no
Tests pass yes
Doc needed no

Use case:

  1. Under "Home" location (Add missing read only properties to role structs #2) create two folders: "Parent" and "Move me".
  2. Move "Move me" folder to "Parent".
  3. Check ezcontentobject_tree.path_identification_string for moved node.

Expected result: node_2/parent/move_me
Actual result: node_2/parent//move_me

TODO:

  • Implement feature / fix a bug.
  • Implement tests.
  • Fix new code according to Coding Standards ($ composer fix-cs).
  • Ask for Code Review.

@SerheyDolgushev
Copy link
Contributor Author

Please note, existing install might require to run SQL to replace // => / in ezcontentobject_tree.path_identification_string

@SerheyDolgushev SerheyDolgushev changed the title 30681: Fixing double slash in path_identification_string after locati… 30681: Fixing double slash in path_identification_string after move Jun 19, 2019
Copy link
Member

@alongosz alongosz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately tests are failing there, so while this fixes some issue in some specific place/for some specific use case, it breaks other parts of the system.

If clean data is incorrect, it should also be a part of the fix.

We cannot accept it in the current form.

@alongosz alongosz changed the title 30681: Fixing double slash in path_identification_string after move EZP-30681: Fixing double slash in path_identification_string after move Jun 28, 2019
@SerheyDolgushev
Copy link
Contributor Author

@alongosz, please have a look

Copy link
Member

@alongosz alongosz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The path_identification_string is deprecated and will be dropped in the future, so I would recommend to stop relying on it in favor of Location::$pathString property.

Issues to resolve:

  1. This bug exists in 6.7 so the fix need to be targeted to that branch.
  2. The issue for me still exists despite the fix.
  3. Test case is still missing. Property is not available on API level, so the test is a bit ugly.
    Please add it to eZ/Publish/API/Repository/Tests/LocationServiceTest.php. Please Note that the test case was done on 7.5 branch, so doing it on 6.7 might require some changes.
    /**
     * Test that Legacy ezcontentobject_tree.path_identification_string field is correctly updated
     * after moving subtree.
     *
     * @covers \eZ\Publish\API\Repository\LocationService::moveSubtree
     *
     * @throws \ErrorException
     * @throws \eZ\Publish\API\Repository\Exceptions\ForbiddenException
     * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException
     */
    public function testMoveSubtreeUpdatesPathIdentificationString()
    {
        $repository = $this->getRepository();
        $locationService = $repository->getLocationService();

        $topNode = $this->createFolder(['eng-US' => 'top_node'], 2);

        $newParentLocation = $locationService->loadLocation(
            $this
                ->createFolder(['eng-US' => 'Parent'], $topNode->contentInfo->mainLocationId)
                ->contentInfo
                ->mainLocationId
        );
        $location = $locationService->loadLocation(
            $this
                ->createFolder(['eng-US' => 'Move Me'], $topNode->contentInfo->mainLocationId)
                ->contentInfo
                ->mainLocationId
        );

        $locationService->moveSubtree($location, $newParentLocation);

        // path location string is not present on API level, so we need to query database
        $connection = $this->getRawDatabaseConnection();
        $query = $connection->createQueryBuilder();
        $query
            ->select('path_identification_string')
            ->from('ezcontentobject_tree')
            ->where('node_id = :nodeId')
            ->setParameter('nodeId', $location->id);

        self::assertEquals(
            'top_node/parent/move_me',
            $query->execute()->fetchColumn()
        );
    }

@SerheyDolgushev SerheyDolgushev changed the base branch from master to 6.7 August 22, 2019 07:31
@SerheyDolgushev
Copy link
Contributor Author

SerheyDolgushev commented Aug 22, 2019

@alongosz

  1. Rebase is done.
  2. The issue is fixed. Please note testMoveHiddenSourceChildUpdate had en edge case: moving location with root path_identification_string. So current fix handles cases like that one.
  3. The test is added.

Please review.

@alongosz alongosz changed the title EZP-30681: Fixing double slash in path_identification_string after move EZP-30681: Fixed double slash in path_identification_string after moveSubtree Aug 22, 2019
@barbaragr barbaragr self-assigned this Aug 23, 2019
@alongosz
Copy link
Member

alongosz commented Aug 26, 2019

@SerheyDolgushev in the future please fetch latest upstream changes before doing rebase. You've rebased against 6.7 from September 2018, which gave our QA a headache 😜

This time I fixed that for you and force-pushed :) // cc @barbaragr

@lserwatka lserwatka merged commit 5d29045 into ezsystems:6.7 Aug 26, 2019
@lserwatka
Copy link
Member

You can merge it up

@alongosz
Copy link
Member

Done

@SerheyDolgushev
Copy link
Contributor Author

@alongosz should a new item be added to PR todo list? Something like "Check that you are using the latest source branch"?

@alongosz
Copy link
Member

@alongosz should a new item be added to PR todo list? Something like "Check that you are using the latest source branch"?

Maybe, but I wonder if this would be understood out of context. Moreover some people (not gonna point fingers ;p) tend to check boxes regardless of if they did the thing, so I started to find this pointless :P
At some point I planned to revise PR template anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

6 participants