PHP5 session_start failed, opendir permission denied.

Today i got the PHP Error:
“session_start() [function.session-start]: ps_files_cleanup_dir: opendir(/var/lib/php5) failed: Permission denied (13) in …”.

reproduce bug:


ini_set('session.gc_probability',1000);
ini_set('session.gc_divisor',1000);

Continue reading “PHP5 session_start failed, opendir permission denied.”

dpkg conflict libmagic1 /etc/magic.mime


Preconfiguring packages ...
(Reading database ... 131336 files and directories currently installed.)
Preparing to replace libmagic1 4.26-1 (using .../libmagic1_5.04-5_i386.deb) ...
Unpacking replacement libmagic1 ...
dpkg: error processing /var/cache/apt/archives/libmagic1_5.04-5_i386.deb (--unpack):
trying to overwrite '/etc/magic.mime', which is also in package file 5.04-5
Selecting previously deselected package libdb4.8.
Unpacking libdb4.8 (from .../libdb4.8_4.8.30-2_i386.deb) ...
Processing triggers for man-db ...
Errors were encountered while processing:
/var/cache/apt/archives/libmagic1_5.04-5_i386.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

this is a debian squeeze problem, you can fix this by:

  1. (re)moving /etc/magic.mime
  2. install the libmagic package manually with force options

dpkg --force-overwrite -i /var/cache/apt/archives/libmagic1_5.04-5_i386.deb

Code Review – ideas

What this post is about (and what not):

is not Develoment Guide, ill create an other document about Continuous integration, Testing, version control (which you already have, else you dont have anything to review, or you wont have), etc.

is not a Coding Standard, because there are already good tools which can format your code according to definable standards, this document does not apply the usual Coding Standard.

In that case it should actually called Code Design Standard, while this is not a standard
ill keep it under Code Review, because most ideas come from code review.

Code Design

Which concepts are important in code design:

  • Consistency
  • Maintainability
  • Readability
  • Re-usability
  • Security

These concepts are closely connected:
without consistency and readability, it should be hard to design your code to be maintainable.


lets start with some of the ideas;


Names

  • Only a developer who understands the system as a whole can create a name that “fits” within this system.
  • If the name is appropriate everything fits together naturally, relationships are clear, meaning is derivable, and reasoning from common human expectations works as expected.

Variable names

  • Names should be concise, but also descriptive.  (typeless is not the same as meaningless).
  • PHP has typeless variables, hungarian notation is not quite usefull.
  • Avoid reassigning a variable with an other meaning (unless the name describes this beforehand)

Method / Function Names

  • Usually a method / function performs an action, so the name should describe this: CheckForErrors() instead of ErrorCheck(),
  • Do not do real work in constructors: only initialize variables only and/or do actions that can’t fail.