Skip to content

E_WARNING: Trying to access array offset on value of type null #28

@Miro-Collas

Description

@Miro-Collas

PHP8.1
Release 2023-04-04a "Jack Jackrum"

2023-09-01 22:49:10E_WARNING: Trying to access array offset on value of type null/home/fswiki/public_html/lib/plugins/discordnotifier/helper.php(37)
    #0 /home/fswiki/public_html/lib/plugins/discordnotifier/helper.php(37): dokuwiki\ErrorHandler::errorHandler(2, 'Trying to acces...', '/home/fswiki/pu...', 37)
    #1 /home/fswiki/public_html/lib/plugins/discordnotifier/action.php(31): helper_plugin_discordnotifier->valid_namespace()
    #2 /home/fswiki/public_html/inc/Extension/EventHandler.php(80): action_plugin_discordnotifier->_handle(Object(dokuwiki\Extension\Event), NULL)
    #3 /home/fswiki/public_html/inc/Extension/Event.php(96): dokuwiki\Extension\EventHandler->process_event(Object(dokuwiki\Extension\Event), 'AFTER')
    #4 /home/fswiki/public_html/inc/File/PageFile.php(194): dokuwiki\Extension\Event->advise_after()
    #5 /home/fswiki/public_html/inc/common.php(1289): dokuwiki\File\PageFile->saveWikiText('', '\xE2\x86\xB7 Page name c...', false)
    #6 /home/fswiki/public_html/lib/plugins/move/helper/op.php(204): saveWikiText('support:test', '', '\xE2\x86\xB7 Page name c...')
    #7 /home/fswiki/public_html/lib/plugins/move/action/rename.php(117): helper_plugin_move_op->movePage('support:test', 'support:test2')
    #8 /home/fswiki/public_html/inc/Extension/EventHandler.php(80): action_plugin_move_rename->handle_ajax(Object(dokuwiki\Extension\Event), NULL)
    #9 /home/fswiki/public_html/inc/Extension/Event.php(74): dokuwiki\Extension\EventHandler->process_event(Object(dokuwiki\Extension\Event), 'BEFORE')
    #10 /home/fswiki/public_html/inc/Ajax.php(27): dokuwiki\Extension\Event->advise_before()
    #11 /home/fswiki/public_html/lib/exe/ajax.php(22): dokuwiki\Ajax->__construct('plugin_move_ren...')
    #12 {main}

the code in question is:

            foreach ( $validNamespacesArr as $namespace ) {
                if ( strpos( $namespace, $INFO['namespace'] ) === 0 ) {
                    return true;
                }
            }

specifically this line:

if ( strpos( $namespace, $INFO['namespace'] ) === 0 )

I am clearly not understanding the logic, I guess. I tried the following change:

            foreach ( $validNamespacesArr as $namespace ) {
                if(isset($namespace) && isset($INFO['namespace']) ) {
                    if ( strpos( $namespace, $INFO['namespace'] ) === 0 ) {
                        return true;
                    }
                }
            }

No errors, but then the page edit is not reported at all.

Note: this happens when the page is being renamed via the move plugin. So there is some kind of conflict. Using that same plugin also causes the name of the person doing the move not to be filled. One of the changes in PR #27 corrects for that, filling in (Unknown). Without that change, the name reported is simply blank/empty.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions