Hi,
while trying Stewart Morgan's patch, I found this situation and would
like your advice before opening a PHP bug.
Look at this sample code:
<?php
$the_query = "INSERT INTO `aaa` (`f1`, `f2`) VALUES ('1', 'aaa')";
preg_match('@INSERT\sINTO\s\`([^\`]+)\`@iu', $the_query,
$error_table = array() );
print_r($error_table);
?>
On PHP 5.1.0-RC4 I get
Array
(
[0] => INSERT INTO `aaa`
[1] => aaa
)
On PHP 5.1.2 I get
Array
(
)
If I change to
preg_match('@INSERT\sINTO\s\`([^\`]+)\`@iu', $the_query, $error_table);
it works.
Is it supposed to be wrong now to use the
$error_table = array()
syntax?
Marc
Hi all, and happy holidays! I just updated my several weeks old CVS,
and I'm having a permissions problem. When I try to log in, I get the
error "Wrong permissions on configuration file, should not be world
writable!". I traced this back to an update on 12/8:
* libraries/Config.class.php: Refuse to load config file with world
writable permissions, refuse to work with existing config dir.
No matter what permissions I set on my config.inc.php, I get the
error, even after I remove basically all permissions. I'm running on
Windows 2003/NTFS/PHP 5.1.1/IIS 6. I'm curious if anybody's tested
the CVS on this platform yet, since that update. I'm out of ideas how
to fix it short of commenting out the source.
-
Matt
Garvin Hicking schrieb:
> Hi!
>
>>> It surprises me that this has ever worked :)
>> it is more than logical that this should work, as = is always evaluated first!
>
> Yes. But NOT if the function parameter expects a REFERENCE variable.
why?
function myFunction(&$param) {}
myFunction($param = true);
this gives the reference $param to the function, there is no reason why
this should not work! true is assigned to $param and than $param is
passed by reference to the function.
>> why?
>>
>> whats the difference between
>>
>> function( anotherFunction() ); function( $var = 'value' );
>>
>> ???
>
> The difference is that
>
> preg_replace($string, $what, resultArray());
>
> will also not work. You can't/shouldn't pass a function as a referenced variable
> because of corruption issues that in the past of PHP have lead to problems,
> which are now being fixed up in recent PHP versions.
yes of course, but it doesn't passes a function, it passes a variable!
>> what do you think is easier to read? and why should this not work in PHP?
>
> I consider it good coding style to not obfuscate function calls.
yes of course thats why variables names are descriptive
sort_array($my_array);
everything is clear, but
db_close(true, false);
is obfuscated!
so i would prefer
db_close($clean_cache = true, $unset_global_link_variable = false);
...
whatever, i still think this is a php bug!
--
Sebastian Mendel
www.sebastianmendel.dewww.sf.net/projects/phpdatetime | www.sf.net/projects/phptimesheet
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello,
I've noticed an "undefined offset" error in common.lib.php:736
v2.7.0pl2 when "manually" inserting a row with a duplicate primary-key
value.
The attached patch adds to mkkeck's update for feature request #1036254
by extracting the table name from "INSERT INTO" as well as "ALTER
TABLE"; there are probably others too.
PMA is a great bit of software, keep up the excellent work!
Stewart,
--
Stewart Morgan MEng MIEE
Technical Director, Nameless-UK
Phone : +44 870 757 1625 | Address : The Production House
Fax : +44 870 168 0210 | 147a Saint Michael's Hill
PGP ID : 0xECD5CE64 | Bristol, BS2 8DB, UK
---------------------------x-------------------------------------
PGP Fingerprint: 89DE F8C3 CA14 598C 30DB 504A 3055 DDD7 ECD5 CE64
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1-nr1 (Windows XP)
iD8DBQFDxSj3MFXd1+zVzmQRAlC9AKDHmk43t5KLVsOEReMMtPT3PXgNUQCffYGy
YOxPyn31uLzfdZesNbelImY=
=Ow7r
-----END PGP SIGNATURE-----
--- common.lib.php.orig Mon Jan 9 15:02:24 2006
+++ common.lib.php Tue Jan 10 12:32:04 2006
@@ -732,7 +732,7 @@
// get the duplicate entry
// get table name
- preg_match( '°ALTER\sTABLE\s\`([^\`]+)\`°iu', $the_query, $error_table = array() );
+ preg_match( '°(?:ALTER\sTABLE|INSERT\sINTO)\s\`([^\`]+)\`°iu', $the_query, $error_table = array() );
$error_table = $error_table[1];
// get fields
Hi
I guess this should go to the list :-)
On Thu, 22 Dec 2005 08:16:41 +0100
Sebastian Mendel <lists(a)sebastianmendel.de> wrote:
> Michal Čihař schrieb:
> > I don't see much benefit of this. This would mean to split files into
> > smaller ones, what means more maintenance. For most things splitting
> > will be tricky or will end in main category.
>
> with templates PMA will not include the text itself, but its name
>
> <?php
> ...
> $strings['CouldNotLoadExtension'] = null;
> $template->append_by_ref( 'errors', $strings['CouldNotLoadExtension'] );
> ...
>
> ...
> // load strings from DB
> $sql = 'SELECT `id`, `string` FROM `cz` WHERE `id` IN (\'' .
> implode(array_keys($strings)) . '\')';
> $strings = PMA_DBI_fetch_result($sql, 'id', 'string');
> ...
>
> ...
> $template->display();
> ...
> ?>
Yes, templates would be great, but I still do not see advantage of db
stored strings ;-).
--
Michal Čihař | http://cihar.com
Hi,
can someone have a look at this, as I'm not familiar with this function.
Here is my problem: in config.default.php we have
$cfg['ForeignKeyDropdownOrder'] = array( 'content-id', 'id-content');
If in config.inc.php I put
$cfg['ForeignKeyDropdownOrder'] = array( 'content-id');
the effective $cfg['ForeignKeyDropdownOrder'] after the merge contains
2 values and not just one are I configured.
This problem can potentially happen with any directive containing an array.
Marc
Hi,
here is what I did in tbl_change.php:
/**
* Sets global variables.
* Here it's better to use a if, instead of the '?' operator
* to avoid setting a variable to '' when it's not present in $_REQUEST
*/
if (isset($_REQUEST['pos'])) {
$pos = $_REQUEST['pos'];
}
if (isset($_REQUEST['session_max_rows'])) {
$session_max_rows = $_REQUEST['session_max_rows'];
}
if (isset($_REQUEST['disp_direction'])) {
$disp_direction = $_REQUEST['disp_direction'];
}
if (isset($_REQUEST['repeat_cells'])) {
$repeat_cells = $_REQUEST['repeat_cells'];
}
if (isset($_REQUEST['dontlimitchars'])) {
$dontlimitchars = $_REQUEST['dontlimitchars'];
}
if (isset($_REQUEST['primary_key'])) {
$primary_key = $_REQUEST['primary_key'];
}
if (isset($_REQUEST['sql_query'])) {
$sql_query = $_REQUEST['sql_query'];
}
-----------
I had to get variables from $_REQUEST to fix bug #1381856.
I think we'll have to do this everywhere, to avoid getting "undefined
variable" errors when fetching something that might not be present in
$_REQUEST.
Comments?
Marc