Giter VIP home page Giter VIP logo

Comments (13)

daun avatar daun commented on June 2, 2024 2

Yeah, that makes sense — if it's a string, the first condition is false, so it will evaluate the second condition. If it was completely empty, it wouldn't. Your isset solution is the way to go here...

from processwire-dashboard.

daun avatar daun commented on June 2, 2024

Mmh. Not sure. The if statement would just skip the second part if the first part is true.

Can you post how you're setting up the panel itself, what you're passing into the 'shortcuts' option?

from processwire-dashboard.

zoeck-dev avatar zoeck-dev commented on June 2, 2024

Sure :)

Heres my code:

$allshortcuts[] = "";
$allshortcuts['Plan erstellen'] = [$this->config->urls->admin.'page/add/?parent_id=1024&template_id=47', 'calendar',     'Einen neuen Plan erstellen.'];
$allshortcuts['News eintragen'] = [$this->config->urls->admin.'page/add/?parent_id=1023&template_id=45', 'newspaper-o', 'Hier kann ein neuer News Eintrag erstellt werden.'];
$allshortcuts['User syncronisieren'] = [$this->config->urls->admin . 'setup/syncuser/', 'refresh', 'User akutalisieren.'];
$allshortcuts['Updates'] = [$this->config->urls->admin . 'setup/upgrades/', 'download', 'Systemupdates suchen und installieren.'];
$allshortcuts['Einstellungen'] = [$this->config->urls->admin . 'page/edit/?id=' . $this->pages->get("/verwaltung/einstellungen/")->id, 'cogs', 'Hier können die Einstellungen geändert werden.'];
$allshortcuts['Alle Seiten'] = ['/ugs/page/', 'files-o', 'Alle vorhandenen Seiten anzeigen.'];

$panels->add([
    'panel' => 'shortcuts',
    'title' => 'Menü',
    'data' => [
        'shortcuts' => $allshortcuts,
        'display' => 'list',
        'fallbackIcon' => 'star-o',
        'checkAccess' => true
    ]
]);

from processwire-dashboard.

szabeszg avatar szabeszg commented on June 2, 2024

The if statement would just skip the second part if the first part is true.

Only if AND is used but no OR, I guess, so
if (!$page || !isset($page->url)) {
should be needed perhaps?

from processwire-dashboard.

szabeszg avatar szabeszg commented on June 2, 2024

BTW, I get the same PHP Notice, so it an issue. I modifed the code as I showed above, it work for me with isset().
https://stackoverflow.com/questions/8138269/multiple-boolean-conditions-operator-precedence
"&& depends of the evaluation of the right expression when left one is true, || doesn't."

from processwire-dashboard.

daun avatar daun commented on June 2, 2024

$page is not an object in this case, so it does exist but doesn't allow property access. @szabeszg's fix should work. I'll try and plug the example config into my test setup to see why $page is not an object in the first place.

from processwire-dashboard.

daun avatar daun commented on June 2, 2024

I don't think this is about faulty boolean logic. If $page is empty, the first condition !$page is already true so it won't evaluate the second condition since true || [anything] will always be true.

from processwire-dashboard.

szabeszg avatar szabeszg commented on June 2, 2024

If $page is empty, the first condition !$page is already true so it won't evaluate the second condition since true || [anything] will always be true.

Apparently it does evaluate the second one...

from processwire-dashboard.

szabeszg avatar szabeszg commented on June 2, 2024

Looks like it fails when $page is a string like: '/admin/page/edit/?id=1'

from processwire-dashboard.

BernhardBaumrock avatar BernhardBaumrock commented on June 2, 2024

Just for reference here is the line in question:

if (!$page || !$page->url) {

Why would a string find it's way to that line? While isset() would work wouldn't it be better to ensure that $page is a Page object at the very top?

from processwire-dashboard.

BernhardBaumrock avatar BernhardBaumrock commented on June 2, 2024

eg this (but I don't know how your module works exactly and what syntax you expect...):

if(is_string($page)) $page = $this->wire->pages->get($page);

from processwire-dashboard.

daun avatar daun commented on June 2, 2024

The string just means it's already a URL. So yeah, I should go with an additional is_object or is_a and then isset. Better safe than sorry.

from processwire-dashboard.

daun avatar daun commented on June 2, 2024

Fixed in 1.5.2, thanks everybody for reporting and helping troubleshoot!

from processwire-dashboard.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.