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

Notice: Undefined offset: 2 in piwik/core/DataArray.php on line 102 #6599

Closed
elpollodiablo opened this issue Nov 5, 2014 · 0 comments
Closed
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Milestone

Comments

@elpollodiablo
Copy link

I got an error today after adding Custom Variables and upgrading to Piwik 2.8.3 (although I think the variables and upgrade themselves may be unrelated and it was just some MySQL corruption):

    Notice: Undefined offset: 2 in /srv/app/piwik-2.8.3_RELEASE_2014-11-03_03.05.42.605263/core/DataArray.php on line 102 

    Backtrace -->

    #0 Piwik\Error::errorHandler(...) called at [/srv/app/piwik-2.8.3_RELEASE_2014-11-03_03.05.42.605263/core/DataArray.php:102]
    #1 Piwik\DataArray->doSumVisitsMetrics(...) called at [/srv/app/piwik-2.8.3_RELEASE_2014-11-03_03.05.42.605263/core/DataArray.php:307]
    #2 Piwik\DataArray->sumMetricsActionsPivot(...) called at [/srv/app/piwik-2.8.3_RELEASE_2014-11-03_03.05.42.605263/plugins/CustomVariables/Archiver.php:177]
    #3 Piwik\Plugins\CustomVariables\Archiver->aggregateActionByKeyAndValue(...) called at [/srv/app/piwik-2.8.3_RELEASE_2014-11-03_03.05.42.605263/plugins/CustomVariables/Archiver.php:135]
    #4 Piwik\Plugins\CustomVariables\Archiver->aggregateFromActions(...) called at [/srv/app/piwik-2.8.3_RELEASE_2014-11-03_03.05.42.605263/plugins/CustomVariables/Archiver.php:96]
    #5 Piwik\Plugins\CustomVariables\Archiver->aggregateCustomVariable(...) called at [/srv/app/piwik-2.8.3_RELEASE_2014-11-03_03.05.42.605263/plugins/CustomVariables/Archiver.php:64]
    #6 Piwik\Plugins\CustomVariables\Archiver->aggregateDayReport(...) called at [/srv/app/piwik-2.8.3_RELEASE_2014-11-03_03.05.42.605263/core/ArchiveProcessor/PluginsArchiver.php:100]
    #7 Piwik\ArchiveProcessor\PluginsArchiver->callAggregateAllPlugins(...) called at [/srv/app/piwik-2.8.3_RELEASE_2014-11-03_03.05.42.605263/core/ArchiveProcessor/Loader.php:122]
    #8 Piwik\ArchiveProcessor\Loader->prepareAllPluginsArchive(...) called at [/srv/app/piwik-2.8.3_RELEASE_2014-11-03_03.05.42.605263/core/ArchiveProcessor/Loader.php:72]
    #9 Piwik\ArchiveProcessor\Loader->prepareArchive(...) called at [/srv/app/piwik-2.8.3_RELEASE_2014-11-03_03.05.42.605263/core/Archive.php:801]
    #10 Piwik\Archive->prepareArchive(...) called at [/srv/app/piwik-2.8.3_RELEASE_2014-11-03_03.05.42.605263/core/Archive.php:614]
    #11 Piwik\Archive->cacheArchiveIdsAfterLaunching(...) called at [/srv/app/piwik-2.8.3_RELEASE_2014-11-03_03.05.42.605263/core/Archive.php:568]
    #12 Piwik\Archive->getArchiveIds(...) called at [/srv/app/piwik-2.8.3_RELEASE_2014-11-03_03.05.42.605263/core/Archive.php:508]
    #13 Piwik\Archive->get(...) called at [/srv/app/piwik-2.8.3_RELEASE_2014-11-03_03.05.42.605263/core/Archive.php:348]
    #14 Piwik\Archive->getDataTableFromNumeric(...) called at [/srv/app/piwik-2.8.3_RELEASE_2014-11-03_03.05.42.605263/plugins/VisitsSummary/API.php:59]
    #15 Piwik\Plugins\VisitsSummary\API->get(...) called at [:]
    #16 call_user_func_array(...) called at [/srv/app/piwik-2.8.3_RELEASE_2014-11-03_03.05.42.605263/core/API/Proxy.php:211]
    #17 Piwik\API\Proxy->call(...) called at [/srv/app/piwik-2.8.3_RELEASE_2014-11-03_03.05.42.605263/plugins/API/API.php:403]
    #18 Piwik\Plugins\API\API->get(...) called at [:]
    #19 call_user_func_array(...) called at [/srv/app/piwik-2.8.3_RELEASE_2014-11-03_03.05.42.605263/core/API/Proxy.php:211]
    #20 Piwik\API\Proxy->call(...) called at [/srv/app/piwik-2.8.3_RELEASE_2014-11-03_03.05.42.605263/core/API/Request.php:216]
    #21 Piwik\API\Request->process(...) called at [/srv/app/piwik-2.8.3_RELEASE_2014-11-03_03.05.42.605263/plugins/API/Controller.php:33]
    #22 Piwik\Plugins\API\Controller->index(...) called at [:]
    #23 call_user_func_array(...) called at [/srv/app/piwik-2.8.3_RELEASE_2014-11-03_03.05.42.605263/core/FrontController.php:587]
    #24 Piwik\FrontController->doDispatch(...) called at [/srv/app/piwik-2.8.3_RELEASE_2014-11-03_03.05.42.605263/core/FrontController.php:95]
    #25 Piwik\FrontController->dispatch(...) called at [/srv/app/piwik-2.8.3_RELEASE_2014-11-03_03.05.42.605263/core/dispatch.php:34]
    #26 require_once(...) called at [/srv/app/piwik-2.8.3_RELEASE_2014-11-03_03.05.42.605263/index.php:46]

