[wp-hackers] Have I gone mad?

Simon Prosser pross at pross.org.uk
Mon Apr 29 11:51:27 UTC 2013


Maybe like this:
 if ( ! isset($_POST['updraft_**restore'] ) || ( isset($_POST['updraft_**
restore'] && ! is_array($_POST['updraft_**restore'] ) ) ) { }


On 29 April 2013 12:40, Peter van der Does <peter at avirtualhome.com> wrote:

> On Mon, 29 Apr 2013 08:46:20 +0100
> David Anderson <david at wordshell.net> wrote:
>
> >
> > >   if (!isset($_POST['updraft_**restore']) ||
> > > !is_array(maybe_unserialize($_POST['updraft_**restore']))) {
> >
> > I've obviously created something of a red herring by serialising the
> > error output and unserialising it together with a typo. Let me
> > explain the problem a different way:
> >
> > Here is the code:
> >
> >          if (!isset($_POST['updraft_restore'])
> > || !is_array($_POST['updraft_restore'])) { echo '<p>'.__('ABORT:
> > Could not find the information on which entities to restore.',
> > 'updraftplus').'</p>'; return false; }
> >
> > I have a user who (every time) hits this error condition. When I get
> > him to print_r his $_POST array (in the same code, so there's no
> > other code editing the $_POST array), he gets this:
> >
> > Array (
> >      [action] => updraft_restore
> >      [backup_timestamp] => 1366984477
> >      [updraft_restore] => Array
> >          (
> >              [0] => plugins
> >              [1] => themes
> >              [2] => uploads
> >              [3] => others
> >              [4] => db
> >          )
> > )
> >
> > How can that happen??
> >
> > David
> >
>
> These are one of these thing where I go crazy on parenthesis. If have
> struggled with the NOT's and AND/OR in other programming languages.
> Sometimes
> the first NOT would negate the ||, making it &&. So your first condition
> would
> be not isset (= FALSE), 2nd not is_array ( = FALSE), but not instead of ||
> it's &&
> and so FALSE && FALSE, yup that is true, error hits.
>
> So i just wrap each condition in parenthesis.
>
> if ( ( !isset($_POST['updraft_restore']) ) || (
> !is_array($_POST['updraft_restore'] ) ))
>
> I know it's not an explanation, but a solution. Maybe it has to do with
> the PHP version, I don't know.
>
> --
> Peter van der Does
>
> GPG key: CB317D6E
>
> Site: http://avirtualhome.com
> GitHub: https://github.com/petervanderdoes
> Twitter: @petervanderdoes
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>



-- 
My Blog: http://pross.org.uk/
Plugins : http://pross.org.uk/plugins/
Themes: http://wordpress.org/extend/themes/profile/pross


More information about the wp-hackers mailing list