php-general Digest 26 Oct 2013 08:44:06 -0000 Issue 8410

Topics (messages 322376 through 322384):

Re: framework or not
        322376 by: Stuart Dallas
        322378 by: Robert Cummings
        322380 by: Stuart Dallas
        322381 by: David Harkness

News Regard Attack; Announcing Official php.net Twitter Account
        322377 by: Daniel Brown
        322379 by: Tedd Sperling

I am puzzled. Error on one site, no error on the other
        322382 by: Stephen
        322383 by: Aziz Saleh

Does a call to trigger_error ever return?
        322384 by: Peter West

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
On 25 Oct 2013, at 15:01, Robert Cummings <rob...@interjinn.com> wrote:

> On 13-10-24 09:41 PM, Larry Garfield wrote:
>> On 10/23/2013 08:51 AM, Jay Blanchard wrote:
>>> [snip] ....a bitter rant....[/snip]
>>> 
>>> Dang Larry - bad night?
>> 
>> That wasn't a bitter rant.  You haven't seen me bitter. :-)  That was
>> "tough love" to the OP.  I don't see a reason to pussyfoot around the
>> original question, which is one that comes up about once a month.  The
>> answer is always the same: How much is your time worth?
> 
> Basic math...
> 
>    Life: finite
>    Time: infinite
> 
>    finite / infinite = 0
> 
> *sniffle*

Who's valuation of your time actually matters? Yours, and yours alone.

Therefore:

Life: n years
Time I can benefit from my life: n years

n years / n years = 1

*hoorah*

Your time is the most precious commodity you have.

Whether you use a framework or not you will (hopefully) reuse code between 
projects. If you choose to make part of that reused code one of the many 
frameworks that exist, you need only do one thing to ensure it continues to be 
worth using: how much of your time do you spend battling against the 
restrictions of the framework? If that's sufficiently low then using that 
framework is probably a good thing. If a significant portion of your time is 
spent battling the framework it's time to make a change.

Also remember that the only person who can truthfully judge whether you're 
"wasting time" is you, unless you earn money by selling your time to someone 
else in which case they have some right to decide what constitutes a waste of 
the time for which they're paying. I found the experience of writing my own 
framework to be hugely beneficial to my future productivity, but I might have 
struggled to justify spending the extra time it took to my employer at the time.

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

--- End Message ---
--- Begin Message ---
On 13-10-25 10:17 AM, Stuart Dallas wrote:
On 25 Oct 2013, at 15:01, Robert Cummings <rob...@interjinn.com> wrote:

On 13-10-24 09:41 PM, Larry Garfield wrote:
On 10/23/2013 08:51 AM, Jay Blanchard wrote:
[snip] ....a bitter rant....[/snip]

Dang Larry - bad night?

That wasn't a bitter rant.  You haven't seen me bitter. :-)  That was
"tough love" to the OP.  I don't see a reason to pussyfoot around the
original question, which is one that comes up about once a month.  The
answer is always the same: How much is your time worth?

Basic math...

    Life: finite
    Time: infinite

    finite / infinite = 0

*sniffle*

Who's valuation of your time actually matters? Yours, and yours alone.

Therefore:

Life: n years
Time I can benefit from my life: n years

n years / n years = 1

*hoorah*

Your time is the most precious commodity you have.

Whether you use a framework or not you will (hopefully) reuse code between 
projects. If you choose to make part of that reused code one of the many 
frameworks that exist, you need only do one thing to ensure it continues to be 
worth using: how much of your time do you spend battling against the 
restrictions of the framework? If that's sufficiently low then using that 
framework is probably a good thing. If a significant portion of your time is 
spent battling the framework it's time to make a change.

Also remember that the only person who can truthfully judge whether you're "wasting 
time" is you, unless you earn money by selling your time to someone else in which 
case they have some right to decide what constitutes a waste of the time for which 
they're paying. I found the experience of writing my own framework to be hugely 
beneficial to my future productivity, but I might have struggled to justify spending the 
extra time it took to my employer at the time.

You stripped away the context of my response. By removing the evil grin you made it look like I was serious. You should be a reporter ;)

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

--- End Message ---
--- Begin Message ---
On 25 Oct 2013, at 15:40, Robert Cummings <rob...@interjinn.com> wrote:

> On 13-10-25 10:17 AM, Stuart Dallas wrote:
>> On 25 Oct 2013, at 15:01, Robert Cummings <rob...@interjinn.com> wrote:
>> 
>>> On 13-10-24 09:41 PM, Larry Garfield wrote:
>>>> On 10/23/2013 08:51 AM, Jay Blanchard wrote:
>>>>> [snip] ....a bitter rant....[/snip]
>>>>> 
>>>>> Dang Larry - bad night?
>>>> 
>>>> That wasn't a bitter rant.  You haven't seen me bitter. :-)  That was
>>>> "tough love" to the OP.  I don't see a reason to pussyfoot around the
>>>> original question, which is one that comes up about once a month.  The
>>>> answer is always the same: How much is your time worth?
>>> 
>>> Basic math...
>>> 
>>>    Life: finite
>>>    Time: infinite
>>> 
>>>    finite / infinite = 0
>>> 
>>> *sniffle*
>> 
>> Who's valuation of your time actually matters? Yours, and yours alone.
>> 
>> Therefore:
>> 
>> Life: n years
>> Time I can benefit from my life: n years
>> 
>> n years / n years = 1
>> 
>> *hoorah*
>> 
>> Your time is the most precious commodity you have.
>> 
>> Whether you use a framework or not you will (hopefully) reuse code between 
>> projects. If you choose to make part of that reused code one of the many 
>> frameworks that exist, you need only do one thing to ensure it continues to 
>> be worth using: how much of your time do you spend battling against the 
>> restrictions of the framework? If that's sufficiently low then using that 
>> framework is probably a good thing. If a significant portion of your time is 
>> spent battling the framework it's time to make a change.
>> 
>> Also remember that the only person who can truthfully judge whether you're 
>> "wasting time" is you, unless you earn money by selling your time to someone 
>> else in which case they have some right to decide what constitutes a waste 
>> of the time for which they're paying. I found the experience of writing my 
>> own framework to be hugely beneficial to my future productivity, but I might 
>> have struggled to justify spending the extra time it took to my employer at 
>> the time.
> 
> You stripped away the context of my response. By removing the evil grin you 
> made it look like I was serious. You should be a reporter ;)

Who says I'm not! :)

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

--- End Message ---
--- Begin Message ---
On Fri, Oct 25, 2013 at 7:46 AM, Stuart Dallas <stu...@3ft9.com> wrote:

> On 25 Oct 2013, at 15:40, Robert Cummings <rob...@interjinn.com> wrote:
> > You should be a reporter.
>
> I'm not!


Deny it all you like, my friend. We all know the horrific truth!

Ciao,
David

--- End Message ---
--- Begin Message ---
    Greetings, all;

    As some of you may know, php.net was targeted and compromised
yesterday, leading to some services - including the one used by
Google's Chrome browser - to block the site for a short period of
time, and then a whirlwind of news.  Though very brief, the attack
compromised two servers (one hosting www.php.net, the other hosting
bugs.php.net), and was used to inject an iframe (via some obfuscated
JavaScript) that would attempt to force-download a piece of ransomware
onto Windows-based systems.  We immediately took steps to cease the
injection, then moved everything to new, pristine servers ---
verifying the safety and validity of every bit of code for the sites,
distributions, and everything else by hand and by script in the
process.  We're now entering a post-mortem investigative phase to
attempt discovery of how the infiltration was able to take place, and
should there be any worthwhile information to share, there will be
more on that front in the coming days, weeks, or months.

    And one way to stay in touch with information such as that is via
the new (well, I registered it on 21 June, but it just got its first
use yesterday) official php.net Twitter account.  If you're on Twitter
and so desire, you can follow the account at @official_php.  There are
a number of other accounts purporting to be official, connected, or
otherwise related to PHP in some manner, but @official_php is the only
account actually operated by us for the sole purpose of communicating
real information directly from us to the public.

    With all of that said, time to get back to work.  Need to take
advantage of the quiet as much as possible now, since my daughter got
a new baby brother a week ago today.  Not much in the way of peace,
quiet, and sleep anymore, as all of you parents know all too well.

-- 
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/

--- End Message ---
--- Begin Message ---
On Oct 25, 2013, at 10:18 AM, Daniel Brown <danbr...@php.net> wrote:

>  since my daughter got
> a new baby brother a week ago today.  Not much in the way of peace,
> quiet, and sleep anymore, as all of you parents know all too well.
> 
> -- 
> </Daniel P. Brown>
> Network Infrastructure Manager
> http://www.php.net/

Daniel:

Congrats on the new addition (baby 2.0). :-)

Cheers,

tedd
_______________
tedd sperling
tedd.sperl...@gmail.com

--- End Message ---
--- Begin Message ---
Problem Situation

I have two web sites on the same shared host. They share code for the control panel. When executed for one site I get a warning (reproducible always), but on the other there is no warning.

One my home server, set up in the same way, I do not get a warning for either site.

The warning is from this code:

if ( in_array( $keys, $photo_ids ) )

*Warning*: in_array() expects parameter 2 to be array, null given in */home/rois3324/include/cpprocessforms.php* on line *203*

Steps

1) Photos are transferred to incoming directory using ftp.
2) Photo data is imported into database and files moved to web site's file system
3) Photos are linked to a "category" by
    i) Specifying photos to consider by entering filespec using wildcards
    ii) User presented with photos
iii) User selects photos to be added to category and clicks process button
    iv) Form returns array of photo_ids (key in database table)
v) Form processor creates entry in "link" table that links category_id to photo_id
    vi) A check is made to detect and reject when the link already exists

This is where the error occurs

I have looked at the code, but I am at a total loss to figure out why I have trouble on one site and not the other, even though they are using the code. And my home development system has no problems.

I can't play trial and error on the development system.

Anyone have any ideas?

This is the code where the warning is triggered:

function linkphotos( $dbh, $x ) {

  global $thumbsdirectory;

  $ret_str = "";
  $cat_id = $x['category'];
  $photos = $x['list'];
  $sql0 = "SELECT photo_filename FROM photographs WHERE photo_id = :id";
  $sql1 = "SELECT photo_id FROM gallery_photos WHERE photo_category = :id";
  $sql2= "INSERT INTO gallery_photos VALUES ( :id, :photo_id, :order )";

  $stmt = $dbh->prepare($sql0);
  try {
      foreach( $photos as $keys=> $on) {
      $stmt->bindValue(':id', $keys);
      $stmt->execute();
      $row = $stmt->fetch(PDO::FETCH_ASSOC);
      $filenames[$keys] = $thumbsdirectory . "/" . $row['photo_filename'];
     }
  } catch (PDOException $e) {
    return 'Error selecting existing file names: ' . $e->getMessage();
  }

  $stmt = $dbh->prepare($sql1);
  try {
      $stmt->bindValue(':id', $cat_id);
      $stmt->execute();
      while ( list( $id ) = $stmt->fetch(PDO::FETCH_NUM)) {
        $photo_ids[] = $id;
      }
    } catch (PDOException $e) {
    return 'Error selecting existing photos: ' . $e->getMessage();
  }

  $stmt = $dbh->prepare($sql2);
  try {
      $stmt->bindValue(':id', $cat_id);
      foreach( $photos as $keys=> $on) {
$ret_str .= htmlimage($filenames[$keys], $filenames[$keys] ) . "<br />";
        if ( in_array( $keys, $photo_ids ) ) { <<<<<<<<warning raised here
            $ret_str .= "  Duplicate. Already in Category.<br />";
        } else {
          $stmt->bindValue(':photo_id', $keys);
          $stmt->bindValue(':order', $keys);
          $stmt->execute();
          $ret_str .= "  Added to Category.<br />";
        }
      }
  } catch (PDOException $e) {
    return 'Error inserting new photos: ' . $e->getMessage();
  }

  return $ret_str;
}

--
Stephen


--- End Message ---
--- Begin Message ---
On Fri, Oct 25, 2013 at 8:27 PM, Stephen <stephe...@rogers.com> wrote:

> Problem Situation
>
> I have two web sites on the same shared host. They share code for the
> control panel. When executed for one site I get a warning (reproducible
> always), but on the other there is no warning.
>
> One my home server, set up in the same way, I do not get a warning for
> either site.
>
> The warning is from this code:
>
> if ( in_array( $keys, $photo_ids ) )
>
> *Warning*: in_array() expects parameter 2 to be array, null given in
> */home/rois3324/include/**cpprocessforms.php* on line *203*
>
> Steps
>
> 1) Photos are transferred to incoming directory using ftp.
> 2) Photo data is imported into database and files moved to web site's file
> system
> 3) Photos are linked to a "category" by
>     i) Specifying photos to consider by entering filespec using wildcards
>     ii) User presented with photos
>     iii) User selects photos to be added to category and clicks process
> button
>     iv) Form returns array of photo_ids (key in database table)
>     v) Form processor creates entry in "link" table that links category_id
> to photo_id
>     vi) A check is made to detect and reject when the link already exists
>
> This is where the error occurs
>
> I have looked at the code, but I am at a total loss to figure out why I
> have trouble on one site and not the other, even though they are using the
> code. And my home development system has no problems.
>
> I can't play trial and error on the development system.
>
> Anyone have any ideas?
>
> This is the code where the warning is triggered:
>
> function linkphotos( $dbh, $x ) {
>
>   global $thumbsdirectory;
>
>   $ret_str = "";
>   $cat_id = $x['category'];
>   $photos = $x['list'];
>   $sql0 = "SELECT photo_filename FROM photographs WHERE photo_id = :id";
>   $sql1 = "SELECT photo_id FROM gallery_photos WHERE photo_category = :id";
>   $sql2= "INSERT INTO gallery_photos VALUES ( :id, :photo_id, :order )";
>
>   $stmt = $dbh->prepare($sql0);
>   try {
>       foreach( $photos as $keys=> $on) {
>       $stmt->bindValue(':id', $keys);
>       $stmt->execute();
>       $row = $stmt->fetch(PDO::FETCH_ASSOC)**;
>       $filenames[$keys] = $thumbsdirectory . "/" . $row['photo_filename'];
>      }
>   } catch (PDOException $e) {
>     return 'Error selecting existing file names: ' . $e->getMessage();
>   }
>
>   $stmt = $dbh->prepare($sql1);
>   try {
>       $stmt->bindValue(':id', $cat_id);
>       $stmt->execute();
>       while ( list( $id ) = $stmt->fetch(PDO::FETCH_NUM)) {
>         $photo_ids[] = $id;
>       }
>     } catch (PDOException $e) {
>     return 'Error selecting existing photos: ' . $e->getMessage();
>   }
>
>   $stmt = $dbh->prepare($sql2);
>   try {
>       $stmt->bindValue(':id', $cat_id);
>       foreach( $photos as $keys=> $on) {
>         $ret_str .=  htmlimage($filenames[$keys], $filenames[$keys] ) .
> "<br />";
>         if ( in_array( $keys, $photo_ids ) ) { <<<<<<<<warning raised here
>             $ret_str .= "  Duplicate. Already in Category.<br />";
>         } else {
>           $stmt->bindValue(':photo_id', $keys);
>           $stmt->bindValue(':order', $keys);
>           $stmt->execute();
>           $ret_str .= "  Added to Category.<br />";
>         }
>       }
>   } catch (PDOException $e) {
>     return 'Error inserting new photos: ' . $e->getMessage();
>   }
>
>   return $ret_str;
> }
>
> --
> Stephen
>
>
Your $photo_ids array is not declared. After
$photos = $x['list'];
add
$photo_ids = array();

--- End Message ---
--- Begin Message --- As it says. I'm a complete php nube, but form what I can see, and from some tests of interactive php, trigger_error is effectively an exit from the flow of control. (I'm not sure where it exits to, or how it can be made to change its mind.)

So I need to confirm whether I have the right end of the stick, and I need to know, especially, if I ever need to provide for a return from trigger_error in the flow of code.
--- End Message ---

Reply via email to