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

PHP Fatal error: Uncaught Error: Cannot use object of type stdClass as array in #149

Open
foghorn-hash opened this issue Nov 10, 2020 · 1 comment

Comments

@foghorn-hash
Copy link

`Minulla on PHP 7.2 ja Ubuntu 18.04 LTS, joten voisiko tähä virhe ilmoitus johtua liian uudesta PHP:sta?

[10-Nov-2020 07:39:16 UTC] PHP Fatal error: Uncaught Error: Cannot use object of type stdClass as array in /var/www/event/wp-content/themes/eventgeniem/models/page-archive.php:32
Stack trace:
#0 [internal function]: PageArchive->Query()
#1 /var/www/event/vendor/devgeniem/dustpress/classes/model.php(644): call_user_func(Array)
#2 /var/www/event/vendor/devgeniem/dustpress/classes/model.php(336): DustPress\Model->run_function('Query', 'PageArchive')
#3 /var/www/event/vendor/devgeniem/dustpress/dustpress.php(1272): DustPress\Model->fetch_data(Array, true)
#4 /var/www/event/wp-includes/class-wp-hook.php(287): DustPress->create_ajax_instance('/var/www/event/...')
#5 /var/www/event/wp-includes/plugin.php(206): WP_Hook->apply_filters('/var/www/event/...', Array)
#6 /var/www/event/wp-includes/template-loader.php(104): apply_filters('template_includ...', '/var/www/event/...')
#7 /var/www/event/wp-blog-header.php(19): require_once('/var/www/event/...')
#8 /var/www/event/index.php(17): require('/var/www/event/...')
#9 {main}
thrown in /var/www/event/wp-content/themes/eventgeniem/models/page-archive.php on line`

@foghorn-hash
Copy link
Author

foghorn-hash commented Nov 11, 2020

Löysin vian itse.

Eli alla oleva koodi oli väärin ja pitää olla siis näin (eli onko teidän koodissa vika kun, $args = $this->get_args(); muuttuja luo Objektin eikä Arraytä?):

`<?php
/**

  • Template Name: Archive
  • This template needs a page to function!
    */

/**

  • Class Archive
    */
    class PageArchive extends MiddleModel {

    /**

    • Enable DustPress.js usage
    • @var array
      */
      protected $api = [
      'Query'
      ];

    /**

    • Query posts for the archive page.

    • This function also handles pagination.

    • @return array|bool|WP_Query
      */
      public function Query() {
      $args = $this->get_args();

      //var_dump($args);

      // Ajax requests set the page parameter.
      $page = isset( $args->page ) ? $args->page : 1;

      return $this->get_all_posts( $page );
      }
      }`

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

No branches or pull requests

1 participant