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

Support reporting changes in root namespace. #25

Closed
Miro-Collas opened this issue Sep 7, 2023 · 4 comments · Fixed by #30
Closed

Support reporting changes in root namespace. #25

Miro-Collas opened this issue Sep 7, 2023 · 4 comments · Fixed by #30

Comments

@Miro-Collas
Copy link

Currently the code works very well except when changes are made to pages in the root namespace. Say you have a page :test. The function isValidNamespace is receiving 'test' in the $namespace function argument, rather than ':' or an empty string.

isValidNamespace seems to be called from processEvent(PageSaveEvent $event) in action.php, so it looks like the namespace set in the $event argument is incorrect for pages in the root.

NOTE: I am not a PHP programmer, let alone knowledgeable in Dokuwiki coding. I'm just digging, trying to get this to do what I need it to do. I'll keep digging...

@Miro-Collas Miro-Collas changed the title Support reporting changes inn root namespace. Support reporting changes in root namespace. Sep 7, 2023
@Miro-Collas
Copy link
Author

Miro-Collas commented Sep 7, 2023

In PageSaveEvent.php, this function:

    public function getNamespace(): string
    {
        return explode(':', $this->id, 2)[0];
    }

doesn't handle the case where the page is in the root namespace. It returns the page name instead.

I replaced it as follows:

    public function getNamespace(): string
    {
        $pos = strpos($this->id, ':');
        if($pos === false)
        {
            return ('');
        }

        return explode(':', $this->id, 2)[0];
    }

Config.php then needs isValidNamespace() to be changed this way:

    public function isValidNamespace(string $namespace): bool
    {
        if (!$this->namespaces) {
            return true;
        }

        $namespaces = explode(',', $this->namespaces);
        // Handle root namespace
        if ($namespace === '') {
            return in_array(':', $namespaces, true);
        }
        return in_array($namespace, $namespaces, true);
    }
}

Now, I need to figure out how to create a fork of this repo, so as to submit a PR, since I have an existing fork of the discordnotifier plugin and git isn't allowing me to fork this. Grrr....
Meantime, the above is documentation of what I did.

@Miro-Collas
Copy link
Author

Miro-Collas commented Sep 7, 2023

@glensc PR #26 submitted for your review.

@glensc
Copy link
Owner

glensc commented Jan 11, 2024

#26 is closed with no explanation?

@Miro-Collas
Copy link
Author

#26 is closed with no explanation?

See #30

@glensc glensc closed this as completed in #30 Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants