php-general Digest 27 Sep 2012 23:33:24 -0000 Issue 7983

Topics (messages 319276 through 319288):

Re: PHP as Application Server
        319276 by: Maciej Li¿ewski
        319278 by: Alessandro Pellizzari
        319279 by: Sebastian Krebs

Re: about lock some codes.
        319277 by: Maciek Sokolewicz
        319281 by: Jim Giner
        319282 by: Maciek Sokolewicz

Activating the mysql_clear_password plugin
        319280 by: Pierre-Gildas MILLON

Responding to an XML data post
        319283 by: Bastien Koert
        319284 by: Daniel Brown
        319287 by: tamouse mailing lists

Problem with PHP in Moodle LMS
        319285 by: Gary Lebowitz
        319286 by: admin

Re: Static constructor support
        319288 by: David Harkness

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 ---
to Matijn Woudt: you are right there should be something like: public
void synchronized increment(), but that is not the point. Sure there
are disadvantages and other problems but what Alessando is saying is
"I would not use cure for cancer even if it existed because it can
introduce other problems like overpopulation". There are cases when
"application server" adds much overhead that is not needed and there
are cases when it simplifies your tasks a lot. So from his mail the
only problem I can see is memory leaks, and I am not talking about
leaks in application because they can be caught in tests and fixed,
but mostly leaks in poorly wriiten PHP core and modules. Other like
session hijacking are not real problems (other languages somehow
managed it to work) or not so big in face of some other advantages
(like restarting application after change).

Robert Williams points that the main problem is with PHP programmers
who tend to ignore many aspects of multithreaded programming and PHP
helps them in that by hiding all threading aspects. There are still
people who can understand that and take profit from this knowlege.

The memory is also not such problem. I did some quite large PHP
projects and whole source code event if it were loaded in memory use
only few megabytes (event 100mb is not a problem). And am talking
about holding parsed structures in memory not the source files.
Applications I am talking about are mostly targeted to maximize
throughput and they are the only ones on server. In such cases *any*
speed improvement is worth attention.


I am not forcing anybody to use application server approach, but
rather like Robert said - good to have choice and decide on my own if
I want to write simple scripts or stateful application. The only
problem is that I do not have that choice not considering changing
language... at least I do not have such choice for now :)


2012/9/26 Robert Williams <rewilli...@thesba.com>:
> On 9/26/12 10:18, "Matijn Woudt" <tijn...@gmail.com> wrote:
>
>
>>Writing scripts for an application server requires a much deeper
>>understanding of threads and computer internals,so as a result it
>>probably increases error rate.
>
> Well... yes and no. PHP's architecture pretty much keeps you from having
> to mess with thread management, but it does so by shifting the burden to a
> higher level, either process management of multiple PHP processes or
> thread management within the context of the HTTP server. If your
> application is sufficiently simple, that shift may be enough to keep you
> from having to worry about the problem. For most applications, however,
> it's still a concern. In some ways, this can make things worse, simply
> because PHP programmers tend to be oblivious of the potential problems,
> whereas the typical C# or Java programmer has at least some awareness of
> the various traps that await them.
>
> As an example, I see PHP code *all the time* that is wide open to
> concurrency issues with the database. Most code just assumes it's the only
> code doing updates, but unless the server is set up to serialize requests,
> that's an invalid assumption. Recently, more folks have started to address
> this by using database transactions, but this is often done in ignorance
> of what isolation level is being used and what the impact of that is upon
> the code - which can just make things worse. Even when there is that
> awareness, there are database concurrency issues with which transactions
> can't help. (Of course, people who are aware of isolation levels also tend
> to be aware of other concurrency issues.) The point is, if you have
> multiple things running in parallel, whether that be threads within your
> application or entirely separate physical servers running multiple copies
> of your application, you have to deal with concurrency issues. It's a
> necessary evil of parallel programming, and no mere technological solution
> (language, database, whatever), now or in the future, can fully overcome
> it. Well, maybe an AI engine somewhere in the chain, but that's about it,
> and that's not coming anytime soon.
>
> Incidentally, another advantage of PHP's share-nothing approach that
> hasn't been mentioned is relatively easy scalability. In a shared pool
> architecture, the easiest way to scale is typically vertically, that is,
> adding RAM, faster drives, etc. This is fine, but you can only scale
> vertically to a certain point, which you can usually hit pretty quickly.
> With PHP's share-nothing approach, you can still scale vertically, but you
> can almost as easily scale horizontally by adding more servers that each
> run merrily in their own worlds, with the primary added coordination logic
> being in the areas of communicating with the database and the data cache,
> something the application should be designed with, anyway. In contrast,
> the shared approach requires added logic, somewhere, to coordinate the
> sharing amongst the pools of all that data that the application takes for
> granted is always available at low cost.
>
> Having said all that, there are many advantages and disadvantages to both
> approaches. And honestly, I would love to have the option of a shared
> approach with PHP, since that architecture simply works better as a
> solution to certain problems. Assuming the shared-nothing model continues
> on, it would make PHP that much more well-rounded. In that respect, the
> added option isn't that different from the addition of OOP: we now have
> the great ability to use procedural code where it makes sense, and to use
> OOP code where it makes sense. Where neither is a perfect fit, you can
> choose the one that creates the least personal pain. It's a wonderful
> choice to have.
>
>
> Regards,
> Bob
> --
> Robert E. Williams, Jr.
> Associate Vice President of Software Development
> Newtek Businesss Services, Inc. -- The Small Business Authority
> https://www.newtekreferrals.com/rewjr
> http://www.thesba.com/
>
>
>
>
>
>
>
> Notice: This communication, including attachments, may contain information 
> that is confidential. It constitutes non-public information intended to be 
> conveyed only to the designated recipient(s). If the reader or recipient of 
> this communication is not the intended recipient, an employee or agent of the 
> intended recipient who is responsible for delivering it to the intended 
> recipient, or if you believe that you have received this communication in 
> error, please notify the sender immediately by return e-mail and promptly 
> delete this e-mail, including attachments without reading or saving them in 
> any manner. The unauthorized use, dissemination, distribution, or 
> reproduction of this e-mail, including attachments, is prohibited and may be 
> unlawful. If you have received this email in error, please notify us 
> immediately by e-mail or telephone and delete the e-mail and the attachments 
> (if any).
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

--- End Message ---
--- Begin Message ---
Il Thu, 27 Sep 2012 12:28:00 +0200, Maciej Liżewski ha scritto:

> Sure there are
> disadvantages and other problems but what Alessando is saying is "I
> would not use cure for cancer even if it existed because it can
> introduce other problems like overpopulation".

Uhm, no.

I see it as "I would not use chemio if I could remove the cancer with 
laser therapy".

They are two ways to solve the same problem, and I think the non-
application-server way is the best.
It is similar to the Unix way: many small pieces tied together to reach a 
goal.
The application server is more like the Windows way: one big piece to 
reach a goal.

I understand sometimes the application server can be easier or fit 
better, but I think most of the times it is the wrong solution, 
expecially 
in PHP, but not exclusively.

Bye.



--- End Message ---
--- Begin Message ---
Hi,

Once again I didn't read it completely (maybe I will do so), but my 2ct:

I recently played with Ruby and Python and of course with their application
server (at least a little bit). My experience was, that it is less fun as
it sounds in the first place compared to a well designed
webserver-interpreter-stack (and of course common OS-specific stuff for
CLI). In my eyes it is good the way it is: Let PHP do it's job and let
"more intelligent tools" do the other things, like spawning
request-handling processes.

Not saying, that I'm against an application, but I currently don't miss it
:) On the other side someone must maintain it and someone must make sure,
that it is secure and efficient. This resources should not taken from the
core-team.

Regards,
Sebastian

2012/9/27 Alessandro Pellizzari <a...@amiran.it>

> Il Thu, 27 Sep 2012 12:28:00 +0200, Maciej Liżewski ha scritto:
>
> > Sure there are
> > disadvantages and other problems but what Alessando is saying is "I
> > would not use cure for cancer even if it existed because it can
> > introduce other problems like overpopulation".
>
> Uhm, no.
>
> I see it as "I would not use chemio if I could remove the cancer with
> laser therapy".
>
> They are two ways to solve the same problem, and I think the non-
> application-server way is the best.
> It is similar to the Unix way: many small pieces tied together to reach a
> goal.
> The application server is more like the Windows way: one big piece to
> reach a goal.
>
> I understand sometimes the application server can be easier or fit
> better, but I think most of the times it is the wrong solution,
> expecially
> in PHP, but not exclusively.
>
> Bye.
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
github.com/KingCrunch

--- End Message ---
--- Begin Message ---
On 27-09-2012 11:31, lx wrote:
Hello:
        I have a question now.the code is:

                 $ftemp = fopen("$fdoc_tmp/temp_proxy", 'w');
                 fwrite($ftemp, $content);
                 fclose($ftemp);

                 exec("/usr/local/bin/gdnsproxy -a -f $fdoc_tmp/temp_proxy
1>$fdoc_tmp/dout 2>$fdoc_tmp/derr", $data, $ex_result);
                 echo "ret=".$ex_result;

As you see, If a process run these,this is right.But two processes run this
codes.
the order maybe is:
1.process 1 create the temp_proxy1
2.process 2 create the temp_proxy2
3.process 1 exec temp_proxy2
4.process 2 exec temp_proxy2

The temp_proxy1 can't exec.

So,I want to know how to solve it.
Thank you.


Well, there are basically 2 ways:
1. introduce locking; you can lock the file and have the other script check if the file is locked. If so > have it usleep() and check again. 2. If you can run gdnsproxy in parallel, you could instead change the script to make $fdoc_tmp/temp_proxy unique for that script. So instead of just writing, you first check if the file exists, if so, create a file with a different (non-existent) name and then try again. Otherwise, use the first name. Then pass the 'unique' name to gdnsproxy.
--- End Message ---
--- Begin Message ---
On 9/27/2012 7:05 AM, Maciek Sokolewicz wrote:
On 27-09-2012 11:31, lx wrote:
Hello:
        I have a question now.the code is:

                 $ftemp = fopen("$fdoc_tmp/temp_proxy", 'w');
                 fwrite($ftemp, $content);
                 fclose($ftemp);

                 exec("/usr/local/bin/gdnsproxy -a -f
$fdoc_tmp/temp_proxy
1>$fdoc_tmp/dout 2>$fdoc_tmp/derr", $data, $ex_result);
                 echo "ret=".$ex_result;

As you see, If a process run these,this is right.But two processes run
this
codes.
the order maybe is:
1.process 1 create the temp_proxy1
2.process 2 create the temp_proxy2
3.process 1 exec temp_proxy2
4.process 2 exec temp_proxy2

The temp_proxy1 can't exec.

So,I want to know how to solve it.
Thank you.


Well, there are basically 2 ways:
1. introduce locking; you can lock the file and have the other script
check if the file is locked. If so > have it usleep() and check again.
2. If you can run gdnsproxy in parallel, you could instead change the
script to make $fdoc_tmp/temp_proxy unique for that script. So instead
of just writing, you first check if the file exists, if so, create a
file with a different (non-existent) name and then try again. Otherwise,
use the first name. Then pass the 'unique' name to gdnsproxy.
Even simpler - use the 'tempnam' or 'tmpfile' functions to always have a unique name and avoid having to check for an existing file.

Amazing what the php Manual has in it...

--- End Message ---
--- Begin Message ---
On 27-09-2012 15:13, Jim Giner wrote:
Even simpler - use the 'tempnam' or 'tmpfile' functions to always have a
unique name and avoid having to check for an existing file.

Amazing what the php Manual has in it...

Good find, I completely forgot about the existence of those functions ;) It's been a long time since I've had to meddle with unique filenames
--- End Message ---
--- Begin Message ---
I need to use the mysql_clear_password plugin.
I'm using the CentOS php 5.3.3 and manually recompiled the mysql & mysqli extensions with the Oracle MySQL 5.5 libraries.

According to the MySQL documentation ( http://dev.mysql.com/doc/refman/5.5/en/cleartext-authentication-plugin.html), I need to either set the LIBMYSQL_ENABLE_CLEARTEXT_PLUGIN or set the MYSQL_ENABLE_CLEARTEXT_PLUGIN option to the mysql client.

I tried to set the LIBMYSQL_ENABLE_CLEARTEXT_PLUGIN via a SetEnv in Apache with no results. Could anyone help me setting the MYSQL_ENABLE_CLEARTEXT_PLUGIN option to the mysql client ?

Regards,

Pierre-Gildas MILLON
pg.mil...@gmail.com

--- End Message ---
--- Begin Message ---
Hi All,

I am stuck in something where a 3rd party app pushes an XML post to my
site. They need me to respond to that push with a synchronous XML post
back confirming that the data was received / had issues etc. Those
XMLs are defined, but I am not sure how to push that XML back. A
simple

echo $xml;


is not making back to their system. Not sure how I can post back to their site

-- 

Bastien

Cat, the other other white meat

--- End Message ---
--- Begin Message ---
On Thu, Sep 27, 2012 at 1:48 PM, Bastien Koert <phps...@gmail.com> wrote:
> Hi All,
>
> I am stuck in something where a 3rd party app pushes an XML post to my
> site. They need me to respond to that push with a synchronous XML post
> back confirming that the data was received / had issues etc. Those
> XMLs are defined, but I am not sure how to push that XML back. A
> simple
>
> echo $xml;
>
> is not making back to their system. Not sure how I can post back to their site

    If it's an actual postback, they should've given you an API
endpoint for you to do a cURL post back to their side.  If not, and
they're just expecting an XML response, it could be that your XML is
improperly formatted.

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

--- End Message ---
--- Begin Message ---
On Thu, Sep 27, 2012 at 1:00 PM, Daniel Brown <danbr...@php.net> wrote:
> On Thu, Sep 27, 2012 at 1:48 PM, Bastien Koert <phps...@gmail.com> wrote:
>> Hi All,
>>
>> I am stuck in something where a 3rd party app pushes an XML post to my
>> site. They need me to respond to that push with a synchronous XML post
>> back confirming that the data was received / had issues etc. Those
>> XMLs are defined, but I am not sure how to push that XML back. A
>> simple
>>
>> echo $xml;
>>
>> is not making back to their system. Not sure how I can post back to their 
>> site
>
>     If it's an actual postback, they should've given you an API
> endpoint for you to do a cURL post back to their side.  If not, and
> they're just expecting an XML response, it could be that your XML is
> improperly formatted.
>
> --
> </Daniel P. Brown>
> Network Infrastructure Manager
> http://www.php.net/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

Also, make sure you've set the right content type header.

--- End Message ---
--- Begin Message ---
Has anyone ever heard of a problem with the Moodle LMS when trying to edit
an activity (quiz, resource) in which there is a timeout after only a few
seconds and a message saying something to the effect of that the system is
sorry but there was a time out, please retry. When I look in the URL I see
the following after my domain name:

.../course/modeit.php

Is this purely a Moodle thing, or something someone can help me with. (I've
already searched the Moodle site for information about this error, but
can't see anything related to version 2.2.3, which I am using.) Any help
would be appreciated. I thought I might want to up the timout figure in the
php5.ini file in the root directory of my shared Linux hosting with
Godaddy, but I don't think that's really the problem.

Regards,

Gary

--- End Message ---
--- Begin Message ---
> Has anyone ever heard of a problem with the Moodle LMS when trying to edit
an activity (quiz, resource) in which there is a timeout after only a few
seconds and a message saying something to the effect of > that the system is
sorry but there was a time out, please retry. When I look in the URL I see
the following after my domain name:
> 
> .../course/modeit.php
> 
> Is this purely a Moodle thing, or something someone can help me with.
(I've already searched the Moodle site for information about this error, but
can't see anything related to version 2.2.3, which I am 
> using.) Any help would be appreciated. I thought I might want to up the
timout figure in the php5.ini file in the root directory of my shared Linux
hosting with Godaddy, but I don't think that's really the > problem.
> Regards,
>
> Gary

Gary,
        Yes Moodle has a configuration issue. I would switch it to Debug
mode and check the error logs it will tell you exactly what is going wrong.



--- End Message ---
--- Begin Message ---
On Wed, Sep 26, 2012 at 2:29 PM, Yves Goergen
<nospam.l...@unclassified.de>wrote:

> How do other languages than C# call that? :-)
>

Java has "static initializers" which work the same way: they are executed
when the class is first loaded and before any code can make use of the
class.

David

--- End Message ---

Reply via email to