I got three of those errors, one for each of these lines:

    $oldRowToUpdate[Metrics::INDEX_NB_VISITS] += $newRowToAdd[Metrics::INDEX_NB_VISITS];
    $oldRowToUpdate[Metrics::INDEX_NB_ACTIONS] += $newRowToAdd[Metrics::INDEX_NB_ACTIONS];
    $oldRowToUpdate[Metrics::INDEX_NB_UNIQ_VISITORS] += $newRowToAdd[Metrics::INDEX_NB_UNIQ_VISITORS];

after a bit of futzing around, I got the two relevant rows in question:

    Array
    (
        [10] => Array
            (
                [3] => Array
                    (
                        [1] => 15
                        [3] => 1
                        [2] => 0
                   )

            )

    )

    Array
    (
        [custom_var_k8] => fo
        [custom_var_v8] => 346
        [2] => 3
        [1] => 3
        [3] => 4
    )

Since my php-fu isn't sufficient to really debug this, I put a clumsy hotfix in, and let the issue be:

    if (!array_key_exists (Metrics::INDEX_NB_VISITS, $oldRowToUpdate) || !array_key_exists(Metrics::INDEX_NB_VISITS, $newRowToAdd) ||
            !array_key_exists (Metrics::INDEX_NB_ACTIONS, $oldRowToUpdate) || !array_key_exists(Metrics::INDEX_NB_ACTIONS, $newRowToAdd) ||
            !array_key_exists (Metrics::INDEX_NB_UNIQ_VISITORS, $oldRowToUpdate) || !array_key_exists(Metrics::INDEX_NB_UNIQ_VISITORS, $newRowToAdd)) {
            // log
    } else {
            $oldRowToUpdate[Metrics::INDEX_NB_VISITS] += $newRowToAdd[Metrics::INDEX_NB_VISITS];
            $oldRowToUpdate[Metrics::INDEX_NB_ACTIONS] += $newRowToAdd[Metrics::INDEX_NB_ACTIONS];
            $oldRowToUpdate[Metrics::INDEX_NB_UNIQ_VISITORS] += $newRowToAdd[Metrics::INDEX_NB_UNIQ_VISITORS];
    }
@mattab mattab closed this as completed in d78c73e Nov 15, 2014
@mattab mattab added this to the Piwik 2.10.0 milestone Nov 15, 2014
@mattab mattab added the Bug For errors / faults / flaws / inconsistencies etc. label Nov 15, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Projects
None yet
Development

No branches or pull requests

2 participants